Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so Recode _rtld_elf_hash() so it compiles bet...



details:   https://anonhg.NetBSD.org/src/rev/0e488ec1b477
branches:  trunk
changeset: 537704:0e488ec1b477
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Fri Oct 04 20:34:10 2002 +0000

description:
Recode _rtld_elf_hash() so it compiles better (at least on i386 and arm).
Still could be better on i386, but only written in assembler...

diffstat:

 libexec/ld.elf_so/symbol.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (32 lines):

diff -r f3c6f23a9a22 -r 0e488ec1b477 libexec/ld.elf_so/symbol.c
--- a/libexec/ld.elf_so/symbol.c        Fri Oct 04 20:05:14 2002 +0000
+++ b/libexec/ld.elf_so/symbol.c        Fri Oct 04 20:34:10 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: symbol.c,v 1.23 2002/10/03 20:35:20 mycroft Exp $       */
+/*     $NetBSD: symbol.c,v 1.24 2002/10/04 20:34:10 mycroft Exp $       */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -63,14 +63,17 @@
        const unsigned char *p = (const unsigned char *) name;
        unsigned long   h = 0;
        unsigned long   g;
+       unsigned long   c;
 
-       while (*p != '\0') {
-               h = (h << 4) + *p++;
-               if ((g = h & 0xf0000000) != 0)
+       for (; __predict_true((c = *p) != '\0'); p++) {
+               h <<= 4;
+               h += c;
+               if ((g = h & 0xf0000000) != 0) {
+                       h ^= g;
                        h ^= g >> 24;
-               h &= ~g;
+               }
        }
-       return h;
+       return (h);
 }
 
 const Elf_Sym *



Home | Main Index | Thread Index | Old Index