mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-03 18:09:25 +00:00
BUILD: compiler: add the container_of() and container_of_safe() macros
These ones are called from a few places in the code and are only provided by ebtree.h, which is not normal given that some callers do not even use ebtree.
This commit is contained in:
parent
74f2456c42
commit
337f23a112
@ -171,6 +171,23 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Linux-like "container_of". It returns a pointer to the structure of type
|
||||
* <type> which has its member <name> stored at address <ptr>.
|
||||
*/
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, name) ((type *)(((void *)(ptr)) - ((long)&((type *)0)->name)))
|
||||
#endif
|
||||
|
||||
/* returns a pointer to the structure of type <type> which has its member <name>
|
||||
* stored at address <ptr>, unless <ptr> is 0, in which case 0 is returned.
|
||||
*/
|
||||
#ifndef container_of_safe
|
||||
#define container_of_safe(ptr, type, name) \
|
||||
({ void *__p = (ptr); \
|
||||
__p ? (type *)(__p - ((long)&((type *)0)->name)) : (type *)0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
/* Some architectures have a double-word CAS, sometimes even dual-8 bytes.
|
||||
* Some architectures support unaligned accesses, others are fine with them
|
||||
* but only for non-atomic operations. Also mention those supporting unaligned
|
||||
|
Loading…
Reference in New Issue
Block a user