summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorjoerg <joerg@NetBSD.org>2013-12-11 01:24:08 +0000
committerjoerg <joerg@NetBSD.org>2013-12-11 01:24:08 +0000
commit8a05e9a38d7cbb7726fc62dc486cee1896bb5173 (patch)
tree90560bb06ba1978751f965d7585e4754764621aa /sys
parent82b90e35a45c68a97cac0e7d83a6905c2e29c8b7 (diff)
Allow kernel code to access constant databases by moving cdbr(3) and the
required mi_vector_hash(3) into src/common.
Diffstat (limited to 'sys')
-rw-r--r--sys/lib/libkern/Makefile.libkern6
-rw-r--r--sys/lib/libkern/libkern.h4
-rw-r--r--sys/sys/Makefile5
-rw-r--r--sys/sys/cdbr.h64
4 files changed, 75 insertions, 4 deletions
diff --git a/sys/lib/libkern/Makefile.libkern b/sys/lib/libkern/Makefile.libkern
index b3cad74bac8..16f4a39b783 100644
--- a/sys/lib/libkern/Makefile.libkern
+++ b/sys/lib/libkern/Makefile.libkern
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.libkern,v 1.27 2013/12/02 04:39:10 lneto Exp $
+# $NetBSD: Makefile.libkern,v 1.28 2013/12/11 01:24:08 joerg Exp $
#
# Variable definitions for libkern.
@@ -98,6 +98,10 @@ SRCS+= heapsort.c ptree.c rb.c
# for crypto
SRCS+= explicit_memset.c consttime_memequal.c
+.PATH: ${NETBSDSRCDIR}/common/lib/libc/cdb
+SRCS+= cdbr.c
+SRCS+= mi_vector_hash.c
+
# Files to clean up
CLEANFILES+= lib${LIB}.o lib${LIB}.po
diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h
index 02d6799b933..0162675562d 100644
--- a/sys/lib/libkern/libkern.h
+++ b/sys/lib/libkern/libkern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: libkern.h,v 1.109 2013/12/02 04:39:10 lneto Exp $ */
+/* $NetBSD: libkern.h,v 1.110 2013/12/11 01:24:08 joerg Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -321,6 +321,8 @@ char *initstate(unsigned long, char *, size_t);
char *setstate(char *);
#endif /* SMALL_RANDOM */
long random(void);
+void mi_vector_hash(const void * __restrict, size_t, uint32_t,
+ uint32_t[3]);
void mtprng_init32(struct mtprng_state *, uint32_t);
void mtprng_initarray(struct mtprng_state *, const uint32_t *, size_t);
uint32_t mtprng_rawrandom(struct mtprng_state *);
diff --git a/sys/sys/Makefile b/sys/sys/Makefile
index 0ba4aed7df7..afcd259ddf0 100644
--- a/sys/sys/Makefile
+++ b/sys/sys/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.144 2013/10/27 08:35:40 mbalmer Exp $
+# $NetBSD: Makefile,v 1.145 2013/12/11 01:24:08 joerg Exp $
.include <bsd.sys.mk>
@@ -6,7 +6,7 @@ INCSDIR= /usr/include/sys
INCS= acct.h agpio.h aio.h ansi.h aout_mids.h ataio.h atomic.h audioio.h \
bitops.h bootblock.h bswap.h buf.h \
- callback.h callout.h cdefs.h cdefs_aout.h \
+ callback.h callout.h cdbr.h cdefs.h cdefs_aout.h \
cdefs_elf.h cdio.h chio.h clockctl.h condvar.h conf.h core.h \
cpufreq.h cpuio.h ctype_bits.h ctype_inline.h \
device.h device_if.h \
@@ -43,6 +43,7 @@ INCS= acct.h agpio.h aio.h ansi.h aout_mids.h ataio.h atomic.h audioio.h \
wait.h wapbl.h wapbl_replay.h wdog.h xattr.h
INCSYMLINKS=\
+ sys/cdbr.h /usr/include/cdbr.h \
sys/exec_elf.h /usr/include/elf.h \
sys/fcntl.h /usr/include/fcntl.h \
sys/poll.h /usr/include/poll.h \
diff --git a/sys/sys/cdbr.h b/sys/sys/cdbr.h
new file mode 100644
index 00000000000..f0120a25893
--- /dev/null
+++ b/sys/sys/cdbr.h
@@ -0,0 +1,64 @@
+/* $NetBSD: cdbr.h,v 1.1 2013/12/11 01:24:08 joerg Exp $ */
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * 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 COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDERS 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.
+ */
+
+#ifndef _CDBR_H
+#define _CDBR_H
+
+#include <sys/cdefs.h>
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/types.h>
+#else
+#include <inttypes.h>
+#include <stddef.h>
+#endif
+
+#define CDBR_DEFAULT 0
+
+struct cdbr;
+
+__BEGIN_DECLS
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+struct cdbr *cdbr_open(const char *, int);
+#endif
+struct cdbr *cdbr_open_mem(void *, size_t, int,
+ void (*)(void *, void *, size_t), void *);
+uint32_t cdbr_entries(struct cdbr *);
+int cdbr_get(struct cdbr *, uint32_t, const void **, size_t *);
+int cdbr_find(struct cdbr *, const void *, size_t,
+ const void **, size_t *);
+void cdbr_close(struct cdbr *);
+
+__END_DECLS
+
+#endif /* _CDBR_H */