Skip to content

Add structs defined in linux/input.h #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ci/docker/i686-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion ci/docker/x86_64-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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(),
}
});
Expand Down Expand Up @@ -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
}
});
Expand Down Expand Up @@ -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| {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/mips/mips32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/mips/mips64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
113 changes: 113 additions & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/musl/b32/mod.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/musl/b64/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub type c_char = u8;
pub type __u64 = ::c_ulonglong;

pub const SYS_perf_event_open: ::c_long = 241;
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/musl/b64/powerpc64.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub type c_char = u8;
pub type __u64 = ::c_ulong;

pub const SYS_perf_event_open: ::c_long = 319;
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/musl/b64/x86_64.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub type c_char = i8;
pub type __u64 = ::c_ulonglong;

s! {
pub struct mcontext_t {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/other/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/other/b64/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/other/b64/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/other/b64/sparc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/other/b64/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down