1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4
5
6include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
7
8#[repr(C)]
9pub struct _IRStmt__bindgen_ty_1__bindgen_ty_1(());
10
11#[test]
12fn bindgen_test_layout__IRStmt__bindgen_ty_1__bindgen_ty_1() {
13 assert_eq!(
14 ::std::mem::size_of::<_IRStmt__bindgen_ty_1__bindgen_ty_1>(),
15 0usize,
16 concat!(
17 "Size of: ",
18 stringify!(_IRStmt__bindgen_ty_1__bindgen_ty_1)
19 )
20 );
21 assert_eq!(
22 ::std::mem::align_of::<_IRStmt__bindgen_ty_1__bindgen_ty_1>(),
23 1usize,
24 concat!(
25 "Alignment of ",
26 stringify!(_IRStmt__bindgen_ty_1__bindgen_ty_1)
27 )
28 );
29}
30
31#[cfg(test)]
32mod test {
33
34 use libc::{c_char, c_void};
35 use std::mem::{self, MaybeUninit};
36
37 use crate::*;
38
39 unsafe extern "C" fn failure_exit() -> ! {
40 panic!("LibVEX encountered a critical error.")
41 }
42
43 unsafe extern "C" fn failure_disp() {
44 panic!("LibVEX called the display function.")
45 }
46
47 #[cfg(log_bytes)]
48 unsafe extern "C" fn log_bytes(chars: *const c_char, nbytes: u64) {
49 use std::ffi::CString;
50 use libc::printf;
51
52 let format = CString::new("%*s").unwrap();
53 printf(format.as_ptr(), nbytes, chars);
54 }
55
56 #[cfg(not(log_bytes))]
57 unsafe extern "C" fn log_bytes(_: *const c_char, _: u64) {}
58
59 unsafe extern "C" fn return_0(
60 _cb: *mut c_void,
61 _addr: *mut u32,
62 _vge: *const VexGuestExtents,
63 ) -> u32 {
64 0
65 }
66
67 unsafe extern "C" fn self_check(
68 _cb: *mut c_void,
69 _addr: *mut VexRegisterUpdates,
70 _vge: *const VexGuestExtents,
71 ) -> u32 {
72 0
73 }
74
75 unsafe extern "C" fn return_false(_cb: *mut c_void, _addr: u64) -> u8 {
76 0
77 }
78
79 #[test]
81 fn sanity() {
82 let mut host_bytes: [u8; 10000] = [0; 10000];
83 let mut host_bytes_used = 0;
84
85 let mut vcon = mem::MaybeUninit::<VexControl>::uninit();
86 let mut vcon = unsafe {
87 LibVEX_default_VexControl(vcon.as_mut_ptr());
88 vcon.assume_init()
89 };
90 unsafe {
91 LibVEX_Init(Some(failure_exit), Some(log_bytes), 3, &mut vcon);
92 };
93 let va: VexArch = VexArch::VexArchAMD64;
94 let ve: VexEndness = VexEndness::VexEndnessLE;
95
96 let mut vta: VexTranslateArgs = unsafe {
97 MaybeUninit::zeroed().assume_init()
98 };
99 let mut vge: VexGuestExtents = unsafe {
100 MaybeUninit::zeroed().assume_init()
101 };
102 unsafe {
103 LibVEX_default_VexArchInfo(&mut vta.archinfo_guest);
104 LibVEX_default_VexArchInfo(&mut vta.archinfo_host);
105 }
106 vta.guest_extents = &mut vge;
107
108 vta.abiinfo_both.guest_stack_redzone_size = 128;
110
111 vta.archinfo_guest.arm64_dMinLine_lg2_szB = 6;
113 vta.archinfo_guest.arm64_iMinLine_lg2_szB = 6;
114
115 vta.arch_guest = va;
118 vta.archinfo_guest.endness = ve;
119 vta.archinfo_guest.hwcaps = 0;
120 vta.arch_host = va;
121 vta.archinfo_host.endness = ve;
122 vta.archinfo_host.hwcaps = 0;
123 vta.callback_opaque = 0 as *mut c_void;
124 vta.guest_bytes = sanity as *const u8;
125 vta.guest_bytes_addr = sanity as Addr;
126 vta.chase_into_ok = Some(return_false);
127 vta.host_bytes = host_bytes.as_mut_ptr();
128 vta.host_bytes_size = host_bytes.len() as i32;
129 vta.host_bytes_used = &mut host_bytes_used;
130 vta.instrument1 = None;
131 vta.instrument2 = None;
132 vta.finaltidy = None;
133 vta.needs_self_check = Some(self_check);
134 vta.preamble_function = None;
135 vta.traceflags = -1;
136 vta.sigill_diag = 0;
137 vta.addProfInc = 0;
138 vta.disp_cp_chain_me_to_slowEP = failure_disp as *const c_void;
139 vta.disp_cp_chain_me_to_fastEP = failure_disp as *const c_void;
140 vta.disp_cp_xindir = failure_disp as *const c_void;
141 vta.disp_cp_xassisted = failure_disp as *const c_void;
142
143 let vtr = unsafe { LibVEX_Translate(&mut vta) };
144
145 assert!(vtr.status == VexTranslateResult_VexTransOK);
146 }
147}