| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hash.c,v 1.3 2010/04/20 00:32:23 joerg Exp $ */ | | 1 | /* $NetBSD: hash.c,v 1.4 2012/05/15 16:45:45 christos Exp $ */ |
2 | /* NetBSD: hash.c,v 1.30 2008/09/11 12:58:00 joerg Exp */ | | 2 | /* NetBSD: hash.c,v 1.30 2008/09/11 12:58:00 joerg Exp */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 1990, 1993, 1994 | | 5 | * Copyright (c) 1990, 1993, 1994 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * Margo Seltzer. | | 9 | * Margo Seltzer. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -26,49 +26,51 @@ | | | @@ -26,49 +26,51 @@ |
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
33 | * SUCH DAMAGE. | | 33 | * SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <nbcompat.h> | | 36 | #include <nbcompat.h> |
37 | #include <nbcompat/cdefs.h> | | 37 | #include <nbcompat/cdefs.h> |
38 | | | 38 | |
39 | __RCSID("$NetBSD: hash.c,v 1.3 2010/04/20 00:32:23 joerg Exp $"); | | 39 | __RCSID("$NetBSD: hash.c,v 1.4 2012/05/15 16:45:45 christos Exp $"); |
40 | | | 40 | |
41 | #include <nbcompat/param.h> | | 41 | #include <nbcompat/param.h> |
42 | #include <sys/stat.h> | | 42 | #include <sys/stat.h> |
43 | | | 43 | |
44 | #include <errno.h> | | 44 | #include <errno.h> |
45 | #include <fcntl.h> | | 45 | #include <fcntl.h> |
46 | #include <stdio.h> | | 46 | #include <stdio.h> |
47 | #include <stdlib.h> | | 47 | #include <stdlib.h> |
48 | #include <string.h> | | 48 | #include <string.h> |
49 | #include <unistd.h> | | 49 | #include <unistd.h> |
50 | #include <assert.h> | | 50 | #include <assert.h> |
51 | | | 51 | |
52 | #include <nbcompat/db.h> | | 52 | #include <nbcompat/db.h> |
53 | #include "hash.h" | | 53 | #include "hash.h" |
54 | #include "page.h" | | 54 | #include "page.h" |
55 | #include "extern.h" | | 55 | #include "extern.h" |
56 | | | 56 | |
57 | #ifdef BROKEN_PWRITE | | 57 | #ifdef BROKEN_PWRITE |
58 | #include "../pwrite.c" | | 58 | #include "../pwrite.c" |
59 | #endif | | 59 | #endif |
60 | | | 60 | |
| | | 61 | #ifndef __UNCONST |
61 | #define __UNCONST(a) ((void *)(size_t)(const void *)(a)) | | 62 | #define __UNCONST(a) ((void *)(size_t)(const void *)(a)) |
| | | 63 | #endif |
62 | | | 64 | |
63 | static int alloc_segs(HTAB *, int); | | 65 | static int alloc_segs(HTAB *, int); |
64 | static int flush_meta(HTAB *); | | 66 | static int flush_meta(HTAB *); |
65 | static int hash_access(HTAB *, ACTION, DBT *, DBT *); | | 67 | static int hash_access(HTAB *, ACTION, DBT *, DBT *); |
66 | static int hash_close(DB *); | | 68 | static int hash_close(DB *); |
67 | static int hash_delete(const DB *, const DBT *, uint32_t); | | 69 | static int hash_delete(const DB *, const DBT *, uint32_t); |
68 | static int hash_fd(const DB *); | | 70 | static int hash_fd(const DB *); |
69 | static int hash_get(const DB *, const DBT *, DBT *, uint32_t); | | 71 | static int hash_get(const DB *, const DBT *, DBT *, uint32_t); |
70 | static int hash_put(const DB *, DBT *, const DBT *, uint32_t); | | 72 | static int hash_put(const DB *, DBT *, const DBT *, uint32_t); |
71 | static void *hash_realloc(SEGMENT **, size_t, size_t); | | 73 | static void *hash_realloc(SEGMENT **, size_t, size_t); |
72 | static int hash_seq(const DB *, DBT *, DBT *, uint32_t); | | 74 | static int hash_seq(const DB *, DBT *, DBT *, uint32_t); |
73 | static int hash_sync(const DB *, uint32_t); | | 75 | static int hash_sync(const DB *, uint32_t); |
74 | static int hdestroy(HTAB *); | | 76 | static int hdestroy(HTAB *); |