summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2025-06-11 17:39:02 +0100
committerBrooks Davis <brooks@FreeBSD.org>2025-06-11 17:39:02 +0100
commit2e783ea70a7a1aa0bec116451d70abd8cf05ce42 (patch)
tree68cb14bac5ae4c2e03dd8e206800a12b9d8da4ef /include
parent5a2f6016dec69cbcfe9595c7f40a7e44d85a9288 (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/stddef.h6
1 files 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 */