summaryrefslogtreecommitdiff
path: root/libc/src/unix/newlib
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/unix/newlib')
-rw-r--r--libc/src/unix/newlib/align.rs61
-rw-r--r--libc/src/unix/newlib/mod.rs197
-rw-r--r--libc/src/unix/newlib/no_align.rs51
3 files changed, 191 insertions, 118 deletions
diff --git a/libc/src/unix/newlib/align.rs b/libc/src/unix/newlib/align.rs
new file mode 100644
index 0000000..c018fbc
--- /dev/null
+++ b/libc/src/unix/newlib/align.rs
@@ -0,0 +1,61 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ #[cfg_attr(all(target_pointer_width = "32",
+ any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc")),
+ repr(align(4)))]
+ #[cfg_attr(any(target_pointer_width = "64",
+ not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc"))),
+ repr(align(8)))]
+ pub struct pthread_mutex_t { // Unverified
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ #[cfg_attr(all(target_pointer_width = "32",
+ any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc")),
+ repr(align(4)))]
+ #[cfg_attr(any(target_pointer_width = "64",
+ not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc"))),
+ repr(align(8)))]
+ pub struct pthread_rwlock_t { // Unverified
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+
+ #[cfg_attr(any(target_pointer_width = "32",
+ target_arch = "x86_64",
+ target_arch = "powerpc64",
+ target_arch = "mips64",
+ target_arch = "s390x",
+ target_arch = "sparc64"),
+ repr(align(4)))]
+ #[cfg_attr(not(any(target_pointer_width = "32",
+ target_arch = "x86_64",
+ target_arch = "powerpc64",
+ target_arch = "mips64",
+ target_arch = "s390x",
+ target_arch = "sparc64")),
+ repr(align(8)))]
+ pub struct pthread_mutexattr_t { // Unverified
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ #[repr(align(8))]
+ pub struct pthread_cond_t { // Unverified
+ size: [u8; ::__SIZEOF_PTHREAD_COND_T],
+ }
+
+ #[repr(align(4))]
+ pub struct pthread_condattr_t { // Unverified
+ size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
+ }
+ }
+ }
+}
diff --git a/libc/src/unix/newlib/mod.rs b/libc/src/unix/newlib/mod.rs
index 0cc411d..c9a25a3 100644
--- a/libc/src/unix/newlib/mod.rs
+++ b/libc/src/unix/newlib/mod.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
pub type blkcnt_t = i32;
pub type blksize_t = i32;
pub type clock_t = i32;
@@ -238,103 +236,10 @@ s! {
__size: [u64; 7]
}
- #[cfg_attr(all(feature = "align",
- target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))),
- repr(align(8)))]
- pub struct pthread_mutex_t { // Unverified
- #[cfg(all(not(feature = "align"),
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_long; 0],
- #[cfg(not(any(feature = "align",
- target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_longlong; 0],
- size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[cfg_attr(all(feature = "align",
- target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))),
- repr(align(8)))]
- pub struct pthread_rwlock_t { // Unverified
- #[cfg(all(not(feature = "align"),
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_long; 0],
- #[cfg(not(any(feature = "align",
- target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc")))]
- __align: [::c_longlong; 0],
- size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "32",
- target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- not(any(target_pointer_width = "32",
- target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64"))),
- repr(align(8)))]
- pub struct pthread_mutexattr_t { // Unverified
- #[cfg(all(not(feature = "align"),
- any(target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64")))]
- __align: [::c_int; 0],
- #[cfg(all(not(feature = "align"),
- not(any(target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64"))))]
- __align: [::c_long; 0],
- size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
pub struct pthread_rwlockattr_t { // Unverified
__lockkind: ::c_int,
__pshared: ::c_int,
}
-
- #[cfg_attr(feature = "align", repr(align(8)))]
- pub struct pthread_cond_t { // Unverified
- #[cfg(not(feature = "align"))]
- __align: [::c_longlong; 0],
- size: [u8; __SIZEOF_PTHREAD_COND_T],
- }
-
- #[cfg_attr(feature = "align", repr(align(4)))]
- pub struct pthread_condattr_t { // Unverified
- #[cfg(not(feature = "align"))]
- __align: [::c_int; 0],
- size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
- }
-
}
// unverified constants
@@ -501,7 +406,8 @@ pub const SEEK_SET: ::c_int = 0;
pub const SEEK_CUR: ::c_int = 1;
pub const SEEK_END: ::c_int = 2;
-pub const FIONBIO: ::c_int = 1;
+pub const FIONBIO: ::c_ulong = 1;
+pub const FIOCLEX: ::c_ulong = 0x20006601;
pub const S_BLKSIZE: ::mode_t = 1024;
pub const S_IREAD: ::mode_t = 256;
@@ -552,15 +458,41 @@ pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;
-pub const SO_REUSEADDR: ::c_int = 4;
-pub const SO_LINGER: ::c_int = 128;
-pub const SO_OOBINLINE: ::c_int = 256;
-pub const SO_SNDBUF: ::c_int = 4097;
-pub const SO_RCVBUF: ::c_int = 4098;
-pub const SO_SNDLOWAT: ::c_int = 4099;
-pub const SO_RCVLOWAT: ::c_int = 4100;
-pub const SO_TYPE: ::c_int = 4104;
-pub const SO_ERROR: ::c_int = 4105;
+pub const SO_BINTIME: ::c_int = 0x2000;
+pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
+pub const SO_NO_DDP: ::c_int = 0x8000;
+pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
+pub const SO_LABEL: ::c_int = 0x1009;
+pub const SO_PEERLABEL: ::c_int = 0x1010;
+pub const SO_LISTENQLIMIT: ::c_int = 0x1011;
+pub const SO_LISTENQLEN: ::c_int = 0x1012;
+pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
+pub const SO_SETFIB: ::c_int = 0x1014;
+pub const SO_USER_COOKIE: ::c_int = 0x1015;
+pub const SO_PROTOCOL: ::c_int = 0x1016;
+pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
+pub const SO_VENDOR: ::c_int = 0x80000000;
+pub const SO_DEBUG: ::c_int = 0x01;
+pub const SO_ACCEPTCONN: ::c_int = 0x0002;
+pub const SO_REUSEADDR: ::c_int = 0x0004;
+pub const SO_KEEPALIVE: ::c_int = 0x0008;
+pub const SO_DONTROUTE: ::c_int = 0x0010;
+pub const SO_BROADCAST: ::c_int = 0x0020;
+pub const SO_USELOOPBACK: ::c_int = 0x0040;
+pub const SO_LINGER: ::c_int = 0x0080;
+pub const SO_OOBINLINE: ::c_int = 0x0100;
+pub const SO_REUSEPORT: ::c_int = 0x0200;
+pub const SO_TIMESTAMP: ::c_int = 0x0400;
+pub const SO_NOSIGPIPE: ::c_int = 0x0800;
+pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
+pub const SO_SNDBUF: ::c_int = 0x1001;
+pub const SO_RCVBUF: ::c_int = 0x1002;
+pub const SO_SNDLOWAT: ::c_int = 0x1003;
+pub const SO_RCVLOWAT: ::c_int = 0x1004;
+pub const SO_SNDTIMEO: ::c_int = 0x1005;
+pub const SO_RCVTIMEO: ::c_int = 0x1006;
+pub const SO_ERROR: ::c_int = 0x1007;
+pub const SO_TYPE: ::c_int = 0x1008;
pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
@@ -586,20 +518,32 @@ pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
-pub const IPPROTO_IP: ::c_int = 0;
-pub const IPPROTO_UDP: ::c_int = 17;
-pub const IPPROTO_TCP: ::c_int = 6;
-
pub const TCP_NODELAY: ::c_int = 8193;
pub const TCP_MAXSEG: ::c_int = 8194;
+pub const TCP_NOPUSH: ::c_int = 4;
+pub const TCP_NOOPT: ::c_int = 8;
+pub const TCP_KEEPIDLE: ::c_int = 256;
+pub const TCP_KEEPINTVL: ::c_int = 512;
+pub const TCP_KEEPCNT: ::c_int = 1024;
-pub const IP_TOS: ::c_int = 7;
+pub const IP_TOS: ::c_int = 3;
pub const IP_TTL: ::c_int = 8;
-pub const IP_MULTICAST_LOOP: ::c_int = 9;
+pub const IP_MULTICAST_IF: ::c_int = 9;
pub const IP_MULTICAST_TTL: ::c_int = 10;
+pub const IP_MULTICAST_LOOP: ::c_int = 11;
pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
+pub const IPV6_UNICAST_HOPS: ::c_int = 4;
+pub const IPV6_MULTICAST_IF: ::c_int = 9;
+pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
+pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
+pub const IPV6_V6ONLY: ::c_int = 27;
+pub const IPV6_JOIN_GROUP: ::c_int = 12;
+pub const IPV6_LEAVE_GROUP: ::c_int = 13;
+pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
+pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
+
pub const HOST_NOT_FOUND: ::c_int = 1;
pub const NO_DATA: ::c_int = 2;
pub const NO_ADDRESS: ::c_int = 2;
@@ -627,20 +571,20 @@ pub const EAI_SOCKTYPE: ::c_int = -307;
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
- let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
(*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
return
}
pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
- let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
}
pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
- let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
let fd = fd as usize;
(*set).fds_bits[fd / bits] |= 1 << (fd % bits);
return
@@ -654,6 +598,12 @@ f! {
}
extern {
+ pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
+ pub fn sem_init(sem: *mut sem_t,
+ pshared: ::c_int,
+ value: ::c_uint)
+ -> ::c_int;
+
pub fn abs(i: ::c_int) -> ::c_int;
pub fn atof(s: *const ::c_char) -> ::c_double;
pub fn labs(i: ::c_long) -> ::c_long;
@@ -674,7 +624,7 @@ extern {
envp: *const *const ::c_char)
-> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(uid: ::uid_t,
+ pub fn getgrgid_r(gid: ::gid_t,
grp: *mut ::group,
buf: *mut ::c_char,
buflen: ::size_t,
@@ -720,9 +670,9 @@ extern {
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
pub fn sigwait(set: *const sigset_t,
sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
- parent: Option<unsafe extern fn()>,
- child: Option<unsafe extern fn()>) -> ::c_int;
+ pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
+ parent: ::Option<unsafe extern fn()>,
+ child: ::Option<unsafe extern fn()>) -> ::c_int;
pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "popen$UNIX2003")]
@@ -744,3 +694,14 @@ cfg_if! {
pub use target_arch_not_implemented;
}
}
+
+cfg_if! {
+ if #[cfg(libc_align)] {
+ #[macro_use]
+ mod align;
+ } else {
+ #[macro_use]
+ mod no_align;
+ }
+}
+expand_align!();
diff --git a/libc/src/unix/newlib/no_align.rs b/libc/src/unix/newlib/no_align.rs
new file mode 100644
index 0000000..316c464
--- /dev/null
+++ b/libc/src/unix/newlib/no_align.rs
@@ -0,0 +1,51 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ pub struct pthread_mutex_t { // Unverified
+ #[cfg(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc"))]
+ __align: [::c_long; 0],
+ #[cfg(not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc")))]
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ pub struct pthread_rwlock_t { // Unverified
+ #[cfg(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc"))]
+ __align: [::c_long; 0],
+ #[cfg(not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc")))]
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+
+ pub struct pthread_mutexattr_t { // Unverified
+ #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
+ target_arch = "mips64", target_arch = "s390x",
+ target_arch = "sparc64"))]
+ __align: [::c_int; 0],
+ #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64",
+ target_arch = "mips64", target_arch = "s390x",
+ target_arch = "sparc64")))]
+ __align: [::c_long; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ pub struct pthread_cond_t { // Unverified
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_COND_T],
+ }
+
+ pub struct pthread_condattr_t { // Unverified
+ __align: [::c_int; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
+ }
+ }
+ }
+}