diff options
author | David Lamparter <equinox@diac24.net> | 2017-07-13 14:57:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-13 14:57:44 +0200 |
commit | f4b0619dc6596f7821f520ae731a0fd02a2a424a (patch) | |
tree | 851bd0003573b3b0a7717284b48537fddb506b98 /lib/hash.c | |
parent | Merge pull request #791 from LabNConsulting/working/master/patch-set/style (diff) | |
parent | lib: use 32-bit atomics, s/pow/mul (diff) | |
download | frr-f4b0619dc6596f7821f520ae731a0fd02a2a424a.tar.xz frr-f4b0619dc6596f7821f520ae731a0fd02a2a424a.zip |
Merge pull request #796 from qlyoung/fix-hash-stats
lib: use 32-bit atomics, s/pow/mul
Diffstat (limited to 'lib/hash.c')
-rw-r--r-- | lib/hash.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/hash.c b/lib/hash.c index 62a39953c..bdb2e097c 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -87,13 +87,8 @@ hash_alloc_intern (void *arg) } #define hash_update_ssq(hz, old, new) \ - do { \ - long double res; \ - res = powl(old, 2.0); \ - hz->stats.ssq -= (uint64_t) res;\ - res = powl(new, 2.0); \ - hz->stats.ssq += (uint64_t) res; \ - } while (0); \ + atomic_fetch_add_explicit(&hz->stats.ssq, (new + old)*(new - old),\ + memory_order_relaxed); /* Expand hash if the chain length exceeds the threshold. */ static void hash_expand (struct hash *hash) |