Skip to content

Commit 7c8e397

Browse files
committed
Auto merge of #1438 - AdminXVII:extra-traits-redox, r=gnzlbg
Increase Redox & Relibc support - Add a lot of constants from relibc - Fix the timezone not found error found previously on Redox - Wrap WIFEXITED _et al._ in an unsafe block to match the rest of the API - Add support for the extra_traits feature and Redox - Fmt cc @jackpot51
2 parents d660c38 + 4d4a423 commit 7c8e397

File tree

2 files changed

+595
-189
lines changed

2 files changed

+595
-189
lines changed

src/unix/mod.rs

+42-32
Original file line numberDiff line numberDiff line change
@@ -605,33 +605,13 @@ extern {
605605
#[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
606606
pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
607607

608-
#[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
609-
link_name = "fdopendir$INODE64")]
610-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
611-
link_name = "fdopendir$INODE64$UNIX2003")]
612-
pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
613-
614608
#[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")]
615609
#[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
616610
#[cfg_attr(
617611
all(target_os = "freebsd", not(freebsd12)),
618612
link_name = "readdir@FBSD_1.0"
619613
)]
620614
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
621-
#[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
622-
#[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
623-
#[cfg_attr(
624-
all(target_os = "freebsd", not(freebsd12)),
625-
link_name = "readdir_r@FBSD_1.0"
626-
)]
627-
/// The 64-bit libc on Solaris and illumos only has readdir_r. If a
628-
/// 32-bit Solaris or illumos target is ever created, it should use
629-
/// __posix_readdir_r. See libc(3LIB) on Solaris or illumos:
630-
/// https://illumos.org/man/3lib/libc
631-
/// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html
632-
/// https://www.unix.com/man-page/opensolaris/3LIB/libc/
633-
pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
634-
result: *mut *mut ::dirent) -> ::c_int;
635615
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
636616
link_name = "closedir$UNIX2003")]
637617
pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
@@ -641,8 +621,6 @@ extern {
641621
link_name = "rewinddir$INODE64$UNIX2003")]
642622
pub fn rewinddir(dirp: *mut ::DIR);
643623

644-
pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
645-
flags: ::c_int, ...) -> ::c_int;
646624
pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
647625
mode: ::mode_t, flags: ::c_int) -> ::c_int;
648626
pub fn fchown(fd: ::c_int,
@@ -661,10 +639,6 @@ extern {
661639
pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char,
662640
newdirfd: ::c_int, newpath: *const ::c_char,
663641
flags: ::c_int) -> ::c_int;
664-
pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
665-
mode: ::mode_t) -> ::c_int;
666-
pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
667-
buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
668642
pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
669643
newdirfd: ::c_int, newpath: *const ::c_char)
670644
-> ::c_int;
@@ -725,9 +699,6 @@ extern {
725699
pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
726700
pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
727701
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
728-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
729-
link_name = "pause$UNIX2003")]
730-
pub fn pause() -> ::c_int;
731702
pub fn pipe(fds: *mut ::c_int) -> ::c_int;
732703
pub fn posix_memalign(memptr: *mut *mut ::c_void,
733704
align: ::size_t,
@@ -836,7 +807,6 @@ extern {
836807
pub fn symlink(path1: *const c_char,
837808
path2: *const c_char) -> ::c_int;
838809

839-
pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
840810
pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
841811

842812
pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
@@ -1071,8 +1041,6 @@ extern {
10711041
#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
10721042
pub fn timegm(tm: *mut ::tm) -> time_t;
10731043

1074-
pub fn getsid(pid: pid_t) -> pid_t;
1075-
10761044
pub fn sysconf(name: ::c_int) -> ::c_long;
10771045

10781046
pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
@@ -1131,6 +1099,48 @@ extern {
11311099
stream: *mut FILE) -> ssize_t;
11321100
}
11331101

1102+
cfg_if! {
1103+
if #[cfg(not(target_os = "redox"))] {
1104+
extern {
1105+
pub fn getsid(pid: pid_t) -> pid_t;
1106+
pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
1107+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1108+
link_name = "pause$UNIX2003")]
1109+
pub fn pause() -> ::c_int;
1110+
1111+
pub fn readlinkat(dirfd: ::c_int,
1112+
pathname: *const ::c_char,
1113+
buf: *mut ::c_char,
1114+
bufsiz: ::size_t) -> ::ssize_t;
1115+
pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
1116+
mode: ::mode_t) -> ::c_int;
1117+
pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
1118+
flags: ::c_int, ...) -> ::c_int;
1119+
1120+
#[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
1121+
link_name = "fdopendir$INODE64")]
1122+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1123+
link_name = "fdopendir$INODE64$UNIX2003")]
1124+
pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
1125+
1126+
#[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
1127+
#[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
1128+
#[cfg_attr(
1129+
all(target_os = "freebsd", not(freebsd12)),
1130+
link_name = "readdir_r@FBSD_1.0"
1131+
)]
1132+
/// The 64-bit libc on Solaris and illumos only has readdir_r. If a
1133+
/// 32-bit Solaris or illumos target is ever created, it should use
1134+
/// __posix_readdir_r. See libc(3LIB) on Solaris or illumos:
1135+
/// https://illumos.org/man/3lib/libc
1136+
/// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html
1137+
/// https://www.unix.com/man-page/opensolaris/3LIB/libc/
1138+
pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
1139+
result: *mut *mut ::dirent) -> ::c_int;
1140+
}
1141+
}
1142+
}
1143+
11341144
cfg_if! {
11351145
if #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] {
11361146
extern {

0 commit comments

Comments
 (0)