-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtommy_ext.h
39 lines (30 loc) · 823 Bytes
/
tommy_ext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*-
* xnumon - monitor macOS for malicious activity
* https://www.roe.ch/xnumon
*
* Copyright (c) 2017-2019, Daniel Roethlisberger <[email protected]>.
* All rights reserved.
*
* Licensed under the Open Software License version 3.0.
*/
#ifndef TOMMY_EXT_H
#define TOMMY_EXT_H
/*
* Trivial extensions to TommyDS, dual-licenced under the licensing terms of
* xnumon (OSL 3.0) and TommyDS (2-Clause BSD).
*/
#include "minmax.h"
#include "tommytypes.h"
/* go for 75% of next power of two to stay clear of hashtable
* performance drop but also avoiding overmuch slack space */
static inline size_t
bucket_max_for_buckets(size_t buckets) {
size_t bmax;
if (buckets == 0)
return 0;
bmax = (tommy_roundup_pow2_u32(buckets) >> 2) * 3;
if (buckets > bmax)
bmax <<= 1;
return max(bmax, (size_t)16);
}
#endif