diff options
| author | Michael Biebl <biebl@debian.org> | 2019-07-31 10:51:42 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-07-31 10:51:42 +0200 |
| commit | 2e5fa45ddfbb5cffa1e78221f1cea706e2f298af (patch) | |
| tree | 86f69d36c56de3074280456eddc854a780b8e04b /shared/nm-glib-aux/nm-hash-utils.c | |
| parent | 85563b7fc7ec2cd21e38debb9b28db342e2e8e7c (diff) | |
New upstream version 1.19.90 upstream/1.19.90
Diffstat (limited to 'shared/nm-glib-aux/nm-hash-utils.c')
| -rw-r--r-- | shared/nm-glib-aux/nm-hash-utils.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/shared/nm-glib-aux/nm-hash-utils.c b/shared/nm-glib-aux/nm-hash-utils.c index 6e728e6b..a6158269 100644 --- a/shared/nm-glib-aux/nm-hash-utils.c +++ b/shared/nm-glib-aux/nm-hash-utils.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* NetworkManager -- Network link manager * * This library is free software; you can redistribute it and/or @@ -45,7 +44,10 @@ _get_hash_key_init (void) * to use it as guint* or guint64* pointer. */ static union { guint8 v8[HASH_KEY_SIZE]; - } g_arr _nm_alignas (guint64); + guint _align_as_uint; + guint32 _align_as_uint32; + guint64 _align_as_uint64; + } g_arr; const guint8 *g; union { guint8 v8[HASH_KEY_SIZE]; @@ -125,14 +127,17 @@ void nm_hash_siphash42_init (CSipHash *h, guint static_seed) { const guint8 *g; - guint seed[HASH_KEY_SIZE_GUINT]; + union { + guint64 _align_as_uint64; + guint arr[HASH_KEY_SIZE_GUINT]; + } seed; nm_assert (h); g = _get_hash_key (); - memcpy (seed, g, HASH_KEY_SIZE); - seed[0] ^= static_seed; - c_siphash_init (h, (const guint8 *) seed); + memcpy (&seed, g, HASH_KEY_SIZE); + seed.arr[0] ^= static_seed; + c_siphash_init (h, (const guint8 *) &seed); } guint @@ -194,3 +199,25 @@ nm_pstr_equal (gconstpointer a, gconstpointer b) && s2 && nm_streq0 (*s1, *s2)); } + +guint +nm_pdirect_hash (gconstpointer p) +{ + const void *const*s = p; + + if (!s) + return nm_hash_static (1852748873u); + return nm_direct_hash (*s); +} + +gboolean +nm_pdirect_equal (gconstpointer a, gconstpointer b) +{ + const void *const*s1 = a; + const void *const*s2 = b; + + return (s1 == s2) + || ( s1 + && s2 + && *s1 == *s2); +} |