diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index bdc2272a35dce..31a87371af4e2 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -18,6 +18,13 @@ RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \ 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 9c2499948a287..38e2c2d70d72a 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -9,5 +9,12 @@ RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \ ./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 d573baaf908c5..b77b3161b2191 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -181,6 +181,7 @@ fn main() { 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 @@ fn main() { } } "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 @@ fn main() { // 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 @@ fn main() { // 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/linux/mips/mips32.rs b/src/unix/notbsd/linux/mips/mips32.rs index 59c2486efefed..f3e4c4788c9ab 100644 --- a/src/unix/notbsd/linux/mips/mips32.rs +++ b/src/unix/notbsd/linux/mips/mips32.rs @@ -10,6 +10,7 @@ pub type ino_t = u32; 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 1f28ea81f0039..1a56b6cc48819 100644 --- a/src/unix/notbsd/linux/mips/mips64.rs +++ b/src/unix/notbsd/linux/mips/mips64.rs @@ -10,6 +10,7 @@ pub type suseconds_t = i64; 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 7404f2ce43af7..40dd63f255b69 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -19,6 +19,12 @@ pub type nfds_t = ::c_ulong; 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 @@ s! { 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 61eb6dba17414..f9521053756e3 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 23f7dd35e5c98..003ee58c4d151 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 4b8ca10aab57b..e492107842899 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 2cfd903ca84fb..c611950b303a8 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 0f936c7e2444e..8b8b1d5ac2fd5 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 __fsword_t = i32; 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 77cee3d217518..705ae52fba431 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 wchar_t = u32; 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 8c19b0713dc5e..7ff498d5f2b56 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 wchar_t = i32; 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 12598e0522941..8f5fc85bb8092 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 wchar_t = i32; 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 e1b65e8e71be7..b5bddb6209642 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 nlink_t = u64; pub type blksize_t = i64; pub type greg_t = i64; pub type suseconds_t = i64; +pub type __u64 = ::c_ulonglong; s! { pub struct stat {