1 /* $NetBSD: hash.h,v 1.6 2022/09/23 12:15:33 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #ifndef ISC_HASH_H 17 #define ISC_HASH_H 1 18 19 #include <inttypes.h> 20 #include <stdbool.h> 21 22 #include "isc/lang.h" 23 #include "isc/types.h" 24 25 /*** 26 *** Functions 27 ***/ 28 ISC_LANG_BEGINDECLS 29 30 const void * 31 isc_hash_get_initializer(void); 32 33 void 34 isc_hash_set_initializer(const void *initializer); 35 36 #define isc_hash_function isc_hash64 37 38 uint32_t 39 isc_hash32(const void *data, const size_t length, const bool case_sensitive); 40 uint64_t 41 isc_hash64(const void *data, const size_t length, const bool case_sensitive); 42 /*!< 43 * \brief Calculate a hash over data. 44 * 45 * This hash function is useful for hashtables. The hash function is 46 * opaque and not important to the caller. The returned hash values are 47 * non-deterministic and will have different mapping every time a 48 * process using this library is run, but will have uniform 49 * distribution. 50 * 51 * isc_hash_32/64() calculates the hash from start to end over the 52 * input data. 53 * 54 * 'data' is the data to be hashed. 55 * 56 * 'length' is the size of the data to be hashed. 57 * 58 * 'case_sensitive' specifies whether the hash key should be treated as 59 * case_sensitive values. It should typically be false if the hash key 60 * is a DNS name. 61 * 62 * Returns: 63 * \li 32 or 64-bit hash value 64 */ 65 66 ISC_LANG_ENDDECLS 67 68 #endif /* ISC_HASH_H */ 69