about summary refs log tree commit diff
diff options
context:
space:
mode:
authorleo60228 <iakornfeld@gmail.com>2019-11-21 13:42:25 -0500
committerleo60228 <iakornfeld@gmail.com>2019-11-22 12:27:07 -0500
commitd448ab0cf10a6c822b209f208a87ce200efd0772 (patch)
treebab9f051660368c6726b804ba1eb1814135fed2c
parent55fe6d8d5875f1378747ea1681deac64536ef9dc (diff)
downloadrust-d448ab0cf10a6c822b209f208a87ce200efd0772.tar.gz
rust-d448ab0cf10a6c822b209f208a87ce200efd0772.zip
Make std::sys::unix::args::init a no-op on glibc Linux
-rw-r--r--src/libstd/sys/unix/args.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs
index 58fa305a819..15dafb1bcf9 100644
--- a/src/libstd/sys/unix/args.rs
+++ b/src/libstd/sys/unix/args.rs
@@ -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