[libdazzle] build: use GLIB_SIZEOF_VOID_P



commit 914248449de5c8693bbca7bab049c2ebd28d9353
Author: Christian Hergert <chergert redhat com>
Date:   Wed Nov 22 03:36:52 2017 -0800

    build: use GLIB_SIZEOF_VOID_P
    
    This is more portable than our LP64 checks, as glib should set
    it for us on all platforms.

 src/search/dzl-fuzzy-index-cursor.c |   12 ++++++------
 src/search/dzl-trie.c               |   24 ++++++++++--------------
 src/util/dzl-int-pair.h             |    2 +-
 3 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/src/search/dzl-fuzzy-index-cursor.c b/src/search/dzl-fuzzy-index-cursor.c
index 9403ee4..3570cbf 100644
--- a/src/search/dzl-fuzzy-index-cursor.c
+++ b/src/search/dzl-fuzzy-index-cursor.c
@@ -25,10 +25,6 @@
 #include "search/dzl-fuzzy-index-private.h"
 #include "util/dzl-int-pair.h"
 
-#if defined(__LP64__) || defined(_WIN64)
-# define DZL_FUZZY_64 1
-#endif
-
 struct _DzlFuzzyIndexCursor
 {
   GObject          object;
@@ -91,7 +87,7 @@ pointer_to_float (gpointer ptr)
 {
   union {
     gpointer ptr;
-#ifdef DZL_FUZZY_64
+#if GLIB_SIZEOF_VOID_P == 8
     gdouble fval;
 #else
     gfloat fval;
@@ -106,7 +102,7 @@ float_to_pointer (gfloat fval)
 {
   union {
     gpointer ptr;
-#ifdef DZL_FUZZY_64
+#if GLIB_SIZEOF_VOID_P == 8
     gdouble fval;
 #else
     gfloat fval;
@@ -116,6 +112,10 @@ float_to_pointer (gfloat fval)
   return convert.ptr;
 }
 
+/* Not guaranteed, so assert to be sure */
+G_STATIC_ASSERT (sizeof(gdouble) == 8);
+G_STATIC_ASSERT (sizeof(gfloat) == 4);
+
 static void
 dzl_fuzzy_index_cursor_finalize (GObject *object)
 {
diff --git a/src/search/dzl-trie.c b/src/search/dzl-trie.c
index ee1b928..27d87b0 100644
--- a/src/search/dzl-trie.c
+++ b/src/search/dzl-trie.c
@@ -23,10 +23,6 @@
 #include "search/dzl-trie.h"
 #include "util/dzl-macros.h"
 
-#if defined(__LP64__) || defined(_WIN64)
-# define TRIE_64 1
-#endif
-
 /**
  * SECTION:trie
  * @title: DzlTrie
@@ -52,16 +48,16 @@ G_DEFINE_BOXED_TYPE (DzlTrie, dzl_trie, dzl_trie_ref, dzl_trie_unref)
  * everwhere, such as x86_64 compiled with -m32. However, accomidating that
  * will require some changes to the layout of each chunk.
  */
-#ifdef TRIE_64
-#define FIRST_CHUNK_KEYS         4
-#define TRIE_NODE_SIZE          64
-#define TRIE_NODE_CHUNK_SIZE    64
-#define TRIE_NODE_CHUNK_KEYS(c) (((c)->is_inline) ? 4 : 6)
+#if GLIB_SIZEOF_VOID_P == 8
+# define FIRST_CHUNK_KEYS         4
+# define TRIE_NODE_SIZE          64
+# define TRIE_NODE_CHUNK_SIZE    64
+# define TRIE_NODE_CHUNK_KEYS(c) (((c)->is_inline) ? 4 : 6)
 #else
-#define FIRST_CHUNK_KEYS         3
-#define TRIE_NODE_SIZE          32
-#define TRIE_NODE_CHUNK_SIZE    32
-#define TRIE_NODE_CHUNK_KEYS(c) (((c)->is_inline) ? 3 : 5)
+# define FIRST_CHUNK_KEYS         3
+# define TRIE_NODE_SIZE          32
+# define TRIE_NODE_CHUNK_SIZE    32
+# define TRIE_NODE_CHUNK_KEYS(c) (((c)->is_inline) ? 3 : 5)
 #endif
 
 /**
@@ -112,7 +108,7 @@ struct _DzlTrie
    DzlTrieNode    *root;
 };
 
-#ifdef TRIE_64
+#if GLIB_SIZEOF_VOID_P == 8
   G_STATIC_ASSERT (sizeof(gpointer) == 8);
   G_STATIC_ASSERT ((FIRST_CHUNK_KEYS-1) == 3);
   G_STATIC_ASSERT (((FIRST_CHUNK_KEYS-1) * sizeof(gpointer)) == 24);
diff --git a/src/util/dzl-int-pair.h b/src/util/dzl-int-pair.h
index 059218b..b66992b 100644
--- a/src/util/dzl-int-pair.h
+++ b/src/util/dzl-int-pair.h
@@ -26,7 +26,7 @@
 
 G_BEGIN_DECLS
 
-#if defined(__LP64__) || defined(_WIN64)
+#if GLIB_SIZEOF_VOID_P == 8
 # define DZL_INT_PAIR_64
 #endif
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]