|
1 | 1 | use crate::cmp;
|
2 |
| -use crate::ffi::{CStr, CString}; |
| 2 | +use crate::ffi::CStr; |
3 | 3 | use crate::io;
|
4 | 4 | use crate::mem;
|
5 | 5 | use crate::num::NonZero;
|
@@ -228,78 +228,6 @@ impl Thread {
|
228 | 228 | // Newlib, Emscripten, and VxWorks have no way to set a thread name.
|
229 | 229 | }
|
230 | 230 |
|
231 |
| - #[cfg(any( |
232 |
| - target_os = "linux", |
233 |
| - target_os = "freebsd", |
234 |
| - target_os = "netbsd", |
235 |
| - target_os = "solaris", |
236 |
| - target_os = "illumos" |
237 |
| - ))] |
238 |
| - pub fn get_name() -> Option<CString> { |
239 |
| - #[cfg(target_os = "linux")] |
240 |
| - const TASK_COMM_LEN: usize = 16; |
241 |
| - #[cfg(target_os = "freebsd")] |
242 |
| - const TASK_COMM_LEN: usize = libc::MAXCOMLEN + 1; |
243 |
| - #[cfg(any(target_os = "netbsd", target_os = "solaris", target_os = "illumos"))] |
244 |
| - const TASK_COMM_LEN: usize = 32; |
245 |
| - let mut name = vec![0u8; TASK_COMM_LEN]; |
246 |
| - let res = unsafe { |
247 |
| - libc::pthread_getname_np(libc::pthread_self(), name.as_mut_ptr().cast(), name.len()) |
248 |
| - }; |
249 |
| - if res != 0 { |
250 |
| - return None; |
251 |
| - } |
252 |
| - name.truncate(name.iter().position(|&c| c == 0)?); |
253 |
| - CString::new(name).ok() |
254 |
| - } |
255 |
| - |
256 |
| - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] |
257 |
| - pub fn get_name() -> Option<CString> { |
258 |
| - let mut name = vec![0u8; libc::MAXTHREADNAMESIZE]; |
259 |
| - let res = unsafe { |
260 |
| - libc::pthread_getname_np(libc::pthread_self(), name.as_mut_ptr().cast(), name.len()) |
261 |
| - }; |
262 |
| - if res != 0 { |
263 |
| - return None; |
264 |
| - } |
265 |
| - name.truncate(name.iter().position(|&c| c == 0)?); |
266 |
| - CString::new(name).ok() |
267 |
| - } |
268 |
| - |
269 |
| - #[cfg(target_os = "haiku")] |
270 |
| - pub fn get_name() -> Option<CString> { |
271 |
| - unsafe { |
272 |
| - let mut tinfo = mem::MaybeUninit::<libc::thread_info>::uninit(); |
273 |
| - // See BeOS teams group and threads api. |
274 |
| - // https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_ThreadsAndTeams_Overview.html |
275 |
| - let thread_self = libc::find_thread(ptr::null_mut()); |
276 |
| - let res = libc::get_thread_info(thread_self, tinfo.as_mut_ptr()); |
277 |
| - if res != libc::B_OK { |
278 |
| - return None; |
279 |
| - } |
280 |
| - let info = tinfo.assume_init(); |
281 |
| - let name = |
282 |
| - core::slice::from_raw_parts(info.name.as_ptr() as *const u8, info.name.len()); |
283 |
| - CStr::from_bytes_until_nul(name).map(CStr::to_owned).ok() |
284 |
| - } |
285 |
| - } |
286 |
| - |
287 |
| - #[cfg(not(any( |
288 |
| - target_os = "linux", |
289 |
| - target_os = "freebsd", |
290 |
| - target_os = "netbsd", |
291 |
| - target_os = "macos", |
292 |
| - target_os = "ios", |
293 |
| - target_os = "tvos", |
294 |
| - target_os = "watchos", |
295 |
| - target_os = "haiku", |
296 |
| - target_os = "solaris", |
297 |
| - target_os = "illumos" |
298 |
| - )))] |
299 |
| - pub fn get_name() -> Option<CString> { |
300 |
| - None |
301 |
| - } |
302 |
| - |
303 | 231 | #[cfg(not(target_os = "espidf"))]
|
304 | 232 | pub fn sleep(dur: Duration) {
|
305 | 233 | let mut secs = dur.as_secs();
|
|
0 commit comments