diff options
author | Andrzej Janik <[email protected]> | 2020-11-23 22:24:35 +0100 |
---|---|---|
committer | Andrzej Janik <[email protected]> | 2020-11-23 22:24:35 +0100 |
commit | 690f4f3ad2e1daf255749aa65ba14996ada51bbf (patch) | |
tree | 0227a7e84846d74739ae8f04e7276e991d18bd0b | |
parent | 8fa044004f60210e5e52a42413ab400618d4e3cd (diff) | |
download | ZLUDA-690f4f3ad2e1daf255749aa65ba14996ada51bbf.tar.gz ZLUDA-690f4f3ad2e1daf255749aa65ba14996ada51bbf.zip |
Append short project name to the device if there's not enough space for long name
-rw-r--r-- | zluda/src/impl/device.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/zluda/src/impl/device.rs b/zluda/src/impl/device.rs index 23b75f0..8fa24a8 100644 --- a/zluda/src/impl/device.rs +++ b/zluda/src/impl/device.rs @@ -8,7 +8,8 @@ use std::{ sync::atomic::{AtomicU32, Ordering}, }; -const PROJECT_URL_SUFFIX: &'static str = " [github.com/vosen/ZLUDA]"; +const PROJECT_URL_SUFFIX_SHORT: &'static str = " [ZLUDA]"; +const PROJECT_URL_SUFFIX_LONG: &'static str = " [github.com/vosen/ZLUDA]"; #[repr(transparent)] #[derive(Clone, Copy, Eq, PartialEq, Hash)] @@ -152,15 +153,24 @@ pub fn get_name(name: *mut c_char, len: i32, dev_idx: Index) -> Result<(), CUres .unwrap_or(256); let mut dst_null_pos = cmp::min((len - 1) as usize, name_len); unsafe { std::ptr::copy_nonoverlapping(name_ptr, name, dst_null_pos) }; - if name_len + PROJECT_URL_SUFFIX.len() < (len as usize) { + if name_len + PROJECT_URL_SUFFIX_LONG.len() < (len as usize) { unsafe { std::ptr::copy_nonoverlapping( - PROJECT_URL_SUFFIX.as_ptr(), + PROJECT_URL_SUFFIX_LONG.as_ptr(), name.add(name_len) as *mut _, - PROJECT_URL_SUFFIX.len(), + PROJECT_URL_SUFFIX_LONG.len(), ) }; - dst_null_pos += PROJECT_URL_SUFFIX.len(); + dst_null_pos += PROJECT_URL_SUFFIX_LONG.len(); + } else if name_len + PROJECT_URL_SUFFIX_SHORT.len() < (len as usize) { + unsafe { + std::ptr::copy_nonoverlapping( + PROJECT_URL_SUFFIX_SHORT.as_ptr(), + name.add(name_len) as *mut _, + PROJECT_URL_SUFFIX_SHORT.len(), + ) + }; + dst_null_pos += PROJECT_URL_SUFFIX_SHORT.len(); } unsafe { *(name.add(dst_null_pos)) = 0 }; Ok(()) |