mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Merge branch '3243-mr-6035-fix' into 'main'
Turn isc_hash_bits32() into static online function Closes #3243 See merge request isc-projects/bind9!6050
This commit is contained in:
commit
fe4cd556b3
2 changed files with 10 additions and 7 deletions
|
|
@ -1431,6 +1431,8 @@ gcov:
|
|||
# Help gcovr process the nasty tricks in lib/dns/code.h, where we include C
|
||||
# source files from lib/dns/rdata/*/, using an even nastier trick.
|
||||
- find lib/dns/rdata/* -name "*.c" -execdir cp -f "{}" ../../ \;
|
||||
# Help gcovr process inline function in the isc/hash.h
|
||||
- cp -f lib/isc/include/isc/hash.h lib/dns/hash.h
|
||||
# Generate XML file in the Cobertura XML format suitable for use by GitLab
|
||||
# for the purpose of displaying code coverage information in the diff view
|
||||
# of a given merge request.
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include <isc/assertions.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#define ISC_HASHSIZE(bits) (UINT64_C(1) << (bits))
|
||||
#define ISC_HASH_OVERCOMMIT 3
|
||||
|
|
@ -80,12 +81,12 @@ isc_hash64(const void *data, const size_t length, const bool case_sensitive);
|
|||
* \li a hash value of length 'bits'.
|
||||
*/
|
||||
#define ISC_HASH_GOLDENRATIO_32 0x61C88647
|
||||
#define isc_hash_bits32(val, bits) \
|
||||
({ \
|
||||
REQUIRE(bits <= 32U); \
|
||||
uint32_t __v = (val & 0xffff); \
|
||||
__v = ((__v * ISC_HASH_GOLDENRATIO_32) >> (32 - bits)); \
|
||||
__v; \
|
||||
})
|
||||
|
||||
static inline uint32_t
|
||||
isc_hash_bits32(uint32_t val, unsigned int bits) {
|
||||
ISC_REQUIRE(bits <= ISC_HASH_MAX_BITS);
|
||||
/* High bits are more random. */
|
||||
return (val * ISC_HASH_GOLDENRATIO_32 >> (32 - bits));
|
||||
}
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
|
|
|||
Loading…
Reference in a new issue