Skip to content

Commit 0e702c1

Browse files
committed
Auto merge of #1379 - gnzlbg:deprecate_fixed_width_ints, r=gnzlbg
Deprecate fixed width integer type aliases cc @emilio - I think it makes sense to ensure that the latest released version of bindgen works properly with this change. That is, that even when asked to use C types from, e.g., `libc::`, it does not use aliases for the fixed-width integer C types (e.g. `libc::int64_t`) but uses Rust primitive types instead (e.g. `u64`). Closes #1304 .
2 parents e66b2a8 + afa3edf commit 0e702c1

File tree

37 files changed

+759
-762
lines changed

37 files changed

+759
-762
lines changed

src/cloudabi/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
pub type int8_t = i8;
2-
pub type int16_t = i16;
3-
pub type int32_t = i32;
4-
pub type int64_t = i64;
5-
pub type uint8_t = u8;
6-
pub type uint16_t = u16;
7-
pub type uint32_t = u32;
8-
pub type uint64_t = u64;
9-
101
pub type c_schar = i8;
112
pub type c_uchar = u8;
123
pub type c_short = i16;

src/fixed_width_ints.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//! This module contains type aliases for C's fixed-width integer types .
2+
//!
3+
//! These aliases are deprecated: use the Rust types instead.
4+
5+
#[deprecated(
6+
since = "0.2.55",
7+
note = "Use i8 instead."
8+
)]
9+
pub type int8_t = i8;
10+
#[deprecated(
11+
since = "0.2.55",
12+
note = "Use i16 instead."
13+
)]
14+
pub type int16_t = i16;
15+
#[deprecated(
16+
since = "0.2.55",
17+
note = "Use i32 instead."
18+
)]
19+
pub type int32_t = i32;
20+
#[deprecated(
21+
since = "0.2.55",
22+
note = "Use i64 instead."
23+
)]
24+
pub type int64_t = i64;
25+
#[deprecated(
26+
since = "0.2.55",
27+
note = "Use u8 instead."
28+
)]
29+
pub type uint8_t = u8;
30+
#[deprecated(
31+
since = "0.2.55",
32+
note = "Use u16 instead."
33+
)]
34+
pub type uint16_t = u16;
35+
#[deprecated(
36+
since = "0.2.55",
37+
note = "Use u32 instead."
38+
)]
39+
pub type uint32_t = u32;
40+
#[deprecated(
41+
since = "0.2.55",
42+
note = "Use u64 instead."
43+
)]
44+
pub type uint64_t = u64;

src/fuchsia/mod.rs

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55
66
// PUB_TYPE
77

8-
pub type int8_t = i8;
9-
pub type int16_t = i16;
10-
pub type int32_t = i32;
11-
pub type int64_t = i64;
12-
pub type uint8_t = u8;
13-
pub type uint16_t = u16;
14-
pub type uint32_t = u32;
15-
pub type uint64_t = u64;
16-
178
pub type c_schar = i8;
189
pub type c_uchar = u8;
1910
pub type c_short = i16;
@@ -410,8 +401,8 @@ s! {
410401
}
411402

412403
pub struct epoll_event {
413-
pub events: ::uint32_t,
414-
pub u64: ::uint64_t,
404+
pub events: u32,
405+
pub u64: u64,
415406
}
416407

417408
pub struct lconv {
@@ -521,40 +512,40 @@ s! {
521512
}
522513

523514
pub struct dqblk {
524-
pub dqb_bhardlimit: ::uint64_t,
525-
pub dqb_bsoftlimit: ::uint64_t,
526-
pub dqb_curspace: ::uint64_t,
527-
pub dqb_ihardlimit: ::uint64_t,
528-
pub dqb_isoftlimit: ::uint64_t,
529-
pub dqb_curinodes: ::uint64_t,
530-
pub dqb_btime: ::uint64_t,
531-
pub dqb_itime: ::uint64_t,
532-
pub dqb_valid: ::uint32_t,
515+
pub dqb_bhardlimit: u64,
516+
pub dqb_bsoftlimit: u64,
517+
pub dqb_curspace: u64,
518+
pub dqb_ihardlimit: u64,
519+
pub dqb_isoftlimit: u64,
520+
pub dqb_curinodes: u64,
521+
pub dqb_btime: u64,
522+
pub dqb_itime: u64,
523+
pub dqb_valid: u32,
533524
}
534525

535526
pub struct signalfd_siginfo {
536-
pub ssi_signo: ::uint32_t,
537-
pub ssi_errno: ::int32_t,
538-
pub ssi_code: ::int32_t,
539-
pub ssi_pid: ::uint32_t,
540-
pub ssi_uid: ::uint32_t,
541-
pub ssi_fd: ::int32_t,
542-
pub ssi_tid: ::uint32_t,
543-
pub ssi_band: ::uint32_t,
544-
pub ssi_overrun: ::uint32_t,
545-
pub ssi_trapno: ::uint32_t,
546-
pub ssi_status: ::int32_t,
547-
pub ssi_int: ::int32_t,
548-
pub ssi_ptr: ::uint64_t,
549-
pub ssi_utime: ::uint64_t,
550-
pub ssi_stime: ::uint64_t,
551-
pub ssi_addr: ::uint64_t,
552-
pub ssi_addr_lsb: ::uint16_t,
553-
_pad2: ::uint16_t,
554-
pub ssi_syscall: ::int32_t,
555-
pub ssi_call_addr: ::uint64_t,
556-
pub ssi_arch: ::uint32_t,
557-
_pad: [::uint8_t; 28],
527+
pub ssi_signo: u32,
528+
pub ssi_errno: i32,
529+
pub ssi_code: i32,
530+
pub ssi_pid: u32,
531+
pub ssi_uid: u32,
532+
pub ssi_fd: i32,
533+
pub ssi_tid: u32,
534+
pub ssi_band: u32,
535+
pub ssi_overrun: u32,
536+
pub ssi_trapno: u32,
537+
pub ssi_status: i32,
538+
pub ssi_int: i32,
539+
pub ssi_ptr: u64,
540+
pub ssi_utime: u64,
541+
pub ssi_stime: u64,
542+
pub ssi_addr: u64,
543+
pub ssi_addr_lsb: u16,
544+
_pad2: u16,
545+
pub ssi_syscall: i32,
546+
pub ssi_call_addr: u64,
547+
pub ssi_arch: u32,
548+
_pad: [u8; 28],
558549
}
559550

560551
pub struct itimerspec {
@@ -1803,16 +1794,16 @@ pub const MNT_EXPIRE: ::c_int = 0x4;
18031794
pub const Q_GETFMT: ::c_int = 0x800004;
18041795
pub const Q_GETINFO: ::c_int = 0x800005;
18051796
pub const Q_SETINFO: ::c_int = 0x800006;
1806-
pub const QIF_BLIMITS: ::uint32_t = 1;
1807-
pub const QIF_SPACE: ::uint32_t = 2;
1808-
pub const QIF_ILIMITS: ::uint32_t = 4;
1809-
pub const QIF_INODES: ::uint32_t = 8;
1810-
pub const QIF_BTIME: ::uint32_t = 16;
1811-
pub const QIF_ITIME: ::uint32_t = 32;
1812-
pub const QIF_LIMITS: ::uint32_t = 5;
1813-
pub const QIF_USAGE: ::uint32_t = 10;
1814-
pub const QIF_TIMES: ::uint32_t = 48;
1815-
pub const QIF_ALL: ::uint32_t = 63;
1797+
pub const QIF_BLIMITS: u32 = 1;
1798+
pub const QIF_SPACE: u32 = 2;
1799+
pub const QIF_ILIMITS: u32 = 4;
1800+
pub const QIF_INODES: u32 = 8;
1801+
pub const QIF_BTIME: u32 = 16;
1802+
pub const QIF_ITIME: u32 = 32;
1803+
pub const QIF_LIMITS: u32 = 5;
1804+
pub const QIF_USAGE: u32 = 10;
1805+
pub const QIF_TIMES: u32 = 48;
1806+
pub const QIF_ALL: u32 = 63;
18161807

18171808
pub const MNT_FORCE: ::c_int = 0x1;
18181809

src/hermit/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313
// Ported by Colin Fink <[email protected]>
1414
// and Stefan Lankes <[email protected]>
1515

16-
pub type int8_t = i8;
17-
pub type int16_t = i16;
18-
pub type int32_t = i32;
19-
pub type int64_t = i64;
20-
pub type uint8_t = u8;
21-
pub type uint16_t = u16;
22-
pub type uint32_t = u32;
23-
pub type uint64_t = u64;
24-
2516
pub type c_schar = i8;
2617
pub type c_uchar = u8;
2718
pub type c_short = i16;

src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,51 @@ cfg_if! {
9090

9191
cfg_if! {
9292
if #[cfg(windows)] {
93+
mod fixed_width_ints;
94+
pub use fixed_width_ints::*;
95+
9396
mod windows;
9497
pub use windows::*;
9598
} else if #[cfg(target_os = "cloudabi")] {
99+
mod fixed_width_ints;
100+
pub use fixed_width_ints::*;
101+
96102
mod cloudabi;
97103
pub use cloudabi::*;
98104
} else if #[cfg(target_os = "fuchsia")] {
105+
mod fixed_width_ints;
106+
pub use fixed_width_ints::*;
107+
99108
mod fuchsia;
100109
pub use fuchsia::*;
101110
} else if #[cfg(target_os = "switch")] {
111+
mod fixed_width_ints;
112+
pub use fixed_width_ints::*;
113+
102114
mod switch;
103115
pub use switch::*;
104116
} else if #[cfg(unix)] {
117+
mod fixed_width_ints;
118+
pub use fixed_width_ints::*;
119+
105120
mod unix;
106121
pub use unix::*;
107122
} else if #[cfg(target_os = "hermit")] {
123+
mod fixed_width_ints;
124+
pub use fixed_width_ints::*;
125+
108126
mod hermit;
109127
pub use hermit::*;
110128
} else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
129+
mod fixed_width_ints;
130+
pub use fixed_width_ints::*;
131+
111132
mod sgx;
112133
pub use sgx::*;
113134
} else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
135+
mod fixed_width_ints;
136+
pub use fixed_width_ints::*;
137+
114138
mod wasi;
115139
pub use wasi::*;
116140
} else {

src/sgx.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
//! SGX C types definition
22
3-
pub type int8_t = i8;
4-
pub type int16_t = i16;
5-
pub type int32_t = i32;
6-
pub type int64_t = i64;
7-
pub type uint8_t = u8;
8-
pub type uint16_t = u16;
9-
pub type uint32_t = u32;
10-
pub type uint64_t = u64;
11-
123
pub type c_schar = i8;
134
pub type c_uchar = u8;
145
pub type c_short = i16;

src/switch.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
//! Switch C type definitions
22
3-
pub type int8_t = i8;
4-
pub type int16_t = i16;
5-
pub type int32_t = i32;
6-
pub type int64_t = i64;
7-
pub type uint8_t = u8;
8-
pub type uint16_t = u16;
9-
pub type uint32_t = u32;
10-
pub type uint64_t = u64;
11-
123
pub type c_schar = i8;
134
pub type c_uchar = u8;
145
pub type c_short = i16;

src/unix/bsd/apple/b32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ s! {
3939

4040
pub struct bpf_hdr {
4141
pub bh_tstamp: ::timeval,
42-
pub bh_caplen: ::uint32_t,
43-
pub bh_datalen: ::uint32_t,
42+
pub bh_caplen: u32,
43+
pub bh_datalen: u32,
4444
pub bh_hdrlen: ::c_ushort,
4545
}
4646
}

src/unix/bsd/apple/b64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ s! {
4444

4545
pub struct bpf_hdr {
4646
pub bh_tstamp: ::timeval32,
47-
pub bh_caplen: ::uint32_t,
48-
pub bh_datalen: ::uint32_t,
47+
pub bh_caplen: u32,
48+
pub bh_datalen: u32,
4949
pub bh_hdrlen: ::c_ushort,
5050
}
5151
}

0 commit comments

Comments
 (0)