From f4aa666add2c0946ff1be25c0fcd2521c8e6b8e2 Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Mon, 3 Oct 2011 10:22:28 +0300 Subject: [PATCH] [build] Use autoconf to find out cl_word_alignment. 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 | 3 +++ include/cln/config.h.in | 6 ++++++ include/cln/object.h | 19 +------------------ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index bdd21dc..4a70321 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/include/cln/config.h.in b/include/cln/config.h.in index 78215ce..2c1293c 100644 --- a/include/cln/config.h.in +++ b/include/cln/config.h.in @@ -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. diff --git a/include/cln/object.h b/include/cln/object.h index e8c1b9d..61a614e 100644 --- a/include/cln/object.h +++ b/include/cln/object.h @@ -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: // -- 2.49.0