summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2001-03-02 16:57:29 +0000
committerMarc Espie <espie@cvs.openbsd.org>2001-03-02 16:57:29 +0000
commitd6e1f4c8f283fa66af06a6cd16be84525841f74c (patch)
treece7ffc0e1853ff80d0002115345fc1b5f92a0aa1 /usr.bin/make
parentc5dce9de17bd545fa1991eb96971b697561ce457 (diff)
Use the ohash_* that's now in libc.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/Makefile21
-rw-r--r--usr.bin/make/arch.c50
-rw-r--r--usr.bin/make/dir.c84
-rw-r--r--usr.bin/make/dir.h4
-rw-r--r--usr.bin/make/generate.c4
-rw-r--r--usr.bin/make/make.h4
-rw-r--r--usr.bin/make/ohash/hash_create_entry.c53
-rw-r--r--usr.bin/make/ohash/hash_delete.c45
-rw-r--r--usr.bin/make/ohash/hash_do.c132
-rw-r--r--usr.bin/make/ohash/hash_entries.c40
-rw-r--r--usr.bin/make/ohash/hash_enum.c52
-rw-r--r--usr.bin/make/ohash/hash_init.c58
-rw-r--r--usr.bin/make/ohash/hash_interval.c46
-rw-r--r--usr.bin/make/ohash/hash_lookup_interval.c84
-rw-r--r--usr.bin/make/ohash/hash_lookup_memory.c81
-rw-r--r--usr.bin/make/ohash/hash_lookup_string.c80
-rw-r--r--usr.bin/make/ohash/hash_qlookup.c42
-rw-r--r--usr.bin/make/ohash/hash_qlookupi.c44
-rw-r--r--usr.bin/make/ohash/ohash.3249
-rw-r--r--usr.bin/make/ohash/ohash.h88
-rw-r--r--usr.bin/make/ohash/ohash_int.h15
-rw-r--r--usr.bin/make/targ.c28
-rw-r--r--usr.bin/make/var.c42
23 files changed, 111 insertions, 1235 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile
index f2642fac1ee..107a0893eb6 100644
--- a/usr.bin/make/Makefile
+++ b/usr.bin/make/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.24 2000/11/24 14:36:33 espie Exp $
+# $OpenBSD: Makefile,v 1.25 2001/03/02 16:57:26 espie Exp $
PROG= make
CFLAGS+= -I${.OBJDIR} -I${.CURDIR} -Wall -Wno-char-subscripts -Wstrict-prototypes
@@ -18,21 +18,6 @@ SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
.PATH: ${.CURDIR}/lst.lib
-make: libohash.a
-.PATH: ${.CURDIR}/ohash
-CFLAGS+=-I${.CURDIR}/ohash
-LDADD=-L${.OBJDIR} -lohash
-
-LIBOBJS= hash_create_entry.o hash_delete.o hash_do.o hash_entries.o \
- hash_enum.o hash_init.o hash_interval.o \
- hash_lookup_interval.o hash_lookup_memory.o hash_lookup_string.o \
- hash_qlookup.o hash_qlookupi.o
-
-libohash.a: ${LIBOBJS}
- rm -f $@
- ar cq $@ `lorder ${LIBOBJS}|tsort`
- ranlib $@
-
CLEANFILES+=generate hashconsts.h generate.o regress.o check
CLEANFILES+=${LIBOBJS} libohash.a
@@ -45,10 +30,10 @@ MAGICSLOTS=34
hashconsts.h: generate
${.OBJDIR}/generate ${MAGICSLOTS} >${.TARGET}
-generate: generate.o error.o libohash.a
+generate: generate.o error.o
${CC} -o ${.TARGET} ${CFLAGS} ${.ALLSRC} ${LDADD}
-check: regress.o str.o error.o buf.o libohash.a
+check: regress.o str.o error.o buf.o
${CC} -o ${.TARGET} ${CFLAGS} ${.ALLSRC} ${LDADD}
regress: check
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index 64ccfeec615..b191fe4b089 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arch.c,v 1.42 2000/11/27 20:37:16 espie Exp $ */
+/* $OpenBSD: arch.c,v 1.43 2001/03/02 16:57:26 espie Exp $ */
/* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */
/*
@@ -135,7 +135,7 @@
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: arch.c,v 1.42 2000/11/27 20:37:16 espie Exp $";
+static char rcsid[] = "$OpenBSD: arch.c,v 1.43 2001/03/02 16:57:26 espie Exp $";
#endif
#endif /* not lint */
@@ -148,10 +148,10 @@ static char rcsid[] = "$OpenBSD: arch.c,v 1.42 2000/11/27 20:37:16 espie Exp $";
#define MACHINE_ARCH TARGET_MACHINE_ARCH
#endif
-static struct hash archives; /* Archives we've already examined */
+static struct ohash archives; /* Archives we've already examined */
typedef struct Arch_ {
- struct hash members; /* All the members of this archive, as
+ struct ohash members; /* All the members of this archive, as
* struct arch_member entries. */
char name[1]; /* Archive name */
} Arch;
@@ -170,12 +170,12 @@ struct arch_member {
char name[1]; /* Member name. */
};
-static struct hash_info members_info = {
+static struct ohash_info members_info = {
offsetof(struct arch_member, name), NULL,
hash_alloc, hash_free, element_alloc
};
-static struct hash_info arch_info = {
+static struct ohash_info arch_info = {
offsetof(Arch, name), NULL, hash_alloc, hash_free, element_alloc
};
@@ -215,7 +215,7 @@ new_arch_member(hdr, name)
const char *end = NULL;
struct arch_member *n;
- n = hash_create_entry(&members_info, name, &end);
+ n = ohash_create_entry(&members_info, name, &end);
/* XXX ar entries are NOT null terminated. */
memcpy(n->date, &(hdr->ar_date), AR_DATE_SIZE);
n->date[AR_DATE_SIZE] = '\0';
@@ -248,11 +248,11 @@ ArchFree(ap)
unsigned int i;
/* Free memory from hash entries */
- for (mem = hash_first(&a->members, &i); mem != NULL;
- mem = hash_next(&a->members, &i))
+ for (mem = ohash_first(&a->members, &i); mem != NULL;
+ mem = ohash_next(&a->members, &i))
free(mem);
- hash_delete(&a->members);
+ ohash_delete(&a->members);
free(a);
}
#endif
@@ -550,8 +550,8 @@ read_archive(archive, end)
return NULL;
}
- ar = hash_create_entry(&arch_info, archive, &end);
- hash_init(&ar->members, 8, &members_info);
+ ar = ohash_create_entry(&arch_info, archive, &end);
+ ohash_init(&ar->members, 8, &members_info);
for (;;) {
size_t n;
@@ -633,8 +633,8 @@ read_archive(archive, end)
}
#endif
- hash_insert(&ar->members,
- hash_qlookup(&ar->members, memName),
+ ohash_insert(&ar->members,
+ ohash_qlookup(&ar->members, memName),
new_arch_member(&arh, memName));
}
if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0)
@@ -642,7 +642,7 @@ read_archive(archive, end)
}
fclose(arch);
- hash_delete(&ar->members);
+ ohash_delete(&ar->members);
#ifdef SVR4ARCHIVES
efree(list.fnametab);
#endif
@@ -693,8 +693,8 @@ ArchMTimeMember(archive, member, hash)
member = cp + 1;
/* Try to find archive in cache. */
- slot = hash_qlookupi(&archives, archive, &end);
- ar = hash_find(&archives, slot);
+ slot = ohash_qlookupi(&archives, archive, &end);
+ ar = ohash_find(&archives, slot);
/* If not found, get it now. */
if (ar == NULL) {
@@ -714,22 +714,22 @@ ArchMTimeMember(archive, member, hash)
}
ar = read_archive(archive, end);
if (ar != NULL)
- hash_insert(&archives, slot, ar);
+ ohash_insert(&archives, slot, ar);
}
/* If archive was found, get entry we seek. */
if (ar != NULL) {
struct arch_member *he;
end = NULL;
- he = hash_find(&ar->members, hash_qlookupi(&ar->members, member, &end));
+ he = ohash_find(&ar->members, ohash_qlookupi(&ar->members, member, &end));
if (he != NULL)
return mtime_of_member(he);
else {
if (end - member > AR_NAME_SIZE) {
/* Try truncated name */
end = member + AR_NAME_SIZE;
- he = hash_find(&ar->members,
- hash_qlookupi(&ar->members, member, &end));
+ he = ohash_find(&ar->members,
+ ohash_qlookupi(&ar->members, member, &end));
if (he != NULL)
return mtime_of_member(he);
}
@@ -1237,7 +1237,7 @@ Arch_LibOODate (gn)
void
Arch_Init()
{
- hash_init(&archives, 4, &arch_info);
+ ohash_init(&archives, 4, &arch_info);
}
@@ -1258,10 +1258,10 @@ Arch_End ()
Arch *e;
unsigned int i;
- for (e = hash_first(&archives, &i); e != NULL;
- e = hash_next(&archives, &i))
+ for (e = ohash_first(&archives, &i); e != NULL;
+ e = ohash_next(&archives, &i))
ArchFree(e);
- hash_delete(&archives);
+ ohash_delete(&archives);
#endif
}
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 36d45ff2253..8007c14ae3e 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.29 2000/11/24 14:36:33 espie Exp $ */
+/* $OpenBSD: dir.c,v 1.30 2001/03/02 16:57:26 espie Exp $ */
/* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */
/*
@@ -96,7 +96,7 @@
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: dir.c,v 1.29 2000/11/24 14:36:33 espie Exp $";
+static char rcsid[] = "$OpenBSD: dir.c,v 1.30 2001/03/02 16:57:26 espie Exp $";
#endif
#endif /* not lint */
@@ -171,7 +171,7 @@ static char rcsid[] = "$OpenBSD: dir.c,v 1.29 2000/11/24 14:36:33 espie Exp $";
LIST dirSearchPath; /* main search path */
-static struct hash openDirectories; /* cache all open directories */
+static struct ohash openDirectories; /* cache all open directories */
/*
* Variables for gathering statistics on the efficiency of the hashing
@@ -189,7 +189,7 @@ struct file_stamp {
char name[1]; /* ...for that file. */
};
-static struct hash mtimes; /* Results of doing a last-resort stat in
+static struct ohash mtimes; /* Results of doing a last-resort stat in
* Dir_FindFile -- if we have to go to the
* system to find the file, we might as well
* have its mtime on record. XXX: If this is done
@@ -203,20 +203,20 @@ static struct hash mtimes; /* Results of doing a last-resort stat in
* - to collate files's last modification times (global mtimes)
* - to collate file names (in each Path structure)
* - to collate known directories (global openDirectories). */
-static struct hash_info stamp_info = { offsetof(struct file_stamp, name),
+static struct ohash_info stamp_info = { offsetof(struct file_stamp, name),
NULL, hash_alloc, hash_free, element_alloc };
-static struct hash_info file_info = { 0,
+static struct ohash_info file_info = { 0,
NULL, hash_alloc, hash_free, element_alloc };
-static struct hash_info dir_info = { offsetof(Path, name),
+static struct ohash_info dir_info = { offsetof(Path, name),
NULL, hash_alloc, hash_free, element_alloc };
static void record_stamp __P((const char *, TIMESTAMP));
static void add_file __P((Path *, const char *));
static char *find_file_hash __P((Path *, const char *, const char *, u_int32_t));
static struct file_stamp *find_stamp __P((const char *));
-static void free_hash __P((struct hash *));
+static void free_hash __P((struct ohash *));
static Path *DirReaddir __P((const char *, const char *));
static void DirMatchFiles __P((char *, Path *, Lst));
@@ -234,14 +234,14 @@ record_stamp(file, t)
const char *end = NULL;
struct file_stamp *n;
- slot = hash_qlookupi(&mtimes, file, &end);
- n = hash_find(&mtimes, slot);
+ slot = ohash_qlookupi(&mtimes, file, &end);
+ n = ohash_find(&mtimes, slot);
if (n)
n->mtime = t;
else {
- n = hash_create_entry(&stamp_info, file, &end);
+ n = ohash_create_entry(&stamp_info, file, &end);
n->mtime = t;
- hash_insert(&mtimes, slot, n);
+ ohash_insert(&mtimes, slot, n);
}
}
@@ -249,7 +249,7 @@ static struct file_stamp *
find_stamp(file)
const char *file;
{
- return hash_find(&mtimes, hash_qlookup(&mtimes, file));
+ return ohash_find(&mtimes, ohash_qlookup(&mtimes, file));
}
static void
@@ -260,13 +260,13 @@ add_file(p, file)
unsigned slot;
const char *end = NULL;
char *n;
- struct hash *h = &p->files;
+ struct ohash *h = &p->files;
- slot = hash_qlookupi(h, file, &end);
- n = hash_find(h, slot);
+ slot = ohash_qlookupi(h, file, &end);
+ n = ohash_find(h, slot);
if (n == NULL) {
- n = hash_create_entry(&file_info, file, &end);
- hash_insert(h, slot, n);
+ n = ohash_create_entry(&file_info, file, &end);
+ ohash_insert(h, slot, n);
}
}
@@ -277,21 +277,21 @@ find_file_hash(p, file, e, hv)
const char *e;
u_int32_t hv;
{
- struct hash *h = &p->files;
+ struct ohash *h = &p->files;
- return hash_find(h, hash_lookup_interval(h, file, e, hv));
+ return ohash_find(h, ohash_lookup_interval(h, file, e, hv));
}
static void
free_hash(h)
- struct hash *h;
+ struct ohash *h;
{
void *e;
unsigned i;
- for (e = hash_first(h, &i); e != NULL; e = hash_next(h, &i))
+ for (e = ohash_first(h, &i); e != NULL; e = ohash_next(h, &i))
free(e);
- hash_delete(h);
+ ohash_delete(h);
}
/*-
@@ -310,8 +310,8 @@ void
Dir_Init()
{
Lst_Init(&dirSearchPath);
- hash_init(&openDirectories, 4, &dir_info);
- hash_init(&mtimes, 4, &stamp_info);
+ ohash_init(&openDirectories, 4, &dir_info);
+ ohash_init(&mtimes, 4, &stamp_info);
dot = DirReaddir(".", NULL);
@@ -342,10 +342,10 @@ Dir_End()
dot->refCount--;
Dir_Destroy(dot);
Lst_Destroy(&dirSearchPath, Dir_Destroy);
- for (p = hash_first(&openDirectories, &i); p != NULL;
- p = hash_next(&openDirectories, &i))
+ for (p = ohash_first(&openDirectories, &i); p != NULL;
+ p = ohash_next(&openDirectories, &i))
Dir_Destroy(p);
- hash_delete(&openDirectories);
+ ohash_delete(&openDirectories);
free_hash(&mtimes);
#endif
}
@@ -423,8 +423,8 @@ DirMatchFiles (pattern, p, expansions)
isDot = (*p->name == '.' && p->name[1] == '\0');
- for (entry = hash_first(&p->files, &search); entry != NULL;
- entry = hash_next(&p->files, &search)) {
+ for (entry = ohash_first(&p->files, &search); entry != NULL;
+ entry = ohash_next(&p->files, &search)) {
/* See if the file matches the given pattern. Note we follow the UNIX
* convention that dot files will only be found if the pattern
* begins with a dot (note also that as a side effect of the hashing
@@ -743,7 +743,7 @@ Dir_FindFile(name, path)
}
e = NULL;
- hv = hash_interval(cp, &e);
+ hv = ohash_interval(cp, &e);
if (DEBUG(DIR)) {
printf("Searching for %s...", name);
@@ -986,8 +986,8 @@ Dir_MTime(gn)
} else
fullName = gn->path;
- slot = hash_qlookup(&mtimes, fullName);
- entry = hash_find(&mtimes, slot);
+ slot = ohash_qlookup(&mtimes, fullName);
+ entry = ohash_find(&mtimes, slot);
if (entry != NULL) {
/* Only do this once -- the second time folks are checking to
* see if the file was actually updated, so we need to actually go
@@ -997,7 +997,7 @@ Dir_MTime(gn)
Targ_FmtTime(entry->mtime), fullName);
mtime = entry->mtime;
free(entry);
- hash_remove(&mtimes, slot);
+ ohash_remove(&mtimes, slot);
} else if (stat(fullName, &stb) == 0)
grab_stat(stb, mtime);
else {
@@ -1026,16 +1026,16 @@ DirReaddir(name, end)
struct dirent *dp; /* entry in directory */
unsigned int slot;
- slot = hash_qlookupi(&openDirectories, name, &end);
- p = hash_find(&openDirectories, slot);
+ slot = ohash_qlookupi(&openDirectories, name, &end);
+ p = ohash_find(&openDirectories, slot);
if (p != NULL)
return p;
- p = hash_create_entry(&dir_info, name, &end);
+ p = ohash_create_entry(&dir_info, name, &end);
p->hits = 0;
p->refCount = 0;
- hash_init(&p->files, 4, &file_info);
+ ohash_init(&p->files, 4, &file_info);
if (DEBUG(DIR)) {
printf("Caching %s...", p->name);
@@ -1062,7 +1062,7 @@ DirReaddir(name, end)
if (DEBUG(DIR))
printf("done\n");
- hash_insert(&openDirectories, slot, p);
+ ohash_insert(&openDirectories, slot, p);
return p;
}
@@ -1180,7 +1180,7 @@ Dir_Destroy (pp)
Path *p = (Path *) pp;
if (--p->refCount == 0) {
- hash_remove(&openDirectories, hash_qlookup(&openDirectories, p->name));
+ ohash_remove(&openDirectories, ohash_qlookup(&openDirectories, p->name));
free_hash(&p->files);
free(p);
}
@@ -1254,8 +1254,8 @@ Dir_PrintDirectories()
(hits+bigmisses+nearmisses ?
hits * 100 / (hits + bigmisses + nearmisses) : 0));
printf ("# %-20s referenced\thits\n", "directory");
- for (p = hash_first(&openDirectories, &i); p != NULL;
- p = hash_next(&openDirectories, &i))
+ for (p = ohash_first(&openDirectories, &i); p != NULL;
+ p = ohash_next(&openDirectories, &i))
printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
}
diff --git a/usr.bin/make/dir.h b/usr.bin/make/dir.h
index a4de9798461..b1ea1b511a2 100644
--- a/usr.bin/make/dir.h
+++ b/usr.bin/make/dir.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.h,v 1.12 2000/11/24 14:36:33 espie Exp $ */
+/* $OpenBSD: dir.h,v 1.13 2001/03/02 16:57:26 espie Exp $ */
/* $NetBSD: dir.h,v 1.4 1996/11/06 17:59:05 christos Exp $ */
/*
@@ -51,7 +51,7 @@ typedef struct Path_ {
int refCount; /* Number of paths with this directory */
int hits; /* the number of times a file in this
* directory has been found */
- struct hash files; /* Hash table of files in directory */
+ struct ohash files; /* Hash table of files in directory */
char name[1]; /* Name of directory */
} Path;
diff --git a/usr.bin/make/generate.c b/usr.bin/make/generate.c
index f37b23b300b..4fa1013f906 100644
--- a/usr.bin/make/generate.c
+++ b/usr.bin/make/generate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: generate.c,v 1.1 2000/06/23 16:27:29 espie Exp $ */
+/* $OpenBSD: generate.c,v 1.2 2001/03/02 16:57:26 espie Exp $ */
/* Written by Marc Espie 1999.
* Public domain.
*/
@@ -56,7 +56,7 @@ main(int argc, char *argv[])
printf("/* Generated file, do not edit */\n");
for (i = 0; i < sizeof(table)/sizeof(char *); i++) {
e = NULL;
- v = hash_interval(table[i], &e);
+ v = ohash_interval(table[i], &e);
h = v % slots;
if (occupied[h]) {
fprintf(stderr, "Collision: %s / %s (%d)\n", occupied[h],
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index 87b1f8cd5df..b8d64d31561 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: make.h,v 1.29 2000/11/24 14:36:35 espie Exp $ */
+/* $OpenBSD: make.h,v 1.30 2001/03/02 16:57:26 espie Exp $ */
/* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */
/*
@@ -156,7 +156,7 @@ typedef struct {
struct Var_ *locals[LOCAL_SIZE];
} SymTable;
-typedef struct hash GSymT;
+typedef struct ohash GSymT;
/*-
* The structure for an individual graph node. Each node has several
* pieces of data associated with it.
diff --git a/usr.bin/make/ohash/hash_create_entry.c b/usr.bin/make/ohash/hash_create_entry.c
deleted file mode 100644
index a1ed8597194..00000000000
--- a/usr.bin/make/ohash/hash_create_entry.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* $OpenBSD: hash_create_entry.c,v 1.1 2000/06/23 16:24:50 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-/* This handles the common case of variable length keys, where the
- * key is stored at the end of the record.
- */
-void *
-hash_create_entry(i, start, end)
- struct hash_info *i;
- const char *start;
- const char **end;
-{
- char *p;
-
- if (!*end)
- *end = start + strlen(start);
- p = (i->alloc)(i->key_offset + (*end - start) + 1, i->data);
- if (p) {
- memcpy(p+i->key_offset, start, *end-start);
- p[i->key_offset + (*end - start)] = '\0';
- }
- return (void *)p;
-}
diff --git a/usr.bin/make/ohash/hash_delete.c b/usr.bin/make/ohash/hash_delete.c
deleted file mode 100644
index 1506837e0b4..00000000000
--- a/usr.bin/make/ohash/hash_delete.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $OpenBSD: hash_delete.c,v 1.1 2000/06/23 16:24:50 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-/* hash_delete only frees the hash structure. Use hash_first/hash_next
- * to free entries as well. */
-void
-hash_delete(h)
- struct hash *h;
-{
- (h->info.hfree)(h->t, sizeof(struct hash_record) * h->size,
- h->info.data);
-#ifndef NDEBUG
- h->t = NULL;
-#endif
-}
-
diff --git a/usr.bin/make/ohash/hash_do.c b/usr.bin/make/ohash/hash_do.c
deleted file mode 100644
index 8c9af5d6ff8..00000000000
--- a/usr.bin/make/ohash/hash_do.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* $OpenBSD: hash_do.c,v 1.2 2000/06/28 10:12:46 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-static void hash_resize __P((struct hash *));
-
-static void
-hash_resize(h)
- struct hash *h;
-{
- struct hash_record *n;
- unsigned int ns, j;
- unsigned int i, incr;
-
- if (4 * h->deleted < h->total)
- ns = h->size << 1;
- else if (3 * h->deleted > 2 * h->total)
- ns = h->size >> 1;
- else
- ns = h->size;
- if (ns < MINSIZE)
- ns = MINSIZE;
-#ifdef STATS_HASH
- STAT_HASH_EXPAND++;
- STAT_HASH_SIZE += ns - h->size;
-#endif
- n = (h->info.halloc)(sizeof(struct hash_record) * ns, h->info.data);
- if (!n)
- return;
-
- for (j = 0; j < h->size; j++) {
- if (h->t[j].p != NULL && h->t[j].p != DELETED) {
- i = h->t[j].hv % ns;
- incr = ((h->t[j].hv % (ns - 2)) & ~1) + 1;
- while (n[i].p != NULL) {
- i += incr;
- if (i >= ns)
- i -= ns;
- }
- n[i].hv = h->t[j].hv;
- n[i].p = h->t[j].p;
- }
- }
- (h->info.hfree)(h->t, sizeof(struct hash_record) * h->size,
- h->info.data);
- h->t = n;
- h->size = ns;
- h->total -= h->deleted;
- h->deleted = 0;
-}
-
-void *
-hash_remove(h, i)
- struct hash *h;
- unsigned int i;
-{
- void *result = (void *)h->t[i].p;
-
- if (result == NULL || result == DELETED)
- return NULL;
-
-#ifdef STATS_HASH
- STAT_HASH_ENTRIES--;
-#endif
- h->t[i].p = DELETED;
- h->deleted++;
- if (h->deleted >= MINDELETED && 4 * h->deleted > h->total)
- hash_resize(h);
- return result;
-}
-
-void *
-hash_find(h, i)
- struct hash *h;
- unsigned int i;
-{
- if (h->t[i].p == DELETED)
- return NULL;
- else
- return (void *)h->t[i].p;
-}
-
-void *
-hash_insert(h, i, p)
- struct hash *h;
- unsigned int i;
- void *p;
-{
-#ifdef STATS_HASH
- STAT_HASH_ENTRIES++;
-#endif
- if (h->t[i].p == DELETED) {
- h->deleted--;
- h->t[i].p = p;
- } else {
- h->t[i].p = p;
- /* Arbitrary resize boundary. Tweak if not efficient enough. */
- if (++h->total * 4 > h->size * 3)
- hash_resize(h);
- }
- return p;
-}
-
diff --git a/usr.bin/make/ohash/hash_entries.c b/usr.bin/make/ohash/hash_entries.c
deleted file mode 100644
index 4dfe55ad14b..00000000000
--- a/usr.bin/make/ohash/hash_entries.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* $OpenBSD: hash_entries.c,v 1.2 2000/06/28 10:12:46 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-unsigned int
-hash_entries(h)
- struct hash *h;
-{
- return h->total - h->deleted;
-}
-
diff --git a/usr.bin/make/ohash/hash_enum.c b/usr.bin/make/ohash/hash_enum.c
deleted file mode 100644
index b370f404f10..00000000000
--- a/usr.bin/make/ohash/hash_enum.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* $OpenBSD: hash_enum.c,v 1.2 2000/06/28 10:12:47 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-void *
-hash_first(h, pos)
- struct hash *h;
- unsigned int *pos;
-{
- *pos = 0;
- return hash_next(h, pos);
-}
-
-void *
-hash_next(h, pos)
- struct hash *h;
- unsigned int *pos;
-{
- for (; *pos < h->size; (*pos)++)
- if (h->t[*pos].p != DELETED && h->t[*pos].p != NULL)
- return (void *)h->t[(*pos)++].p;
- return NULL;
-}
diff --git a/usr.bin/make/ohash/hash_init.c b/usr.bin/make/ohash/hash_init.c
deleted file mode 100644
index 54096692d92..00000000000
--- a/usr.bin/make/ohash/hash_init.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $OpenBSD: hash_init.c,v 1.2 2000/06/28 10:12:47 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "ohash_int.h"
-
-void
-hash_init(h, size, info)
- struct hash *h;
- unsigned int size;
- struct hash_info*info;
-{
- h->size = 1UL << size;
- if (h->size < MINSIZE)
- h->size = MINSIZE;
-#ifdef STATS_HASH
- STAT_HASH_CREATION++;
- STAT_HASH_SIZE += h->size;
-#endif
- /* Copy info so that caller may free it. */
- h->info.key_offset = info->key_offset;
- h->info.halloc = info->halloc;
- h->info.hfree = info->hfree;
- h->info.alloc = info->alloc;
- h->info.data = info->data;
- h->t = (h->info.halloc)(sizeof(struct hash_record) * h->size,
- h->info.data);
- h->total = h->deleted = 0;
-}
-
diff --git a/usr.bin/make/ohash/hash_interval.c b/usr.bin/make/ohash/hash_interval.c
deleted file mode 100644
index 23b2a283bb0..00000000000
--- a/usr.bin/make/ohash/hash_interval.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* $OpenBSD: hash_interval.c,v 1.1 2000/06/23 16:24:50 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-u_int32_t
-hash_interval(s, e)
- const char *s;
- const char **e;
-{
- u_int32_t k;
-
- k = *s++;
- while (*s && s != *e)
- k = ((k << 2) | (k >> 30)) ^ *s++;
- *e = s;
- return k;
-}
diff --git a/usr.bin/make/ohash/hash_lookup_interval.c b/usr.bin/make/ohash/hash_lookup_interval.c
deleted file mode 100644
index dcf94022b8e..00000000000
--- a/usr.bin/make/ohash/hash_lookup_interval.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* $OpenBSD: hash_lookup_interval.c,v 1.2 2000/06/28 10:12:47 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-unsigned int
-hash_lookup_interval(h, start, end, hv)
- struct hash *h;
- const char *start;
- const char *end;
- u_int32_t hv;
-{
- unsigned int i, incr;
- unsigned int empty;
-
-#ifdef STATS_HASH
- STAT_HASH_LOOKUP++;
-#endif
- empty = NONE;
- i = hv % h->size;
- incr = ((hv % (h->size-2)) & ~1) + 1;
- while (h->t[i].p != NULL) {
-#ifdef STATS_HASH
- STAT_HASH_LENGTH++;
-#endif
- if (h->t[i].p == DELETED) {
- if (empty == NONE)
- empty = i;
- } else if (h->t[i].hv == hv &&
- strncmp(h->t[i].p+h->info.key_offset, start,
- end - start) == 0 &&
- (h->t[i].p+h->info.key_offset)[end-start] == '\0') {
- if (empty != NONE) {
- h->t[empty].hv = hv;
- h->t[empty].p = h->t[i].p;
- h->t[i].p = DELETED;
- return empty;
- } else {
-#ifdef STATS_HASH
- STAT_HASH_POSITIVE++;
-#endif
- return i;
- }
- }
- i += incr;
- if (i >= h->size)
- i -= h->size;
- }
-
- /* Found an empty position. */
- if (empty != NONE)
- i = empty;
- h->t[i].hv = hv;
- return i;
-}
-
diff --git a/usr.bin/make/ohash/hash_lookup_memory.c b/usr.bin/make/ohash/hash_lookup_memory.c
deleted file mode 100644
index e4c6755de21..00000000000
--- a/usr.bin/make/ohash/hash_lookup_memory.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* $OpenBSD: hash_lookup_memory.c,v 1.2 2000/06/28 10:12:48 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-unsigned int
-hash_lookup_memory(h, k, size, hv)
- struct hash *h;
- const char *k;
- size_t size;
- u_int32_t hv;
-{
- unsigned int i, incr;
- unsigned int empty;
-
-#ifdef STATS_HASH
- STAT_HASH_LOOKUP++;
-#endif
- empty = NONE;
- i = hv % h->size;
- incr = ((hv % (h->size-2)) & ~1) + 1;
- while (h->t[i].p != NULL) {
-#ifdef STATS_HASH
- STAT_HASH_LENGTH++;
-#endif
- if (h->t[i].p == DELETED) {
- if (empty == NONE)
- empty = i;
- } else if (h->t[i].hv == hv &&
- memcmp(h->t[i].p+h->info.key_offset, k, size) == 0) {
- if (empty != NONE) {
- h->t[empty].hv = hv;
- h->t[empty].p = h->t[i].p;
- h->t[i].p = DELETED;
- return empty;
- } else {
-#ifdef STATS_HASH
- STAT_HASH_POSITIVE++;
-#endif
- } return i;
- }
- i += incr;
- if (i >= h->size)
- i -= h->size;
- }
-
- /* Found an empty position. */
- if (empty != NONE)
- i = empty;
- h->t[i].hv = hv;
- return i;
-}
-
diff --git a/usr.bin/make/ohash/hash_lookup_string.c b/usr.bin/make/ohash/hash_lookup_string.c
deleted file mode 100644
index 3cd115ed3ed..00000000000
--- a/usr.bin/make/ohash/hash_lookup_string.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* $OpenBSD: hash_lookup_string.c,v 1.2 2000/06/28 10:12:48 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-unsigned int
-hash_lookup_string(h, k, hv)
- struct hash *h;
- const char *k;
- u_int32_t hv;
-{
- unsigned int i, incr;
- unsigned int empty;
-
-#ifdef STATS_HASH
- STAT_HASH_LOOKUP++;
-#endif
- empty = NONE;
- i = hv % h->size;
- incr = ((hv % (h->size-2)) & ~1) + 1;
- while (h->t[i].p != NULL) {
-#ifdef STATS_HASH
- STAT_HASH_LENGTH++;
-#endif
- if (h->t[i].p == DELETED) {
- if (empty == NONE)
- empty = i;
- } else if (h->t[i].hv == hv &&
- strcmp(h->t[i].p+h->info.key_offset, k) == 0) {
- if (empty != NONE) {
- h->t[empty].hv = hv;
- h->t[empty].p = h->t[i].p;
- h->t[i].p = DELETED;
- return empty;
- } else {
-#ifdef STATS_HASH
- STAT_HASH_POSITIVE++;
-#endif
- return i;
- }
- }
- i += incr;
- if (i >= h->size)
- i -= h->size;
- }
-
- /* Found an empty position. */
- if (empty != NONE)
- i = empty;
- h->t[i].hv = hv;
- return i;
-}
diff --git a/usr.bin/make/ohash/hash_qlookup.c b/usr.bin/make/ohash/hash_qlookup.c
deleted file mode 100644
index 3d38189b845..00000000000
--- a/usr.bin/make/ohash/hash_qlookup.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* $OpenBSD: hash_qlookup.c,v 1.2 2000/06/28 10:12:48 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-unsigned int
-hash_qlookup(h, s)
- struct hash *h;
- const char *s;
-{
- const char *e = NULL;
- return hash_qlookupi(h, s, &e);
-}
-
diff --git a/usr.bin/make/ohash/hash_qlookupi.c b/usr.bin/make/ohash/hash_qlookupi.c
deleted file mode 100644
index 74b48cedc0d..00000000000
--- a/usr.bin/make/ohash/hash_qlookupi.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $OpenBSD: hash_qlookupi.c,v 1.2 2000/06/28 10:12:48 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "ohash_int.h"
-
-unsigned int
-hash_qlookupi(h, s, e)
- struct hash *h;
- const char *s;
- const char **e;
-{
- u_int32_t hv;
-
- hv = hash_interval(s, e);
- return hash_lookup_interval(h, s, *e, hv);
-}
diff --git a/usr.bin/make/ohash/ohash.3 b/usr.bin/make/ohash/ohash.3
deleted file mode 100644
index d94b52b05b1..00000000000
--- a/usr.bin/make/ohash/ohash.3
+++ /dev/null
@@ -1,249 +0,0 @@
-.\" $OpenBSD: ohash.3,v 1.2 2001/01/28 15:45:44 espie Exp $
-.\"
-.\" Copyright (c) 1999 Marc Espie.
-.\"
-.\" Code written for the OpenBSD project.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
-.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
-.\" PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.Dd November 3, 1999
-.Dt OPEN_HASH 3
-.Os
-.Sh NAME
-.Nm hash_init ,
-.Nm hash_delete ,
-.Nm hash_lookup_string ,
-.Nm hash_lookup_interval ,
-.Nm hash_lookup_memory ,
-.Nm hash_find ,
-.Nm hash_remove ,
-.Nm hash_insert ,
-.Nm hash_first ,
-.Nm hash_next ,
-.Nm hash_entries
-.Nd light-weight open hashing
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <stddef.h>
-.Fd #include <ohash.h>
-.Ft void
-.Fn hash_init "struct hash *h" "unsigned int size" "struct hash_info *info"
-.Ft void
-.Fn hash_delete "struct hash *h"
-.Ft "unsigned int"
-.Fn hash_lookup_string "struct hash *h" "const char *k" "u_int32_t v"
-.Ft "unsigned int"
-.Fn hash_lookup_interval "struct hash *h" "const char *start" "const char *end" "u_int32_t hv"
-.Ft "unsigned int"
-.Fn hash_lookup_memory "struct hash *h" "const char *k" "size_t s" "u_int32_t hv"
-.Ft void *
-.Fn hash_find "struct hash *h" "unsigned int i"
-.Ft void *
-.Fn hash_remove "struct hash *h" "unsigned int i"
-.Ft void *
-.Fn hash_insert "struct hash *h" "unsigned int i" "void *p"
-.Ft void *
-.Fn hash_first "struct hash *h" "unsigned int *i"
-.Ft void *
-.Fn hash_next "struct hash *h" "unsigned int *i"
-.Ft "unsigned int"
-.Fn hash_entries "struct hash *h"
-.Sh DESCRIPTION
-Those functions have been designed as a fast, extensible alternative to
-the usual hash table functions.
-These provide storing and retrieval of records indexed by keys,
-where a key is a contiguous sequence of bytes at a fixed position in
-each record.
-Keys can either be null-terminated strings, or fixed-size memory areas.
-All functions take a pointer to a hash structure as the
-.Fa h
-function argument.
-Storage for this structure should be provided by user code.
-.Pp
-.Fn hash_init
-initializes the table to store roughly 2 to the power
-.Fa size
-elements.
-.Fa info
-holds the position of the key in each record, and two pointers to
-.Xr calloc 3
-and
-.Xr free 3
--like functions, to use for managing the table internal storage.
-.Pp
-.Fn hash_delete
-frees storage internal to
-.Fa h .
-Elements themselves should be freed by the user first, using for instance
-.Fn hash_first
-and
-.Fn hash_next .
-.Pp
-.Fn hash_lookup_string ,
-.Fn hash_lookup_interval
-and
-.Fn hash_lookup_memory
-are the basic look-up element functions.
-The hashing function result is provided by the user as
-.Fa hv .
-These return a
-.Qq slot
-in the hash table
-.Fa h ,
-to be used with
-.Fn hash_find ,
-.Fn hash_insert ,
-or
-.Fn hash_remove .
-This slot is only valid up to the next call to
-.Fn hash_insert
-or
-.Fn hash_remove .
-.Pp
-.Fn hash_lookup_string
-and
-.Fn hash_lookup_interval
-handle string-like keys.
-.Fn hash_lookup_string
-assumes a null-terminated
-.Ft char *
-.Fa k ,
-whereas
-.Fn hash_lookup_interval
-assumes the key is the interval between
-.Fa start
-and
-.Fa end ,
-exclusive.
-In both cases, the actual elements stored in the hash should contain
-null-terminated keys.
-.Pp
-.Fn hash_lookup_memory
-assumes the key is the memory area starting at
-.Fa k
-of size
-.Fa s .
-All bytes are significant in key comparison.
-.Pp
-.Fn hash_find
-retrieves an element from a slot
-.Fa i
-returned by the
-.Fn hash_lookup*
-functions.
-It returns
-.Va NULL
-if the slot is empty.
-.Pp
-.Fn hash_insert
-inserts a new element
-.Fa p
-at slot
-.Fa i .
-Slot
-.Fa i
-must be empty and element
-.Fa p
-must have a key corresponding to the
-.Fn hash_lookup*
-call.
-.Pp
-.Fn hash_remove
-removes element of hash table at slot
-.Fa i .
-It returns the removed element, for user code to dispose of, or
-.Va NULL
-if the slot was empty.
-.Pp
-.Fn hash_first
-and
-.Fn hash_next
-can be used to access all elements in a hash table, like this:
-.Pp
-.Bd -literal
- for (n = hash_first(h, &i); n != NULL; n = hash_next(h, &i))
- do_something_with(n);
-.Ed
-.Pp
-.Fa i
-points to an auxiliary unsigned integer used to record the current position
-in the hash table.
-Those functions are safe to use even while entries are added to/removed
-from the table, but in such a case they don't guarantee that new entries
-will be returned.
-As a special case, they can safely be used to free elements in the table.
-.Pp
-.Fn hash_entries
-returns the number of elements in the hash table.
-.Sh STORAGE HANDLING
-Only
-.Fn hash_init ,
-.Fn hash_insert ,
-.Fn hash_remove
-and
-.Fn hash_delete
-may call the user-supplied memory functions.
-It is the responsability of the user memory allocation code to verify
-that those calls did not fail.
-.Pp
-In case memory allocation fails,
-.Fn hash_init
-returns a useless hash table.
-.Fn hash_insert
-and
-.Fn hash_remove
-still perform the requested operation, but the returned table should be
-considered read-only.
-It can still be accessed by
-.Fn hash_lookup* ,
-.Fn hash_find ,
-.Fn hash_first
-and
-.Fn hash_next
-to dump relevant information to disk before aborting.
-.Sh THREAD SAFETY
-The open hashing functions are not thread-safe by design.
-In particular, it cannot be guaranteed that a
-.Qq slot
-will not move in a threaded environment between a
-.Fn hash_lookup*
-and a
-.Fn hash_find ,
-.Fn hash_insert
-or
-.Fn hash_remove
-call.
-.Pp
-Multi-threaded applications should explicitly protect hash table access.
-.Sh SEE ALSO
-.Rs
-.%A Donald E. Knuth
-.%B The Art of Computer Programming
-.%V Vol. 3
-.%P pp 506-550
-.%D 1973
-.Re
-.Sh HISTORY
-Those functions were designed and written for
-.Ox
-make
-by Marc Espie in 1999.
diff --git a/usr.bin/make/ohash/ohash.h b/usr.bin/make/ohash/ohash.h
deleted file mode 100644
index 58c0c5914fa..00000000000
--- a/usr.bin/make/ohash/ohash.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef OHASH_H
-#define OHASH_H
-/* $OpenBSD: ohash.h,v 1.2 2000/06/28 10:12:49 espie Exp $ */
-/* ex:ts=8 sw=4:
- */
-
-/*
- * Copyright (c) 1999 Marc Espie.
- *
- * Code written for the OpenBSD project.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
- * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Open hashing support.
- * Open hashing was chosen because it is much lighter than other hash
- * techniques, and more efficient in most cases.
- */
-
-struct hash_info {
- ptrdiff_t key_offset;
- void *data; /* user data */
- void *(*halloc) __P((size_t, void *));
- void (*hfree) __P((void *, size_t, void *));
- void *(*alloc) __P((size_t, void *));
-};
-
-struct hash {
- struct hash_record *t;
- struct hash_info info;
- unsigned int size;
- unsigned int total;
- unsigned int deleted;
-};
-
-struct hash_record {
- u_int32_t hv;
- const char *p;
-};
-
-/* For this to be tweakable, we use small primitives, and leave part of the
- * logic to the client application. e.g., hashing is left to the client
- * application. We also provide a simple table entry lookup that yields
- * a hashing table index (opaque) to be used in find/insert/remove.
- * The keys are stored at a known position in the client data.
- */
-__BEGIN_DECLS
-void hash_init __P((struct hash *, unsigned, struct hash_info *));
-void hash_delete __P((struct hash *));
-
-unsigned int hash_lookup_string __P((struct hash *, const char *, u_int32_t));
-unsigned int hash_lookup_interval __P((struct hash *, const char *, \
- const char *, u_int32_t));
-unsigned int hash_lookup_memory __P((struct hash *, const char *, \
- size_t, u_int32_t));
-void *hash_find __P((struct hash *, unsigned int));
-void *hash_remove __P((struct hash *, unsigned int));
-void *hash_insert __P((struct hash *, unsigned int, void *));
-void *hash_first __P((struct hash *, unsigned int *));
-void *hash_next __P((struct hash *, unsigned int *));
-unsigned int hash_entries __P((struct hash *));
-
-void *hash_create_entry __P((struct hash_info *, const char *, const char **));
-u_int32_t hash_interval __P((const char *, const char **));
-
-unsigned int hash_qlookupi __P((struct hash *, const char *, const char **));
-unsigned int hash_qlookup __P((struct hash *, const char *));
-__END_DECLS
-#endif
diff --git a/usr.bin/make/ohash/ohash_int.h b/usr.bin/make/ohash/ohash_int.h
deleted file mode 100644
index bc280b64282..00000000000
--- a/usr.bin/make/ohash/ohash_int.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* $OpenBSD: ohash_int.h,v 1.2 2001/01/29 01:58:05 niklas Exp $ */
-
-#include <sys/types.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include "ohash.h"
-
-#define DELETED ((const char *)h)
-#define NONE (h->size)
-
-/* Don't bother changing the hash table if the change is small enough. */
-#define MINSIZE (1UL << 4)
-#define MINDELETED 4
-
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index 1d739ddcd09..7e3ee9247fb 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: targ.c,v 1.29 2000/11/24 14:36:35 espie Exp $ */
+/* $OpenBSD: targ.c,v 1.30 2001/03/02 16:57:26 espie Exp $ */
/* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */
/*
@@ -87,15 +87,15 @@
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
UNUSED
-static char *rcsid = "$OpenBSD: targ.c,v 1.29 2000/11/24 14:36:35 espie Exp $";
+static char *rcsid = "$OpenBSD: targ.c,v 1.30 2001/03/02 16:57:26 espie Exp $";
#endif
#endif /* not lint */
#ifdef CLEANUP
static LIST allGNs; /* List of all the GNodes */
#endif
-static struct hash targets; /* a hash table of same */
-static struct hash_info gnode_info = {
+static struct ohash targets; /* a hash table of same */
+static struct ohash_info gnode_info = {
offsetof(GNode, name),
NULL, hash_alloc, hash_free, element_alloc };
@@ -122,7 +122,7 @@ Targ_Init()
Lst_Init(&allGNs);
#endif
/* A small make file already creates 200 targets. */
- hash_init(&targets, 10, &gnode_info);
+ ohash_init(&targets, 10, &gnode_info);
}
/*-
@@ -139,7 +139,7 @@ Targ_End ()
{
#ifdef CLEANUP
Lst_Destroy(&allGNs, TargFreeGN);
- hash_delete(&targets);
+ ohash_delete(&targets);
#endif
}
@@ -163,7 +163,7 @@ Targ_NewGN(name, end)
{
GNode *gn;
- gn = hash_create_entry(&gnode_info, name, &end);
+ gn = ohash_create_entry(&gnode_info, name, &end);
gn->path = NULL;
if (name[0] == '-' && name[1] == 'l') {
gn->type = OP_LIB;
@@ -253,13 +253,13 @@ Targ_FindNode(name, flags)
GNode *gn; /* node in that element */
unsigned int slot;
- slot = hash_qlookupi(&targets, name, &end);
+ slot = ohash_qlookupi(&targets, name, &end);
- gn = hash_find(&targets, slot);
+ gn = ohash_find(&targets, slot);
if (gn == NULL && (flags & TARG_CREATE)) {
gn = Targ_NewGN(name, end);
- hash_insert(&targets, slot, gn);
+ ohash_insert(&targets, slot, gn);
}
return gn;
@@ -563,13 +563,13 @@ Targ_PrintGraph(pass)
unsigned int i;
printf("#*** Input graph:\n");
- for (gn = hash_first(&targets, &i); gn != NULL;
- gn = hash_next(&targets, &i))
+ for (gn = ohash_first(&targets, &i); gn != NULL;
+ gn = ohash_next(&targets, &i))
TargPrintNode(gn, pass);
printf("\n\n");
printf("#\n# Files that are only sources:\n");
- for (gn = hash_first(&targets, &i); gn != NULL;
- gn = hash_next(&targets, &i))
+ for (gn = ohash_first(&targets, &i); gn != NULL;
+ gn = ohash_next(&targets, &i))
TargPrintOnlySrc(gn);
printf("#*** Global Variables:\n");
Var_Dump(VAR_GLOBAL);
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 0df8a9bf5ef..a40a5fb0d83 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.51 2000/12/07 00:15:43 espie Exp $ */
+/* $OpenBSD: var.c,v 1.52 2001/03/02 16:57:26 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
@@ -131,7 +131,7 @@
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
UNUSED
-static char rcsid[] = "$OpenBSD: var.c,v 1.51 2000/12/07 00:15:43 espie Exp $";
+static char rcsid[] = "$OpenBSD: var.c,v 1.52 2001/03/02 16:57:26 espie Exp $";
#endif
#endif /* not lint */
@@ -195,7 +195,7 @@ typedef struct Var_ {
char name[1]; /* the variable's name */
} Var;
-static struct hash_info var_info = {
+static struct ohash_info var_info = {
offsetof(Var, name),
NULL, hash_alloc, hash_free, element_alloc };
static int quick_lookup __P((const char *, const char **, u_int32_t *));
@@ -238,7 +238,7 @@ quick_lookup(name, end, pk)
{
size_t len;
- *pk = hash_interval(name, end);
+ *pk = ohash_interval(name, end);
len = *end - name;
/* substitute short version for long local name */
switch (*pk % MAGICSLOTS) { /* MAGICSLOTS should be the */
@@ -398,7 +398,7 @@ new_var(name, val)
Var *v;
const char *end = NULL;
- v = hash_create_entry(&var_info, name, &end);
+ v = ohash_create_entry(&var_info, name, &end);
if (val != NULL) {
size_t len = strlen(val);
@@ -417,7 +417,7 @@ getvar(ctxt, name, end, k)
const char *end;
u_int32_t k;
{
- return hash_find(ctxt, hash_lookup_interval(ctxt, name, end, k));
+ return ohash_find(ctxt, ohash_lookup_interval(ctxt, name, end, k));
}
/*-
@@ -547,7 +547,7 @@ VarAdd(name, val, ctxt)
Parse_Error(PARSE_FATAL, "Trying to set dynamic variable %s",
v->name);
else
- hash_insert(ctxt, hash_lookup_interval(ctxt, name, end, k), v);
+ ohash_insert(ctxt, ohash_lookup_interval(ctxt, name, end, k), v);
return v;
}
@@ -591,7 +591,7 @@ Var_Delete(name, ctxt)
if (DEBUG(VAR))
printf("%s:delete %s\n", context_name(ctxt), name);
(void)quick_lookup(name, &end, &k);
- v = hash_remove(ctxt, hash_lookup_interval(ctxt, name, end, k));
+ v = ohash_remove(ctxt, ohash_lookup_interval(ctxt, name, end, k));
if (v != NULL)
VarDelete(v);
@@ -1119,9 +1119,9 @@ Var_Init()
VAR_GLOBAL = &global_vars;
VAR_CMD = &cmd_vars;
VAR_ENV = &env_vars;
- hash_init(VAR_GLOBAL, 10, &var_info);
- hash_init(VAR_CMD, 5, &var_info);
- hash_init(VAR_ENV, 5, &var_info);
+ ohash_init(VAR_GLOBAL, 10, &var_info);
+ ohash_init(VAR_CMD, 5, &var_info);
+ ohash_init(VAR_ENV, 5, &var_info);
CTXT_GLOBAL = (SymTable *)VAR_GLOBAL;
CTXT_CMD = (SymTable *)VAR_CMD;
CTXT_ENV = (SymTable *)VAR_ENV;
@@ -1135,14 +1135,14 @@ Var_End()
Var *v;
unsigned int i;
- for (v = hash_first(VAR_GLOBAL, &i); v != NULL;
- v = hash_next(VAR_GLOBAL, &i))
+ for (v = ohash_first(VAR_GLOBAL, &i); v != NULL;
+ v = ohash_next(VAR_GLOBAL, &i))
VarDelete(v);
- for (v = hash_first(VAR_CMD, &i); v != NULL;
- v = hash_next(VAR_CMD, &i))
+ for (v = ohash_first(VAR_CMD, &i); v != NULL;
+ v = ohash_next(VAR_CMD, &i))
VarDelete(v);
- for (v = hash_first(VAR_ENV, &i); v != NULL;
- v = hash_next(VAR_ENV, &i))
+ for (v = ohash_first(VAR_ENV, &i); v != NULL;
+ v = ohash_next(VAR_ENV, &i))
VarDelete(v);
#endif
}
@@ -1171,8 +1171,8 @@ Var_Dump(ctxt)
Var *v;
unsigned int i;
- for (v = hash_first(ctxt, &i); v != NULL;
- v = hash_next(ctxt, &i))
+ for (v = ohash_first(ctxt, &i); v != NULL;
+ v = ohash_next(ctxt, &i))
VarPrintVar(v);
}
@@ -1195,8 +1195,8 @@ Var_AddCmdline(name)
Buf_Init(&buf, MAKE_BSIZE);
- for (v = hash_first(VAR_CMD, &i); v != NULL;
- v = hash_next(VAR_CMD, &i)) {
+ for (v = ohash_first(VAR_CMD, &i); v != NULL;
+ v = ohash_next(VAR_CMD, &i)) {
/* We assume variable names don't need quoting */
Buf_AddString(&buf, v->name);
Buf_AddChar(&buf, '=');