aboutsummaryrefslogtreecommitdiff
path: root/libc/src/unix/uclibc/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/unix/uclibc/mod.rs')
-rw-r--r--libc/src/unix/uclibc/mod.rs260
1 files changed, 108 insertions, 152 deletions
diff --git a/libc/src/unix/uclibc/mod.rs b/libc/src/unix/uclibc/mod.rs
index c04c22a..e3baba0 100644
--- a/libc/src/unix/uclibc/mod.rs
+++ b/libc/src/unix/uclibc/mod.rs
@@ -1,5 +1,3 @@
-use dox::{mem, Option};
-
pub type sa_family_t = u16;
pub type pthread_key_t = ::c_uint;
pub type speed_t = ::c_uint;
@@ -24,11 +22,30 @@ pub type nfds_t = ::c_ulong;
pub type nl_item = ::c_int;
pub type idtype_t = ::c_uint;
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos64_t {} // TODO: fill this out with a struct
+impl ::Copy for fpos64_t {}
+impl ::Clone for fpos64_t {
+ fn clone(&self) -> fpos64_t { *self }
+}
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
+impl ::Copy for timezone {}
+impl ::Clone for timezone {
+ fn clone(&self) -> timezone { *self }
+}
s! {
+ pub struct in_addr {
+ pub s_addr: ::in_addr_t,
+ }
+
+ pub struct ip_mreq {
+ pub imr_multiaddr: in_addr,
+ pub imr_interface: in_addr,
+ }
+
pub struct sockaddr {
pub sa_family: sa_family_t,
pub sa_data: [::c_char; 14],
@@ -49,20 +66,6 @@ s! {
pub sin6_scope_id: u32,
}
- pub struct sockaddr_un {
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 108]
- }
-
- pub struct sockaddr_storage {
- pub ss_family: sa_family_t,
- __ss_align: ::size_t,
- #[cfg(target_pointer_width = "32")]
- __ss_pad2: [u8; 128 - 2 * 4],
- #[cfg(target_pointer_width = "64")]
- __ss_pad2: [u8; 128 - 2 * 8],
- }
-
pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
@@ -123,23 +126,6 @@ s! {
pub dli_saddr: *mut ::c_void,
}
- #[cfg_attr(any(all(target_arch = "x86",
- target_arch = "x86_64")),
- repr(packed))]
- pub struct epoll_event {
- pub events: ::uint32_t,
- pub u64: ::uint64_t,
- }
-
- pub struct utsname {
- pub sysname: [::c_char; 65],
- pub nodename: [::c_char; 65],
- pub release: [::c_char; 65],
- pub version: [::c_char; 65],
- pub machine: [::c_char; 65],
- pub domainname: [::c_char; 65]
- }
-
pub struct lconv {
pub decimal_point: *mut ::c_char,
pub thousands_sep: *mut ::c_char,
@@ -180,22 +166,6 @@ s! {
__unused1: [::c_int; 12]
}
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
@@ -224,103 +194,11 @@ s! {
pub ifa_data: *mut ::c_void
}
- #[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 {
- #[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 {
- #[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 {
- #[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 {
__lockkind: ::c_int,
__pshared: ::c_int,
}
- #[cfg_attr(feature = "align", repr(align(8)))]
- pub struct pthread_cond_t {
- #[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 {
- #[cfg(not(feature = "align"))]
- __align: [::c_int; 0],
- size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
- }
-
pub struct passwd {
pub pw_name: *mut ::c_char,
pub pw_passwd: *mut ::c_char,
@@ -436,6 +314,62 @@ s! {
}
}
+s_no_extra_traits! {
+ #[cfg_attr(
+ any(target_arch = "x86", target_arch = "x86_64"),
+ repr(packed)
+ )]
+ #[allow(missing_debug_implementations)]
+ pub struct epoll_event {
+ pub events: ::uint32_t,
+ pub u64: ::uint64_t,
+ }
+
+ #[allow(missing_debug_implementations)]
+ pub struct sockaddr_un {
+ pub sun_family: sa_family_t,
+ pub sun_path: [::c_char; 108]
+ }
+
+ #[allow(missing_debug_implementations)]
+ pub struct sockaddr_storage {
+ pub ss_family: sa_family_t,
+ __ss_align: ::size_t,
+ #[cfg(target_pointer_width = "32")]
+ __ss_pad2: [u8; 128 - 2 * 4],
+ #[cfg(target_pointer_width = "64")]
+ __ss_pad2: [u8; 128 - 2 * 8],
+ }
+
+ #[allow(missing_debug_implementations)]
+ pub struct utsname {
+ pub sysname: [::c_char; 65],
+ pub nodename: [::c_char; 65],
+ pub release: [::c_char; 65],
+ pub version: [::c_char; 65],
+ pub machine: [::c_char; 65],
+ pub domainname: [::c_char; 65]
+ }
+
+ #[allow(missing_debug_implementations)]
+ pub struct dirent {
+ pub d_ino: ::ino_t,
+ pub d_off: ::off_t,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+
+ #[allow(missing_debug_implementations)]
+ pub struct dirent64 {
+ pub d_ino: ::ino64_t,
+ pub d_off: ::off64_t,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+}
+
// intentionally not public, only used for fd_set
cfg_if! {
if #[cfg(target_pointer_width = "32")] {
@@ -1459,20 +1393,20 @@ pub const AF_MAX: ::c_int = 39;
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
- let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
(*set).fds_bits[fd / size] &= !(1 << (fd % size));
return
}
pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
let fd = fd as usize;
- let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
}
pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
- let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
(*set).fds_bits[fd / size] |= 1 << (fd % size);
return
}
@@ -1522,21 +1456,23 @@ f! {
}
pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.bits[idx] |= 1 << offset;
()
}
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.bits[idx] &= !(1 << offset);
()
}
pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
+ let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
0 != (cpuset.bits[idx] & (1 << offset))
}
@@ -1551,6 +1487,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;
@@ -1857,7 +1799,7 @@ extern {
pub fn glob(pattern: *const c_char,
flags: ::c_int,
- errfunc: Option<extern fn(epath: *const c_char,
+ errfunc: ::Option<extern fn(epath: *const c_char,
errno: ::c_int) -> ::c_int>,
pglob: *mut ::glob_t) -> ::c_int;
pub fn globfree(pglob: *mut ::glob_t);
@@ -1895,7 +1837,7 @@ extern {
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;
#[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,
@@ -1941,9 +1883,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 pthread_create(native: *mut ::pthread_t,
attr: *const ::pthread_attr_t,
f: extern fn(*mut ::c_void) -> *mut ::c_void,
@@ -1963,8 +1905,22 @@ cfg_if! {
} else if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
+ } else if #[cfg(target_arch = "arm")] {
+ mod arm;
+ pub use self::arm::*;
} else {
pub use unsupported_target;
}
}
+cfg_if! {
+ if #[cfg(libc_align)] {
+ #[macro_use]
+ mod align;
+ } else {
+ #[macro_use]
+ mod no_align;
+ }
+}
+
+expand_align!();