Skip to content

Commit ee3c3df

Browse files
authored
Merge pull request #3827 from tgross35/backport-beetroot
Backport beetroot
2 parents 07559cf + 66cdb6b commit ee3c3df

File tree

7 files changed

+62
-22
lines changed

7 files changed

+62
-22
lines changed

libc-test/semver/apple.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ COPYFILE_STATE_SRC_FD
256256
COPYFILE_STATE_SRC_FILENAME
257257
COPYFILE_STATE_STATUS_CB
258258
COPYFILE_STATE_STATUS_CTX
259-
COPYFILE_STATE_XATTRNAME
260259
COPYFILE_STATE_WAS_CLONED
261-
COPYFILE_VERBOSE
260+
COPYFILE_STATE_XATTRNAME
262261
COPYFILE_UNLINK
262+
COPYFILE_VERBOSE
263263
COPYFILE_XATTR
264264
CR0
265265
CR1
@@ -441,6 +441,9 @@ F_LOG2PHYS
441441
F_LOG2PHYS_EXT
442442
F_NOCACHE
443443
F_NODIRECT
444+
F_OFD_GETLK
445+
F_OFD_SETLK
446+
F_OFD_SETLKW
444447
F_PEOFPOSMODE
445448
F_PREALLOCATE
446449
F_PUNCHHOLE
@@ -2093,19 +2096,19 @@ posix_spawn_file_actions_t
20932096
posix_spawnattr_destroy
20942097
posix_spawnattr_get_qos_class_np
20952098
posix_spawnattr_getarchpref_np
2099+
posix_spawnattr_getbinpref_np
20962100
posix_spawnattr_getflags
20972101
posix_spawnattr_getpgroup
20982102
posix_spawnattr_getsigdefault
20992103
posix_spawnattr_getsigmask
21002104
posix_spawnattr_init
21012105
posix_spawnattr_set_qos_class_np
21022106
posix_spawnattr_setarchpref_np
2107+
posix_spawnattr_setbinpref_np
21032108
posix_spawnattr_setflags
21042109
posix_spawnattr_setpgroup
21052110
posix_spawnattr_setsigdefault
21062111
posix_spawnattr_setsigmask
2107-
posix_spawnattr_getbinpref_np
2108-
posix_spawnattr_setbinpref_np
21092112
posix_spawnattr_t
21102113
posix_spawnp
21112114
preadv

libc-test/semver/wasi.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fd_set
2+
FD_SET
3+
FD_ZERO
4+
FD_ISSET
5+
select

src/unix/bsd/apple/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,6 +3609,10 @@ pub const F_GLOBAL_NOCACHE: ::c_int = 55;
36093609
pub const F_NODIRECT: ::c_int = 62;
36103610
pub const F_LOG2PHYS_EXT: ::c_int = 65;
36113611
pub const F_BARRIERFSYNC: ::c_int = 85;
3612+
// See https://github.com/apple/darwin-xnu/blob/main/bsd/sys/fcntl.h
3613+
pub const F_OFD_SETLK: ::c_int = 90; /* Acquire or release open file description lock */
3614+
pub const F_OFD_SETLKW: ::c_int = 91; /* (as F_OFD_SETLK but blocking if conflicting lock) */
3615+
pub const F_OFD_GETLK: ::c_int = 92; /* Examine OFD lock */
36123616
pub const F_PUNCHHOLE: ::c_int = 99;
36133617
pub const F_TRIM_ACTIVE_FILE: ::c_int = 100;
36143618
pub const F_SPECULATIVE_READ: ::c_int = 101;

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,17 @@ extern "C" {
706706
dev: dev_t,
707707
) -> ::c_int;
708708
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
709+
710+
pub fn getnameinfo(
711+
sa: *const ::sockaddr,
712+
salen: ::socklen_t,
713+
host: *mut ::c_char,
714+
hostlen: ::socklen_t,
715+
serv: *mut ::c_char,
716+
servlen: ::socklen_t,
717+
flags: ::c_int,
718+
) -> ::c_int;
719+
709720
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const ::timespec) -> ::c_int;
710721
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut ::c_int) -> ::c_int;
711722
pub fn pthread_condattr_setclock(

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,15 +2648,6 @@ extern "C" {
26482648
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
26492649
#[link_name = "__gettimeofday50"]
26502650
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
2651-
pub fn getnameinfo(
2652-
sa: *const ::sockaddr,
2653-
salen: ::socklen_t,
2654-
host: *mut ::c_char,
2655-
hostlen: ::socklen_t,
2656-
serv: *mut ::c_char,
2657-
servlen: ::socklen_t,
2658-
flags: ::c_int,
2659-
) -> ::c_int;
26602651
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
26612652
pub fn sysctl(
26622653
name: *const ::c_int,

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,15 +2018,6 @@ extern "C" {
20182018
atflag: ::c_int,
20192019
) -> ::c_int;
20202020
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
2021-
pub fn getnameinfo(
2022-
sa: *const ::sockaddr,
2023-
salen: ::socklen_t,
2024-
host: *mut ::c_char,
2025-
hostlen: ::size_t,
2026-
serv: *mut ::c_char,
2027-
servlen: ::size_t,
2028-
flags: ::c_int,
2029-
) -> ::c_int;
20302021
pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int;
20312022
pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int;
20322023
pub fn kevent(

src/wasi.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ s! {
175175
pub st_ctim: timespec,
176176
__reserved: [c_longlong; 3],
177177
}
178+
179+
pub struct fd_set {
180+
__nfds: usize,
181+
__fds: [c_int; FD_SETSIZE as usize],
182+
}
178183
}
179184

180185
// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
@@ -442,6 +447,28 @@ pub const NOEXPR: ::nl_item = 0x50001;
442447
pub const YESSTR: ::nl_item = 0x50002;
443448
pub const NOSTR: ::nl_item = 0x50003;
444449

450+
f! {
451+
pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
452+
let set = &*set;
453+
let n = set.__nfds;
454+
return set.__fds[..n].iter().any(|p| *p == fd)
455+
}
456+
457+
pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
458+
let set = &mut *set;
459+
let n = set.__nfds;
460+
if !set.__fds[..n].iter().any(|p| *p == fd) {
461+
set.__nfds = n + 1;
462+
set.__fds[n] = fd;
463+
}
464+
}
465+
466+
pub fn FD_ZERO(set: *mut fd_set) -> () {
467+
(*set).__nfds = 0;
468+
return
469+
}
470+
}
471+
445472
#[cfg_attr(
446473
feature = "rustc-dep-of-std",
447474
link(
@@ -737,6 +764,14 @@ extern "C" {
737764
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
738765
pub fn nl_langinfo_l(item: ::nl_item, loc: ::locale_t) -> *mut ::c_char;
739766

767+
pub fn select(
768+
nfds: c_int,
769+
readfds: *mut fd_set,
770+
writefds: *mut fd_set,
771+
errorfds: *mut fd_set,
772+
timeout: *const timeval,
773+
) -> c_int;
774+
740775
pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int;
741776
pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int;
742777
pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int;

0 commit comments

Comments
 (0)