Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

Commit

Permalink
Unpin bindgen and use --size_t-is-usize
Browse files Browse the repository at this point in the history
Add an assertion that doing so is safe.
See rust-lang/rust-bindgen#1671

Can't use static_assert from <linux/build_bug.h> because that's
5.1+-only, but the underlying _Static_assert compiler builtin is
available widely.
See torvalds/linux@6bab69c
  • Loading branch information
geofft committed Aug 9, 2020
1 parent ce54a90 commit 2e77244
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ edition = "2018"
bitflags = "1"

[build-dependencies]
bindgen = "0.51.0"
bindgen = "*"
cc = "1.0"
shlex = "0.1"
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ fn main() {
.use_core()
.ctypes_prefix("c_types")
.derive_default(true)
.size_t_is_usize(true)
.rustfmt_bindings(true);

builder = builder.clang_arg(format!("--target={}", target));
Expand Down
4 changes: 4 additions & 0 deletions src/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ int access_ok_helper(const void __user *addr, unsigned long n)
return access_ok(0, addr, n);
#endif
}

/* see https://github.com/rust-lang/rust-bindgen/issues/1671 */
_Static_assert(__builtin_types_compatible_p(size_t, uintptr_t),
"size_t must match uintptr_t, what architecture is this??");

0 comments on commit 2e77244

Please sign in to comment.