@@ -200,6 +200,9 @@ cfg_if! {
200
200
201
201
cfg_if ! {
202
202
if #[ cfg( windows) ] {
203
+ use std:: ptr;
204
+ use std:: io;
205
+
203
206
use winapi:: shared:: basetsd:: * ;
204
207
use winapi:: shared:: minwindef:: { LPVOID , BOOL } ;
205
208
use winapi:: shared:: ntdef:: * ;
@@ -264,18 +267,22 @@ cfg_if! {
264
267
// to the current stack. Threads coverted to fibers still act like
265
268
// regular threads, but they have associated fiber data. We later
266
269
// convert it back to a regular thread and free the fiber data.
267
- ConvertThreadToFiber ( 0i32 as _ )
270
+ ConvertThreadToFiber ( ptr :: null_mut ( ) )
268
271
}
269
272
} ,
270
273
} ;
271
- if info. parent_fiber == 0i32 as _ {
274
+ if info. parent_fiber. is_null ( ) {
272
275
// We don't have a handle to the fiber, so we can't switch back
273
- panic!( "unable to convert thread to fiber" ) ;
276
+ panic!( "unable to convert thread to fiber: {}" , io :: Error :: last_os_error ( ) ) ;
274
277
}
275
278
276
- let fiber = CreateFiber ( stack_size as _, Some ( fiber_proc) , & mut info as * mut FiberInfo as * mut _) ;
277
- if fiber == 0i32 as _ {
278
- panic!( "unable to allocate fiber" ) ;
279
+ let fiber = CreateFiber (
280
+ stack_size as SIZE_T ,
281
+ Some ( fiber_proc) ,
282
+ & mut info as * mut FiberInfo as * mut _,
283
+ ) ;
284
+ if fiber. is_null( ) {
285
+ panic!( "unable to allocate fiber: {}" , io:: Error :: last_os_error( ) ) ;
279
286
}
280
287
281
288
// Switch to the fiber we created. This changes stacks and starts executing
@@ -288,7 +295,9 @@ cfg_if! {
288
295
// If we started out on a non-fiber thread, we converted that thread to a fiber.
289
296
// Here we convert back.
290
297
if !was_fiber {
291
- ConvertFiberToThread ( ) ;
298
+ if ConvertFiberToThread ( ) == 0 {
299
+ panic!( "unable to convert back to thread: {}" , io:: Error :: last_os_error( ) ) ;
300
+ }
292
301
}
293
302
294
303
if let Err ( payload) = info. result. unwrap( ) {
0 commit comments