Skip to content

Commit a73b187

Browse files
TiwalunKowasaki
authored andcommitted
Omit accessor functions for large bitfields
1 parent 79afa5e commit a73b187

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/codegen/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,7 @@ fn flush_bitfields<'a, I>(ctx: &BindgenContext,
924924
4 => quote_ty!(ctx.ext_cx(), u32),
925925
2 => quote_ty!(ctx.ext_cx(), u16),
926926
1 => quote_ty!(ctx.ext_cx(), u8),
927-
_ => panic!("physical field containing bitfields should be sized \
928-
8, 4, 2, or 1 bytes")
927+
_ => return field
929928
};
930929
let bitfield_int_ty = BlobTyBuilder::new(bitfield_layout).build();
931930

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug, Default, Copy)]
9+
pub struct HasBigBitfield {
10+
pub _bitfield_1: [u8; 16usize],
11+
}
12+
#[test]
13+
fn bindgen_test_layout_HasBigBitfield() {
14+
assert_eq!(::std::mem::size_of::<HasBigBitfield>() , 16usize , concat ! (
15+
"Size of: " , stringify ! ( HasBigBitfield ) ));
16+
}
17+
impl Clone for HasBigBitfield {
18+
fn clone(&self) -> Self { *self }
19+
}
20+
#[repr(C)]
21+
#[derive(Debug, Default, Copy)]
22+
pub struct HasTwoBigBitfields {
23+
pub _bitfield_1: [u8; 16usize],
24+
}
25+
#[test]
26+
fn bindgen_test_layout_HasTwoBigBitfields() {
27+
assert_eq!(::std::mem::size_of::<HasTwoBigBitfields>() , 16usize , concat
28+
! ( "Size of: " , stringify ! ( HasTwoBigBitfields ) ));
29+
}
30+
impl Clone for HasTwoBigBitfields {
31+
fn clone(&self) -> Self { *self }
32+
}

tests/headers/bitfield-large.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct HasBigBitfield {
2+
__int128 x : 128;
3+
};
4+
5+
6+
struct HasTwoBigBitfields {
7+
__int128 x : 80;
8+
__int128 y : 48;
9+
};

0 commit comments

Comments
 (0)