1 #![allow(
2 dead_code,
3 non_snake_case,
4 non_camel_case_types,
5 non_upper_case_globals
6 )]
7
8 #[repr(C)]
9 #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
10 pub struct __BindgenBitfieldUnit<Storage> {
11 storage: Storage,
12 }
13 impl<Storage> __BindgenBitfieldUnit<Storage> {
14 #[inline]
new(storage: Storage) -> Self15 pub const fn new(storage: Storage) -> Self {
16 Self { storage }
17 }
18 }
19 impl<Storage> __BindgenBitfieldUnit<Storage>
20 where
21 Storage: AsRef<[u8]> + AsMut<[u8]>,
22 {
23 #[inline]
get_bit(&self, index: usize) -> bool24 pub fn get_bit(&self, index: usize) -> bool {
25 debug_assert!(index / 8 < self.storage.as_ref().len());
26 let byte_index = index / 8;
27 let byte = self.storage.as_ref()[byte_index];
28 let bit_index = if cfg!(target_endian = "big") {
29 7 - (index % 8)
30 } else {
31 index % 8
32 };
33 let mask = 1 << bit_index;
34 byte & mask == mask
35 }
36 #[inline]
set_bit(&mut self, index: usize, val: bool)37 pub fn set_bit(&mut self, index: usize, val: bool) {
38 debug_assert!(index / 8 < self.storage.as_ref().len());
39 let byte_index = index / 8;
40 let byte = &mut self.storage.as_mut()[byte_index];
41 let bit_index = if cfg!(target_endian = "big") {
42 7 - (index % 8)
43 } else {
44 index % 8
45 };
46 let mask = 1 << bit_index;
47 if val {
48 *byte |= mask;
49 } else {
50 *byte &= !mask;
51 }
52 }
53 #[inline]
get(&self, bit_offset: usize, bit_width: u8) -> u6454 pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
55 debug_assert!(bit_width <= 64);
56 debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
57 debug_assert!(
58 (bit_offset + (bit_width as usize)) / 8 <=
59 self.storage.as_ref().len()
60 );
61 let mut val = 0;
62 for i in 0..(bit_width as usize) {
63 if self.get_bit(i + bit_offset) {
64 let index = if cfg!(target_endian = "big") {
65 bit_width as usize - 1 - i
66 } else {
67 i
68 };
69 val |= 1 << index;
70 }
71 }
72 val
73 }
74 #[inline]
set(&mut self, bit_offset: usize, bit_width: u8, val: u64)75 pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
76 debug_assert!(bit_width <= 64);
77 debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
78 debug_assert!(
79 (bit_offset + (bit_width as usize)) / 8 <=
80 self.storage.as_ref().len()
81 );
82 for i in 0..(bit_width as usize) {
83 let mask = 1 << i;
84 let val_bit_is_set = val & mask == mask;
85 let index = if cfg!(target_endian = "big") {
86 bit_width as usize - 1 - i
87 } else {
88 i
89 };
90 self.set_bit(index + bit_offset, val_bit_is_set);
91 }
92 }
93 }
94 #[repr(C)]
95 #[derive(Debug, Copy, Clone)]
96 pub struct timex {
97 pub tai: ::std::os::raw::c_int,
98 pub _bitfield_align_1: [u8; 0],
99 pub _bitfield_1: __BindgenBitfieldUnit<[u8; 44usize]>,
100 }
101 #[test]
bindgen_test_layout_timex()102 fn bindgen_test_layout_timex() {
103 const UNINIT: ::std::mem::MaybeUninit<timex> =
104 ::std::mem::MaybeUninit::uninit();
105 let ptr = UNINIT.as_ptr();
106 assert_eq!(
107 ::std::mem::size_of::<timex>(),
108 48usize,
109 concat!("Size of: ", stringify!(timex))
110 );
111 assert_eq!(
112 ::std::mem::align_of::<timex>(),
113 4usize,
114 concat!("Alignment of ", stringify!(timex))
115 );
116 assert_eq!(
117 unsafe { ::std::ptr::addr_of!((*ptr).tai) as usize - ptr as usize },
118 0usize,
119 concat!(
120 "Offset of field: ",
121 stringify!(timex),
122 "::",
123 stringify!(tai)
124 )
125 );
126 }
127 impl Default for timex {
default() -> Self128 fn default() -> Self {
129 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
130 unsafe {
131 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
132 s.assume_init()
133 }
134 }
135 }
136 #[repr(C)]
137 #[derive(Debug, Copy, Clone)]
138 pub struct timex_named {
139 pub tai: ::std::os::raw::c_int,
140 pub _bitfield_align_1: [u32; 0],
141 pub _bitfield_1: __BindgenBitfieldUnit<[u8; 44usize]>,
142 }
143 #[test]
bindgen_test_layout_timex_named()144 fn bindgen_test_layout_timex_named() {
145 const UNINIT: ::std::mem::MaybeUninit<timex_named> =
146 ::std::mem::MaybeUninit::uninit();
147 let ptr = UNINIT.as_ptr();
148 assert_eq!(
149 ::std::mem::size_of::<timex_named>(),
150 48usize,
151 concat!("Size of: ", stringify!(timex_named))
152 );
153 assert_eq!(
154 ::std::mem::align_of::<timex_named>(),
155 4usize,
156 concat!("Alignment of ", stringify!(timex_named))
157 );
158 assert_eq!(
159 unsafe { ::std::ptr::addr_of!((*ptr).tai) as usize - ptr as usize },
160 0usize,
161 concat!(
162 "Offset of field: ",
163 stringify!(timex_named),
164 "::",
165 stringify!(tai)
166 )
167 );
168 }
169 impl Default for timex_named {
default() -> Self170 fn default() -> Self {
171 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
172 unsafe {
173 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
174 s.assume_init()
175 }
176 }
177 }
178 impl timex_named {
179 #[inline]
a(&self) -> ::std::os::raw::c_int180 pub fn a(&self) -> ::std::os::raw::c_int {
181 unsafe {
182 ::std::mem::transmute(self._bitfield_1.get(0usize, 32u8) as u32)
183 }
184 }
185 #[inline]
set_a(&mut self, val: ::std::os::raw::c_int)186 pub fn set_a(&mut self, val: ::std::os::raw::c_int) {
187 unsafe {
188 let val: u32 = ::std::mem::transmute(val);
189 self._bitfield_1.set(0usize, 32u8, val as u64)
190 }
191 }
192 #[inline]
b(&self) -> ::std::os::raw::c_int193 pub fn b(&self) -> ::std::os::raw::c_int {
194 unsafe {
195 ::std::mem::transmute(self._bitfield_1.get(32usize, 32u8) as u32)
196 }
197 }
198 #[inline]
set_b(&mut self, val: ::std::os::raw::c_int)199 pub fn set_b(&mut self, val: ::std::os::raw::c_int) {
200 unsafe {
201 let val: u32 = ::std::mem::transmute(val);
202 self._bitfield_1.set(32usize, 32u8, val as u64)
203 }
204 }
205 #[inline]
c(&self) -> ::std::os::raw::c_int206 pub fn c(&self) -> ::std::os::raw::c_int {
207 unsafe {
208 ::std::mem::transmute(self._bitfield_1.get(64usize, 32u8) as u32)
209 }
210 }
211 #[inline]
set_c(&mut self, val: ::std::os::raw::c_int)212 pub fn set_c(&mut self, val: ::std::os::raw::c_int) {
213 unsafe {
214 let val: u32 = ::std::mem::transmute(val);
215 self._bitfield_1.set(64usize, 32u8, val as u64)
216 }
217 }
218 #[inline]
d(&self) -> ::std::os::raw::c_int219 pub fn d(&self) -> ::std::os::raw::c_int {
220 unsafe {
221 ::std::mem::transmute(self._bitfield_1.get(96usize, 32u8) as u32)
222 }
223 }
224 #[inline]
set_d(&mut self, val: ::std::os::raw::c_int)225 pub fn set_d(&mut self, val: ::std::os::raw::c_int) {
226 unsafe {
227 let val: u32 = ::std::mem::transmute(val);
228 self._bitfield_1.set(96usize, 32u8, val as u64)
229 }
230 }
231 #[inline]
e(&self) -> ::std::os::raw::c_int232 pub fn e(&self) -> ::std::os::raw::c_int {
233 unsafe {
234 ::std::mem::transmute(self._bitfield_1.get(128usize, 32u8) as u32)
235 }
236 }
237 #[inline]
set_e(&mut self, val: ::std::os::raw::c_int)238 pub fn set_e(&mut self, val: ::std::os::raw::c_int) {
239 unsafe {
240 let val: u32 = ::std::mem::transmute(val);
241 self._bitfield_1.set(128usize, 32u8, val as u64)
242 }
243 }
244 #[inline]
f(&self) -> ::std::os::raw::c_int245 pub fn f(&self) -> ::std::os::raw::c_int {
246 unsafe {
247 ::std::mem::transmute(self._bitfield_1.get(160usize, 32u8) as u32)
248 }
249 }
250 #[inline]
set_f(&mut self, val: ::std::os::raw::c_int)251 pub fn set_f(&mut self, val: ::std::os::raw::c_int) {
252 unsafe {
253 let val: u32 = ::std::mem::transmute(val);
254 self._bitfield_1.set(160usize, 32u8, val as u64)
255 }
256 }
257 #[inline]
g(&self) -> ::std::os::raw::c_int258 pub fn g(&self) -> ::std::os::raw::c_int {
259 unsafe {
260 ::std::mem::transmute(self._bitfield_1.get(192usize, 32u8) as u32)
261 }
262 }
263 #[inline]
set_g(&mut self, val: ::std::os::raw::c_int)264 pub fn set_g(&mut self, val: ::std::os::raw::c_int) {
265 unsafe {
266 let val: u32 = ::std::mem::transmute(val);
267 self._bitfield_1.set(192usize, 32u8, val as u64)
268 }
269 }
270 #[inline]
h(&self) -> ::std::os::raw::c_int271 pub fn h(&self) -> ::std::os::raw::c_int {
272 unsafe {
273 ::std::mem::transmute(self._bitfield_1.get(224usize, 32u8) as u32)
274 }
275 }
276 #[inline]
set_h(&mut self, val: ::std::os::raw::c_int)277 pub fn set_h(&mut self, val: ::std::os::raw::c_int) {
278 unsafe {
279 let val: u32 = ::std::mem::transmute(val);
280 self._bitfield_1.set(224usize, 32u8, val as u64)
281 }
282 }
283 #[inline]
i(&self) -> ::std::os::raw::c_int284 pub fn i(&self) -> ::std::os::raw::c_int {
285 unsafe {
286 ::std::mem::transmute(self._bitfield_1.get(256usize, 32u8) as u32)
287 }
288 }
289 #[inline]
set_i(&mut self, val: ::std::os::raw::c_int)290 pub fn set_i(&mut self, val: ::std::os::raw::c_int) {
291 unsafe {
292 let val: u32 = ::std::mem::transmute(val);
293 self._bitfield_1.set(256usize, 32u8, val as u64)
294 }
295 }
296 #[inline]
j(&self) -> ::std::os::raw::c_int297 pub fn j(&self) -> ::std::os::raw::c_int {
298 unsafe {
299 ::std::mem::transmute(self._bitfield_1.get(288usize, 32u8) as u32)
300 }
301 }
302 #[inline]
set_j(&mut self, val: ::std::os::raw::c_int)303 pub fn set_j(&mut self, val: ::std::os::raw::c_int) {
304 unsafe {
305 let val: u32 = ::std::mem::transmute(val);
306 self._bitfield_1.set(288usize, 32u8, val as u64)
307 }
308 }
309 #[inline]
k(&self) -> ::std::os::raw::c_int310 pub fn k(&self) -> ::std::os::raw::c_int {
311 unsafe {
312 ::std::mem::transmute(self._bitfield_1.get(320usize, 32u8) as u32)
313 }
314 }
315 #[inline]
set_k(&mut self, val: ::std::os::raw::c_int)316 pub fn set_k(&mut self, val: ::std::os::raw::c_int) {
317 unsafe {
318 let val: u32 = ::std::mem::transmute(val);
319 self._bitfield_1.set(320usize, 32u8, val as u64)
320 }
321 }
322 }
323