aya_ebpf_cty/
lib.rs

1//! Type aliases to C types like c_int for use with bindgen
2//!
3//! # MSRV
4//!
5//! This crate is guaranteed to compile on stable Rust 1.30.0 and up. It *might* compile with older
6//! versions but that may change in any new patch release.
7#![no_std]
8#![expect(non_camel_case_types)]
9
10// AD = Architecture dependent
11pub use ad::*;
12// OD = OS dependent
13pub use od::*;
14
15#[cfg(target_arch = "bpf")]
16mod ad {
17    pub type c_int = i32;
18    pub type c_uint = u32;
19
20    #[cfg(any(
21        bpf_target_arch = "aarch64",
22        bpf_target_arch = "arm",
23        bpf_target_arch = "powerpc64",
24        bpf_target_arch = "riscv64",
25        bpf_target_arch = "s390x",
26        bpf_target_arch = "mips",
27    ))]
28    pub type c_char = super::c_uchar;
29
30    #[cfg(any(bpf_target_arch = "loongarch64", bpf_target_arch = "x86_64"))]
31    pub type c_char = super::c_schar;
32}
33
34#[cfg(any(
35    target_arch = "aarch64",
36    target_arch = "arm",
37    target_arch = "asmjs",
38    target_arch = "wasm32",
39    target_arch = "wasm64",
40    target_arch = "powerpc",
41    target_arch = "powerpc64",
42    target_arch = "s390x",
43    target_arch = "riscv32",
44    target_arch = "riscv64"
45))]
46mod ad {
47    pub type c_char = super::c_uchar;
48
49    pub type c_int = i32;
50    pub type c_uint = u32;
51}
52
53#[cfg(any(
54    target_arch = "loongarch64",
55    target_arch = "mips",
56    target_arch = "mips64",
57    target_arch = "nvptx",
58    target_arch = "nvptx64",
59    target_arch = "sparc64",
60    target_arch = "x86",
61    target_arch = "x86_64",
62    target_arch = "xtensa",
63))]
64mod ad {
65    pub type c_char = super::c_schar;
66
67    pub type c_int = i32;
68    pub type c_uint = u32;
69}
70
71#[cfg(target_arch = "msp430")]
72mod ad {
73    pub type c_char = super::c_uchar;
74
75    pub type c_int = i16;
76    pub type c_uint = u16;
77}
78
79// NOTE c_{,u}long definitions come from libc v0.2.3
80#[cfg(not(any(windows, target_os = "redox", target_os = "solaris")))]
81mod od {
82    #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
83    pub type c_long = i32;
84    #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
85    pub type c_ulong = u32;
86
87    #[cfg(target_pointer_width = "64")]
88    pub type c_long = i64;
89    #[cfg(target_pointer_width = "64")]
90    pub type c_ulong = u64;
91}
92
93#[cfg(windows)]
94mod od {
95    pub type c_long = i32;
96    pub type c_ulong = u32;
97}
98
99#[cfg(any(target_os = "redox", target_os = "solaris"))]
100mod od {
101    pub type c_long = i64;
102    pub type c_ulong = u64;
103}
104
105pub type int8_t = i8;
106pub type int16_t = i16;
107pub type int32_t = i32;
108pub type int64_t = i64;
109
110pub type uint8_t = u8;
111pub type uint16_t = u16;
112pub type uint32_t = u32;
113pub type uint64_t = u64;
114
115pub type c_schar = i8;
116pub type c_short = i16;
117pub type c_longlong = i64;
118
119pub type c_uchar = u8;
120pub type c_ushort = u16;
121pub type c_ulonglong = u64;
122
123pub type c_float = f32;
124pub type c_double = f64;
125
126pub type intmax_t = i64;
127pub type uintmax_t = u64;
128
129pub type size_t = usize;
130pub type ptrdiff_t = isize;
131pub type intptr_t = isize;
132pub type uintptr_t = usize;
133pub type ssize_t = isize;
134
135pub type c_void = core::ffi::c_void;