mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
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.
This commit is contained in:
parent
4226c8247f
commit
ec30a3b171
1 changed files with 13 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue