Auto merge of #625 - Susurrus:termios_more, r=alexcrichton
Add more termios constants
Went through and found some more termios constants that were missing and added them. I skipped some platforms (solaris, uclibc) and assumed Android has the same constants are Linux, as I couldn't find a good reference for what Android exposes, but it generally follows linux, so I assumed the same was true for some of those values.
## References:
FreeBSD:
* https://github.com/freebsd/freebsd/blob/d39171bb1f2256bd3bf018314aec600f79b89bc6/sys/sys/_termios.h
* https://github.com/freebsd/freebsd/blob/d39171bb1f2256bd3bf018314aec600f79b89bc6/include/termios.h
NetBSD: https://github.com/NetBSD/src/blob/0bff031265b50be8e8b7719aed82212928d6c1df/sys/sys/termios.h
musl: /usr/x86_64-linux-musl/include/bits/termios.h (identical to Linux-x86_64)
linux: /usr/include/bits/termios.h
OpenBSD: https://github.com/openbsd/src/blob/5271000b44abe23907b73bbb3aa38ddf4a0bce08/sys/sys/termios.h
DragonFlyBSD:
* https://github.com/DragonFlyBSD/DragonFlyBSD/blob/ddad68003a1b070d6955ae737c834cd3267d3ead/sys/sys/_termios.h
* https://github.com/DragonFlyBSD/DragonFlyBSD/blob/ddad68003a1b070d6955ae737c834cd3267d3ead/sys/sys/termios.h
Android: Just use the same as Linux
uclibc: skipped
haiku-os: http://cgit.haiku-os.org/haiku/tree/headers/posix/termios.h
mac: /usr/include/sys/termios.h and /usr/include/sys/_types/_posix_vdisable.h
solaris: skipped
bitrig (follows openbsd): https://github.com/bitrig/bitrig/blob/d31f5220a98fae4e74abafe27c8d150843cc8105/sys/sys/termios.h
diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile
index bdc2272..31a8737 100644
--- a/ci/docker/i686-unknown-linux-musl/Dockerfile
+++ b/ci/docker/i686-unknown-linux-musl/Dockerfile
@@ -18,6 +18,13 @@
CC=gcc CFLAGS=-m32 ./configure --prefix=/musl-i686 --disable-shared --target=i686 && \
make CROSS_COMPILE= install -j4 && \
cd .. && \
- rm -rf musl-1.1.15
+ rm -rf musl-1.1.15 && \
+# Install linux kernel headers sanitized for use with musl
+ curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \
+ tar xzf - && \
+ cd kernel-headers-3.12.6-5 && \
+ make ARCH=i386 prefix=/musl-i686 install -j4 && \
+ cd .. && \
+ rm -rf kernel-headers-3.12.6-5
ENV PATH=$PATH:/musl-i686/bin:/rust/bin \
CC_i686_unknown_linux_musl=musl-gcc
diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile
index 9c24999..38e2c2d 100644
--- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile
+++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile
@@ -9,5 +9,12 @@
./configure --prefix=/musl-x86_64 && \
make install -j4 && \
cd .. && \
- rm -rf musl-1.1.15
+ rm -rf musl-1.1.15 && \
+# Install linux kernel headers sanitized for use with musl
+ curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \
+ tar xzf - && \
+ cd kernel-headers-3.12.6-5 && \
+ make ARCH=x86_64 prefix=/musl-x86_64 install -j4 && \
+ cd .. && \
+ rm -rf kernel-headers-3.12.6-5
ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin
diff --git a/libc-test/build.rs b/libc-test/build.rs
index d573baa..b77b316 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -181,6 +181,7 @@
cfg.header("sys/fsuid.h");
cfg.header("pty.h");
cfg.header("shadow.h");
+ cfg.header("linux/input.h");
if x86_64 {
cfg.header("sys/io.h");
}
@@ -301,6 +302,9 @@
}
}
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
+ "type_" if linux &&
+ (struct_ == "input_event" || struct_ == "input_mask" ||
+ struct_ == "ff_effect") => "type".to_string(),
s => s.to_string(),
}
});
@@ -329,6 +333,10 @@
// This is actually a union, not a struct
"sigval" => true,
+ // Linux kernel headers used on musl are too old to have this
+ // definition. Because it's tested on other Linux targets, skip it.
+ "input_mask" if musl => true,
+
_ => false
}
});
@@ -551,7 +559,9 @@
// aio_buf is "volatile void*" and Rust doesn't understand volatile
(struct_ == "aiocb" && field == "aio_buf") ||
// stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930
- (freebsd && struct_ == "stack_t" && field == "ss_sp")
+ (freebsd && struct_ == "stack_t" && field == "ss_sp") ||
+ // this one is an anonymous union
+ (linux && struct_ == "ff_effect" && field == "u")
});
cfg.skip_field(move |struct_, field| {
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index 48fa795..26624ae 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -254,6 +254,7 @@
pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83;
pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84;
pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85;
+pub const _SC_NPROCESSORS_CONF: ::c_int = 96;
pub const _SC_NPROCESSORS_ONLN: ::c_int = 97;
pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
diff --git a/src/unix/notbsd/linux/mips/mips32.rs b/src/unix/notbsd/linux/mips/mips32.rs
index 59c2486..f3e4c47 100644
--- a/src/unix/notbsd/linux/mips/mips32.rs
+++ b/src/unix/notbsd/linux/mips/mips32.rs
@@ -10,6 +10,7 @@
pub type blkcnt_t = i32;
pub type blksize_t = i32;
pub type nlink_t = u32;
+pub type __u64 = ::c_ulonglong;
s! {
pub struct aiocb {
diff --git a/src/unix/notbsd/linux/mips/mips64.rs b/src/unix/notbsd/linux/mips/mips64.rs
index 1f28ea8..1a56b6c 100644
--- a/src/unix/notbsd/linux/mips/mips64.rs
+++ b/src/unix/notbsd/linux/mips/mips64.rs
@@ -10,6 +10,7 @@
pub type time_t = i64;
pub type wchar_t = i32;
pub type clock_t = i64;
+pub type __u64 = ::c_ulong;
s! {
pub struct aiocb {
diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs
index 6e207a4..9ff1910 100644
--- a/src/unix/notbsd/linux/mod.rs
+++ b/src/unix/notbsd/linux/mod.rs
@@ -19,6 +19,12 @@
pub type nl_item = ::c_int;
pub type idtype_t = ::c_uint;
+pub type __u8 = ::c_uchar;
+pub type __u16 = ::c_ushort;
+pub type __s16 = ::c_short;
+pub type __u32 = ::c_uint;
+pub type __s32 = ::c_int;
+
pub enum fpos64_t {} // TODO: fill this out with a struct
s! {
@@ -231,6 +237,113 @@
pub sem_op: ::c_short,
pub sem_flg: ::c_short,
}
+
+ pub struct input_event {
+ pub time: ::timeval,
+ pub type_: ::__u16,
+ pub code: ::__u16,
+ pub value: ::__s32,
+ }
+
+ pub struct input_id {
+ pub bustype: ::__u16,
+ pub vendor: ::__u16,
+ pub product: ::__u16,
+ pub version: ::__u16,
+ }
+
+ pub struct input_absinfo {
+ pub value: ::__s32,
+ pub minimum: ::__s32,
+ pub maximum: ::__s32,
+ pub fuzz: ::__s32,
+ pub flat: ::__s32,
+ pub resolution: ::__s32,
+ }
+
+ pub struct input_keymap_entry {
+ pub flags: ::__u8,
+ pub len: ::__u8,
+ pub index: ::__u16,
+ pub keycode: ::__u32,
+ pub scancode: [::__u8; 32],
+ }
+
+ pub struct input_mask {
+ pub type_: ::__u32,
+ pub codes_size: ::__u32,
+ pub codes_ptr: ::__u64,
+ }
+
+ pub struct ff_replay {
+ pub length: ::__u16,
+ pub delay: ::__u16,
+ }
+
+ pub struct ff_trigger {
+ pub button: ::__u16,
+ pub interval: ::__u16,
+ }
+
+ pub struct ff_envelope {
+ pub attack_length: ::__u16,
+ pub attack_level: ::__u16,
+ pub fade_length: ::__u16,
+ pub fade_level: ::__u16,
+ }
+
+ pub struct ff_constant_effect {
+ pub level: ::__s16,
+ pub envelope: ff_envelope,
+ }
+
+ pub struct ff_ramp_effect {
+ pub start_level: ::__s16,
+ pub end_level: ::__s16,
+ pub envelope: ff_envelope,
+ }
+
+ pub struct ff_condition_effect {
+ pub right_saturation: ::__u16,
+ pub left_saturation: ::__u16,
+
+ pub right_coeff: ::__s16,
+ pub left_coeff: ::__s16,
+
+ pub deadband: ::__u16,
+ pub center: ::__s16,
+ }
+
+ pub struct ff_periodic_effect {
+ pub waveform: ::__u16,
+ pub period: ::__u16,
+ pub magnitude: ::__s16,
+ pub offset: ::__s16,
+ pub phase: ::__u16,
+
+ pub envelope: ff_envelope,
+
+ pub custom_len: ::__u32,
+ pub custom_data: *mut ::__s16,
+ }
+
+ pub struct ff_rumble_effect {
+ pub strong_magnitude: ::__u16,
+ pub weak_magnitude: ::__u16,
+ }
+
+ pub struct ff_effect {
+ pub type_: ::__u16,
+ pub id: ::__s16,
+ pub direction: ::__u16,
+ pub trigger: ff_trigger,
+ pub replay: ff_replay,
+ // FIXME this is actually a union
+ #[cfg(target_pointer_width = "64")]
+ pub u: [u64; 4],
+ #[cfg(target_pointer_width = "32")]
+ pub u: [u32; 7],
+ }
}
pub const ABDAY_1: ::nl_item = 0x20000;
diff --git a/src/unix/notbsd/linux/musl/b32/mod.rs b/src/unix/notbsd/linux/musl/b32/mod.rs
index 61eb6db..f952105 100644
--- a/src/unix/notbsd/linux/musl/b32/mod.rs
+++ b/src/unix/notbsd/linux/musl/b32/mod.rs
@@ -1,6 +1,7 @@
pub type c_long = i32;
pub type c_ulong = u32;
pub type nlink_t = u32;
+pub type __u64 = ::c_ulonglong;
s! {
pub struct pthread_attr_t {
diff --git a/src/unix/notbsd/linux/musl/b64/aarch64.rs b/src/unix/notbsd/linux/musl/b64/aarch64.rs
index 23f7dd3..003ee58 100644
--- a/src/unix/notbsd/linux/musl/b64/aarch64.rs
+++ b/src/unix/notbsd/linux/musl/b64/aarch64.rs
@@ -1,3 +1,4 @@
pub type c_char = u8;
+pub type __u64 = ::c_ulonglong;
pub const SYS_perf_event_open: ::c_long = 241;
diff --git a/src/unix/notbsd/linux/musl/b64/powerpc64.rs b/src/unix/notbsd/linux/musl/b64/powerpc64.rs
index 4b8ca10..e492107 100644
--- a/src/unix/notbsd/linux/musl/b64/powerpc64.rs
+++ b/src/unix/notbsd/linux/musl/b64/powerpc64.rs
@@ -1,3 +1,4 @@
pub type c_char = u8;
+pub type __u64 = ::c_ulong;
pub const SYS_perf_event_open: ::c_long = 319;
diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs
index 2cfd903..c611950 100644
--- a/src/unix/notbsd/linux/musl/b64/x86_64.rs
+++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs
@@ -1,4 +1,5 @@
pub type c_char = i8;
+pub type __u64 = ::c_ulonglong;
s! {
pub struct mcontext_t {
diff --git a/src/unix/notbsd/linux/other/b32/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs
index 0f936c7..8b8b1d5 100644
--- a/src/unix/notbsd/linux/other/b32/mod.rs
+++ b/src/unix/notbsd/linux/other/b32/mod.rs
@@ -12,6 +12,7 @@
pub type blksize_t = i32;
pub type nlink_t = u32;
+pub type __u64 = ::c_ulonglong;
s! {
pub struct stat {
diff --git a/src/unix/notbsd/linux/other/b64/aarch64.rs b/src/unix/notbsd/linux/other/b64/aarch64.rs
index a3ca948..6021bf0 100644
--- a/src/unix/notbsd/linux/other/b64/aarch64.rs
+++ b/src/unix/notbsd/linux/other/b64/aarch64.rs
@@ -5,6 +5,7 @@
pub type nlink_t = u32;
pub type blksize_t = i32;
pub type suseconds_t = i64;
+pub type __u64 = ::c_ulonglong;
s! {
pub struct stat {
diff --git a/src/unix/notbsd/linux/other/b64/powerpc64.rs b/src/unix/notbsd/linux/other/b64/powerpc64.rs
index 719412e..6653408 100644
--- a/src/unix/notbsd/linux/other/b64/powerpc64.rs
+++ b/src/unix/notbsd/linux/other/b64/powerpc64.rs
@@ -5,6 +5,7 @@
pub type nlink_t = u64;
pub type blksize_t = i64;
pub type suseconds_t = i64;
+pub type __u64 = ::c_ulong;
s! {
pub struct stat {
diff --git a/src/unix/notbsd/linux/other/b64/sparc64.rs b/src/unix/notbsd/linux/other/b64/sparc64.rs
index 1edda70..7b59021 100644
--- a/src/unix/notbsd/linux/other/b64/sparc64.rs
+++ b/src/unix/notbsd/linux/other/b64/sparc64.rs
@@ -5,6 +5,7 @@
pub type nlink_t = u32;
pub type blksize_t = i64;
pub type suseconds_t = i32;
+pub type __u64 = ::c_ulonglong;
s! {
pub struct stat {
diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs
index 228258f..3e6cee9 100644
--- a/src/unix/notbsd/linux/other/b64/x86_64.rs
+++ b/src/unix/notbsd/linux/other/b64/x86_64.rs
@@ -6,6 +6,7 @@
pub type blksize_t = i64;
pub type greg_t = i64;
pub type suseconds_t = i64;
+pub type __u64 = ::c_ulonglong;
s! {
pub struct stat {
diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs
index 2722201..603efb1 100644
--- a/src/unix/uclibc/x86_64/mod.rs
+++ b/src/unix/uclibc/x86_64/mod.rs
@@ -2,6 +2,7 @@
pub type blkcnt_t = i64;
pub type blksize_t = i64;
+pub type clock_t = i64;
pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;
@@ -22,32 +23,70 @@
pub type nfds_t = ::c_ulong;
s! {
- // ------------------------------------------------------------
- // networking
- pub struct in_addr {
- pub s_addr: in_addr_t,
+ pub struct ipc_perm {
+ pub __key: ::key_t,
+ pub uid: ::uid_t,
+ pub gid: ::gid_t,
+ pub cuid: ::uid_t,
+ pub cgid: ::gid_t,
+ pub mode: ::c_ushort, // read / write
+ __pad1: ::c_ushort,
+ pub __seq: ::c_ushort,
+ __pad2: ::c_ushort,
+ __unused1: ::c_ulong,
+ __unused2: ::c_ulong
}
- pub struct in6_addr {
- pub s6_addr: [u8; 16],
- __align: [u32; 0],
+ pub struct siginfo_t {
+ si_signo: ::c_int, // signal number
+ si_errno: ::c_int, // if not zero: error value of signal, see errno.h
+ si_code: ::c_int, // signal code
+ pub _pad: [::c_int; 28], // unported union
+ _align: [usize; 0],
+ }
+
+ pub struct shmid_ds {
+ pub shm_perm: ::ipc_perm,
+ pub shm_segsz: ::size_t, // segment size in bytes
+ pub shm_atime: ::time_t, // time of last shmat()
+ pub shm_dtime: ::time_t,
+ pub shm_ctime: ::time_t,
+ pub shm_cpid: ::pid_t,
+ pub shm_lpid: ::pid_t,
+ pub shm_nattch: ::shmatt_t,
+ __unused1: ::c_ulong,
+ __unused2: ::c_ulong
+ }
+
+ pub struct msqid_ds {
+ pub msg_perm: ::ipc_perm,
+ pub msg_stime: ::time_t,
+ pub msg_rtime: ::time_t,
+ pub msg_ctime: ::time_t,
+ __msg_cbytes: ::c_ulong,
+ pub msg_qnum: ::msgqnum_t,
+ pub msg_qbytes: ::msglen_t,
+ pub msg_lspid: ::pid_t,
+ pub msg_lrpid: ::pid_t,
+ __ignored1: ::c_ulong,
+ __ignored2: ::c_ulong,
}
pub struct sockaddr {
- pub sa_family: sa_family_t,
+ pub sa_family: ::sa_family_t,
pub sa_data: [::c_char; 14],
}
pub struct sockaddr_in {
- pub sin_family: sa_family_t,
+ pub sin_family: ::sa_family_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [u8; 8],
}
pub struct sockaddr_in6 {
- pub sin6_family: sa_family_t,
- pub sin6_port: in_port_t,
+ pub sin6_family: ::sa_family_t,
+ pub sin6_port: ::in_port_t,
pub sin6_flowinfo: u32,
pub sin6_addr: ::in6_addr,
pub sin6_scope_id: u32,
@@ -55,6 +94,15 @@
// ------------------------------------------------------------
// definitions below are *unverified* and might **break** the software
+// pub struct in_addr {
+// pub s_addr: in_addr_t,
+// }
+//
+// pub struct in6_addr {
+// pub s6_addr: [u8; 16],
+// __align: [u32; 0],
+// }
+
pub struct stat { // ToDo
pub st_dev: ::c_ulong,
st_pad1: [::c_long; 2],
@@ -100,16 +148,16 @@
}
pub struct dirent { // Todo
- pub d_ino: ino_64_t,
- pub d_off: off64_t,
+ pub d_ino: ::ino64_t,
+ pub d_off: ::off64_t,
d_reclen: u16,
pub d_type: u8,
pub d_name: [i8; 256],
}
pub struct dirent64 { //
- pub d_ino: ino64_t,
- pub d_off: off64_t,
+ pub d_ino: ::ino64_t,
+ pub d_off: ::off64_t,
pub d_reclen: u16,
pub d_type: u8,
pub d_name: [i8; 256],
@@ -303,6 +351,7 @@
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
+pub const RLIM_INFINITY: u64 = 0xffffffffffffffff;
pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;