[glib/glib-2-60: 1/2] ghash: Disable small-arrays under valgrind
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-60: 1/2] ghash: Disable small-arrays under valgrind
- Date: Mon, 20 May 2019 15:55:23 +0000 (UTC)
commit 75f8ec1df9b48b0c3a13a9125f2c7d7c5adf5159
Author: Allison Karlitskaya <allison karlitskaya redhat com>
Date: Tue May 14 09:49:56 2019 +0200
ghash: Disable small-arrays under valgrind
Valgrind can't find 64bit pointers when we pack them into an array of
32bit values. Disable this optimisation if we detect that we are
running under valgrind.
Fixes #1749
glib/ghash.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/glib/ghash.c b/glib/ghash.c
index dac5552bd..c58e8c585 100644
--- a/glib/ghash.c
+++ b/glib/ghash.c
@@ -38,6 +38,7 @@
#include "gtestutils.h"
#include "gslice.h"
#include "grefcount.h"
+#include "gvalgrind.h"
/* The following #pragma is here so we can do this...
*
@@ -1014,6 +1015,7 @@ g_hash_table_new_full (GHashFunc hash_func,
GDestroyNotify value_destroy_func)
{
GHashTable *hash_table;
+ gboolean small;
hash_table = g_slice_new (GHashTable);
g_hash_table_set_shift (hash_table, HASH_TABLE_MIN_SHIFT);
@@ -1031,14 +1033,24 @@ g_hash_table_new_full (GHashFunc hash_func,
hash_table->values = hash_table->keys;
hash_table->hashes = g_new0 (guint, hash_table->size);
+ /* We want to use small arrays only if:
+ * - we are running on a system where that makes sense (64 bit); and
+ * - we are not running under valgrind.
+ */
+ small = FALSE;
+
#ifdef USE_SMALL_ARRAYS
- hash_table->have_big_keys = FALSE;
- hash_table->have_big_values = FALSE;
-#else
- hash_table->have_big_keys = TRUE;
- hash_table->have_big_values = TRUE;
+ small = TRUE;
+
+# ifdef ENABLE_VALGRIND
+ if (RUNNING_ON_VALGRIND)
+ small = FALSE;
+# endif
#endif
+ hash_table->have_big_keys = !small;
+ hash_table->have_big_values = !small;
+
return hash_table;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]