Add structs defined in linux/input.h

This commit is contained in:
Mateusz Sieczko 2017-06-13 17:26:14 +02:00
parent 70f2986087
commit 60d93226ff
15 changed files with 151 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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| {

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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 {

View File

@ -1,3 +1,4 @@
pub type c_char = u8;
pub type __u64 = ::c_ulonglong;
pub const SYS_perf_event_open: ::c_long = 241;

View File

@ -1,3 +1,4 @@
pub type c_char = u8;
pub type __u64 = ::c_ulong;
pub const SYS_perf_event_open: ::c_long = 319;

View File

@ -1,4 +1,5 @@
pub type c_char = i8;
pub type __u64 = ::c_ulonglong;
s! {
pub struct mcontext_t {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {