|
1 | 1 | use c2rust_bitfields::BitfieldStruct;
|
2 |
| -use libc::{c_double, c_short, c_uchar, c_uint, c_ulong, c_ushort}; |
| 2 | +use std::ffi::{c_double, c_short, c_uchar, c_uint, c_ulong, c_ushort}; |
3 | 3 | use std::mem::{size_of, transmute};
|
4 | 4 |
|
5 | 5 | #[link(name = "test")]
|
@@ -46,8 +46,8 @@ struct CompactDate {
|
46 | 46 | // Compact combination of d + m
|
47 | 47 | // which can't be accessed via ptr in C anyway
|
48 | 48 | // so we combine the fields into one:
|
49 |
| - #[bitfield(name = "d", ty = "libc::c_uchar", bits = "0..=4")] |
50 |
| - #[bitfield(name = "m", ty = "libc::c_uchar", bits = "8..=11")] |
| 49 | + #[bitfield(name = "d", ty = "std::ffi::c_uchar", bits = "0..=4")] |
| 50 | + #[bitfield(name = "m", ty = "std::ffi::c_uchar", bits = "8..=11")] |
51 | 51 | d_m: [u8; 2],
|
52 | 52 | y: u16,
|
53 | 53 | }
|
@@ -190,8 +190,8 @@ fn test_overflow() {
|
190 | 190 | struct OverlappingByteDate {
|
191 | 191 | // This is also compact, however, the first byte is shared between the two
|
192 | 192 | // bitfields and the month also has a bit in the second byte
|
193 |
| - #[bitfield(name = "d", ty = "libc::c_ulong", bits = "0..=4")] |
194 |
| - #[bitfield(name = "m", ty = "libc::c_ushort", bits = "5..=8")] |
| 193 | + #[bitfield(name = "d", ty = "std::ffi::c_ulong", bits = "0..=4")] |
| 194 | + #[bitfield(name = "m", ty = "std::ffi::c_ushort", bits = "5..=8")] |
195 | 195 | d_m: [u8; 2],
|
196 | 196 | y: u16,
|
197 | 197 | #[bitfield(padding)]
|
@@ -261,11 +261,11 @@ fn test_overlapping_byte_date2() {
|
261 | 261 | #[derive(BitfieldStruct, Copy, Clone)]
|
262 | 262 | struct UnnamedBitfield {
|
263 | 263 | z: f64,
|
264 |
| - #[bitfield(name = "x", ty = "libc::c_ushort", bits = "0..=4")] |
| 264 | + #[bitfield(name = "x", ty = "std::ffi::c_ushort", bits = "0..=4")] |
265 | 265 | x: [u8; 1],
|
266 | 266 | #[bitfield(padding)]
|
267 | 267 | _pad: [u8; 1],
|
268 |
| - #[bitfield(name = "y", ty = "libc::c_ushort", bits = "0..=8")] |
| 268 | + #[bitfield(name = "y", ty = "std::ffi::c_ushort", bits = "0..=8")] |
269 | 269 | y: [u8; 2],
|
270 | 270 | }
|
271 | 271 |
|
@@ -301,9 +301,9 @@ fn test_unnamed_bitfield() {
|
301 | 301 | #[repr(C, align(2))]
|
302 | 302 | #[derive(BitfieldStruct, Copy, Clone)]
|
303 | 303 | struct SignedBitfields {
|
304 |
| - #[bitfield(name = "x", ty = "libc::c_short", bits = "0..=3")] |
305 |
| - #[bitfield(name = "y", ty = "libc::c_ushort", bits = "4..=8")] |
306 |
| - #[bitfield(name = "z", ty = "libc::c_short", bits = "9..=13")] |
| 304 | + #[bitfield(name = "x", ty = "std::ffi::c_short", bits = "0..=3")] |
| 305 | + #[bitfield(name = "y", ty = "std::ffi::c_ushort", bits = "4..=8")] |
| 306 | + #[bitfield(name = "z", ty = "std::ffi::c_short", bits = "9..=13")] |
307 | 307 | x_y_z: [u8; 2],
|
308 | 308 | }
|
309 | 309 |
|
@@ -478,8 +478,8 @@ fn test_signed_underflow_overflow() {
|
478 | 478 | #[repr(C, align(2))]
|
479 | 479 | #[derive(BitfieldStruct, Copy, Clone)]
|
480 | 480 | struct SingleBits {
|
481 |
| - #[bitfield(name = "x", ty = "libc::c_ushort", bits = "0..=0")] |
482 |
| - #[bitfield(name = "y", ty = "libc::c_short", bits = "1..=1")] |
| 481 | + #[bitfield(name = "x", ty = "std::ffi::c_ushort", bits = "0..=0")] |
| 482 | + #[bitfield(name = "y", ty = "std::ffi::c_short", bits = "1..=1")] |
483 | 483 | x_y: [u8; 1],
|
484 | 484 | #[bitfield(padding)]
|
485 | 485 | _pad: [u8; 1],
|
@@ -532,9 +532,9 @@ fn test_single_bits() {
|
532 | 532 | #[repr(C, align(1))]
|
533 | 533 | #[derive(BitfieldStruct)]
|
534 | 534 | struct ThreeByteDate {
|
535 |
| - #[bitfield(name = "day", ty = "libc::c_uchar", bits = "0..=4")] |
536 |
| - #[bitfield(name = "month", ty = "libc::c_uchar", bits = "5..=8")] |
537 |
| - #[bitfield(name = "year", ty = "libc::c_ushort", bits = "9..=23")] |
| 535 | + #[bitfield(name = "day", ty = "std::ffi::c_uchar", bits = "0..=4")] |
| 536 | + #[bitfield(name = "month", ty = "std::ffi::c_uchar", bits = "5..=8")] |
| 537 | + #[bitfield(name = "year", ty = "std::ffi::c_ushort", bits = "9..=23")] |
538 | 538 | day_month_year: [u8; 3],
|
539 | 539 | }
|
540 | 540 |
|
|
0 commit comments