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

Commit 1e8ca1d

Browse files
committed
Unpin bindgen and use --size_t-is-usize
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
1 parent ce54a90 commit 1e8ca1d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ edition = "2018"
88
bitflags = "1"
99

1010
[build-dependencies]
11-
bindgen = "0.51.0"
11+
bindgen = "0.54"
1212
cc = "1.0"
1313
shlex = "0.1"

Diff for: build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ fn main() {
139139
.use_core()
140140
.ctypes_prefix("c_types")
141141
.derive_default(true)
142+
.size_t_is_usize(true)
142143
.rustfmt_bindings(true);
143144

144145
builder = builder.clang_arg(format!("--target={}", target));

Diff for: src/helpers.c

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ int access_ok_helper(const void __user *addr, unsigned long n)
2222
return access_ok(0, addr, n);
2323
#endif
2424
}
25+
26+
/* see https://github.com/rust-lang/rust-bindgen/issues/1671 */
27+
_Static_assert(__builtin_types_compatible_p(size_t, uintptr_t),
28+
"size_t must match uintptr_t, what architecture is this??");

0 commit comments

Comments
 (0)