ngx/core/mod.rs
1mod buffer;
2mod pool;
3pub mod slab;
4mod status;
5mod string;
6
7pub use buffer::*;
8pub use pool::*;
9pub use slab::SlabPool;
10pub use status::*;
11pub use string::*;
12
13/// Gets an outer object pointer from a pointer to one of its fields.
14/// While there is no corresponding C macro, the pattern is common in the NGINX source.
15///
16/// # Safety
17///
18/// `$ptr` must be a valid pointer to the field `$field` of `$type`.
19#[macro_export]
20macro_rules! ngx_container_of {
21 ($ptr:expr, $type:path, $field:ident) => {
22 $ptr.byte_sub(::core::mem::offset_of!($type, $field))
23 .cast::<$type>()
24 };
25}