util: add container_of() macro
This commit is contained in:
parent
0cd8b52b18
commit
45afb2268e
@ -1,6 +1,8 @@
|
||||
#ifndef EPOLL_UTIL_H_
|
||||
#define EPOLL_UTIL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
#define SSIZE_T_DEFINED
|
||||
typedef intptr_t ssize_t;
|
||||
@ -8,4 +10,7 @@ typedef intptr_t ssize_t;
|
||||
|
||||
#define array_count(a) (sizeof(a) / (sizeof((a)[0])))
|
||||
|
||||
#define container_of(ptr, type, member) \
|
||||
((type*) ((char*) (ptr) -offsetof(type, member)))
|
||||
|
||||
#endif /* EPOLL_UTIL_H_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user