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