forked from rust-lang/libc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional Linux AF_PACKET options (rust-lang#3540)
- Loading branch information
1 parent
31c3cd4
commit a8a3267
Showing
3 changed files
with
535 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
macro_rules! expand_align { | ||
() => { | ||
s! { | ||
#[cfg_attr(any(target_pointer_width = "32", | ||
target_arch = "x86_64", | ||
target_arch = "powerpc64", | ||
target_arch = "mips64", | ||
target_arch = "mips64r6", | ||
target_arch = "s390x", | ||
target_arch = "sparc64", | ||
target_arch = "aarch64", | ||
target_arch = "riscv64", | ||
target_arch = "riscv32", | ||
target_arch = "loongarch64"), | ||
repr(align(4)))] | ||
#[cfg_attr(not(any(target_pointer_width = "32", | ||
target_arch = "x86_64", | ||
target_arch = "powerpc64", | ||
target_arch = "mips64", | ||
target_arch = "mips64r6", | ||
target_arch = "s390x", | ||
target_arch = "sparc64", | ||
target_arch = "aarch64", | ||
target_arch = "riscv64", | ||
target_arch = "riscv32", | ||
target_arch = "loongarch64")), | ||
repr(align(8)))] | ||
pub struct pthread_mutexattr_t { | ||
#[doc(hidden)] | ||
size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], | ||
} | ||
|
||
#[cfg_attr(any(target_env = "musl", target_env = "ohos", target_pointer_width = "32"), | ||
repr(align(4)))] | ||
#[cfg_attr(all(not(target_env = "musl"), | ||
not(target_env = "ohos"), | ||
target_pointer_width = "64"), | ||
repr(align(8)))] | ||
pub struct pthread_rwlockattr_t { | ||
#[doc(hidden)] | ||
size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], | ||
} | ||
|
||
#[repr(align(4))] | ||
pub struct pthread_condattr_t { | ||
#[doc(hidden)] | ||
size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], | ||
} | ||
|
||
#[repr(align(4))] | ||
pub struct pthread_barrierattr_t { | ||
#[doc(hidden)] | ||
size: [u8; ::__SIZEOF_PTHREAD_BARRIERATTR_T], | ||
} | ||
|
||
#[repr(align(8))] | ||
pub struct fanotify_event_metadata { | ||
pub event_len: __u32, | ||
pub vers: __u8, | ||
pub reserved: __u8, | ||
pub metadata_len: __u16, | ||
pub mask: __u64, | ||
pub fd: ::c_int, | ||
pub pid: ::c_int, | ||
} | ||
|
||
#[repr(align(8))] | ||
pub struct tpacket_rollover_stats { | ||
pub tp_all: ::__u64, | ||
pub tp_huge: ::__u64, | ||
pub tp_failed: ::__u64, | ||
} | ||
|
||
#[repr(align(8))] | ||
pub struct tpacket_hdr_v1 { | ||
pub block_status: ::__u32, | ||
pub num_pkts: ::__u32, | ||
pub offset_to_first_pkt: ::__u32, | ||
pub blk_len: ::__u32, | ||
pub seq_num: ::__u64, | ||
pub ts_first_pkt: ::tpacket_bd_ts, | ||
pub ts_last_pkt: ::tpacket_bd_ts, | ||
} | ||
} | ||
|
||
s_no_extra_traits! { | ||
#[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), | ||
target_pointer_width = "32"), | ||
repr(align(4)))] | ||
#[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), | ||
target_pointer_width = "64"), | ||
repr(align(8)))] | ||
#[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), | ||
target_arch = "x86"), | ||
repr(align(4)))] | ||
#[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), | ||
not(target_arch = "x86")), | ||
repr(align(8)))] | ||
pub struct pthread_cond_t { | ||
#[doc(hidden)] | ||
size: [u8; ::__SIZEOF_PTHREAD_COND_T], | ||
} | ||
|
||
#[cfg_attr(all(target_pointer_width = "32", | ||
any(target_arch = "mips", | ||
target_arch = "mips32r6", | ||
target_arch = "arm", | ||
target_arch = "hexagon", | ||
target_arch = "m68k", | ||
target_arch = "csky", | ||
target_arch = "powerpc", | ||
target_arch = "sparc", | ||
target_arch = "x86_64", | ||
target_arch = "x86")), | ||
repr(align(4)))] | ||
#[cfg_attr(any(target_pointer_width = "64", | ||
not(any(target_arch = "mips", | ||
target_arch = "mips32r6", | ||
target_arch = "arm", | ||
target_arch = "hexagon", | ||
target_arch = "m68k", | ||
target_arch = "csky", | ||
target_arch = "powerpc", | ||
target_arch = "sparc", | ||
target_arch = "x86_64", | ||
target_arch = "x86"))), | ||
repr(align(8)))] | ||
pub struct pthread_mutex_t { | ||
#[doc(hidden)] | ||
size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], | ||
} | ||
|
||
#[cfg_attr(all(target_pointer_width = "32", | ||
any(target_arch = "mips", | ||
target_arch = "mips32r6", | ||
target_arch = "arm", | ||
target_arch = "hexagon", | ||
target_arch = "m68k", | ||
target_arch = "csky", | ||
target_arch = "powerpc", | ||
target_arch = "sparc", | ||
target_arch = "x86_64", | ||
target_arch = "x86")), | ||
repr(align(4)))] | ||
#[cfg_attr(any(target_pointer_width = "64", | ||
not(any(target_arch = "mips", | ||
target_arch = "mips32r6", | ||
target_arch = "arm", | ||
target_arch = "hexagon", | ||
target_arch = "m68k", | ||
target_arch = "powerpc", | ||
target_arch = "sparc", | ||
target_arch = "x86_64", | ||
target_arch = "x86"))), | ||
repr(align(8)))] | ||
pub struct pthread_rwlock_t { | ||
size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], | ||
} | ||
|
||
#[cfg_attr(all(target_pointer_width = "32", | ||
any(target_arch = "mips", | ||
target_arch = "mips32r6", | ||
target_arch = "arm", | ||
target_arch = "hexagon", | ||
target_arch = "m68k", | ||
target_arch = "csky", | ||
target_arch = "powerpc", | ||
target_arch = "sparc", | ||
target_arch = "x86_64", | ||
target_arch = "x86")), | ||
repr(align(4)))] | ||
#[cfg_attr(any(target_pointer_width = "64", | ||
not(any(target_arch = "mips", | ||
target_arch = "mips32r6", | ||
target_arch = "arm", | ||
target_arch = "hexagon", | ||
target_arch = "m68k", | ||
target_arch = "csky", | ||
target_arch = "powerpc", | ||
target_arch = "sparc", | ||
target_arch = "x86_64", | ||
target_arch = "x86"))), | ||
repr(align(8)))] | ||
pub struct pthread_barrier_t { | ||
size: [u8; ::__SIZEOF_PTHREAD_BARRIER_T], | ||
} | ||
|
||
// linux/can.h | ||
#[repr(align(8))] | ||
#[allow(missing_debug_implementations)] | ||
pub struct can_frame { | ||
pub can_id: canid_t, | ||
pub can_dlc: u8, | ||
__pad: u8, | ||
__res0: u8, | ||
__res1: u8, | ||
pub data: [u8; CAN_MAX_DLEN], | ||
} | ||
|
||
#[repr(align(8))] | ||
#[allow(missing_debug_implementations)] | ||
pub struct canfd_frame { | ||
pub can_id: canid_t, | ||
pub len: u8, | ||
pub flags: u8, | ||
__res0: u8, | ||
__res1: u8, | ||
pub data: [u8; CANFD_MAX_DLEN], | ||
} | ||
|
||
#[repr(align(8))] | ||
#[allow(missing_debug_implementations)] | ||
pub struct canxl_frame { | ||
pub prio: canid_t, | ||
pub flags: u8, | ||
pub sdt: u8, | ||
pub len: u16, | ||
pub af: u32, | ||
pub data: [u8; CANXL_MAX_DLEN], | ||
} | ||
} | ||
}; | ||
} |
Oops, something went wrong.