diff options
-rw-r--r-- | lib/libc/hidden/icdb.h | 35 | ||||
-rw-r--r-- | lib/libc/stdlib/icdb.c | 13 |
2 files changed, 47 insertions, 1 deletions
diff --git a/lib/libc/hidden/icdb.h b/lib/libc/hidden/icdb.h new file mode 100644 index 00000000000..d8d6ca3600d --- /dev/null +++ b/lib/libc/hidden/icdb.h @@ -0,0 +1,35 @@ +/* $OpenBSD: icdb.h,v 1.1 2015/11/25 15:49:50 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_ICDB_H_ +#define _LIBC_ICDB_H_ + +#include_next <icdb.h> + +PROTO_NORMAL(icdb_add); +PROTO_NORMAL(icdb_close); +PROTO_NORMAL(icdb_entries); +PROTO_NORMAL(icdb_get); +PROTO_NORMAL(icdb_lookup); +PROTO_NORMAL(icdb_nentries); +PROTO_NORMAL(icdb_new); +PROTO_NORMAL(icdb_open); +PROTO_NORMAL(icdb_rehash); +PROTO_NORMAL(icdb_save); +PROTO_NORMAL(icdb_update); + +#endif /* !_LIBC_ICDB_H_ */ diff --git a/lib/libc/stdlib/icdb.c b/lib/libc/stdlib/icdb.c index 35747c065fc..16d5300ab3d 100644 --- a/lib/libc/stdlib/icdb.c +++ b/lib/libc/stdlib/icdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icdb.c,v 1.2 2015/11/18 17:59:56 tedu Exp $ */ +/* $OpenBSD: icdb.c,v 1.3 2015/11/25 15:49:50 guenther Exp $ */ /* * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> * @@ -146,6 +146,7 @@ icdb_new(uint32_t version, uint32_t nentries, uint32_t entrysize, } return db; } +DEF_WEAK(icdb_new); struct icdb * icdb_open(const char *name, int flags, uint32_t version) @@ -195,6 +196,7 @@ fail: free(db); return NULL; } +DEF_WEAK(icdb_open); int icdb_get(struct icdb *db, void *entry, uint32_t idx) @@ -204,6 +206,7 @@ icdb_get(struct icdb *db, void *entry, uint32_t idx) memcpy(entry, (uint8_t *)db->entries + idx * entrysize, entrysize); return 0; } +DEF_WEAK(icdb_get); int icdb_lookup(struct icdb *db, int keynum, const void *key, void *entry, uint32_t *idxp) @@ -235,18 +238,21 @@ icdb_lookup(struct icdb *db, int keynum, const void *key, void *entry, uint32_t } return 1; } +DEF_WEAK(icdb_lookup); int icdb_nentries(struct icdb *db) { return db->info->nentries; } +DEF_WEAK(icdb_nentries); const void * icdb_entries(struct icdb *db) { return db->entries; } +DEF_WEAK(icdb_entries); int icdb_update(struct icdb *db, const void *entry, int offset) @@ -267,6 +273,7 @@ icdb_update(struct icdb *db, const void *entry, int offset) msync(db->entries + offset * entrysize, entrysize, MS_SYNC); return 0; } +DEF_WEAK(icdb_update); int icdb_add(struct icdb *db, const void *entry) @@ -287,6 +294,7 @@ icdb_add(struct icdb *db, const void *entry) info->nentries++; return 0; } +DEF_WEAK(icdb_add); int icdb_rehash(struct icdb *db) @@ -323,6 +331,7 @@ icdb_rehash(struct icdb *db) } return 0; } +DEF_WEAK(icdb_rehash); int icdb_save(struct icdb *db, int fd) @@ -351,6 +360,7 @@ icdb_save(struct icdb *db, int fd) return -1; return 0; } +DEF_WEAK(icdb_save); int icdb_close(struct icdb *db) @@ -369,3 +379,4 @@ icdb_close(struct icdb *db) free(db); return 0; } +DEF_WEAK(icdb_close); |