From 60d93226ffd6e096a16f12a7d6a491a9f819ac24 Mon Sep 17 00:00:00 2001 From: Mateusz Sieczko Date: Tue, 13 Jun 2017 17:26:14 +0200 Subject: Add structs defined in linux/input.h --- ci/docker/i686-unknown-linux-musl/Dockerfile | 9 +- ci/docker/x86_64-unknown-linux-musl/Dockerfile | 9 +- libc-test/build.rs | 12 ++- src/unix/notbsd/linux/mips/mips32.rs | 1 + src/unix/notbsd/linux/mips/mips64.rs | 1 + src/unix/notbsd/linux/mod.rs | 113 +++++++++++++++++++++++++ src/unix/notbsd/linux/musl/b32/mod.rs | 1 + src/unix/notbsd/linux/musl/b64/aarch64.rs | 1 + src/unix/notbsd/linux/musl/b64/powerpc64.rs | 1 + src/unix/notbsd/linux/musl/b64/x86_64.rs | 1 + src/unix/notbsd/linux/other/b32/mod.rs | 1 + src/unix/notbsd/linux/other/b64/aarch64.rs | 1 + src/unix/notbsd/linux/other/b64/powerpc64.rs | 1 + src/unix/notbsd/linux/other/b64/sparc64.rs | 1 + src/unix/notbsd/linux/other/b64/x86_64.rs | 1 + 15 files changed, 151 insertions(+), 3 deletions(-) diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index bdc2272a35..31a87371af 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 9c2499948a..38e2c2d70d 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 d573baaf90..b77b3161b2 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 042495e70e..afcc6c5b6b 100644 --- a/src/unix/notbsd/linux/mips/mips32.rs +++ b/src/unix/notbsd/linux/mips/mips32.rs @@ -13,6 +13,7 @@ pub type nlink_t = u32; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; pub type rlim_t = c_ulong; +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 dacd4bda1e..6566755dc2 100644 --- a/src/unix/notbsd/linux/mips/mips64.rs +++ b/src/unix/notbsd/linux/mips/mips64.rs @@ -13,6 +13,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 942f51b3a8..9a4a3ba112 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 61eb6dba17..f952105375 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 23f7dd35e5..003ee58c4d 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 4b8ca10aab..e492107842 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 2cfd903ca8..c611950b30 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 0f936c7e24..8b8b1d5ac2 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 77cee3d217..705ae52fba 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 8c19b0713d..7ff498d5f2 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 12598e0522..8f5fc85bb8 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 e1b65e8e71..b5bddb6209 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 { -- cgit v1.2.1