-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathlayout_array.rs
305 lines (304 loc) · 10.2 KB
/
layout_array.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
pub const RTE_MEMPOOL_OPS_NAMESIZE: u32 = 32;
/** Prototype for implementation specific data provisioning function.
The function should provide the implementation specific memory for
for use by the other mempool ops functions in a given mempool ops struct.
E.g. the default ops provides an instance of the rte_ring for this purpose.
it will most likely point to a different type of data structure, and
will be transparent to the application programmer.
This function should set mp->pool_data.*/
pub type rte_mempool_alloc_t = ::std::option::Option<
unsafe extern "C" fn(mp: *mut rte_mempool) -> ::std::os::raw::c_int,
>;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct rte_mempool {
_unused: [u8; 0],
}
/// Free the opaque private data pointed to by mp->pool_data pointer.
pub type rte_mempool_free_t = ::std::option::Option<
unsafe extern "C" fn(mp: *mut rte_mempool),
>;
/// Enqueue an object into the external pool.
pub type rte_mempool_enqueue_t = ::std::option::Option<
unsafe extern "C" fn(
mp: *mut rte_mempool,
obj_table: *const *mut ::std::os::raw::c_void,
n: ::std::os::raw::c_uint,
) -> ::std::os::raw::c_int,
>;
/// Dequeue an object from the external pool.
pub type rte_mempool_dequeue_t = ::std::option::Option<
unsafe extern "C" fn(
mp: *mut rte_mempool,
obj_table: *mut *mut ::std::os::raw::c_void,
n: ::std::os::raw::c_uint,
) -> ::std::os::raw::c_int,
>;
/// Return the number of available objects in the external pool.
pub type rte_mempool_get_count = ::std::option::Option<
unsafe extern "C" fn(mp: *const rte_mempool) -> ::std::os::raw::c_uint,
>;
/// Structure defining mempool operations structure
#[repr(C)]
#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct rte_mempool_ops {
///< Name of mempool ops struct.
pub name: [::std::os::raw::c_char; 32usize],
///< Allocate private data.
pub alloc: rte_mempool_alloc_t,
///< Free the external pool.
pub free: rte_mempool_free_t,
///< Enqueue an object.
pub enqueue: rte_mempool_enqueue_t,
///< Dequeue an object.
pub dequeue: rte_mempool_dequeue_t,
///< Get qty of available objs.
pub get_count: rte_mempool_get_count,
}
#[test]
fn bindgen_test_layout_rte_mempool_ops() {
const UNINIT: ::std::mem::MaybeUninit<rte_mempool_ops> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<rte_mempool_ops>(),
128usize,
"Size of rte_mempool_ops",
);
assert_eq!(
::std::mem::align_of::<rte_mempool_ops>(),
64usize,
"Alignment of rte_mempool_ops",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize },
0usize,
"Offset of field: rte_mempool_ops::name",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).alloc) as usize - ptr as usize },
32usize,
"Offset of field: rte_mempool_ops::alloc",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).free) as usize - ptr as usize },
40usize,
"Offset of field: rte_mempool_ops::free",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).enqueue) as usize - ptr as usize },
48usize,
"Offset of field: rte_mempool_ops::enqueue",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).dequeue) as usize - ptr as usize },
56usize,
"Offset of field: rte_mempool_ops::dequeue",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).get_count) as usize - ptr as usize },
64usize,
"Offset of field: rte_mempool_ops::get_count",
);
}
impl Default for rte_mempool_ops {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl ::std::cmp::PartialEq for rte_mempool_ops {
fn eq(&self, other: &rte_mempool_ops) -> bool {
self.name == other.name && self.alloc == other.alloc && self.free == other.free
&& self.enqueue == other.enqueue && self.dequeue == other.dequeue
&& self.get_count == other.get_count
}
}
pub const RTE_MEMPOOL_MAX_OPS_IDX: u32 = 16;
/// The rte_spinlock_t type.
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_spinlock_t {
///< lock status 0 = unlocked, 1 = locked
pub locked: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_rte_spinlock_t() {
const UNINIT: ::std::mem::MaybeUninit<rte_spinlock_t> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<rte_spinlock_t>(),
4usize,
"Size of rte_spinlock_t",
);
assert_eq!(
::std::mem::align_of::<rte_spinlock_t>(),
4usize,
"Alignment of rte_spinlock_t",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).locked) as usize - ptr as usize },
0usize,
"Offset of field: rte_spinlock_t::locked",
);
}
/** Structure storing the table of registered ops structs, each of which contain
the function pointers for the mempool ops functions.
Each process has its own storage for this ops struct array so that
the mempools can be shared across primary and secondary processes.
The indices used to access the array are valid across processes, whereas
any function pointers stored directly in the mempool struct would not be.
This results in us simply having "ops_index" in the mempool struct.*/
#[repr(C)]
#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct rte_mempool_ops_table {
///< Spinlock for add/delete.
pub sl: rte_spinlock_t,
///< Number of used ops structs in the table.
pub num_ops: u32,
pub __bindgen_padding_0: [u64; 7usize],
/// Storage for all possible ops structs.
pub ops: [rte_mempool_ops; 16usize],
}
#[test]
fn bindgen_test_layout_rte_mempool_ops_table() {
const UNINIT: ::std::mem::MaybeUninit<rte_mempool_ops_table> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<rte_mempool_ops_table>(),
2112usize,
"Size of rte_mempool_ops_table",
);
assert_eq!(
::std::mem::align_of::<rte_mempool_ops_table>(),
64usize,
"Alignment of rte_mempool_ops_table",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).sl) as usize - ptr as usize },
0usize,
"Offset of field: rte_mempool_ops_table::sl",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).num_ops) as usize - ptr as usize },
4usize,
"Offset of field: rte_mempool_ops_table::num_ops",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).ops) as usize - ptr as usize },
64usize,
"Offset of field: rte_mempool_ops_table::ops",
);
}
impl Default for rte_mempool_ops_table {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub const RTE_HEAP_NUM_FREELISTS: u32 = 13;
/// Structure to hold malloc heap
#[repr(C)]
#[repr(align(64))]
#[derive(Copy, Clone)]
pub struct malloc_heap {
pub lock: rte_spinlock_t,
pub free_head: [malloc_heap__bindgen_ty_1; 13usize],
pub alloc_count: ::std::os::raw::c_uint,
pub total_size: usize,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct malloc_heap__bindgen_ty_1 {
pub lh_first: *mut malloc_elem,
}
#[test]
fn bindgen_test_layout_malloc_heap__bindgen_ty_1() {
const UNINIT: ::std::mem::MaybeUninit<malloc_heap__bindgen_ty_1> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<malloc_heap__bindgen_ty_1>(),
8usize,
"Size of malloc_heap__bindgen_ty_1",
);
assert_eq!(
::std::mem::align_of::<malloc_heap__bindgen_ty_1>(),
8usize,
"Alignment of malloc_heap__bindgen_ty_1",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).lh_first) as usize - ptr as usize },
0usize,
"Offset of field: malloc_heap__bindgen_ty_1::lh_first",
);
}
impl Default for malloc_heap__bindgen_ty_1 {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[test]
fn bindgen_test_layout_malloc_heap() {
const UNINIT: ::std::mem::MaybeUninit<malloc_heap> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(::std::mem::size_of::<malloc_heap>(), 128usize, "Size of malloc_heap");
assert_eq!(
::std::mem::align_of::<malloc_heap>(),
64usize,
"Alignment of malloc_heap",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).lock) as usize - ptr as usize },
0usize,
"Offset of field: malloc_heap::lock",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).free_head) as usize - ptr as usize },
8usize,
"Offset of field: malloc_heap::free_head",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).alloc_count) as usize - ptr as usize },
112usize,
"Offset of field: malloc_heap::alloc_count",
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).total_size) as usize - ptr as usize },
120usize,
"Offset of field: malloc_heap::total_size",
);
}
impl Default for malloc_heap {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
impl ::std::cmp::PartialEq for malloc_heap {
fn eq(&self, other: &malloc_heap) -> bool {
self.lock == other.lock && self.free_head == other.free_head
&& self.alloc_count == other.alloc_count
&& self.total_size == other.total_size
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct malloc_elem {
pub _address: u8,
}