@@ -16,6 +16,23 @@ pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
1616#[ cfg( target_os = "vxworks" ) ]
1717pub const DEFAULT_MIN_STACK_SIZE : usize = 256 * 1024 ;
1818
19+ #[ cfg( target_os = "fuchsia" ) ]
20+ mod zircon {
21+ type zx_handle_t = u32 ;
22+ type zx_status_t = i32 ;
23+ pub const ZX_PROP_NAME : u32 = 3 ;
24+
25+ extern "C" {
26+ pub fn zx_object_set_property (
27+ handle : zx_handle_t ,
28+ property : u32 ,
29+ value : * const libc:: c_void ,
30+ value_size : libc:: size_t ,
31+ ) -> zx_status_t ;
32+ pub fn zx_thread_self ( ) -> zx_handle_t ;
33+ }
34+ }
35+
1936pub struct Thread {
2037 id : libc:: pthread_t ,
2138}
@@ -134,6 +151,19 @@ impl Thread {
134151 }
135152 }
136153
154+ #[ cfg( target_os = "fuchsia" ) ]
155+ pub fn set_name ( name : & CStr ) {
156+ use self :: zircon:: * ;
157+ unsafe {
158+ zx_object_set_property (
159+ zx_thread_self ( ) ,
160+ ZX_PROP_NAME ,
161+ name. as_ptr ( ) as * const libc:: c_void ,
162+ name. to_bytes ( ) . len ( ) ,
163+ ) ;
164+ }
165+ }
166+
137167 #[ cfg( any(
138168 target_env = "newlib" ,
139169 target_os = "haiku" ,
@@ -145,10 +175,6 @@ impl Thread {
145175 pub fn set_name ( _name : & CStr ) {
146176 // Newlib, Haiku, Emscripten, and VxWorks have no way to set a thread name.
147177 }
148- #[ cfg( target_os = "fuchsia" ) ]
149- pub fn set_name ( _name : & CStr ) {
150- // FIXME: determine whether Fuchsia has a way to set a thread name.
151- }
152178
153179 pub fn sleep ( dur : Duration ) {
154180 let mut secs = dur. as_secs ( ) ;
0 commit comments