Make std::sys::unix::args::init a no-op on glibc Linux
This commit is contained in:
parent
55fe6d8d58
commit
d448ab0cf1
1 changed files with 8 additions and 2 deletions
|
@ -72,12 +72,18 @@ mod imp {
|
|||
// acquire this mutex reentrantly!
|
||||
static LOCK: Mutex = Mutex::new();
|
||||
|
||||
pub unsafe fn init(argc: isize, argv: *const *const u8) {
|
||||
unsafe fn really_init(argc: isize, argv: *const *const u8) {
|
||||
let _guard = LOCK.lock();
|
||||
ARGC = argc;
|
||||
ARGV = argv;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
|
||||
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
|
||||
really_init(_argc, _argv);
|
||||
}
|
||||
|
||||
/// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.
|
||||
/// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows.
|
||||
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
||||
|
@ -94,7 +100,7 @@ mod imp {
|
|||
_envp: *const *const u8,
|
||||
) {
|
||||
unsafe {
|
||||
init(argc as isize, argv);
|
||||
really_init(argc as isize, argv);
|
||||
}
|
||||
}
|
||||
init_wrapper
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue