1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/lib/webfuse_provider/impl/util/container_of.h
2020-06-21 21:18:43 +02:00

22 lines
486 B
C

#ifndef WFP_UTIL_CONTAINER_OF_H
#define WFP_UTIL_CONTAINER_OF_H
#ifndef __cplusplus
#include <stddef.h>
#else
#include <cstddef>
#endif
#ifdef __GNUC__
#define wfp_container_of(pointer, type, member) \
({ \
const typeof( ((type *)0)->member ) * __member = (pointer); \
(type *)( (char *)__member - offsetof(type, member) ); \
})
#else
#define wfp_container_of(pointer, type, member) \
(type *) (((char *) pointer) - offsetof(type, member))
#endif
#endif