summaryrefslogtreecommitdiff
path: root/include/libc
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2022-02-13 02:05:11 -0300
committerGitHub <noreply@github.com>2022-02-13 00:05:11 -0500
commit2191c8b0a073cf58a5106bd3055fb276eead8b83 (patch)
tree130eca1b72e156fb288f890ce3d5ca1e69582a65 /include/libc
parented0daabf98a92ab0232dcfb9ea071bd3411b762e (diff)
Use `__builtin_offsetof` for non IDO builds (#1140)
* Add offsetof macro * Change old uses of OFFSETOF with offsetof
Diffstat (limited to 'include/libc')
-rw-r--r--include/libc/stddef.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/libc/stddef.h b/include/libc/stddef.h
index ac71ed362..b8c9859b0 100644
--- a/include/libc/stddef.h
+++ b/include/libc/stddef.h
@@ -7,4 +7,10 @@ typedef unsigned long size_t;
typedef unsigned int uintptr_t;
+#ifdef __GNUC__
+#define offsetof(structure, member) __builtin_offsetof (structure, member)
+#else
+#define offsetof(structure, member) ((size_t)&(((structure*)0)->member))
+#endif
+
#endif