]> www.ginac.de Git - cln.git/commitdiff
[build] Use autoconf to find out cl_word_alignment.
authorAlexey Sheplyakov <asheplyakov@yandex.ru>
Mon, 3 Oct 2011 07:22:28 +0000 (10:22 +0300)
committerAlexey Sheplyakov <asheplyakov@altlinux.org>
Sun, 20 Dec 2020 13:45:58 +0000 (17:45 +0400)
This way there's no need to define cl_word_alignment for every CPU. Also we
can stop exposing __$cpu__ macros in the public headers (for one our macros
conflict with compiler defined ones).

configure.ac
include/cln/config.h.in
include/cln/object.h

index bdd21dc48b24e1127c455db3c7859ab931d9c932..4a703212c7efe7730c68e693b33d9adf61224857 100644 (file)
@@ -92,6 +92,9 @@ dnl
 AC_LANG([C++])
 AX_CXX_COMPILE_STDCXX([11], [ext], [optional])
 dnl
+AC_CHECK_ALIGNOF([void*])
+AC_DEFINE_UNQUOTED([cl_word_alignment], [$ac_cv_alignof_voidp], [Normal alignment of void*])
+dnl
 dnl           checks for header files
 dnl
 AC_CHECK_HEADERS([unistd.h])
index 78215cea6b7a4d76c1e773f36e20db815bb9aa9b..2c1293c9bcbb313d3a90eb812d657839082135f8 100644 (file)
@@ -4,6 +4,12 @@
 #include "cln/host_cpu.h"
 #include "cln/version.h"
 
+/**
+ * Alignment of a `void*'. CLN needs it to distinguish between pointers
+ * and immediate values.
+ */
+#undef cl_word_alignment
+
 /* 
  * Numbers in the heap are stored as "digit" (or "limb" in GMP speak)
  * sequences. A digit is an unsigned int with sizeof(void *)*CHAR_BIT bits.
index e8c1b9d9ae08b017b0cb9238d7d2b3f2821a9016..61a614eb5239d969f3ccdad231fe26e062863280 100644 (file)
@@ -13,25 +13,8 @@ namespace cln {
 // is sufficient. Is also has the advantage of being mostly non-interrupting.
 
 
-// An object is either a pointer to heap allocated data
-//              or immediate data.
-
+// An object is either a pointer to heap allocated data or immediate data.
 // It is possible to distinguish these because pointers are aligned.
-// cl_word_alignment is the guaranteed alignment of a `void*' or `long'
-// in memory. Must be > 1.
-#if defined(__m68k__)
-  #define cl_word_alignment  2
-#endif
-#if defined(__i386__) || (defined(__mips__) && !defined(__LP64__)) || (defined(__sparc__) && !defined(__arch64__)) || defined(__hppa__) || defined(__arm__) || defined(__rs6000__) || defined(__m88k__) || defined(__convex__) || (defined(__s390__) && !defined(__s390x__)) || defined(__sh__) || (defined(__x86_64__) && defined(__ILP32__))
-  #define cl_word_alignment  4
-#endif
-#if defined(__alpha__) || defined(__ia64__) || defined(__mips64__) || defined(__powerpc64__) || (defined(__sparc__) && defined(__arch64__)) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(__s390x__) || defined(__aarch64__) || (defined(__riscv) && __riscv_xlen == 64) || defined(__e2k__)
-  #define cl_word_alignment  8
-#endif
-#if !defined(cl_word_alignment)
-  #error "Define cl_word_alignment for your CPU!"
-#endif
-
 
 // Four basic classes are introduced:
 //