summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest2
-rw-r--r--usr/src/common/refhash/refhash.c (renamed from usr/src/uts/common/refhash/refhash.c)30
-rw-r--r--usr/src/lib/Makefile2
-rw-r--r--usr/src/lib/librefhash/Makefile41
-rw-r--r--usr/src/lib/librefhash/Makefile.com43
-rw-r--r--usr/src/lib/librefhash/amd64/Makefile19
-rw-r--r--usr/src/lib/librefhash/common/mapfile-vers48
-rw-r--r--usr/src/lib/librefhash/i386/Makefile18
-rw-r--r--usr/src/lib/librefhash/sparc/Makefile18
-rw-r--r--usr/src/lib/librefhash/sparcv9/Makefile19
-rw-r--r--usr/src/uts/common/Makefile.rules13
-rw-r--r--usr/src/uts/common/sys/Makefile1
-rw-r--r--usr/src/uts/common/sys/refhash.h8
13 files changed, 246 insertions, 16 deletions
diff --git a/manifest b/manifest
index a6899c3130..9dec860247 100644
--- a/manifest
+++ b/manifest
@@ -5304,6 +5304,7 @@ f usr/lib/amd64/libraidcfg.so.1 0755 root bin
s usr/lib/amd64/libraidcfg.so=libraidcfg.so.1
s usr/lib/amd64/librcm.so.1=../../../lib/amd64/librcm.so.1
s usr/lib/amd64/librcm.so=../../../lib/amd64/librcm.so.1
+f usr/lib/amd64/librefhash.so.1 0755 root bin
f usr/lib/amd64/librename.so.1 0755 root bin
f usr/lib/amd64/libreparse.so.1 0755 root bin
s usr/lib/amd64/libreparse.so=libreparse.so.1
@@ -6823,6 +6824,7 @@ f usr/lib/libraidcfg.so.1 0755 root bin
s usr/lib/libraidcfg.so=libraidcfg.so.1
s usr/lib/librcm.so.1=../../lib/librcm.so.1
s usr/lib/librcm.so=../../lib/librcm.so.1
+f usr/lib/librefhash.so.1 0755 root bin
f usr/lib/librename.so.1 0755 root bin
f usr/lib/libreparse.so.1 0755 root bin
s usr/lib/libreparse.so=libreparse.so.1
diff --git a/usr/src/uts/common/refhash/refhash.c b/usr/src/common/refhash/refhash.c
index e2de00597e..02ba869ef9 100644
--- a/usr/src/uts/common/refhash/refhash.c
+++ b/usr/src/common/refhash/refhash.c
@@ -10,15 +10,28 @@
*/
/*
- * Copyright 2015 Joyent, Inc.
+ * Copyright (c) 2018, Joyent, Inc.
*/
#include <sys/refhash.h>
-#include <sys/sysmacros.h>
#include <sys/types.h>
-#include <sys/kmem.h>
#include <sys/list.h>
+#include <sys/debug.h>
+
+#ifdef _KERNEL
+#include <sys/sysmacros.h>
#include <sys/ddi.h>
+#include <sys/kmem.h>
+#define REFHASH_ALLOC kmem_alloc
+#define REFHASH_ZALLOC kmem_zalloc
+#define REFHASH_FREE kmem_free
+#else
+#include <stddef.h>
+#include <umem.h>
+#define REFHASH_ALLOC umem_alloc
+#define REFHASH_ZALLOC umem_zalloc
+#define REFHASH_FREE umem_free
+#endif
#define RHL_F_DEAD 0x01
@@ -43,12 +56,13 @@ refhash_create(uint_t bucket_count, refhash_hash_f hash,
refhash_t *hp;
uint_t i;
- hp = kmem_alloc(sizeof (refhash_t), km_flags);
+ hp = REFHASH_ALLOC(sizeof (refhash_t), km_flags);
if (hp == NULL)
return (NULL);
- hp->rh_buckets = kmem_zalloc(bucket_count * sizeof (list_t), km_flags);
+ hp->rh_buckets = REFHASH_ZALLOC(bucket_count * sizeof (list_t),
+ km_flags);
if (hp->rh_buckets == NULL) {
- kmem_free(hp, sizeof (refhash_t));
+ REFHASH_FREE(hp, sizeof (refhash_t));
return (NULL);
}
hp->rh_bucket_count = bucket_count;
@@ -75,8 +89,8 @@ refhash_destroy(refhash_t *hp)
{
ASSERT(list_is_empty(&hp->rh_objs));
- kmem_free(hp->rh_buckets, hp->rh_bucket_count * sizeof (list_t));
- kmem_free(hp, sizeof (refhash_t));
+ REFHASH_FREE(hp->rh_buckets, hp->rh_bucket_count * sizeof (list_t));
+ REFHASH_FREE(hp, sizeof (refhash_t));
}
void
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 1363c5cc1b..bc1de518c8 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -194,6 +194,7 @@ SUBDIRS += \
libpthread \
libraidcfg \
librcm \
+ librefhash \
librename \
libreparse \
libresolv \
@@ -670,6 +671,7 @@ libproject: libpool libproc libsecdb
libprtdiag: libkstat
libprtdiag_psr: libprtdiag
libraidcfg: libdevinfo
+librefhash: libumem
librestart: libuutil libscf libpool libproject libsecdb libsysevent
libsasl: libgss pkcs11
libsaveargs: libdisasm
diff --git a/usr/src/lib/librefhash/Makefile b/usr/src/lib/librefhash/Makefile
new file mode 100644
index 0000000000..b6853cb0c6
--- /dev/null
+++ b/usr/src/lib/librefhash/Makefile
@@ -0,0 +1,41 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2020 Joyent, Inc.
+#
+
+include ../Makefile.lib
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
+
+.KEEP_STATE:
+
+all clean clobber install: $(SUBDIRS)
+
+install: install_h $(SUBDIRS)
+
+install_h: $(ROOTHDRS)
+
+check: $(CHECKHDRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/lib/librefhash/Makefile.com b/usr/src/lib/librefhash/Makefile.com
new file mode 100644
index 0000000000..1f914c46a6
--- /dev/null
+++ b/usr/src/lib/librefhash/Makefile.com
@@ -0,0 +1,43 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2020 Joyent, Inc.
+#
+
+LIBRARY = librefhash.a
+VERS = .1
+OBJECTS = list.o \
+ refhash.o
+HASHCOMDIR = $(SRC)/common/refhash
+LISTCOMDIR = $(SRC)/common/list
+
+include ../../Makefile.lib
+
+SRCDIR = ../common
+SRCS = $(HASHCOMDIR)/refhash.c $(LISTCOMDIR)/list.c
+LIBS = $(DYNLIB)
+
+LDLIBS += -lc -lumem
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+include ../../Makefile.targ
+
+objs/%.o pics/%.o: $(LISTCOMDIR)/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+objs/%.o pics/%.o: $(HASHCOMDIR)/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
diff --git a/usr/src/lib/librefhash/amd64/Makefile b/usr/src/lib/librefhash/amd64/Makefile
new file mode 100644
index 0000000000..5a2ea08b45
--- /dev/null
+++ b/usr/src/lib/librefhash/amd64/Makefile
@@ -0,0 +1,19 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2020 Joyent, Inc.
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/librefhash/common/mapfile-vers b/usr/src/lib/librefhash/common/mapfile-vers
new file mode 100644
index 0000000000..f7f91ef84f
--- /dev/null
+++ b/usr/src/lib/librefhash/common/mapfile-vers
@@ -0,0 +1,48 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2014 Joyent, Inc. All rights reserved.
+#
+
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION ILLUMOSprivate {
+ global:
+ refhash_create;
+ refhash_destroy;
+ refhash_insert;
+ refhash_remove;
+ refhash_lookup;
+ refhash_linear_search;
+ refhash_hold;
+ refhash_rele;
+ refhash_first;
+ refhash_next;
+ refhash_obj_valid;
+ local:
+ *;
+};
+
diff --git a/usr/src/lib/librefhash/i386/Makefile b/usr/src/lib/librefhash/i386/Makefile
new file mode 100644
index 0000000000..aeec694b08
--- /dev/null
+++ b/usr/src/lib/librefhash/i386/Makefile
@@ -0,0 +1,18 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2020 Joyent, Inc.
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/librefhash/sparc/Makefile b/usr/src/lib/librefhash/sparc/Makefile
new file mode 100644
index 0000000000..aeec694b08
--- /dev/null
+++ b/usr/src/lib/librefhash/sparc/Makefile
@@ -0,0 +1,18 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2020 Joyent, Inc.
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/librefhash/sparcv9/Makefile b/usr/src/lib/librefhash/sparcv9/Makefile
new file mode 100644
index 0000000000..5a2ea08b45
--- /dev/null
+++ b/usr/src/lib/librefhash/sparcv9/Makefile
@@ -0,0 +1,19 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2020 Joyent, Inc.
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules
index 46b6dfe391..1d052bdcc2 100644
--- a/usr/src/uts/common/Makefile.rules
+++ b/usr/src/uts/common/Makefile.rules
@@ -23,7 +23,7 @@
# Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2016 Garrett D'Amore <garrett@damore.org>
# Copyright 2013 Saso Kiselkov. All rights reserved.
-# Copyright 2019 Joyent, Inc.
+# Copyright 2020 Joyent, Inc.
# Copyright 2018 Nexenta Systems, Inc.
# Copyright (c) 2017 by Delphix. All rights reserved.
#
@@ -1583,6 +1583,10 @@ $(OBJS_DIR)/%.o: $(COMMONBASE)/nvpair/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
+$(OBJS_DIR)/%.o: $(COMMONBASE)/refhash/%.c
+ $(COMPILE.c) -o $@ $<
+ $(CTFCONVERT_O)
+
$(OBJS_DIR)/%.o: $(UTSBASE)/common/os/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
@@ -1603,10 +1607,6 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/common/pcmcia/pcs/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
-$(OBJS_DIR)/%.o: $(UTSBASE)/common/refhash/%.c
- $(COMPILE.c) -o $@ $<
- $(CTFCONVERT_O)
-
$(OBJS_DIR)/%.o: $(UTSBASE)/common/rpc/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
@@ -2773,9 +2773,6 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/common/pcmcia/nexus/%.c
$(LINTS_DIR)/%.ln: $(UTSBASE)/common/pcmcia/pcs/%.c
@($(LHEAD) $(LINT.c) $< $(LTAIL))
-$(LINTS_DIR)/%.ln: $(UTSBASE)/common/refhash/%.c
- @($(LHEAD) $(LINT.c) $< $(LTAIL))
-
$(LINTS_DIR)/%.ln: $(UTSBASE)/common/rpc/%.c
@($(LHEAD) $(LINT.c) $< $(LTAIL))
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile
index 7ae4558f97..c340476574 100644
--- a/usr/src/uts/common/sys/Makefile
+++ b/usr/src/uts/common/sys/Makefile
@@ -495,6 +495,7 @@ CHKHDRS= \
rctl_impl.h \
rds.h \
reboot.h \
+ refhash.h \
refstr.h \
refstr_impl.h \
resource.h \
diff --git a/usr/src/uts/common/sys/refhash.h b/usr/src/uts/common/sys/refhash.h
index b7427a454d..469cb6d686 100644
--- a/usr/src/uts/common/sys/refhash.h
+++ b/usr/src/uts/common/sys/refhash.h
@@ -19,6 +19,10 @@
#include <sys/types.h>
#include <sys/list.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define RHL_F_DEAD 0x01
typedef struct refhash_link {
@@ -58,4 +62,8 @@ extern void *refhash_first(refhash_t *);
extern void *refhash_next(refhash_t *, void *);
extern boolean_t refhash_obj_valid(refhash_t *hp, const void *);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _SYS_REFHASH_H */