@@ -13,6 +13,23 @@ pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
13
13
#[ cfg( target_os = "vxworks" ) ]
14
14
pub const DEFAULT_MIN_STACK_SIZE : usize = 256 * 1024 ;
15
15
16
+ #[ cfg( target_os = "fuchsia" ) ]
17
+ mod zircon {
18
+ type zx_handle_t = u32 ;
19
+ type zx_status_t = i32 ;
20
+ pub const ZX_PROP_NAME : u32 = 3 ;
21
+
22
+ extern "C" {
23
+ pub fn zx_object_set_property (
24
+ handle : zx_handle_t ,
25
+ property : u32 ,
26
+ value : * const libc:: c_void ,
27
+ value_size : libc:: size_t ,
28
+ ) -> zx_status_t ;
29
+ pub fn zx_thread_self ( ) -> zx_handle_t ;
30
+ }
31
+ }
32
+
16
33
pub struct Thread {
17
34
id : libc:: pthread_t ,
18
35
}
@@ -131,6 +148,19 @@ impl Thread {
131
148
}
132
149
}
133
150
151
+ #[ cfg( target_os = "fuchsia" ) ]
152
+ pub fn set_name ( name : & CStr ) {
153
+ use self :: zircon:: * ;
154
+ unsafe {
155
+ zx_object_set_property (
156
+ zx_thread_self ( ) ,
157
+ ZX_PROP_NAME ,
158
+ name. as_ptr ( ) as * const libc:: c_void ,
159
+ libc:: strlen ( name. as_ptr ( ) ) ,
160
+ ) ;
161
+ }
162
+ }
163
+
134
164
#[ cfg( any(
135
165
target_env = "newlib" ,
136
166
target_os = "haiku" ,
@@ -142,10 +172,6 @@ impl Thread {
142
172
pub fn set_name ( _name : & CStr ) {
143
173
// Newlib, Haiku, Emscripten, and VxWorks have no way to set a thread name.
144
174
}
145
- #[ cfg( target_os = "fuchsia" ) ]
146
- pub fn set_name ( _name : & CStr ) {
147
- // FIXME: determine whether Fuchsia has a way to set a thread name.
148
- }
149
175
150
176
pub fn sleep ( dur : Duration ) {
151
177
let mut secs = dur. as_secs ( ) ;
0 commit comments