The branch main has been updated by brooks:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2e783ea70a7a1aa0bec116451d70abd8cf05ce42

commit 2e783ea70a7a1aa0bec116451d70abd8cf05ce42
Author:     Brooks Davis <bro...@freebsd.org>
AuthorDate: 2025-06-11 16:39:02 +0000
Commit:     Brooks Davis <bro...@freebsd.org>
CommitDate: 2025-06-11 16:39:02 +0000

    stddef.h: don't include sys/cdefs.h
    
    Switch to sys/_visible.h for visibility macros.
    
    Prefer __builtin_offsetof over __offset.  sys/cdefs.h always defines
    __offsetof to __builtin_offsetof so just use the latter to remove a
    dependency on sys/cdefs.h.  Realistically, we're never going to care
    about a compiler that doesn't supply this builtin.
    
    Add a somewhat questionable guard around the offsetof() definition
    because the compiler no longer thinks it the same as a number of other
    redundent definitions scattered around (e.g., in the openzfs codebase).
    It is actually the same and those defintions likely shouldn't exist at
    all, but it's easy to add a guard for now.
    
    Reviewed by:    imp
    Exp-run by:     antoine (PR 286274)
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1595
---
 include/stddef.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/stddef.h b/include/stddef.h
index 2255ea47a49a..3ba9a9946b01 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -32,9 +32,9 @@
 #ifndef _STDDEF_H_
 #define _STDDEF_H_
 
-#include <sys/cdefs.h>
 #include <sys/_null.h>
 #include <sys/_types.h>
+#include <sys/_visible.h>
 
 #ifndef _PTRDIFF_T_DECLARED
 typedef        __ptrdiff_t     ptrdiff_t;
@@ -61,7 +61,9 @@ typedef       __max_align_t   max_align_t;
 #endif
 #endif
 
-#define        offsetof(type, field)   __offsetof(type, field)
+#ifndef offsetof
+#define        offsetof(type, field)   __builtin_offsetof(type, field)
+#endif
 
 #if __EXT1_VISIBLE
 /* ISO/IEC 9899:2011 K.3.3.2 */

Reply via email to