1 #ifndef _EXT2FS_COMPILER_H 2 #define _EXT2FS_COMPILER_H 3 4 #ifndef __has_builtin 5 #define __has_builtin(x) 0 6 #endif 7 8 #undef offsetof 9 #if __has_builtin(__builtin_offsetof) 10 #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) 11 #elif defined(__compiler_offsetof) 12 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) 13 #else 14 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 15 #endif 16 17 #define container_of(ptr, type, member) ({ \ 18 const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ 19 (type *)( (char *)__mptr - offsetof(type,member) );}) 20 21 22 #endif /* _EXT2FS_COMPILER_H */