summary refs log tree commit diff
path: root/nis
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-11-23 14:08:11 +0100
committerFlorian Weimer <fweimer@redhat.com>2017-11-23 14:08:11 +0100
commit67f36c7922fe5053549ec9aa7f60ed2c5c2d65b4 (patch)
treec078a7a50a890570e7c8eb24bf9f81fa45409bcc /nis
parentcccb6d4e87053ed63c74aee063fa84eb63ebf7b8 (diff)
downloadglibc-67f36c7922fe5053549ec9aa7f60ed2c5c2d65b4.tar.gz
glibc-67f36c7922fe5053549ec9aa7f60ed2c5c2d65b4.tar.xz
glibc-67f36c7922fe5053549ec9aa7f60ed2c5c2d65b4.zip
nss: Export nscd hash function as __nss_hash [BZ #22459]
Diffstat (limited to 'nis')
-rw-r--r--nis/nis_hash.c65
-rw-r--r--nis/rpcsvc/nislib.h1
2 files changed, 11 insertions, 55 deletions
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 <kukuk@suse.de>, 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
    <http://www.gnu.org/licenses/>.  */
 
-#include <stdint.h>
-#include <rpcsvc/nis.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT (libnsl, GLIBC_2_1, GLIBC_2_27)
+
+# include <nss.h>
 
-/* 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;