Skip to content

Commit 92b635c

Browse files
authored
Unrolled build for #152672
Rollup merge of #152672 - joboet:apple_args_libc, r=jhpratt std: use libc version of `_NSGetArgc`/`_NSGetArgv` These were added to libc in rust-lang/libc#3702.
2 parents 8387095 + bd52364 commit 92b635c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

library/std/src/sys/args/unix.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,14 @@ mod imp {
164164
// of this used `[[NSProcessInfo processInfo] arguments]`.
165165
#[cfg(target_vendor = "apple")]
166166
mod imp {
167-
use crate::ffi::{c_char, c_int};
167+
use crate::ffi::c_char;
168168

169169
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
170170
// No need to initialize anything in here, `libdyld.dylib` has already
171171
// done the work for us.
172172
}
173173

174174
pub fn argc_argv() -> (isize, *const *const c_char) {
175-
unsafe extern "C" {
176-
// These functions are in crt_externs.h.
177-
fn _NSGetArgc() -> *mut c_int;
178-
fn _NSGetArgv() -> *mut *mut *mut c_char;
179-
}
180-
181175
// SAFETY: The returned pointer points to a static initialized early
182176
// in the program lifetime by `libdyld.dylib`, and as such is always
183177
// valid.
@@ -187,9 +181,9 @@ mod imp {
187181
// doesn't exist a lock that we can take. Instead, it is generally
188182
// expected that it's only modified in `main` / before other code
189183
// runs, so reading this here should be fine.
190-
let argc = unsafe { _NSGetArgc().read() };
184+
let argc = unsafe { libc::_NSGetArgc().read() };
191185
// SAFETY: Same as above.
192-
let argv = unsafe { _NSGetArgv().read() };
186+
let argv = unsafe { libc::_NSGetArgv().read() };
193187

194188
// Cast from `*mut *mut c_char` to `*const *const c_char`
195189
(argc as isize, argv.cast())

0 commit comments

Comments
 (0)