mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-20 22:15:40 +00:00
MINOR: compiler: introduce offsetoff().
Add a offsetof() macro, if it is no there already.
This commit is contained in:
parent
25ae45a078
commit
928fbfa8b7
@ -107,5 +107,23 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GNUC_PREREQ__
|
||||||
|
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
||||||
|
#define __GNUC_PREREQ__(ma, mi) \
|
||||||
|
(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
|
||||||
|
#else
|
||||||
|
#define __GNUC_PREREQ__(ma, mi) 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef offsetof
|
||||||
|
#if __GNUC_PREREQ__(4, 1)
|
||||||
|
#define offsetof(type, field) __builtin_offsetof(type, field)
|
||||||
|
#else
|
||||||
|
#define offsetof(type, field) \
|
||||||
|
((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* _COMMON_COMPILER_H */
|
#endif /* _COMMON_COMPILER_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user