From 67f36c7922fe5053549ec9aa7f60ed2c5c2d65b4 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 23 Nov 2017 14:08:11 +0100 Subject: nss: Export nscd hash function as __nss_hash [BZ #22459] --- nis/nis_hash.c | 65 +++++++++-------------------------------------------- nis/rpcsvc/nislib.h | 1 - 2 files changed, 11 insertions(+), 55 deletions(-) (limited to 'nis') diff --git a/nis/nis_hash.c b/nis/nis_hash.c index cc42ac8911..5dba1cba0f 100644 --- a/nis/nis_hash.c +++ b/nis/nis_hash.c @@ -1,6 +1,6 @@ -/* Copyright (c) 1997-2017 Free Software Foundation, Inc. +/* Forward __nis_hash calls to __nss_hash, for ABI compatibility. + Copyright (c) 2017 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,61 +16,18 @@ License along with the GNU C Library; if not, see . */ -#include -#include +#include + +#if SHLIB_COMPAT (libnsl, GLIBC_2_1, GLIBC_2_27) + +# include -/* This is from libc/db/hash/hash_func.c, hash3 is static there */ -/* - * This is INCREDIBLY ugly, but fast. We break the string up into 8 byte - * units. On the first time through the loop we get the "leftover bytes" - * (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle - * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If - * this routine is heavily used enough, it's worth the ugly coding. - * - * OZ's original sdbm hash - */ uint32_t __nis_hash (const void *keyarg, size_t len) { - const u_char *key; - size_t loop; - uint32_t h; + return __nss_hash (keyarg, len); +} -#define HASHC h = *key++ + 65599 * h +compat_symbol (libnsl, __nis_hash, __nis_hash, GLIBC_2_1); - h = 0; - key = keyarg; - if (len > 0) - { - loop = (len + 8 - 1) >> 3; - switch (len & (8 - 1)) - { - case 0: - do { - HASHC; - /* FALLTHROUGH */ - case 7: - HASHC; - /* FALLTHROUGH */ - case 6: - HASHC; - /* FALLTHROUGH */ - case 5: - HASHC; - /* FALLTHROUGH */ - case 4: - HASHC; - /* FALLTHROUGH */ - case 3: - HASHC; - /* FALLTHROUGH */ - case 2: - HASHC; - /* FALLTHROUGH */ - case 1: - HASHC; - } while (--loop); - } - } - return h; -} +#endif diff --git a/nis/rpcsvc/nislib.h b/nis/rpcsvc/nislib.h index 52fbba4b8f..ad22c9c767 100644 --- a/nis/rpcsvc/nislib.h +++ b/nis/rpcsvc/nislib.h @@ -244,7 +244,6 @@ extern uint32_t __nis_default_ttl (char *) __THROW; extern unsigned int __nis_default_access (char *, unsigned int) __THROW; extern fd_result *__nis_finddirectory (directory_obj *, const_nis_name) __THROW; extern void __free_fdresult (fd_result *) __THROW; -extern uint32_t __nis_hash (const void *__keyarg, size_t __len) __THROW; /* NIS+ cache locking */ extern int __nis_lock_cache (void) __THROW; -- cgit 1.4.1