Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 105 lines (91 sloc) 3.132 kB
ac2936d @gstrauss prep for public release
authored
1 /*
2 * mcdb_make - create mcdb
3 *
4 * Copyright (c) 2010, Glue Logic LLC. All rights reserved. code()gluelogic.com
5 *
6 * This file is part of mcdb.
7 *
8 * mcdb is free software: you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 2.1 of the License, or
11 * (at your option) any later version.
12 *
13 * mcdb is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with mcdb. If not, see <http://www.gnu.org/licenses/>.
20 *
21 *
22 * mcdb is originally based upon the Public Domain cdb-0.75 by Dan Bernstein
2c4c6c3 @gstrauss more code addition, code restructure;
authored
23 */
ca11100 @gstrauss mmap constant db: initial cut from Dan Bernstein cdb-0.75
authored
24
7a8f2ec @gstrauss create nss_mcdb.h (extract from nss_mcdb.c)
authored
25 #ifndef INCLUDED_MCDB_MAKE_H
26 #define INCLUDED_MCDB_MAKE_H
ca11100 @gstrauss mmap constant db: initial cut from Dan Bernstein cdb-0.75
authored
27
d6a097e @gstrauss mcdb_make - another ~5% faster writing large mcdb
authored
28 #include <sys/types.h> /* size_t */
29 #include <stdint.h>
ca11100 @gstrauss mmap constant db: initial cut from Dan Bernstein cdb-0.75
authored
30
dc8f706 @gstrauss - rename mcdb_uint32.h and mcdb_attribute.h for more generic usage
authored
31 #include "code_attributes.h"
245db10 @gstrauss mcdb_make - ~5% faster writing large mcdb
authored
32 #include "mcdb.h" /* MCDB_SLOTS */
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
33
7be3b1e @gstrauss restructure routines that parse djb cdb input format into mcdb_makefm…
authored
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
d6a097e @gstrauss mcdb_make - another ~5% faster writing large mcdb
authored
38 struct mcdb_hp { uintptr_t p; uint32_t h; uint32_t l; }; /*(private structure)*/
39 struct mcdb_hplist; /*(private structure)*/
ca11100 @gstrauss mmap constant db: initial cut from Dan Bernstein cdb-0.75
authored
40
2c4c6c3 @gstrauss more code addition, code restructure;
authored
41 struct mcdb_make {
42 size_t pos;
ddc091c @gstrauss Major restructure to mcdb_make
authored
43 size_t offset;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
44 char * restrict map;
ddc091c @gstrauss Major restructure to mcdb_make
authored
45 size_t fsz;
3d55a22 @gstrauss mcdb_make: reliably detect No space left on device
authored
46 size_t osz;
ddc091c @gstrauss Major restructure to mcdb_make
authored
47 size_t msz;
48 size_t pgalign;
d6a097e @gstrauss mcdb_make - another ~5% faster writing large mcdb
authored
49 struct mcdb_hp hp;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
50 void * (*fn_malloc)(size_t); /* fn ptr to malloc() */
51 void (*fn_free)(void *); /* fn ptr to free() */
6a55572 @gstrauss mcdb_makefn encapsulation and fix compiler warning
authored
52 const char *fname;
53 char *fntmp; /*(compiler warning for const char * restrict passed to free())*/
040401a @gstrauss mcdb_makefn - create temp file, atomically install
authored
54 int fd;
55 mode_t st_mode;
245db10 @gstrauss mcdb_make - ~5% faster writing large mcdb
authored
56 uint32_t count[MCDB_SLOTS];
d6a097e @gstrauss mcdb_make - another ~5% faster writing large mcdb
authored
57 struct mcdb_hplist *head[MCDB_SLOTS];
2c4c6c3 @gstrauss more code addition, code restructure;
authored
58 };
59
81f6405 @gstrauss checkpoint support for initgroups() and getgrouplist() (not tested)
authored
60
61 /*
62 * Note: mcdb *_make_* routines are not thread-safe
63 * (no need for thread-safety; mcdb is typically created from a single stream)
64 */
65
66
2c4c6c3 @gstrauss more code addition, code restructure;
authored
67 extern int
68 mcdb_make_start(struct mcdb_make * restrict, int,
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
69 void * (*)(size_t), void (*)(void *))
b7769de @gstrauss markup code with GCC __attribute__((warn_unused_result))
authored
70 __attribute_nonnull__ __attribute_warn_unused_result__;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
71 extern int
72 mcdb_make_add(struct mcdb_make * restrict,
73 const char * restrict, size_t,
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
74 const char * restrict, size_t)
b7769de @gstrauss markup code with GCC __attribute__((warn_unused_result))
authored
75 __attribute_nonnull__ __attribute_warn_unused_result__;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
76 extern int
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
77 mcdb_make_finish(struct mcdb_make * restrict)
b7769de @gstrauss markup code with GCC __attribute__((warn_unused_result))
authored
78 __attribute_nonnull__ __attribute_warn_unused_result__;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
79 extern int
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
80 mcdb_make_destroy(struct mcdb_make * restrict)
81 __attribute_nonnull__;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
82
83 /* support for adding entries from input stream, instead of fully in memory */
84 extern int
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
85 mcdb_make_addbegin(struct mcdb_make * restrict, size_t, size_t)
b7769de @gstrauss markup code with GCC __attribute__((warn_unused_result))
authored
86 __attribute_nonnull__ __attribute_warn_unused_result__;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
87 extern void
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
88 mcdb_make_addbuf_key(struct mcdb_make * restrict,const char * restrict,size_t)
89 __attribute_nonnull__;
2c4c6c3 @gstrauss more code addition, code restructure;
authored
90 extern void
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
91 mcdb_make_addbuf_data(struct mcdb_make * restrict,const char * restrict,size_t)
92 __attribute_nonnull__;
bcd7a95 @gstrauss Code simplification and abstraction for reusability
authored
93 extern void
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
94 mcdb_make_addend(struct mcdb_make * restrict)
95 __attribute_nonnull__;
bcd7a95 @gstrauss Code simplification and abstraction for reusability
authored
96 extern void
1efff6b @gstrauss create mcdb_findtagstart() and mcdb_findtagnext()
authored
97 mcdb_make_addrevert(struct mcdb_make * restrict)
98 __attribute_nonnull__;
ca11100 @gstrauss mmap constant db: initial cut from Dan Bernstein cdb-0.75
authored
99
7be3b1e @gstrauss restructure routines that parse djb cdb input format into mcdb_makefm…
authored
100 #ifdef __cplusplus
101 }
102 #endif
103
ca11100 @gstrauss mmap constant db: initial cut from Dan Bernstein cdb-0.75
authored
104 #endif
Something went wrong with that request. Please try again.