5 use std::mem::{size_of, align_of};
6 use std::os::raw::c_int;
8 // The two enums that follow are designed so that bugs trigger layout optimization.
9 // Specifically, if either of the following reprs used here is not detected by the compiler,
10 // then the sizes will be wrong.
24 // Check that repr(int) and repr(C) are in fact different from the above
59 pub struct p0f_api_query {
66 assert_eq!(size_of::<E1>(), 8);
67 assert_eq!(size_of::<E2>(), 8);
68 assert_eq!(size_of::<E3>(), 6);
69 assert_eq!(size_of::<E4>(), 8);
70 assert_eq!(size_of::<E5>(), align_size(10, align_of::<u32>()));
71 assert_eq!(size_of::<E6>(), align_size(14, align_of::<u64>()));
72 assert_eq!(size_of::<E7>(), align_size(6 + size_of::<c_int>(), align_of::<c_int>()));
73 assert_eq!(size_of::<p0f_api_query>(), 21);
76 fn align_size(size: usize, align: usize) -> usize {
77 if size % align != 0 {
78 size + (align - (size % align))