Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fcntl OFD commands for macOS #3563

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/full_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
contents: read # to fetch code (actions/checkout)

name: macOS
runs-on: macos-13
runs-on: macos-14
strategy:
fail-fast: true
matrix:
target: [
x86_64-apple-darwin,
aarch64-apple-darwin,
]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -218,10 +218,10 @@ jobs:
max-parallel: 4
matrix:
target:
- { toolchain: stable, os: macos-13 }
- { toolchain: beta, os: macos-13 }
- { toolchain: nightly, os: macos-13 }
- { toolchain: 1.71.0, os: macos-13 }
- { toolchain: stable, os: macos-14 }
- { toolchain: beta, os: macos-14 }
- { toolchain: nightly, os: macos-14 }
- { toolchain: 1.71.0, os: macos-14 }
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 0 additions & 2 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ x86_64-unknown-redox \

RUST_APPLE_TARGETS="\
aarch64-apple-ios \
x86_64-apple-darwin \
x86_64-apple-ios \
"

RUST_NIGHTLY_APPLE_TARGETS="\
Expand Down
8 changes: 4 additions & 4 deletions ci/install-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ fi
if [ "$OS" = "windows" ]; then
: "${TARGET?The TARGET environment variable must be set.}"
rustup set profile minimal
rustup update --force $toolchain-"$TARGET"
rustup default $toolchain-"$TARGET"
rustup update --force "$toolchain-$TARGET"
rustup default "$toolchain-$TARGET"
else
rustup set profile minimal
rustup update --force $toolchain
rustup default $toolchain
rustup update --force "$toolchain"
rustup default "$toolchain"
fi

if [ -n "$TARGET" ]; then
Expand Down
Empty file modified ci/style.sh
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ fn test_apple(target: &str) {
let mut cfg = ctest_cfg();
cfg.flag("-Wno-deprecated-declarations");
cfg.define("__APPLE_USE_RFC_3542", None);
cfg.define("PRIVATE", None);

headers! { cfg:
"aio.h",
Expand All @@ -203,6 +204,7 @@ fn test_apple(target: &str) {
"limits.h",
"locale.h",
"malloc/malloc.h",
"mach-o/utils.h",
"net/bpf.h",
"net/dlil.h",
"net/if.h",
Expand Down
11 changes: 7 additions & 4 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ COPYFILE_STATE_SRC_FD
COPYFILE_STATE_SRC_FILENAME
COPYFILE_STATE_STATUS_CB
COPYFILE_STATE_STATUS_CTX
COPYFILE_STATE_XATTRNAME
COPYFILE_STATE_WAS_CLONED
COPYFILE_VERBOSE
COPYFILE_STATE_XATTRNAME
COPYFILE_UNLINK
COPYFILE_VERBOSE
COPYFILE_XATTR
CR0
CR1
Expand Down Expand Up @@ -440,6 +440,9 @@ F_LOG2PHYS
F_LOG2PHYS_EXT
F_NOCACHE
F_NODIRECT
F_OFD_GETLK
F_OFD_SETLK
F_OFD_SETLKW
F_PEOFPOSMODE
F_PREALLOCATE
F_PUNCHHOLE
Expand Down Expand Up @@ -1969,19 +1972,19 @@ posix_spawn_file_actions_t
posix_spawnattr_destroy
posix_spawnattr_get_qos_class_np
posix_spawnattr_getarchpref_np
posix_spawnattr_getbinpref_np
posix_spawnattr_getflags
posix_spawnattr_getpgroup
posix_spawnattr_getsigdefault
posix_spawnattr_getsigmask
posix_spawnattr_init
posix_spawnattr_set_qos_class_np
posix_spawnattr_setarchpref_np
posix_spawnattr_setbinpref_np
posix_spawnattr_setflags
posix_spawnattr_setpgroup
posix_spawnattr_setsigdefault
posix_spawnattr_setsigmask
posix_spawnattr_getbinpref_np
posix_spawnattr_setbinpref_np
posix_spawnattr_t
posix_spawnp
preadv
Expand Down
7 changes: 6 additions & 1 deletion src/fixed_width_ints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub type uint32_t = u32;
pub type uint64_t = u64;

cfg_if! {
if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] {
if #[cfg(all(target_arch = "aarch64", not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))))] {
// This introduces partial support for FFI with __int128 and
// equivalent types on platforms where Rust's definition is validated
// to match the standard C ABI of that platform.
Expand Down Expand Up @@ -92,5 +92,10 @@ cfg_if! {

// static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128);
// static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128);
} else if #[cfg(all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos")))] {
/// C __int128_t (alternate name for [__int128][])
pub type __int128_t = i128;
/// C __uint128_t (alternate name for [__uint128][])
pub type __uint128_t = u128;
}
}
12 changes: 5 additions & 7 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ s! {
pub rmx_rtt: u32,
pub rmx_rttvar: u32,
pub rmx_pksent: u32,
pub rmx_state: u32,
pub rmx_filler: [u32; 3],
pub rmx_filler: [u32; 4],
}

pub struct rt_msghdr {
Expand Down Expand Up @@ -3413,6 +3412,10 @@ pub const F_GLOBAL_NOCACHE: ::c_int = 55;
pub const F_NODIRECT: ::c_int = 62;
pub const F_LOG2PHYS_EXT: ::c_int = 65;
pub const F_BARRIERFSYNC: ::c_int = 85;
// See https://github.com/apple/darwin-xnu/blob/main/bsd/sys/fcntl.h
pub const F_OFD_SETLK: ::c_int = 90; /* Acquire or release open file description lock */
pub const F_OFD_SETLKW: ::c_int = 91; /* (as F_OFD_SETLK but blocking if conflicting lock) */
pub const F_OFD_GETLK: ::c_int = 92; /* Examine OFD lock */
pub const F_PUNCHHOLE: ::c_int = 99;
pub const F_TRIM_ACTIVE_FILE: ::c_int = 100;
pub const F_SPECULATIVE_READ: ::c_int = 101;
Expand Down Expand Up @@ -6113,7 +6116,6 @@ extern "C" {
out_processor_infoCnt: *mut mach_msg_type_number_t,
) -> ::kern_return_t;

pub static mut mach_task_self_: ::mach_port_t;
pub fn task_for_pid(
host: ::mach_port_t,
pid: ::pid_t,
Expand Down Expand Up @@ -6230,10 +6232,6 @@ extern "C" {
) -> ::c_int;
}

pub unsafe fn mach_task_self() -> ::mach_port_t {
mach_task_self_
}

cfg_if! {
if #[cfg(target_os = "macos")] {
extern "C" {
Expand Down