fix: unit tests

This commit is contained in:
Danielhu 2023-08-31 00:26:06 +08:00
parent f33f18bb8c
commit aa9544a03e
5 changed files with 662 additions and 72 deletions

2
.gitignore vendored
View File

@ -16,3 +16,5 @@ unity-sandbox/*.csproj.user
unity-sandbox/*.sln unity-sandbox/*.sln
unity-sandbox/Library unity-sandbox/Library
unity-sandbox/Logs/ unity-sandbox/Logs/
csbindgen-tests/src/lz4.rs

View File

@ -2,15 +2,15 @@ use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn Error>> {
//fn main() { //fn main() {
// bindgen::Builder::default() bindgen::Builder::default()
// .header("c/lz4/lz4.h") .header("c/lz4/lz4.h")
// .header("c/lz4/lz4hc.h") .header("c/lz4/lz4hc.h")
// .header("c/lz4/lz4frame.h") .header("c/lz4/lz4frame.h")
// .header("c/lz4/xxhash.h") .header("c/lz4/xxhash.h")
// .generate() .generate()
// .unwrap() .unwrap()
// .write_to_file("src/lz4.rs") .write_to_file("src/lz4.rs")
// .unwrap(); .unwrap();
cc::Build::new() cc::Build::new()
.files([ .files([
@ -31,7 +31,6 @@ fn main() -> Result<(), Box<dyn Error>> {
// .generate()? // .generate()?
// .write_to_file("src/quiche.rs")?; // .write_to_file("src/quiche.rs")?;
// bindgen::Builder::default() // bindgen::Builder::default()
// .header("c/sqlite3/sqlite3.h") // .header("c/sqlite3/sqlite3.h")
// .generate()? // .generate()?
@ -65,7 +64,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.csharp_generate_const(true) .csharp_generate_const(true)
.generate_to_file("src/lz4_ffi.rs", "../dotnet-sandbox/lz4_bindgen.cs") .generate_to_file("src/lz4_ffi.rs", "../dotnet-sandbox/lz4_bindgen.cs")
.unwrap(); .unwrap();
// csbindgen::Builder::default() // csbindgen::Builder::default()
// .input_bindgen_file("src/sqlite3.rs") // .input_bindgen_file("src/sqlite3.rs")
// .method_filter(|x| x.starts_with("sqlite3_")) // .method_filter(|x| x.starts_with("sqlite3_"))
@ -100,7 +99,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.csharp_use_function_pointer(true) .csharp_use_function_pointer(true)
.generate_csharp_file("../dotnet-sandbox/NestedModuleTests.cs") .generate_csharp_file("../dotnet-sandbox/NestedModuleTests.cs")
.unwrap(); .unwrap();
csbindgen::Builder::new() csbindgen::Builder::new()
.input_bindgen_file("src/zstd.rs") .input_bindgen_file("src/zstd.rs")
.method_filter(|x| x.starts_with("ZSTD_")) .method_filter(|x| x.starts_with("ZSTD_"))
@ -126,7 +125,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.csharp_generate_const(true) .csharp_generate_const(true)
.generate_to_file("src/bullet3_ffi.rs", "../dotnet-sandbox/bullet3_bindgen.cs")?; .generate_to_file("src/bullet3_ffi.rs", "../dotnet-sandbox/bullet3_bindgen.cs")?;
csbindgen::Builder::new() csbindgen::Builder::new()
.input_bindgen_file("src/libpng16.rs") .input_bindgen_file("src/libpng16.rs")
//.method_filter(|x| x.starts_with("png_")) //.method_filter(|x| x.starts_with("png_"))
@ -135,7 +133,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.csharp_dll_name("libpng16") .csharp_dll_name("libpng16")
.generate_csharp_file("../dotnet-sandbox/libpng16_csbindgen.cs")?; .generate_csharp_file("../dotnet-sandbox/libpng16_csbindgen.cs")?;
csbindgen::Builder::new() csbindgen::Builder::new()
.input_bindgen_file("src/physx/lib.rs") .input_bindgen_file("src/physx/lib.rs")
.input_bindgen_file("src/physx/physx_generated.rs") .input_bindgen_file("src/physx/physx_generated.rs")

View File

@ -126,7 +126,6 @@ pub const CCHAR: char = 'あ';
pub const BOOLCONST_T: bool = true; pub const BOOLCONST_T: bool = true;
pub const BOOLCONST_F: bool = false; pub const BOOLCONST_F: bool = false;
/// my comment! /// my comment!
#[no_mangle] #[no_mangle]
extern "C" fn comment_one(_flags: EnumFlags) {} extern "C" fn comment_one(_flags: EnumFlags) {}
@ -345,7 +344,7 @@ pub struct MyVector3 {
pub z: f32, pub z: f32,
} }
// not repr(C) // not repr(C)
pub struct InternalCounterContext { pub struct InternalCounterContext {
pub set: HashSet<i32>, pub set: HashSet<i32>,
} }
@ -475,6 +474,7 @@ pub struct Context {
fn build_test() { fn build_test() {
let path = std::env::current_dir().unwrap(); let path = std::env::current_dir().unwrap();
println!("starting dir: {}", path.display()); // csbindgen/csbindgen-tests println!("starting dir: {}", path.display()); // csbindgen/csbindgen-tests
std::env::set_current_dir(path.parent().unwrap()).unwrap();
// // unsafe { // // unsafe {
// // let num = lz4::LZ4_versionNumber(); // // let num = lz4::LZ4_versionNumber();

View File

@ -13,22 +13,80 @@ pub const LZ4_MAX_INPUT_SIZE: u32 = 2113929216;
pub const LZ4_HASHLOG: u32 = 12; pub const LZ4_HASHLOG: u32 = 12;
pub const LZ4_HASHTABLESIZE: u32 = 16384; pub const LZ4_HASHTABLESIZE: u32 = 16384;
pub const LZ4_HASH_SIZE_U32: u32 = 4096; pub const LZ4_HASH_SIZE_U32: u32 = 4096;
pub const _VCRT_COMPILER_PREPROCESSOR: u32 = 1; pub const __WORDSIZE: u32 = 64;
pub const _SAL_VERSION: u32 = 20; pub const __DARWIN_ONLY_64_BIT_INO_T: u32 = 1;
pub const __SAL_H_VERSION: u32 = 180000000; pub const __DARWIN_ONLY_UNIX_CONFORMANCE: u32 = 1;
pub const _USE_DECLSPECS_FOR_SAL: u32 = 0; pub const __DARWIN_ONLY_VERS_1050: u32 = 1;
pub const _USE_ATTRIBUTES_FOR_SAL: u32 = 0; pub const __DARWIN_UNIX03: u32 = 1;
pub const _CRT_PACKING: u32 = 8; pub const __DARWIN_64_BIT_INO_T: u32 = 1;
pub const _HAS_EXCEPTIONS: u32 = 1; pub const __DARWIN_VERS_1050: u32 = 1;
pub const _STL_LANG: u32 = 0; pub const __DARWIN_NON_CANCELABLE: u32 = 0;
pub const _HAS_CXX17: u32 = 0; pub const __DARWIN_SUF_EXTSN: &[u8; 14usize] = b"$DARWIN_EXTSN\0";
pub const _HAS_CXX20: u32 = 0; pub const __DARWIN_C_ANSI: u32 = 4096;
pub const _HAS_CXX23: u32 = 0; pub const __DARWIN_C_FULL: u32 = 900000;
pub const _HAS_NODISCARD: u32 = 0; pub const __DARWIN_C_LEVEL: u32 = 900000;
pub const WCHAR_MIN: u32 = 0; pub const __STDC_WANT_LIB_EXT1__: u32 = 1;
pub const WCHAR_MAX: u32 = 65535; pub const __DARWIN_NO_LONG_LONG: u32 = 0;
pub const WINT_MIN: u32 = 0; pub const _DARWIN_FEATURE_64_BIT_INODE: u32 = 1;
pub const WINT_MAX: u32 = 65535; pub const _DARWIN_FEATURE_ONLY_64_BIT_INODE: u32 = 1;
pub const _DARWIN_FEATURE_ONLY_VERS_1050: u32 = 1;
pub const _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE: u32 = 1;
pub const _DARWIN_FEATURE_UNIX_CONFORMANCE: u32 = 3;
pub const __has_ptrcheck: u32 = 0;
pub const __PTHREAD_SIZE__: u32 = 8176;
pub const __PTHREAD_ATTR_SIZE__: u32 = 56;
pub const __PTHREAD_MUTEXATTR_SIZE__: u32 = 8;
pub const __PTHREAD_MUTEX_SIZE__: u32 = 56;
pub const __PTHREAD_CONDATTR_SIZE__: u32 = 8;
pub const __PTHREAD_COND_SIZE__: u32 = 40;
pub const __PTHREAD_ONCE_SIZE__: u32 = 8;
pub const __PTHREAD_RWLOCK_SIZE__: u32 = 192;
pub const __PTHREAD_RWLOCKATTR_SIZE__: u32 = 16;
pub const INT8_MAX: u32 = 127;
pub const INT16_MAX: u32 = 32767;
pub const INT32_MAX: u32 = 2147483647;
pub const INT64_MAX: u64 = 9223372036854775807;
pub const INT8_MIN: i32 = -128;
pub const INT16_MIN: i32 = -32768;
pub const INT32_MIN: i32 = -2147483648;
pub const INT64_MIN: i64 = -9223372036854775808;
pub const UINT8_MAX: u32 = 255;
pub const UINT16_MAX: u32 = 65535;
pub const UINT32_MAX: u32 = 4294967295;
pub const UINT64_MAX: i32 = -1;
pub const INT_LEAST8_MIN: i32 = -128;
pub const INT_LEAST16_MIN: i32 = -32768;
pub const INT_LEAST32_MIN: i32 = -2147483648;
pub const INT_LEAST64_MIN: i64 = -9223372036854775808;
pub const INT_LEAST8_MAX: u32 = 127;
pub const INT_LEAST16_MAX: u32 = 32767;
pub const INT_LEAST32_MAX: u32 = 2147483647;
pub const INT_LEAST64_MAX: u64 = 9223372036854775807;
pub const UINT_LEAST8_MAX: u32 = 255;
pub const UINT_LEAST16_MAX: u32 = 65535;
pub const UINT_LEAST32_MAX: u32 = 4294967295;
pub const UINT_LEAST64_MAX: i32 = -1;
pub const INT_FAST8_MIN: i32 = -128;
pub const INT_FAST16_MIN: i32 = -32768;
pub const INT_FAST32_MIN: i32 = -2147483648;
pub const INT_FAST64_MIN: i64 = -9223372036854775808;
pub const INT_FAST8_MAX: u32 = 127;
pub const INT_FAST16_MAX: u32 = 32767;
pub const INT_FAST32_MAX: u32 = 2147483647;
pub const INT_FAST64_MAX: u64 = 9223372036854775807;
pub const UINT_FAST8_MAX: u32 = 255;
pub const UINT_FAST16_MAX: u32 = 65535;
pub const UINT_FAST32_MAX: u32 = 4294967295;
pub const UINT_FAST64_MAX: i32 = -1;
pub const INTPTR_MAX: u64 = 9223372036854775807;
pub const INTPTR_MIN: i64 = -9223372036854775808;
pub const UINTPTR_MAX: i32 = -1;
pub const SIZE_MAX: i32 = -1;
pub const RSIZE_MAX: i32 = -1;
pub const WINT_MIN: i32 = -2147483648;
pub const WINT_MAX: u32 = 2147483647;
pub const SIG_ATOMIC_MIN: i32 = -2147483648;
pub const SIG_ATOMIC_MAX: u32 = 2147483647;
pub const LZ4_STREAM_MINSIZE: u32 = 16416; pub const LZ4_STREAM_MINSIZE: u32 = 16416;
pub const LZ4_STREAMDECODE_MINSIZE: u32 = 32; pub const LZ4_STREAMDECODE_MINSIZE: u32 = 32;
pub const LZ4HC_CLEVEL_MIN: u32 = 3; pub const LZ4HC_CLEVEL_MIN: u32 = 3;
@ -56,7 +114,7 @@ pub const XXH_VERSION_MAJOR: u32 = 0;
pub const XXH_VERSION_MINOR: u32 = 6; pub const XXH_VERSION_MINOR: u32 = 6;
pub const XXH_VERSION_RELEASE: u32 = 5; pub const XXH_VERSION_RELEASE: u32 = 5;
pub const XXH_VERSION_NUMBER: u32 = 605; pub const XXH_VERSION_NUMBER: u32 = 605;
pub type wchar_t = ::std::os::raw::c_ushort; pub type wchar_t = ::std::os::raw::c_int;
pub type max_align_t = f64; pub type max_align_t = f64;
extern "C" { extern "C" {
pub fn LZ4_versionNumber() -> ::std::os::raw::c_int; pub fn LZ4_versionNumber() -> ::std::os::raw::c_int;
@ -219,41 +277,571 @@ extern "C" {
dictSize: ::std::os::raw::c_int, dictSize: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int; ) -> ::std::os::raw::c_int;
} }
pub type va_list = *mut ::std::os::raw::c_char; pub type int_least8_t = i8;
extern "C" { pub type int_least16_t = i16;
pub fn __va_start(arg1: *mut *mut ::std::os::raw::c_char, ...); pub type int_least32_t = i32;
pub type int_least64_t = i64;
pub type uint_least8_t = u8;
pub type uint_least16_t = u16;
pub type uint_least32_t = u32;
pub type uint_least64_t = u64;
pub type int_fast8_t = i8;
pub type int_fast16_t = i16;
pub type int_fast32_t = i32;
pub type int_fast64_t = i64;
pub type uint_fast8_t = u8;
pub type uint_fast16_t = u16;
pub type uint_fast32_t = u32;
pub type uint_fast64_t = u64;
pub type __int8_t = ::std::os::raw::c_schar;
pub type __uint8_t = ::std::os::raw::c_uchar;
pub type __int16_t = ::std::os::raw::c_short;
pub type __uint16_t = ::std::os::raw::c_ushort;
pub type __int32_t = ::std::os::raw::c_int;
pub type __uint32_t = ::std::os::raw::c_uint;
pub type __int64_t = ::std::os::raw::c_longlong;
pub type __uint64_t = ::std::os::raw::c_ulonglong;
pub type __darwin_intptr_t = ::std::os::raw::c_long;
pub type __darwin_natural_t = ::std::os::raw::c_uint;
pub type __darwin_ct_rune_t = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Copy, Clone)]
pub union __mbstate_t {
pub __mbstate8: [::std::os::raw::c_char; 128usize],
pub _mbstateL: ::std::os::raw::c_longlong,
} }
pub type __vcrt_bool = bool; #[test]
extern "C" { fn bindgen_test_layout___mbstate_t() {
pub fn __security_init_cookie(); const UNINIT: ::std::mem::MaybeUninit<__mbstate_t> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<__mbstate_t>(),
128usize,
concat!("Size of: ", stringify!(__mbstate_t))
);
assert_eq!(
::std::mem::align_of::<__mbstate_t>(),
8usize,
concat!("Alignment of ", stringify!(__mbstate_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__mbstate8) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__mbstate_t),
"::",
stringify!(__mbstate8)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr)._mbstateL) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__mbstate_t),
"::",
stringify!(_mbstateL)
)
);
} }
extern "C" { pub type __darwin_mbstate_t = __mbstate_t;
pub fn __security_check_cookie(_StackCookie: usize); pub type __darwin_ptrdiff_t = ::std::os::raw::c_long;
pub type __darwin_size_t = ::std::os::raw::c_ulong;
pub type __darwin_va_list = __builtin_va_list;
pub type __darwin_wchar_t = ::std::os::raw::c_int;
pub type __darwin_rune_t = __darwin_wchar_t;
pub type __darwin_wint_t = ::std::os::raw::c_int;
pub type __darwin_clock_t = ::std::os::raw::c_ulong;
pub type __darwin_socklen_t = __uint32_t;
pub type __darwin_ssize_t = ::std::os::raw::c_long;
pub type __darwin_time_t = ::std::os::raw::c_long;
pub type __darwin_blkcnt_t = __int64_t;
pub type __darwin_blksize_t = __int32_t;
pub type __darwin_dev_t = __int32_t;
pub type __darwin_fsblkcnt_t = ::std::os::raw::c_uint;
pub type __darwin_fsfilcnt_t = ::std::os::raw::c_uint;
pub type __darwin_gid_t = __uint32_t;
pub type __darwin_id_t = __uint32_t;
pub type __darwin_ino64_t = __uint64_t;
pub type __darwin_ino_t = __darwin_ino64_t;
pub type __darwin_mach_port_name_t = __darwin_natural_t;
pub type __darwin_mach_port_t = __darwin_mach_port_name_t;
pub type __darwin_mode_t = __uint16_t;
pub type __darwin_off_t = __int64_t;
pub type __darwin_pid_t = __int32_t;
pub type __darwin_sigset_t = __uint32_t;
pub type __darwin_suseconds_t = __int32_t;
pub type __darwin_uid_t = __uint32_t;
pub type __darwin_useconds_t = __uint32_t;
pub type __darwin_uuid_t = [::std::os::raw::c_uchar; 16usize];
pub type __darwin_uuid_string_t = [::std::os::raw::c_char; 37usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __darwin_pthread_handler_rec {
pub __routine: ::std::option::Option<unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void)>,
pub __arg: *mut ::std::os::raw::c_void,
pub __next: *mut __darwin_pthread_handler_rec,
} }
extern "C" { #[test]
pub fn __report_gsfailure(_StackCookie: usize) -> !; fn bindgen_test_layout___darwin_pthread_handler_rec() {
const UNINIT: ::std::mem::MaybeUninit<__darwin_pthread_handler_rec> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<__darwin_pthread_handler_rec>(),
24usize,
concat!("Size of: ", stringify!(__darwin_pthread_handler_rec))
);
assert_eq!(
::std::mem::align_of::<__darwin_pthread_handler_rec>(),
8usize,
concat!("Alignment of ", stringify!(__darwin_pthread_handler_rec))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__routine) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__darwin_pthread_handler_rec),
"::",
stringify!(__routine)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__arg) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__darwin_pthread_handler_rec),
"::",
stringify!(__arg)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__next) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__darwin_pthread_handler_rec),
"::",
stringify!(__next)
)
);
} }
extern "C" { #[repr(C)]
pub static mut __security_cookie: usize; #[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_attr_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 56usize],
} }
pub type int_least8_t = ::std::os::raw::c_schar; #[test]
pub type int_least16_t = ::std::os::raw::c_short; fn bindgen_test_layout__opaque_pthread_attr_t() {
pub type int_least32_t = ::std::os::raw::c_int; const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_attr_t> =
pub type int_least64_t = ::std::os::raw::c_longlong; ::std::mem::MaybeUninit::uninit();
pub type uint_least8_t = ::std::os::raw::c_uchar; let ptr = UNINIT.as_ptr();
pub type uint_least16_t = ::std::os::raw::c_ushort; assert_eq!(
pub type uint_least32_t = ::std::os::raw::c_uint; ::std::mem::size_of::<_opaque_pthread_attr_t>(),
pub type uint_least64_t = ::std::os::raw::c_ulonglong; 64usize,
pub type int_fast8_t = ::std::os::raw::c_schar; concat!("Size of: ", stringify!(_opaque_pthread_attr_t))
pub type int_fast16_t = ::std::os::raw::c_int; );
pub type int_fast32_t = ::std::os::raw::c_int; assert_eq!(
pub type int_fast64_t = ::std::os::raw::c_longlong; ::std::mem::align_of::<_opaque_pthread_attr_t>(),
pub type uint_fast8_t = ::std::os::raw::c_uchar; 8usize,
pub type uint_fast16_t = ::std::os::raw::c_uint; concat!("Alignment of ", stringify!(_opaque_pthread_attr_t))
pub type uint_fast32_t = ::std::os::raw::c_uint; );
pub type uint_fast64_t = ::std::os::raw::c_ulonglong; assert_eq!(
pub type intmax_t = ::std::os::raw::c_longlong; unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
pub type uintmax_t = ::std::os::raw::c_ulonglong; 0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_attr_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_attr_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_cond_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 40usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_cond_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_cond_t> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_cond_t>(),
48usize,
concat!("Size of: ", stringify!(_opaque_pthread_cond_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_cond_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_cond_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_cond_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_cond_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_condattr_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 8usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_condattr_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_condattr_t> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_condattr_t>(),
16usize,
concat!("Size of: ", stringify!(_opaque_pthread_condattr_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_condattr_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_condattr_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_condattr_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_condattr_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_mutex_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 56usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_mutex_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_mutex_t> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_mutex_t>(),
64usize,
concat!("Size of: ", stringify!(_opaque_pthread_mutex_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_mutex_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_mutex_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_mutex_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_mutex_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_mutexattr_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 8usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_mutexattr_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_mutexattr_t> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_mutexattr_t>(),
16usize,
concat!("Size of: ", stringify!(_opaque_pthread_mutexattr_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_mutexattr_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_mutexattr_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_mutexattr_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_mutexattr_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_once_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 8usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_once_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_once_t> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_once_t>(),
16usize,
concat!("Size of: ", stringify!(_opaque_pthread_once_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_once_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_once_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_once_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_once_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_rwlock_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 192usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_rwlock_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_rwlock_t> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_rwlock_t>(),
200usize,
concat!("Size of: ", stringify!(_opaque_pthread_rwlock_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_rwlock_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_rwlock_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_rwlock_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_rwlock_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_rwlockattr_t {
pub __sig: ::std::os::raw::c_long,
pub __opaque: [::std::os::raw::c_char; 16usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_rwlockattr_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_rwlockattr_t> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_rwlockattr_t>(),
24usize,
concat!("Size of: ", stringify!(_opaque_pthread_rwlockattr_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_rwlockattr_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_rwlockattr_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_rwlockattr_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_rwlockattr_t),
"::",
stringify!(__opaque)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _opaque_pthread_t {
pub __sig: ::std::os::raw::c_long,
pub __cleanup_stack: *mut __darwin_pthread_handler_rec,
pub __opaque: [::std::os::raw::c_char; 8176usize],
}
#[test]
fn bindgen_test_layout__opaque_pthread_t() {
const UNINIT: ::std::mem::MaybeUninit<_opaque_pthread_t> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<_opaque_pthread_t>(),
8192usize,
concat!("Size of: ", stringify!(_opaque_pthread_t))
);
assert_eq!(
::std::mem::align_of::<_opaque_pthread_t>(),
8usize,
concat!("Alignment of ", stringify!(_opaque_pthread_t))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__sig) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_t),
"::",
stringify!(__sig)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__cleanup_stack) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_t),
"::",
stringify!(__cleanup_stack)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).__opaque) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(_opaque_pthread_t),
"::",
stringify!(__opaque)
)
);
}
pub type __darwin_pthread_attr_t = _opaque_pthread_attr_t;
pub type __darwin_pthread_cond_t = _opaque_pthread_cond_t;
pub type __darwin_pthread_condattr_t = _opaque_pthread_condattr_t;
pub type __darwin_pthread_key_t = ::std::os::raw::c_ulong;
pub type __darwin_pthread_mutex_t = _opaque_pthread_mutex_t;
pub type __darwin_pthread_mutexattr_t = _opaque_pthread_mutexattr_t;
pub type __darwin_pthread_once_t = _opaque_pthread_once_t;
pub type __darwin_pthread_rwlock_t = _opaque_pthread_rwlock_t;
pub type __darwin_pthread_rwlockattr_t = _opaque_pthread_rwlockattr_t;
pub type __darwin_pthread_t = *mut _opaque_pthread_t;
pub type u_int8_t = ::std::os::raw::c_uchar;
pub type u_int16_t = ::std::os::raw::c_ushort;
pub type u_int32_t = ::std::os::raw::c_uint;
pub type u_int64_t = ::std::os::raw::c_ulonglong;
pub type register_t = i64;
pub type user_addr_t = u_int64_t;
pub type user_size_t = u_int64_t;
pub type user_ssize_t = i64;
pub type user_long_t = i64;
pub type user_ulong_t = u_int64_t;
pub type user_time_t = i64;
pub type user_off_t = i64;
pub type syscall_arg_t = u_int64_t;
pub type intmax_t = ::std::os::raw::c_long;
pub type uintmax_t = ::std::os::raw::c_ulong;
pub type LZ4_i8 = i8; pub type LZ4_i8 = i8;
pub type LZ4_byte = u8; pub type LZ4_byte = u8;
pub type LZ4_u16 = u16; pub type LZ4_u16 = u16;
@ -1043,19 +1631,19 @@ pub const LZ4F_blockSizeID_t_LZ4F_max64KB: LZ4F_blockSizeID_t = 4;
pub const LZ4F_blockSizeID_t_LZ4F_max256KB: LZ4F_blockSizeID_t = 5; pub const LZ4F_blockSizeID_t_LZ4F_max256KB: LZ4F_blockSizeID_t = 5;
pub const LZ4F_blockSizeID_t_LZ4F_max1MB: LZ4F_blockSizeID_t = 6; pub const LZ4F_blockSizeID_t_LZ4F_max1MB: LZ4F_blockSizeID_t = 6;
pub const LZ4F_blockSizeID_t_LZ4F_max4MB: LZ4F_blockSizeID_t = 7; pub const LZ4F_blockSizeID_t_LZ4F_max4MB: LZ4F_blockSizeID_t = 7;
pub type LZ4F_blockSizeID_t = ::std::os::raw::c_int; pub type LZ4F_blockSizeID_t = ::std::os::raw::c_uint;
pub const LZ4F_blockMode_t_LZ4F_blockLinked: LZ4F_blockMode_t = 0; pub const LZ4F_blockMode_t_LZ4F_blockLinked: LZ4F_blockMode_t = 0;
pub const LZ4F_blockMode_t_LZ4F_blockIndependent: LZ4F_blockMode_t = 1; pub const LZ4F_blockMode_t_LZ4F_blockIndependent: LZ4F_blockMode_t = 1;
pub type LZ4F_blockMode_t = ::std::os::raw::c_int; pub type LZ4F_blockMode_t = ::std::os::raw::c_uint;
pub const LZ4F_contentChecksum_t_LZ4F_noContentChecksum: LZ4F_contentChecksum_t = 0; pub const LZ4F_contentChecksum_t_LZ4F_noContentChecksum: LZ4F_contentChecksum_t = 0;
pub const LZ4F_contentChecksum_t_LZ4F_contentChecksumEnabled: LZ4F_contentChecksum_t = 1; pub const LZ4F_contentChecksum_t_LZ4F_contentChecksumEnabled: LZ4F_contentChecksum_t = 1;
pub type LZ4F_contentChecksum_t = ::std::os::raw::c_int; pub type LZ4F_contentChecksum_t = ::std::os::raw::c_uint;
pub const LZ4F_blockChecksum_t_LZ4F_noBlockChecksum: LZ4F_blockChecksum_t = 0; pub const LZ4F_blockChecksum_t_LZ4F_noBlockChecksum: LZ4F_blockChecksum_t = 0;
pub const LZ4F_blockChecksum_t_LZ4F_blockChecksumEnabled: LZ4F_blockChecksum_t = 1; pub const LZ4F_blockChecksum_t_LZ4F_blockChecksumEnabled: LZ4F_blockChecksum_t = 1;
pub type LZ4F_blockChecksum_t = ::std::os::raw::c_int; pub type LZ4F_blockChecksum_t = ::std::os::raw::c_uint;
pub const LZ4F_frameType_t_LZ4F_frame: LZ4F_frameType_t = 0; pub const LZ4F_frameType_t_LZ4F_frame: LZ4F_frameType_t = 0;
pub const LZ4F_frameType_t_LZ4F_skippableFrame: LZ4F_frameType_t = 1; pub const LZ4F_frameType_t_LZ4F_skippableFrame: LZ4F_frameType_t = 1;
pub type LZ4F_frameType_t = ::std::os::raw::c_int; pub type LZ4F_frameType_t = ::std::os::raw::c_uint;
#[doc = " LZ4F_frameInfo_t :\n makes it possible to set or read frame parameters.\n Structure must be first init to 0, using memset() or LZ4F_INIT_FRAMEINFO,\n setting all parameters to default.\n It's then possible to update selectively some parameters"] #[doc = " LZ4F_frameInfo_t :\n makes it possible to set or read frame parameters.\n Structure must be first init to 0, using memset() or LZ4F_INIT_FRAMEINFO,\n setting all parameters to default.\n It's then possible to update selectively some parameters"]
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
@ -1463,7 +2051,7 @@ extern "C" {
} }
pub const XXH_errorcode_XXH_OK: XXH_errorcode = 0; pub const XXH_errorcode_XXH_OK: XXH_errorcode = 0;
pub const XXH_errorcode_XXH_ERROR: XXH_errorcode = 1; pub const XXH_errorcode_XXH_ERROR: XXH_errorcode = 1;
pub type XXH_errorcode = ::std::os::raw::c_int; pub type XXH_errorcode = ::std::os::raw::c_uint;
extern "C" { extern "C" {
pub fn XXH_versionNumber() -> ::std::os::raw::c_uint; pub fn XXH_versionNumber() -> ::std::os::raw::c_uint;
} }
@ -1617,3 +2205,4 @@ extern "C" {
extern "C" { extern "C" {
pub fn XXH64_hashFromCanonical(src: *const XXH64_canonical_t) -> XXH64_hash_t; pub fn XXH64_hashFromCanonical(src: *const XXH64_canonical_t) -> XXH64_hash_t;
} }
pub type __builtin_va_list = *mut ::std::os::raw::c_char;

View File

@ -38,7 +38,7 @@ pub(crate) fn generate(
for path in paths { for path in paths {
let file_content = std::fs::read_to_string(path) let file_content = std::fs::read_to_string(path)
.expect(&format!("input file not found, path: {}", path.display())); .unwrap_or_else(|_| panic!("input file not found, path: {}", path.display()));
let file_ast = syn::parse_file(file_content.as_str())?; let file_ast = syn::parse_file(file_content.as_str())?;
match generate_kind { match generate_kind {
@ -158,8 +158,10 @@ mod tests {
let path = std::env::current_dir().unwrap(); let path = std::env::current_dir().unwrap();
println!("starting dir: {}", path.display()); // csbindgen/csbindgen println!("starting dir: {}", path.display()); // csbindgen/csbindgen
std::env::set_current_dir(path.parent().unwrap()).unwrap();
Builder::new() Builder::new()
.input_bindgen_file("csbindgen-tests/src/liblz4.rs") .input_bindgen_file("csbindgen-tests/src/lz4.rs")
.csharp_class_name("LibLz4") .csharp_class_name("LibLz4")
.csharp_dll_name("csbindgen_tests") .csharp_dll_name("csbindgen_tests")
.generate_to_file( .generate_to_file(
@ -178,7 +180,7 @@ mod tests {
// 2: 1.0.0 // 2: 1.0.0
// 3: --nocapture // 3: --nocapture
if args[1] != "update_package_version" { if args.len() < 2 || args[1] != "update_package_version" {
return; return;
} }