summaryrefslogtreecommitdiff
path: root/gdb/buildsym.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>1993-08-09 23:49:18 +0000
committerStan Shebs <shebs@codesourcery.com>1993-08-09 23:49:18 +0000
commit48f075eb2a8dc66ec671a1486073f8ba4d47f9ba (patch)
treeaa9fe38d256e4da7e1f97fdc41b42445079c8408 /gdb/buildsym.c
parent716f859496348d496e01271679f4e079dc8dac86 (diff)
downloadbinutils-gdb-48f075eb2a8dc66ec671a1486073f8ba4d47f9ba.tar.gz
Moved the function hashname from stabsread.c to buildsym.c, since
it's a general-purpose function.
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r--gdb/buildsym.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index ba593ca0b3f..a36ef79c41b 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -855,6 +855,37 @@ push_context (desc, valu)
}
+/* Compute a small integer hash code for the given name. */
+
+int
+hashname (name)
+ char *name;
+{
+ register char *p = name;
+ register int total = p[0];
+ register int c;
+
+ c = p[1];
+ total += c << 2;
+ if (c)
+ {
+ c = p[2];
+ total += c << 4;
+ if (c)
+ {
+ total += p[3] << 6;
+ }
+ }
+
+ /* Ensure result is positive. */
+ if (total < 0)
+ {
+ total += (1000 << 6);
+ }
+ return (total % HASHSIZE);
+}
+
+
/* Initialize anything that needs initializing when starting to read
a fresh piece of a symbol file, e.g. reading in the stuff corresponding
to a psymtab. */