File tree 2 files changed +6
-13
lines changed
2 files changed +6
-13
lines changed Original file line number Diff line number Diff line change 227
227
#![ feature( core_float) ]
228
228
#![ feature( core_intrinsics) ]
229
229
#![ feature( dropck_parametricity) ]
230
+ #![ feature( drop_types_in_const) ]
230
231
#![ feature( float_extras) ]
231
232
#![ feature( float_from_str_radix) ]
232
233
#![ feature( fnbox) ]
Original file line number Diff line number Diff line change @@ -45,12 +45,11 @@ mod imp {
45
45
use prelude:: v1:: * ;
46
46
47
47
use libc:: c_char;
48
- use mem;
49
48
use ffi:: CStr ;
50
49
51
50
use sys_common:: mutex:: Mutex ;
52
51
53
- static mut GLOBAL_ARGS_PTR : usize = 0 ;
52
+ static mut GLOBAL_ARGS : Option < Vec < Vec < u8 > > > = None ;
54
53
static LOCK : Mutex = Mutex :: new ( ) ;
55
54
56
55
pub unsafe fn init ( argc : isize , argv : * const * const u8 ) {
@@ -59,32 +58,25 @@ mod imp {
59
58
} ) . collect ( ) ;
60
59
61
60
LOCK . lock ( ) ;
62
- let ptr = get_global_ptr ( ) ;
63
- assert ! ( ( * ptr) . is_none( ) ) ;
64
- ( * ptr) = Some ( box args) ;
61
+ assert ! ( GLOBAL_ARGS . is_none( ) ) ;
62
+ GLOBAL_ARGS = Some ( args) ;
65
63
LOCK . unlock ( ) ;
66
64
}
67
65
68
66
pub unsafe fn cleanup ( ) {
69
67
LOCK . lock ( ) ;
70
- * get_global_ptr ( ) = None ;
68
+ GLOBAL_ARGS = None ;
71
69
LOCK . unlock ( ) ;
72
70
}
73
71
74
72
pub fn clone ( ) -> Option < Vec < Vec < u8 > > > {
75
73
unsafe {
76
74
LOCK . lock ( ) ;
77
- let ptr = get_global_ptr ( ) ;
78
- let ret = ( * ptr) . as_ref ( ) . map ( |s| ( * * s) . clone ( ) ) ;
75
+ let ret = GLOBAL_ARGS . clone ( ) ;
79
76
LOCK . unlock ( ) ;
80
77
return ret
81
78
}
82
79
}
83
-
84
- fn get_global_ptr ( ) -> * mut Option < Box < Vec < Vec < u8 > > > > {
85
- unsafe { mem:: transmute ( & mut GLOBAL_ARGS_PTR ) }
86
- }
87
-
88
80
}
89
81
90
82
#[ cfg( any( target_os = "macos" ,
You can’t perform that action at this time.
0 commit comments