Skip to content

Commit 3092329

Browse files
authored
Enable the size_t_is_usize option in bindgen. (#63)
This eliminates the `size_t` and `ssize_t` types, and uses `usize` and `isize` in their place. This will reduce the amount of casting needed when working with the bindings.
1 parent 78d2dfc commit 3092329

29 files changed

+42
-99
lines changed

gen/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ fn run_bindgen(
336336
})
337337
.array_pointers_in_arguments(true)
338338
.derive_debug(true)
339-
.size_t_is_usize(false)
340339
.clang_arg(&format!("--target={}", clang_target))
341340
.clang_arg("-DBITS_PER_LONG=(__SIZEOF_LONG__*__CHAR_BIT__)")
342341
.clang_arg("-nostdinc")

src/aarch64/general.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,8 +2539,6 @@ pub const MNT_DETACH: u32 = 2;
25392539
pub const MNT_EXPIRE: u32 = 4;
25402540
pub const UMOUNT_NOFOLLOW: u32 = 8;
25412541
pub const UMOUNT_UNUSED: u32 = 2147483648;
2542-
pub type size_t = crate::ctypes::c_ulong;
2543-
pub type ssize_t = crate::ctypes::c_long;
25442542
pub type __s8 = crate::ctypes::c_schar;
25452543
pub type __u8 = crate::ctypes::c_uchar;
25462544
pub type __s16 = crate::ctypes::c_short;
@@ -5252,15 +5250,15 @@ pub struct msghdr {
52525250
pub msg_name: *mut crate::ctypes::c_void,
52535251
pub msg_namelen: crate::ctypes::c_int,
52545252
pub msg_iov: *mut iovec,
5255-
pub msg_iovlen: size_t,
5253+
pub msg_iovlen: usize,
52565254
pub msg_control: *mut crate::ctypes::c_void,
5257-
pub msg_controllen: size_t,
5255+
pub msg_controllen: usize,
52585256
pub msg_flags: crate::ctypes::c_uint,
52595257
}
52605258
#[repr(C)]
52615259
#[derive(Debug, Copy, Clone)]
52625260
pub struct cmsghdr {
5263-
pub cmsg_len: size_t,
5261+
pub cmsg_len: usize,
52645262
pub cmsg_level: crate::ctypes::c_int,
52655263
pub cmsg_type: crate::ctypes::c_int,
52665264
}

src/aarch64/netlink.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ pub const RTEXT_FILTER_MRP: u32 = 16;
247247
pub const RTEXT_FILTER_CFM_CONFIG: u32 = 32;
248248
pub const RTEXT_FILTER_CFM_STATUS: u32 = 64;
249249
pub const RTEXT_FILTER_MST: u32 = 128;
250-
pub type size_t = crate::ctypes::c_ulong;
251-
pub type ssize_t = crate::ctypes::c_long;
252250
pub type __kernel_sa_family_t = crate::ctypes::c_ushort;
253251
#[repr(C)]
254252
#[derive(Copy, Clone)]

src/arm/general.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,8 +2626,6 @@ pub const MNT_EXPIRE: u32 = 4;
26262626
pub const UMOUNT_NOFOLLOW: u32 = 8;
26272627
pub const UMOUNT_UNUSED: u32 = 2147483648;
26282628
pub const _NSIG: u32 = 64;
2629-
pub type size_t = crate::ctypes::c_uint;
2630-
pub type ssize_t = crate::ctypes::c_int;
26312629
pub type __s8 = crate::ctypes::c_schar;
26322630
pub type __u8 = crate::ctypes::c_uchar;
26332631
pub type __s16 = crate::ctypes::c_short;
@@ -5376,15 +5374,15 @@ pub struct msghdr {
53765374
pub msg_name: *mut crate::ctypes::c_void,
53775375
pub msg_namelen: crate::ctypes::c_int,
53785376
pub msg_iov: *mut iovec,
5379-
pub msg_iovlen: size_t,
5377+
pub msg_iovlen: usize,
53805378
pub msg_control: *mut crate::ctypes::c_void,
5381-
pub msg_controllen: size_t,
5379+
pub msg_controllen: usize,
53825380
pub msg_flags: crate::ctypes::c_uint,
53835381
}
53845382
#[repr(C)]
53855383
#[derive(Debug, Copy, Clone)]
53865384
pub struct cmsghdr {
5387-
pub cmsg_len: size_t,
5385+
pub cmsg_len: usize,
53885386
pub cmsg_level: crate::ctypes::c_int,
53895387
pub cmsg_type: crate::ctypes::c_int,
53905388
}

src/arm/netlink.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,6 @@ pub const RTEXT_FILTER_MRP: u32 = 16;
247247
pub const RTEXT_FILTER_CFM_CONFIG: u32 = 32;
248248
pub const RTEXT_FILTER_CFM_STATUS: u32 = 64;
249249
pub const RTEXT_FILTER_MST: u32 = 128;
250-
pub type size_t = crate::ctypes::c_uint;
251-
pub type ssize_t = crate::ctypes::c_int;
252250
pub type __kernel_sa_family_t = crate::ctypes::c_ushort;
253251
#[repr(C)]
254252
#[derive(Copy, Clone)]

src/mips/general.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,8 +2788,6 @@ pub const MNT_DETACH: u32 = 2;
27882788
pub const MNT_EXPIRE: u32 = 4;
27892789
pub const UMOUNT_NOFOLLOW: u32 = 8;
27902790
pub const UMOUNT_UNUSED: u32 = 2147483648;
2791-
pub type size_t = crate::ctypes::c_uint;
2792-
pub type ssize_t = crate::ctypes::c_int;
27932791
pub type __s8 = crate::ctypes::c_schar;
27942792
pub type __u8 = crate::ctypes::c_uchar;
27952793
pub type __s16 = crate::ctypes::c_short;
@@ -5540,15 +5538,15 @@ pub struct msghdr {
55405538
pub msg_name: *mut crate::ctypes::c_void,
55415539
pub msg_namelen: crate::ctypes::c_int,
55425540
pub msg_iov: *mut iovec,
5543-
pub msg_iovlen: size_t,
5541+
pub msg_iovlen: usize,
55445542
pub msg_control: *mut crate::ctypes::c_void,
5545-
pub msg_controllen: size_t,
5543+
pub msg_controllen: usize,
55465544
pub msg_flags: crate::ctypes::c_uint,
55475545
}
55485546
#[repr(C)]
55495547
#[derive(Debug, Copy, Clone)]
55505548
pub struct cmsghdr {
5551-
pub cmsg_len: size_t,
5549+
pub cmsg_len: usize,
55525550
pub cmsg_level: crate::ctypes::c_int,
55535551
pub cmsg_type: crate::ctypes::c_int,
55545552
}

src/mips/netlink.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ pub const RTEXT_FILTER_MRP: u32 = 16;
256256
pub const RTEXT_FILTER_CFM_CONFIG: u32 = 32;
257257
pub const RTEXT_FILTER_CFM_STATUS: u32 = 64;
258258
pub const RTEXT_FILTER_MST: u32 = 128;
259-
pub type size_t = crate::ctypes::c_uint;
260-
pub type ssize_t = crate::ctypes::c_int;
261259
pub type __kernel_sa_family_t = crate::ctypes::c_ushort;
262260
#[repr(C)]
263261
#[derive(Copy, Clone)]

src/mips64/general.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,8 +2723,6 @@ pub const MNT_DETACH: u32 = 2;
27232723
pub const MNT_EXPIRE: u32 = 4;
27242724
pub const UMOUNT_NOFOLLOW: u32 = 8;
27252725
pub const UMOUNT_UNUSED: u32 = 2147483648;
2726-
pub type size_t = crate::ctypes::c_ulong;
2727-
pub type ssize_t = crate::ctypes::c_long;
27282726
pub type __s8 = crate::ctypes::c_schar;
27292727
pub type __u8 = crate::ctypes::c_uchar;
27302728
pub type __s16 = crate::ctypes::c_short;
@@ -5465,15 +5463,15 @@ pub struct msghdr {
54655463
pub msg_name: *mut crate::ctypes::c_void,
54665464
pub msg_namelen: crate::ctypes::c_int,
54675465
pub msg_iov: *mut iovec,
5468-
pub msg_iovlen: size_t,
5466+
pub msg_iovlen: usize,
54695467
pub msg_control: *mut crate::ctypes::c_void,
5470-
pub msg_controllen: size_t,
5468+
pub msg_controllen: usize,
54715469
pub msg_flags: crate::ctypes::c_uint,
54725470
}
54735471
#[repr(C)]
54745472
#[derive(Debug, Copy, Clone)]
54755473
pub struct cmsghdr {
5476-
pub cmsg_len: size_t,
5474+
pub cmsg_len: usize,
54775475
pub cmsg_level: crate::ctypes::c_int,
54785476
pub cmsg_type: crate::ctypes::c_int,
54795477
}

src/mips64/netlink.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ pub const RTEXT_FILTER_MRP: u32 = 16;
256256
pub const RTEXT_FILTER_CFM_CONFIG: u32 = 32;
257257
pub const RTEXT_FILTER_CFM_STATUS: u32 = 64;
258258
pub const RTEXT_FILTER_MST: u32 = 128;
259-
pub type size_t = crate::ctypes::c_ulong;
260-
pub type ssize_t = crate::ctypes::c_long;
261259
pub type __kernel_sa_family_t = crate::ctypes::c_ushort;
262260
#[repr(C)]
263261
#[derive(Copy, Clone)]

src/powerpc/general.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,6 @@ pub const MNT_DETACH: u32 = 2;
26732673
pub const MNT_EXPIRE: u32 = 4;
26742674
pub const UMOUNT_NOFOLLOW: u32 = 8;
26752675
pub const UMOUNT_UNUSED: u32 = 2147483648;
2676-
pub type size_t = crate::ctypes::c_uint;
2677-
pub type ssize_t = crate::ctypes::c_int;
26782676
pub type __s8 = crate::ctypes::c_schar;
26792677
pub type __u8 = crate::ctypes::c_uchar;
26802678
pub type __s16 = crate::ctypes::c_short;
@@ -5461,15 +5459,15 @@ pub struct msghdr {
54615459
pub msg_name: *mut crate::ctypes::c_void,
54625460
pub msg_namelen: crate::ctypes::c_int,
54635461
pub msg_iov: *mut iovec,
5464-
pub msg_iovlen: size_t,
5462+
pub msg_iovlen: usize,
54655463
pub msg_control: *mut crate::ctypes::c_void,
5466-
pub msg_controllen: size_t,
5464+
pub msg_controllen: usize,
54675465
pub msg_flags: crate::ctypes::c_uint,
54685466
}
54695467
#[repr(C)]
54705468
#[derive(Debug, Copy, Clone)]
54715469
pub struct cmsghdr {
5472-
pub cmsg_len: size_t,
5470+
pub cmsg_len: usize,
54735471
pub cmsg_level: crate::ctypes::c_int,
54745472
pub cmsg_type: crate::ctypes::c_int,
54755473
}

0 commit comments

Comments
 (0)