]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: compiler: move CPU capabilities definition from config.h and complete them
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2020 14:40:58 +0000 (15:40 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2020 15:32:57 +0000 (16:32 +0100)
These ones are irrelevant to the config but rather to the platform, and
as such are better placed in compiler.h.

Here we take the opportunity for declaring a few extra capabilities:
 - HA_UNALIGNED         : CPU supports unaligned accesses
 - HA_UNALIGNED_LE      : CPU supports unaligned accesses in little endian
 - HA_UNALIGNED_FAST    : CPU supports fast unaligned accesses
 - HA_UNALIGNED_ATOMIC  : CPU supports unaligned accesses in atomics

This will help remove a number of #ifdefs with arch-specific statements.

include/common/compiler.h
include/common/config.h

index b6f5af6bfb0db6d0fa85b0e5aa242868794ebba4..179b318377544b1c8fbb8b9798a7504de589d628 100644 (file)
 #endif
 #endif
 
+/* Some architectures have a double-word CAS, sometimes even dual-8 bytes.
+ * Some architectures support unaligned accesses, others are fine with them
+ * but only for non-atomic operations. Also mention those supporting unaligned
+ * accesses and being little endian, and those where unaligned accesses are
+ * known to be fast (almost as fast as aligned ones).
+ */
+#if defined(__x86_64__)
+#define HA_UNALIGNED
+#define HA_UNALIGNED_LE
+#define HA_UNALIGNED_LE64
+#define HA_UNALIGNED_FAST
+#define HA_UNALIGNED_ATOMIC
+#define HA_HAVE_CAS_DW
+#define HA_CAS_IS_8B
+#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
+#define HA_UNALIGNED
+#define HA_UNALIGNED_LE
+#define HA_UNALIGNED_ATOMIC
+#elif defined (__aarch64__) || defined(__ARM_ARCH_8A)
+#define HA_UNALIGNED
+#define HA_UNALIGNED_LE
+#define HA_UNALIGNED_LE64
+#define HA_UNALIGNED_FAST
+#define HA_HAVE_CAS_DW
+#define HA_CAS_IS_8B
+#elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__))
+#define HA_UNALIGNED
+#define HA_UNALIGNED_LE
+#define HA_UNALIGNED_FAST
+#define HA_HAVE_CAS_DW
+#endif
 
 #endif /* _COMMON_COMPILER_H */
index 55ecd59010d37a57ce9edbaa0329f94248973be9..16f47c9e275313ce9965f9dac4e65156043ef529 100644 (file)
 #define THREAD_LOCAL
 #endif
 
-/* Some architectures have a double-word CAS, sometimes even dual-8 bytes */
-#if defined(__x86_64__) || defined (__aarch64__)
-#define HA_HAVE_CAS_DW
-#define HA_CAS_IS_8B
-#elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__))
-#define HA_HAVE_CAS_DW
-#endif
-
 /* On architectures supporting threads and double-word CAS, we can implement
  * lock-less memory pools. This isn't supported for debugging modes however.
  */