Blame sysdeps/i386/i686/dl-hash.h

Packit 6c4009
/* Compute hash alue for given string according to ELF standard.
Packit 6c4009
   Copyright (C) 1998-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _DL_HASH_H
Packit 6c4009
#define _DL_HASH_H	1
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* This is the hashing function specified by the ELF ABI.  It is highly
Packit 6c4009
   optimized for the PII processors.  Though it will run on i586 it
Packit 6c4009
   would be much slower than the generic C implementation.  So don't
Packit 6c4009
   use it.  */
Packit 6c4009
static unsigned int
Packit 6c4009
__attribute__ ((unused))
Packit 6c4009
_dl_elf_hash (const char *name)
Packit 6c4009
{
Packit 6c4009
  unsigned int result;
Packit 6c4009
  unsigned int temp0;
Packit 6c4009
  unsigned int temp1;
Packit 6c4009
Packit 6c4009
  __asm__ __volatile__
Packit 6c4009
    ("movzbl (%1),%2\n\t"
Packit 6c4009
     "testl %2, %2\n\t"
Packit 6c4009
     "jz 1f\n\t"
Packit 6c4009
     "movl %2, %0\n\t"
Packit 6c4009
     "movzbl 1(%1), %2\n\t"
Packit 6c4009
     "jecxz 1f\n\t"
Packit 6c4009
     "shll $4, %0\n\t"
Packit 6c4009
     "addl %2, %0\n\t"
Packit 6c4009
     "movzbl 2(%1), %2\n\t"
Packit 6c4009
     "jecxz 1f\n\t"
Packit 6c4009
     "shll $4, %0\n\t"
Packit 6c4009
     "addl %2, %0\n\t"
Packit 6c4009
     "movzbl 3(%1), %2\n\t"
Packit 6c4009
     "jecxz 1f\n\t"
Packit 6c4009
     "shll $4, %0\n\t"
Packit 6c4009
     "addl %2, %0\n\t"
Packit 6c4009
     "movzbl 4(%1), %2\n\t"
Packit 6c4009
     "jecxz 1f\n\t"
Packit 6c4009
     "shll $4, %0\n\t"
Packit 6c4009
     "addl $5, %1\n\t"
Packit 6c4009
     "addl %2, %0\n\t"
Packit 6c4009
     "movzbl (%1), %2\n\t"
Packit 6c4009
     "jecxz 1f\n"
Packit 6c4009
     "2:\t"
Packit 6c4009
     "shll $4, %0\n\t"
Packit 6c4009
     "movl $0xf0000000, %3\n\t"
Packit 6c4009
     "incl %1\n\t"
Packit 6c4009
     "addl %2, %0\n\t"
Packit 6c4009
     "andl %0, %3\n\t"
Packit 6c4009
     "andl $0x0fffffff, %0\n\t"
Packit 6c4009
     "shrl $24, %3\n\t"
Packit 6c4009
     "movzbl (%1), %2\n\t"
Packit 6c4009
     "xorl %3, %0\n\t"
Packit 6c4009
     "testl %2, %2\n\t"
Packit 6c4009
     "jnz 2b\n"
Packit 6c4009
     "1:\t"
Packit 6c4009
     : "=&r" (result), "=r" (name), "=&c" (temp0), "=&r" (temp1)
Packit 6c4009
     : "0" (0), "1" ((const unsigned char *) name));
Packit 6c4009
Packit 6c4009
  return result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#endif /* dl-hash.h */