From 52199a640ac8f6447f2dda0e026e8ff47714372d Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Thu, 18 Aug 2022 17:04:28 -0700 Subject: [PATCH] Add `confstr` and guaranteed `_CS_*` constants on apple --- libc-test/semver/apple.txt | 5 +++++ src/unix/bsd/apple/mod.rs | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 60e8391ce0126..5b1a28649eff8 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1507,6 +1507,10 @@ XATTR_SHOWCOMPRESSION XUCRED_VERSION YESEXPR YESSTR +_CS_PATH +_CS_DARWIN_USER_DIR +_CS_DARWIN_USER_TEMP_DIR +_CS_DARWIN_USER_CACHE_DIR _IOFBF _IOLBF _IONBF @@ -1681,6 +1685,7 @@ clock_getres clonefile clonefileat cmsghdr +confstr connectx copyfile copyfile_flags_t diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index a831ca850f4be..9fc5159a18653 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3796,6 +3796,11 @@ pub const _SC_TRACE_NAME_MAX: ::c_int = 128; pub const _SC_TRACE_SYS_MAX: ::c_int = 129; pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 130; pub const _SC_PASS_MAX: ::c_int = 131; +// `confstr` keys (only the values guaranteed by `man confstr`). +pub const _CS_PATH: ::c_int = 1; +pub const _CS_DARWIN_USER_DIR: ::c_int = 65536; +pub const _CS_DARWIN_USER_TEMP_DIR: ::c_int = 65537; +pub const _CS_DARWIN_USER_CACHE_DIR: ::c_int = 65538; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; @@ -4846,6 +4851,11 @@ extern "C" { pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int; pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "confstr$UNIX2003" + )] + pub fn confstr(name: ::c_int, buf: *mut ::c_char, len: ::size_t) -> ::size_t; pub fn lio_listio( mode: ::c_int, aiocb_list: *const *mut aiocb,