aboutsummaryrefslogtreecommitdiff
path: root/tools/build/cross-build
diff options
context:
space:
mode:
authorJose Luis Duran <jlduran@users.noreply.github.com>2021-08-30 19:29:17 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-09-07 09:53:50 +0000
commit94d9439b6be6bd5ef9febfaf38128e0cad91476d (patch)
treec8933af49b9e099d75095026855fed56b1716b41 /tools/build/cross-build
parentb5be5c35dbaf38caaa9c70a83025f3535abbfd4f (diff)
downloadsrc-94d9439b6be6bd5ef9febfaf38128e0cad91476d.tar.gz
src-94d9439b6be6bd5ef9febfaf38128e0cad91476d.zip
Fix cross-builds after 4e5d32a445f90d37966cd6de571978551654e3f3
Add alignment macros to cross-build's sys/cdefs.h Pull Request: https://github.com/freebsd/freebsd-src/pull/531 MFC after: immediately (build fix)
Diffstat (limited to 'tools/build/cross-build')
-rw-r--r--tools/build/cross-build/include/common/sys/cdefs.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h
index c129542b6180..6d62333bcffe 100644
--- a/tools/build/cross-build/include/common/sys/cdefs.h
+++ b/tools/build/cross-build/include/common/sys/cdefs.h
@@ -255,3 +255,22 @@
#define __BSD_VISIBLE 1
#define __ISO_C_VISIBLE 2011
#define __EXT1_VISIBLE 1
+
+/* Alignment builtins for better type checking and improved code generation. */
+/* Provide fallback versions for other compilers (GCC/Clang < 10): */
+#if !__has_builtin(__builtin_is_aligned)
+#define __builtin_is_aligned(x, align) \
+ (((__uintptr_t)x & ((align) - 1)) == 0)
+#endif
+#if !__has_builtin(__builtin_align_up)
+#define __builtin_align_up(x, align) \
+ ((__typeof__(x))(((__uintptr_t)(x)+((align)-1))&(~((align)-1))))
+#endif
+#if !__has_builtin(__builtin_align_down)
+#define __builtin_align_down(x, align) \
+ ((__typeof__(x))((x)&(~((align)-1))))
+#endif
+
+#define __align_up(x, y) __builtin_align_up(x, y)
+#define __align_down(x, y) __builtin_align_down(x, y)
+#define __is_aligned(x, y) __builtin_is_aligned(x, y)