254 | | #define __offsetof(type, field) ((size_t)(&((type *)0)->field)) |
255 | | #define __rangeof(type, start, end) \ |
256 | | (__offsetof(type, end) - __offsetof(type, start)) |
| 254 | #if __GNUC_PREREQ__(4, 1) |
| 255 | #define __offsetof(type, field) __builtin_offsetof(type, field) |
| 256 | #else |
| 257 | #ifndef __cplusplus |
| 258 | #define __offsetof(type, field) ((size_t)(&((type *)0)->field)) |
| 259 | #else |
| 260 | #define __offsetof(type, field) \ |
| 261 | (__offsetof__ (reinterpret_cast <size_t> \ |
| 262 | (&reinterpret_cast <const volatile char &> \ |
| 263 | (static_cast<type *> (0)->field)))) |
| 264 | #endif |
| 265 | #endif |
| 266 | #define __rangeof(type, start, end) \ |
| 267 | (__offsetof(type, end) - __offsetof(type, start)) |
| 268 | |