Skip to content

Commit

Permalink
sync for stddef.h
Browse files Browse the repository at this point in the history
[Note: keeping the *_FILENO macros defined in apr-1.x]


apr_general: Use __builtin_offsetof for APR_OFFSETOF if available.  PR 68763.

Sanitizers might warn about &((type *)0)->field being UB, so use the builtin
which is meant to avoid it.


Merges r892156, r1916337 ^/apr/apr/trunk
Submitted by: wrowe, ylavic


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1916338 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ylavic committed Mar 15, 2024
1 parent 5f25e56 commit 2690927
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,7 @@ AC_SUBST(netinet_sctph)
AC_SUBST(netinet_sctp_uioh)
AC_SUBST(netinet_tcph)
AC_SUBST(stdargh)
AC_SUBST(stddefh)
AC_SUBST(stdioh)
AC_SUBST(stdlibh)
AC_SUBST(stringh)
Expand Down
5 changes: 5 additions & 0 deletions include/apr.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#define APR_HAVE_SEMAPHORE_H @semaphoreh@
#define APR_HAVE_SIGNAL_H @signalh@
#define APR_HAVE_STDARG_H @stdargh@
#define APR_HAVE_STDDEF_H @stddefh@
#define APR_HAVE_STDINT_H @stdint@
#define APR_HAVE_STDIO_H @stdioh@
#define APR_HAVE_STDLIB_H @stdlibh@
Expand Down Expand Up @@ -165,6 +166,10 @@
#include <sys/types.h>
#endif

#if APR_HAVE_STDDEF_H
#include <stddef.h>
#endif

#if APR_HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
Expand Down
4 changes: 3 additions & 1 deletion include/apr_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ typedef int apr_signum_t;
* @param field data field within the structure
* @return offset
*/
#if defined(offsetof) && !defined(__cplusplus)
#if defined(__has_builtin) && __has_builtin(__builtin_offsetof)
#define APR_OFFSETOF(s_type,field) __builtin_offsetof(s_type,field)
#elif defined(offsetof) && !defined(__cplusplus)
#define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
#else
#define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
Expand Down

0 comments on commit 2690927

Please sign in to comment.