summaryrefslogtreecommitdiff
path: root/Zend/zend_portability.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-09-13 21:52:17 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-09-14 00:24:47 +0200
commitec30a3b1716fa33a1769bc45ab01164711c0dfd9 (patch)
treeb8e4134b5b5e2d7b9d9d12509fa2662f47f10191 /Zend/zend_portability.h
parent4226c8247f5ba8ade3228581bd313fa5692ef4ad (diff)
downloadphp-git-ec30a3b1716fa33a1769bc45ab01164711c0dfd9.tar.gz
Include stddef.h in zend_portability.h for offsetof() macro
This makes sure that we use compiler builtins when they are available and thus avoid ubsan warnings in clang. And also reindent the fallback implementation.
Diffstat (limited to 'Zend/zend_portability.h')
-rw-r--r--Zend/zend_portability.h30
1 files changed, 13 insertions, 17 deletions
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index 978f25bbfb..1e549d300b 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -55,6 +55,7 @@
#endif
#include <stdarg.h>
+#include <stddef.h>
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
@@ -327,24 +328,19 @@ char *alloca();
#ifndef XtOffsetOf
# if defined(CRAY) || (defined(__ARMCC_VERSION) && !defined(LINUX))
-# ifdef __STDC__
-# define XtOffset(p_type, field) _Offsetof(p_type, field)
-# else
-# ifdef CRAY2
-# define XtOffset(p_type, field) \
- (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
-
-# else /* !CRAY2 */
-
-# define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
-
-# endif /* !CRAY2 */
-# endif /* __STDC__ */
+# ifdef __STDC__
+# define XtOffset(p_type, field) _Offsetof(p_type, field)
+# else
+# ifdef CRAY2
+# define XtOffset(p_type, field) \
+ (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
+# else /* !CRAY2 */
+# define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
+# endif /* !CRAY2 */
+# endif /* __STDC__ */
# else /* ! (CRAY || __arm) */
-
-# define XtOffset(p_type, field) \
- ((zend_long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
-
+# define XtOffset(p_type, field) \
+ ((zend_long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
# endif /* !CRAY */
# ifdef offsetof