diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2022-05-19 17:18:00 -0500 |
---|---|---|
committer | Noah Goldstein <goldstein.w.n@gmail.com> | 2022-05-23 10:38:40 -0500 |
commit | 5f2f0f69777a9781ac65b5619b2abedd88703be2 (patch) | |
tree | a8da06889f3feab2a56983f002722dc82d787fe0 /nss/simple-nss-hash.h | |
parent | 6fd435485f270a8c76e47bf7377c1b872885e683 (diff) | |
download | glibc-5f2f0f69777a9781ac65b5619b2abedd88703be2.zip glibc-5f2f0f69777a9781ac65b5619b2abedd88703be2.tar.gz glibc-5f2f0f69777a9781ac65b5619b2abedd88703be2.tar.bz2 |
nss: Add tests for the nss_hash in nss_hash.h
If we want to further optimize the function tests are needed.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'nss/simple-nss-hash.h')
-rw-r--r-- | nss/simple-nss-hash.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/nss/simple-nss-hash.h b/nss/simple-nss-hash.h new file mode 100644 index 0000000..4770897 --- /dev/null +++ b/nss/simple-nss-hash.h @@ -0,0 +1,42 @@ +/* __simple_nss_hash for testing nss_hash function + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _SIMPLE_NSS_HASH_H +#define _SIMPLE_NSS_HASH_H 1 + +#include <stdint.h> + +/* For testing/benchmarking purposes. Real implementation in + nss/nss_hash.c. */ +static uint32_t +__attribute__ ((unused)) +__simple_nss_hash (const void *keyarg, size_t len) +{ + const unsigned char *key; + size_t i; + uint32_t h = 0; + key = keyarg; + + for (i = 0; i < len; ++i) + h = *key++ + 65599 * h; + + return h; +} + + +#endif /* simple-nss-hash.h */ |