@@ -16,6 +16,23 @@ pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
16
16
#[ cfg( target_os = "vxworks" ) ]
17
17
pub const DEFAULT_MIN_STACK_SIZE : usize = 256 * 1024 ;
18
18
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
+
19
36
pub struct Thread {
20
37
id : libc:: pthread_t ,
21
38
}
@@ -134,6 +151,19 @@ impl Thread {
134
151
}
135
152
}
136
153
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
+
137
167
#[ cfg( any(
138
168
target_env = "newlib" ,
139
169
target_os = "haiku" ,
@@ -145,10 +175,6 @@ impl Thread {
145
175
pub fn set_name ( _name : & CStr ) {
146
176
// Newlib, Haiku, Emscripten, and VxWorks have no way to set a thread name.
147
177
}
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
- }
152
178
153
179
pub fn sleep ( dur : Duration ) {
154
180
let mut secs = dur. as_secs ( ) ;
0 commit comments