Skip to content

Commit 80d2956

Browse files
committed
Simplify unix argument handling
1 parent 79a53cf commit 80d2956

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

Diff for: src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
#![feature(core_float)]
228228
#![feature(core_intrinsics)]
229229
#![feature(dropck_parametricity)]
230+
#![feature(drop_types_in_const)]
230231
#![feature(float_extras)]
231232
#![feature(float_from_str_radix)]
232233
#![feature(fnbox)]

Diff for: src/libstd/sys/common/args.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ mod imp {
4545
use prelude::v1::*;
4646

4747
use libc::c_char;
48-
use mem;
4948
use ffi::CStr;
5049

5150
use sys_common::mutex::Mutex;
5251

53-
static mut GLOBAL_ARGS_PTR: usize = 0;
52+
static mut GLOBAL_ARGS: Option<Vec<Vec<u8>>> = None;
5453
static LOCK: Mutex = Mutex::new();
5554

5655
pub unsafe fn init(argc: isize, argv: *const *const u8) {
@@ -59,32 +58,25 @@ mod imp {
5958
}).collect();
6059

6160
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);
6563
LOCK.unlock();
6664
}
6765

6866
pub unsafe fn cleanup() {
6967
LOCK.lock();
70-
*get_global_ptr() = None;
68+
GLOBAL_ARGS = None;
7169
LOCK.unlock();
7270
}
7371

7472
pub fn clone() -> Option<Vec<Vec<u8>>> {
7573
unsafe {
7674
LOCK.lock();
77-
let ptr = get_global_ptr();
78-
let ret = (*ptr).as_ref().map(|s| (**s).clone());
75+
let ret = GLOBAL_ARGS.clone();
7976
LOCK.unlock();
8077
return ret
8178
}
8279
}
83-
84-
fn get_global_ptr() -> *mut Option<Box<Vec<Vec<u8>>>> {
85-
unsafe { mem::transmute(&mut GLOBAL_ARGS_PTR) }
86-
}
87-
8880
}
8981

9082
#[cfg(any(target_os = "macos",

0 commit comments

Comments
 (0)