From 47354965bcc0b1bc48c84bd7c407b18c6f1f9fdf Mon Sep 17 00:00:00 2001 From: Phil Sorber Date: Tue, 22 Jul 2014 18:31:25 -0300 Subject: [PATCH 01/49] Add support for ppc64le arch --- configure | 2 +- regressions/ck_cohort/validate/Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 6c1a420..6bb8a5d 100755 --- a/configure +++ b/configure @@ -415,7 +415,7 @@ case $PLATFORM in ;; esac ;; - "ppc64") + "ppc64"|"ppc64le") RTM_ENABLE="CK_MD_RTM_DISABLE" MM="${MM:-"CK_MD_RMO"}" PLATFORM=ppc64 diff --git a/regressions/ck_cohort/validate/Makefile b/regressions/ck_cohort/validate/Makefile index 145af3a..8338f46 100644 --- a/regressions/ck_cohort/validate/Makefile +++ b/regressions/ck_cohort/validate/Makefile @@ -8,7 +8,11 @@ validate: validate.c ../../../include/ck_cohort.h $(CC) $(CFLAGS) -o validate validate.c check: all +ifeq ($(expr ($(CORES) / 2) > 0),$(expr 0)) + ./validate 1 2 1 +else ./validate `expr $(CORES) / 2` 2 1 +endif clean: rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) From c1fada9ef27129562efb43a51f4403c064a1d0ce Mon Sep 17 00:00:00 2001 From: Phil Sorber Date: Tue, 22 Jul 2014 21:14:50 -0300 Subject: [PATCH 02/49] Revert Makefile changes as they did not work as intended --- regressions/ck_cohort/validate/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/regressions/ck_cohort/validate/Makefile b/regressions/ck_cohort/validate/Makefile index 8338f46..145af3a 100644 --- a/regressions/ck_cohort/validate/Makefile +++ b/regressions/ck_cohort/validate/Makefile @@ -8,11 +8,7 @@ validate: validate.c ../../../include/ck_cohort.h $(CC) $(CFLAGS) -o validate validate.c check: all -ifeq ($(expr ($(CORES) / 2) > 0),$(expr 0)) - ./validate 1 2 1 -else ./validate `expr $(CORES) / 2` 2 1 -endif clean: rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) From de0e582eba46b1a60adb7c8b9dcc9d1eb172ad31 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Wed, 30 Jul 2014 13:10:16 +0200 Subject: [PATCH 03/49] Add ck_pr_fence_acquire/release to generic GCC version Signed-off-by: Marcin Juszkiewicz --- include/gcc/ck_pr.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/gcc/ck_pr.h b/include/gcc/ck_pr.h index 83fdcfe..6ebadd8 100644 --- a/include/gcc/ck_pr.h +++ b/include/gcc/ck_pr.h @@ -128,6 +128,8 @@ CK_PR_FENCE(store) CK_PR_FENCE(store_store) CK_PR_FENCE(store_load) CK_PR_FENCE(memory) +CK_PR_FENCE(acquire) +CK_PR_FENCE(release) #undef CK_PR_FENCE From f2f04412f61149dba6d66630115d2424cd1a3d62 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Wed, 30 Jul 2014 13:10:42 +0200 Subject: [PATCH 04/49] Add AArch64 (64-bit ARM) support Signed-off-by: Marcin Juszkiewicz --- build/ck.build.aarch64 | 1 + configure | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 build/ck.build.aarch64 diff --git a/build/ck.build.aarch64 b/build/ck.build.aarch64 new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/build/ck.build.aarch64 @@ -0,0 +1 @@ + diff --git a/configure b/configure index 6c1a420..537179d 100755 --- a/configure +++ b/configure @@ -427,6 +427,12 @@ case $PLATFORM in PLATFORM=arm ENVIRONMENT=32 ;; + "aarch64") + RTM_ENABLE="CK_MD_RTM_DISABLE" + MM="${MM:-"CK_MD_RMO"}" + PLATFORM=aarch64 + ENVIRONMENT=64 + ;; *) RTM_ENABLE="CK_MD_RTM_DISABLE" PLATFORM= From 44c7e0a97a49e50aaae6c5898d6f626714a3df33 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 30 Jul 2014 10:32:09 -0400 Subject: [PATCH 05/49] build: Bump minor for release. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 6bb8a5d..8e27af8 100755 --- a/configure +++ b/configure @@ -34,7 +34,7 @@ WANT_PIC=yes P_PWD=`pwd` MAINTAINER='sbahra@repnop.org' -VERSION=${VERSION:-'0.4.2'} +VERSION=${VERSION:-'0.4.3'} VERSION_MAJOR='0' BUILD="$PWD/build/ck.build" PREFIX=${PREFIX:-"/usr/local"} From 0411a0dce5936438df15b7f32dc92c53d40eaf2d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 30 Jul 2014 11:44:31 -0400 Subject: [PATCH 06/49] common: Get rid of EBX restoration for x86-64. It is not a PIC register, break out x86-specific PIC support. This would break x86-64 for less forgiving assemblers that (correctly) do not accept pushl/popl. --- regressions/common.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index 47989a9..f100e89 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -367,7 +367,7 @@ aff_iterate_core(struct affinity *acb CK_CC_UNUSED, unsigned int *core) CK_CC_INLINE static uint64_t rdtsc(void) { -#if defined(__x86_64__) || defined(__x86__) +#if defined(__x86_64__) uint32_t eax = 0, edx; #if defined(CK_MD_RDTSCP) __asm__ __volatile__("rdtscp" @@ -377,9 +377,32 @@ rdtsc(void) return (((uint64_t)edx << 32) | eax); #else + __asm__ __volatile__("cpuid;" + "rdtsc;" + : "+a" (eax), "=d" (edx) + : + : "%ebx", "%ecx", "memory"); - __asm__ __volatile__("pushl %%ebx;" + __asm__ __volatile__("xorl %%eax, %%eax;" "cpuid;" + : + : + : "%eax", "%ebx", "%ecx", "%edx", "memory"); + + return (((uint64_t)edx << 32) | eax); +#endif /* !CK_MD_RDTSCP */ +#elif defined(__x86__) + uint32_t eax = 0, edx; +#if defined(CK_MD_RDTSCP) + __asm__ __volatile__("rdtscp" + : "+a" (eax), "=d" (edx) + : + : "%ecx", "memory"); + + return (((uint64_t)edx << 32) | eax); +#else + __asm__ __volatile__("pushl %%ebx;" + "cpuid;" "rdtsc;" : "+a" (eax), "=d" (edx) : @@ -387,7 +410,7 @@ rdtsc(void) __asm__ __volatile__("xorl %%eax, %%eax;" "cpuid;" - "popl %%ebx;" + "popl %%ebx;" : : : "%eax", "%ecx", "%edx", "memory"); From 7fc90ebf25000fbf37056731c54668f61b4c2bb4 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 30 Jul 2014 11:45:43 -0400 Subject: [PATCH 07/49] regressions/ck_stack: Align stack for cmpxchg16b. --- regressions/ck_stack/validate/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regressions/ck_stack/validate/serial.c b/regressions/ck_stack/validate/serial.c index 50f6c95..c4bea18 100644 --- a/regressions/ck_stack/validate/serial.c +++ b/regressions/ck_stack/validate/serial.c @@ -77,7 +77,7 @@ serial(ck_stack_t *stack) int main(void) { - ck_stack_t stack; + ck_stack_t stack CK_CC_CACHELINE; serial(&stack); return (0); From 3614e8a63fa47ec906eb6ef35b00c6a9e8e2d947 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 1 Aug 2014 10:12:59 -0400 Subject: [PATCH 08/49] update --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index d06b306..73b0eeb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2010-2013 Samy Al Bahra. +Copyright 2010-2014 Samy Al Bahra. Copyright 2011-2013 AppNexus, Inc. All rights reserved. From 4af1985f5fae11cdba9490e56d9f2d00c04c38b3 Mon Sep 17 00:00:00 2001 From: Phil Sorber Date: Mon, 4 Aug 2014 16:44:25 -0600 Subject: [PATCH 09/49] Add workarounds to configure script to mimic automake more --- configure | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 9e24c0e..b9b6898 100755 --- a/configure +++ b/configure @@ -42,6 +42,8 @@ LDNAME="libck.so" LDNAME_VERSION="libck.so.$VERSION" LDNAME_MAJOR="libck.so.$VERSION_MAJOR" +OPTION_CHECKING=1 + export CFLAGS export PREFIX LC_ALL=C @@ -224,16 +226,22 @@ for option in $*; do --without-pic) WANT_PIC=no ;; + --disable-option-checking) + OPTION_CHECKING=0 + ;; --build=*|--host=*|--target=*|--exec-prefix=*|--bindir=*|--sbindir=*|\ --sysconfdir=*|--datadir=*|--libexecdir=*|--localstatedir=*|\ --enable-static|\ - --sharedstatedir=*|--infodir=*|--enable-shared|--disable-shared) + --sharedstatedir=*|--infodir=*|--enable-shared|--disable-shared|\ + --cache-file=*|--srcdir=*) # ignore for compat with regular configure ;; --*) - echo "$0 [--help]" - echo "Unknown option $option" - exit $EXIT_FAILURE + if test "$OPTION_CHECKING" -eq 1; then + echo "$0 [--help]" + echo "Unknown option $option" + exit $EXIT_FAILURE + fi ;; *=*) NAME=`expr "$option" : '\([^=]*\)='` From 20f082797f788b64e1f28ba717a5797237102856 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Sat, 9 Aug 2014 19:05:19 +0200 Subject: [PATCH 10/49] ck_rhs: Change a check from == to >= wanted_probe can't ever be > to map->probe_maximum, but static analyzers can't know this, so consider it a potential bug. --- src/ck_rhs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ck_rhs.c b/src/ck_rhs.c index 553d718..962a94c 100644 --- a/src/ck_rhs.c +++ b/src/ck_rhs.c @@ -991,7 +991,7 @@ ck_rhs_do_backward_shift_delete(struct ck_rhs *hs, long slot) break; wanted_probes++; } - if (wanted_probes == map->probe_maximum) { + if (!(wanted_probes < map->probe_maximum)) { desc->wanted = 0; break; } From 84cd66b2edc3c16b628863067bfe00149ac7ba17 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sat, 9 Aug 2014 14:18:38 -0400 Subject: [PATCH 11/49] build: ck_rhs was not properly included in Makefile. --- src/Makefile.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile.in b/src/Makefile.in index baef71b..367b25e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -35,6 +35,9 @@ ck_epoch.o: $(INCLUDE_DIR)/ck_epoch.h $(SDIR)/ck_epoch.c ck_hs.o: $(INCLUDE_DIR)/ck_hs.h $(SDIR)/ck_hs.c $(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_hs.o $(SDIR)/ck_hs.c +ck_rhs.o: $(INCLUDE_DIR)/ck_rhs.h $(SDIR)/ck_rhs.c + $(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_rhs.o $(SDIR)/ck_rhs.c + ck_ht.o: $(INCLUDE_DIR)/ck_ht.h $(SDIR)/ck_ht.c $(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_ht.o $(SDIR)/ck_ht.c From 747779df1b5615db6da16bde6a6ed9f39e1f1759 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 11 Aug 2014 21:14:52 +0000 Subject: [PATCH 12/49] configure: Allow for multi-option parameters. --- configure | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/configure b/configure index b9b6898..1b31294 100755 --- a/configure +++ b/configure @@ -144,8 +144,18 @@ generate_stdout() echo "Documentation will be installed in $MANDIR" } -for option in $*; do - value=`echo "$option" | sed -e 's/^[^=]*=\(.*\)/\1/'` +for option; do + case "$option" in + *=?*) + value=`expr -- "$option" : '[^=]*=\(.*\)'` + ;; + *=) + value= + ;; + *) + value=yes + ;; + esac case "$option" in --help) @@ -244,9 +254,8 @@ for option in $*; do fi ;; *=*) - NAME=`expr "$option" : '\([^=]*\)='` - VALUE=`echo "$value" | sed "s/'/'\\\\\\\\''/g"` - eval "$NAME='$VALUE'" + NAME=`expr -- "$option" : '\([^=]*\)='` + eval "$NAME='$value'" export $NAME ;; *) From a8556d50addf179d361d2b80ed0e3b8904aa54d7 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Tue, 12 Aug 2014 13:25:41 -0400 Subject: [PATCH 13/49] build: Append CFLAGS and LDFLAGS. This allows for make variable specifications. --- build/ck.build.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/ck.build.in b/build/ck.build.in index 6bcd044..1d6bfe3 100644 --- a/build/ck.build.in +++ b/build/ck.build.in @@ -2,8 +2,8 @@ CC=@CC@ MAKE=make SRC_DIR=@SRC_DIR@ BUILD_DIR=@BUILD_DIR@ -CFLAGS=@CFLAGS@ -I$(SRC_DIR)/include -I$(BUILD_DIR)/include -LDFLAGS=@LDFLAGS@ +CFLAGS+=@CFLAGS@ -I$(SRC_DIR)/include -I$(BUILD_DIR)/include +LDFLAGS+=@LDFLAGS@ ALL_LIBS=@ALL_LIBS@ LD=@LD@ From 6c35206e4c15025ac8acfb9d5e6e84118bc6d9c7 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Tue, 12 Aug 2014 17:29:52 +0000 Subject: [PATCH 14/49] build: Conditionally set CC and MAKE. --- build/ck.build.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/ck.build.in b/build/ck.build.in index 1d6bfe3..3ddf999 100644 --- a/build/ck.build.in +++ b/build/ck.build.in @@ -1,5 +1,5 @@ -CC=@CC@ -MAKE=make +CC?=@CC@ +MAKE?=make SRC_DIR=@SRC_DIR@ BUILD_DIR=@BUILD_DIR@ CFLAGS+=@CFLAGS@ -I$(SRC_DIR)/include -I$(BUILD_DIR)/include From 1d7057eb58fcc2c9e3fb006a354cd712ab76f924 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Tue, 19 Aug 2014 18:34:00 -0400 Subject: [PATCH 15/49] ck_bitmap: add a ck_bitmap_bts function. Signed-off-by: Samy Al Bahra --- include/ck_bitmap.h | 17 +++++++++++++++ regressions/ck_bitmap/validate/serial.c | 28 ++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/include/ck_bitmap.h b/include/ck_bitmap.h index 3c0105e..58cc91e 100644 --- a/include/ck_bitmap.h +++ b/include/ck_bitmap.h @@ -44,6 +44,7 @@ #endif #define CK_BITMAP_BLOCK (sizeof(unsigned int) * CHAR_BIT) +#define CK_BITMAP_OFFSET(i) ((i) % CK_BITMAP_BLOCK) #define CK_BITMAP_BIT(i) (1U << ((i) % CK_BITMAP_BLOCK)) #define CK_BITMAP_PTR(x, i) ((x) + ((i) / CK_BITMAP_BLOCK)) #define CK_BITMAP_BLOCKS(n) (((n) + CK_BITMAP_BLOCK - 1) / CK_BITMAP_BLOCK) @@ -69,6 +70,9 @@ #define CK_BITMAP_SET(a, b) \ ck_bitmap_set(&(a)->bitmap, (b)) +#define CK_BITMAP_BTS(a, b) \ + ck_bitmap_bts(&(a)->bitmap, (b)) + #define CK_BITMAP_RESET(a, b) \ ck_bitmap_reset(&(a)->bitmap, (b)) @@ -171,6 +175,19 @@ ck_bitmap_set(struct ck_bitmap *bitmap, unsigned int n) return; } +/* + * Performs a test-and-set operation at the offset specified in the + * second argument. + * Returns true if the bit at the specified offset was already set, + * false otherwise. + */ +CK_CC_INLINE static bool +ck_bitmap_bts(struct ck_bitmap *bitmap, unsigned int n) +{ + + return ck_pr_bts_uint(CK_BITMAP_PTR(bitmap->map, n), CK_BITMAP_OFFSET(n)); +} + /* * Resets the bit at the offset specified in the second argument. */ diff --git a/regressions/ck_bitmap/validate/serial.c b/regressions/ck_bitmap/validate/serial.c index 79aca8d..ecc5258 100644 --- a/regressions/ck_bitmap/validate/serial.c +++ b/regressions/ck_bitmap/validate/serial.c @@ -73,6 +73,7 @@ check_iteration(ck_bitmap_t *bits, unsigned int len, bool initial) static void test(ck_bitmap_t *bits, unsigned int n_length, bool initial) { + bool r; unsigned int i; CK_BITMAP_INSTANCE(8) u; @@ -92,14 +93,35 @@ test(ck_bitmap_t *bits, unsigned int n_length, bool initial) if (ck_bitmap_test(bits, i) == false) { ck_error("[1] ERROR: Expected bit to be set: %u\n", i); } + ck_bitmap_reset(bits, i); if (ck_bitmap_test(bits, i) == true) { ck_error("[2] ERROR: Expected bit to be cleared: %u\n", i); } + r = ck_bitmap_bts(bits, i); + if (r == true) { + ck_error("[3] ERROR: Expected bit to be cleared before 1st bts: %u\n", i); + } + if (ck_bitmap_test(bits, i) == false) { + ck_error("[4] ERROR: Expected bit to be set: %u\n", i); + } + r = ck_bitmap_bts(bits, i); + if (r == false) { + ck_error("[5] ERROR: Expected bit to be set before 2nd bts: %u\n", i); + } + if (ck_bitmap_test(bits, i) == false) { + ck_error("[6] ERROR: Expected bit to be set: %u\n", i); + } + + ck_bitmap_reset(bits, i); + if (ck_bitmap_test(bits, i) == true) { + ck_error("[7] ERROR: Expected bit to be cleared: %u\n", i); + } + ck_bitmap_set(bits, i); if (ck_bitmap_test(bits, i) == false) { - ck_error("[3] ERROR: Expected bit to be set: %u\n", i); + ck_error("[8] ERROR: Expected bit to be set: %u\n", i); } check_iteration(bits, i, initial); @@ -107,7 +129,7 @@ test(ck_bitmap_t *bits, unsigned int n_length, bool initial) for (i = 0; i < n_length; i++) { if (ck_bitmap_test(bits, i) == false) { - ck_error("[4] ERROR: Expected bit to be set: %u\n", i); + ck_error("[9] ERROR: Expected bit to be set: %u\n", i); } } @@ -115,7 +137,7 @@ test(ck_bitmap_t *bits, unsigned int n_length, bool initial) for (i = 0; i < n_length; i++) { if (ck_bitmap_test(bits, i) == true) { - ck_error("[4] ERROR: Expected bit to be reset: %u\n", i); + ck_error("[10] ERROR: Expected bit to be reset: %u\n", i); } } From 149259083523bad39a19fbcc364cb5e5a654ae39 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Fri, 22 Aug 2014 13:29:02 -0400 Subject: [PATCH 16/49] doc: Add man page for ck_bitmap_bts. --- doc/Makefile.in | 1 + doc/ck_bitmap_bts | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 doc/ck_bitmap_bts diff --git a/doc/Makefile.in b/doc/Makefile.in index ff24a91..3f90ddb 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -48,6 +48,7 @@ OBJECTS=CK_ARRAY_FOREACH \ ck_bitmap_init \ ck_bitmap_reset \ ck_bitmap_set \ + ck_bitmap_bts \ ck_bitmap_test \ ck_bitmap_base \ ck_bitmap_union \ diff --git a/doc/ck_bitmap_bts b/doc/ck_bitmap_bts new file mode 100644 index 0000000..872284c --- /dev/null +++ b/doc/ck_bitmap_bts @@ -0,0 +1,61 @@ +.\" +.\" Copyright 2014 David Joseph. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd August 22, 2014 +.Dt CK_BITMAP_BTS 3 +.Sh NAME +.Nm ck_bitmap_bts +.Nd set the bit at the specified index and fetch its original value +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_bitmap.h +.Ft bool +.Fn ck_bitmap_bts "ck_bitmap_t *bitmap" "unsigned int n" +.Sh DESCRIPTION +.Fn ck_bitmap_bts +sets the bit at the offset specified by the argument +.Fa n +to +.Dv 1 +and fetches its original value. +.Sh RETURN VALUES +This function returns the original value of the bit at offset +.Fa n +in +.Fa bitmap . +.Sh SEE ALSO +.Xr ck_bitmap_base 3 , +.Xr ck_bitmap_size 3 , +.Xr ck_bitmap_init 3 , +.Xr ck_bitmap_reset 3 , +.Xr ck_bitmap_clear 3 , +.Xr ck_bitmap_set 3 , +.Xr ck_bitmap_test 3 , +.Xr ck_bitmap_bits 3 , +.Xr ck_bitmap_buffer 3 +.Pp +Additional information available at http://concurrencykit.org/ From 40c7a1f24c6fd73ac0b95d719a5d6b874a5818f2 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 22 Aug 2014 15:37:25 -0400 Subject: [PATCH 17/49] ck_bitmap: Wrap long lines (style). --- include/ck_bitmap.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/ck_bitmap.h b/include/ck_bitmap.h index 58cc91e..96a8fe9 100644 --- a/include/ck_bitmap.h +++ b/include/ck_bitmap.h @@ -185,7 +185,8 @@ CK_CC_INLINE static bool ck_bitmap_bts(struct ck_bitmap *bitmap, unsigned int n) { - return ck_pr_bts_uint(CK_BITMAP_PTR(bitmap->map, n), CK_BITMAP_OFFSET(n)); + return ck_pr_bts_uint(CK_BITMAP_PTR(bitmap->map, n), + CK_BITMAP_OFFSET(n)); } /* @@ -268,7 +269,8 @@ ck_bitmap_intersection(struct ck_bitmap *dst, const struct ck_bitmap *src) * complete bitmap. Any trailing bit in dst is left as is. */ CK_CC_INLINE static void -ck_bitmap_intersection_negate(struct ck_bitmap *dst, const struct ck_bitmap *src) +ck_bitmap_intersection_negate(struct ck_bitmap *dst, + const struct ck_bitmap *src) { unsigned int n; unsigned int n_intersect = dst->n_bits; @@ -292,8 +294,9 @@ ck_bitmap_intersection_negate(struct ck_bitmap *dst, const struct ck_bitmap *src CK_CC_INLINE static void ck_bitmap_clear(struct ck_bitmap *bitmap) { - unsigned int n_buckets = ck_bitmap_base(bitmap->n_bits) / sizeof(unsigned int); unsigned int i; + unsigned int n_buckets = ck_bitmap_base(bitmap->n_bits) / + sizeof(unsigned int); for (i = 0; i < n_buckets; i++) ck_pr_store_uint(&bitmap->map[i], 0); @@ -396,7 +399,8 @@ ck_bitmap_count(const ck_bitmap_t *bitmap, unsigned int limit) * size, it is truncated to the smallest. */ CK_CC_INLINE static unsigned int -ck_bitmap_count_intersect(const ck_bitmap_t *x, const ck_bitmap_t *y, unsigned int limit) +ck_bitmap_count_intersect(const ck_bitmap_t *x, const ck_bitmap_t *y, + unsigned int limit) { unsigned int count, i, slop, words; @@ -458,7 +462,8 @@ ck_bitmap_init(struct ck_bitmap *bitmap, * Initialize iterator for use with provided bitmap. */ CK_CC_INLINE static void -ck_bitmap_iterator_init(struct ck_bitmap_iterator *i, const struct ck_bitmap *bitmap) +ck_bitmap_iterator_init(struct ck_bitmap_iterator *i, + const struct ck_bitmap *bitmap) { i->n_block = 0; From bc0618e1b4d8e1e29d01ea92e7b22d9f312c8b28 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 18:46:56 -0400 Subject: [PATCH 18/49] ck_hs: Add ck_hs_apply function for in-band mutation. Allows for the application of a user-specified function to avoid re-probe for get conditional put / delete and in-band mutation use-cases. --- src/ck_hs.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/ck_hs.c b/src/ck_hs.c index 6769dad..a4eb423 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -630,6 +630,91 @@ ck_hs_fas(struct ck_hs *hs, return true; } +/* + * An apply function takes two arguments. The first argument is a pointer to a + * pre-existing object. The second argument is a pointer to the fifth argument + * passed to ck_hs_apply. If a non-NULL pointer is passed to the first argument + * and the return value of the apply function is NULL, then the pre-existing + * value is deleted. If the return pointer is the same as the one passed to the + * apply function then no changes are made to the hash table. If the first + * argument is non-NULL and the return pointer is different than that passed to + * the apply function, then the pre-existing value is replaced. For + * replacement, it is required that the value itself is identical to the + * previous value. + */ +bool +ck_hs_apply(struct ck_hs *hs, + unsigned long h, + const void *key, + ck_hs_apply_fn_t *fn, + void *cl) +{ + void **slot, **first, *object, *insert, *delta; + unsigned long n_probes; + struct ck_hs_map *map; + +restart: + map = hs->map; + + slot = ck_hs_map_probe(hs, map, &n_probes, &first, h, key, &object, map->probe_limit, CK_HS_PROBE_INSERT); + if (slot == NULL && first == NULL) { + if (ck_hs_grow(hs, map->capacity << 1) == false) + return false; + + goto restart; + } + + delta = fn(object, cl); + if (delta == NULL) { + /* + * The apply function has requested deletion. If the object doesn't exist, + * then exit early. + */ + if (CK_CC_UNLIKELY(object == NULL)) + return true; + + /* Otherwise, mark slot as deleted. */ + ck_pr_store_ptr(slot, CK_HS_TOMBSTONE); + return true; + } + + /* The apply function has not requested hash set modification so exit early. */ + if (delta == object) + return true; + + /* A modification or insertion has been requested. */ + ck_hs_map_bound_set(map, h, n_probes); + + insert = ck_hs_marshal(hs->mode, delta, h); + if (first != NULL) { + /* + * This follows the same semantics as ck_hs_set, please refer to that + * function for documentation. + */ + ck_pr_store_ptr(first, insert); + + if (object != NULL) { + ck_pr_inc_uint(&map->generation[h & CK_HS_G_MASK]); + ck_pr_fence_atomic_store(); + ck_pr_store_ptr(slot, CK_HS_TOMBSTONE); + } + } else { + /* + * If we are storing into same slot, then atomic store is sufficient + * for replacement. + */ + ck_pr_store_ptr(slot, insert); + } + + if (object == NULL) { + map->n_entries++; + if ((map->n_entries << 1) > map->capacity) + ck_hs_grow(hs, map->capacity << 1); + } + + return true; +} + bool ck_hs_set(struct ck_hs *hs, unsigned long h, From 01aa93f05a5d34f441a7ecaf77587d672a98a6e4 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 18:57:43 -0400 Subject: [PATCH 19/49] regressions/ck_hs: Additional ck_hs_apply coverage. --- include/ck_hs.h | 2 ++ regressions/ck_hs/validate/serial.c | 54 +++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/include/ck_hs.h b/include/ck_hs.h index 91f990b..564e9b6 100644 --- a/include/ck_hs.h +++ b/include/ck_hs.h @@ -108,6 +108,8 @@ typedef struct ck_hs_iterator ck_hs_iterator_t; /* Convenience wrapper to table hash function. */ #define CK_HS_HASH(T, F, K) F((K), (T)->seed) +typedef void *ck_hs_apply_fn_t(void *, void *); +bool ck_hs_apply(ck_hs_t *, unsigned long, const void *, ck_hs_apply_fn_t *, void *); void ck_hs_iterator_init(ck_hs_iterator_t *); bool ck_hs_next(ck_hs_t *, ck_hs_iterator_t *, void **); bool ck_hs_move(ck_hs_t *, ck_hs_t *, ck_hs_hash_cb_t *, diff --git a/regressions/ck_hs/validate/serial.c b/regressions/ck_hs/validate/serial.c index 93a375b..ed3002a 100644 --- a/regressions/ck_hs/validate/serial.c +++ b/regressions/ck_hs/validate/serial.c @@ -85,6 +85,39 @@ hs_compare(const void *previous, const void *compare) return strcmp(previous, compare) == 0; } +static void * +test_ip(void *key, void *closure) +{ + const char *a = key; + const char *b = closure; + + if (strcmp(a, b) != 0) + ck_error("Mismatch: %s != %s\n", a, b); + + return closure; +} + +static void * +test_negative(void *key, void *closure) +{ + + (void)closure; + if (key != NULL) + ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); + + return NULL; +} + +static void * +test_unique(void *key, void *closure) +{ + + if (key != NULL) + ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); + + return closure; +} + static void run_test(unsigned int is, unsigned int ad) { @@ -104,12 +137,19 @@ run_test(unsigned int is, unsigned int ad) continue; } - if (ck_hs_put_unique(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]); + if (i & 1) { + if (ck_hs_put_unique(&hs[j], h, test[i]) == false) + ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]); + } else if (ck_hs_apply(&hs[j], h, test[i], test_unique, (char *)test[i]) == false) { + ck_error("ERROR: Failed to apply for insertion.\n"); + } if (ck_hs_remove(&hs[j], h, test[i]) == false) ck_error("ERROR [%zu]: Failed to remove unique (%s)\n", j, test[i]); + if (ck_hs_apply(&hs[j], h, test[i], test_negative, (char *)test[i]) == false) + ck_error("ERROR: Failed to apply.\n"); + break; } @@ -214,8 +254,16 @@ run_test(unsigned int is, unsigned int ad) } if (strcmp(r, test[i]) != 0) { - ck_error("ERROR [%u]: Invalid &hs[j]: %s != %s\n", (char *)r, test[i], is); + ck_error("ERROR [%u]: Invalid &hs[j]: %s != %s\n", is, test[i], (char *)r); } + + /* Attempt in-place mutation. */ + if (ck_hs_apply(&hs[j], h, test[i], test_ip, (void *)test[i]) == false) + ck_error("ERROR [%u]: Failed to apply: %s != %s\n", is, (char *)r, test[i]); + + d = ck_hs_get(&hs[j], h, test[i]) != NULL; + if (d == false) + ck_error("ERROR [%u]: Expected [%s] to exist.\n", is, test[i]); } if (j == size - 1) From 5201dc3d4531948e845fc761b16452f3f87d0f2a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 19:00:52 -0400 Subject: [PATCH 20/49] regressions/ck_hs: Make set_replace in serial benchmark paranoid. --- regressions/ck_hs/benchmark/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regressions/ck_hs/benchmark/serial.c b/regressions/ck_hs/benchmark/serial.c index 995ef1c..ac4caff 100644 --- a/regressions/ck_hs/benchmark/serial.c +++ b/regressions/ck_hs/benchmark/serial.c @@ -133,7 +133,7 @@ set_replace(const char *value) h = CK_HS_HASH(&hs, hs_hash, value); ck_hs_set(&hs, h, value, &previous); - return previous != NULL; + return previous == value; } static void * From 92645aeb47dc61a863472c6b2673f6dc519a1c13 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 19:33:21 -0400 Subject: [PATCH 21/49] regressions/ck_hs: Add ck_hs_apply benchmark. Preliminary results show 15%-32% latency improvements from large to small hash tables. --- regressions/ck_hs/benchmark/Makefile | 5 +- regressions/ck_hs/benchmark/apply.c | 260 +++++++++++++++++++++++++++ 2 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 regressions/ck_hs/benchmark/apply.c diff --git a/regressions/ck_hs/benchmark/Makefile b/regressions/ck_hs/benchmark/Makefile index ca20809..23b6745 100644 --- a/regressions/ck_hs/benchmark/Makefile +++ b/regressions/ck_hs/benchmark/Makefile @@ -1,12 +1,15 @@ .PHONY: clean distribution -OBJECTS=serial parallel_bytestring parallel_bytestring.delete +OBJECTS=serial parallel_bytestring parallel_bytestring.delete apply all: $(OBJECTS) serial: serial.c ../../../include/ck_hs.h ../../../src/ck_hs.c $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_hs.c +apply: apply.c ../../../include/ck_hs.h ../../../src/ck_hs.c + $(CC) $(CFLAGS) -o apply apply.c ../../../src/ck_hs.c + parallel_bytestring: parallel_bytestring.c ../../../include/ck_hs.h ../../../src/ck_hs.c ../../../src/ck_epoch.c $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c diff --git a/regressions/ck_hs/benchmark/apply.c b/regressions/ck_hs/benchmark/apply.c new file mode 100644 index 0000000..ca4a3da --- /dev/null +++ b/regressions/ck_hs/benchmark/apply.c @@ -0,0 +1,260 @@ +/* + * Copyright 2014 Samy Al Bahra. + * Copyright 2014 Backtrace I/O, Inc. + * All rights reserved. + * + * 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 copyrighs + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyrighs + * 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 AUTHOR 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 AUTHOR 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. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../common.h" +#include "../../../src/ck_ht_hash.h" + +static ck_hs_t hs; +static char **keys; +static size_t keys_length = 0; +static size_t keys_capacity = 128; +static unsigned long global_seed; + +static void * +hs_malloc(size_t r) +{ + + return malloc(r); +} + +static void +hs_free(void *p, size_t b, bool r) +{ + + (void)b; + (void)r; + + free(p); + + return; +} + +static struct ck_malloc my_allocator = { + .malloc = hs_malloc, + .free = hs_free +}; + +static unsigned long +hs_hash(const void *object, unsigned long seed) +{ + const char *c = object; + unsigned long h; + + h = (unsigned long)MurmurHash64A(c, strlen(c), seed); + return h; +} + +static bool +hs_compare(const void *previous, const void *compare) +{ + + return strcmp(previous, compare) == 0; +} + +static void +set_destroy(void) +{ + + ck_hs_destroy(&hs); + return; +} + +static void +set_init(unsigned int size, unsigned int mode) +{ + + if (ck_hs_init(&hs, CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC | mode, hs_hash, hs_compare, + &my_allocator, size, global_seed) == false) { + perror("ck_hs_init"); + exit(EXIT_FAILURE); + } + + return; +} + +static size_t +set_count(void) +{ + + return ck_hs_count(&hs); +} + +static bool +set_reset(void) +{ + + return ck_hs_reset(&hs); +} + +static void * +test_apply(void *key, void *closure) +{ + + (void)key; + + return closure; +} + +static void +run_test(const char *file, size_t r, unsigned int size, unsigned int mode) +{ + FILE *fp; + char buffer[512]; + size_t i, j; + unsigned int d = 0; + uint64_t s, e, a, gp, agp; + struct ck_hs_stat st; + char **t; + + keys = malloc(sizeof(char *) * keys_capacity); + assert(keys != NULL); + + fp = fopen(file, "r"); + assert(fp != NULL); + + while (fgets(buffer, sizeof(buffer), fp) != NULL) { + buffer[strlen(buffer) - 1] = '\0'; + keys[keys_length++] = strdup(buffer); + assert(keys[keys_length - 1] != NULL); + + if (keys_length == keys_capacity) { + t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); + assert(t != NULL); + keys = t; + } + } + + t = realloc(keys, sizeof(char *) * keys_length); + assert(t != NULL); + keys = t; + + set_init(size, mode); + for (i = 0; i < keys_length; i++) { + unsigned long h = CK_HS_HASH(&hs, hs_hash, keys[i]); + + if (ck_hs_get(&hs, h, keys[i]) == false) { + if (ck_hs_put(&hs, h, keys[i]) == false) + ck_error("ERROR: Failed get to put workload.\n"); + } else { + d++; + } + } + ck_hs_stat(&hs, &st); + + fprintf(stderr, "# %zu entries stored, %u duplicates, %u probe.\n", + set_count(), d, st.probe_maximum); + + a = 0; + for (j = 0; j < r; j++) { + if (set_reset() == false) + ck_error("ERROR: Failed to reset hash table.\n"); + + s = rdtsc(); + for (i = 0; i < keys_length; i++) { + unsigned long h = CK_HS_HASH(&hs, hs_hash, keys[i]); + + if (ck_hs_get(&hs, h, keys[i]) == false && + ck_hs_put(&hs, h, keys[i]) == false) { + ck_error("ERROR: Failed get to put workload.\n"); + } + } + e = rdtsc(); + a += e - s; + } + gp = a / (r * keys_length); + + a = 0; + for (j = 0; j < r; j++) { + if (set_reset() == false) + ck_error("ERROR: Failed to reset hash table.\n"); + + s = rdtsc(); + for (i = 0; i < keys_length; i++) { + unsigned long h = CK_HS_HASH(&hs, hs_hash, keys[i]); + + if (ck_hs_apply(&hs, h, keys[i], test_apply, (void *)keys[i]) == false) + ck_error("ERROR: Failed in apply workload.\n"); + } + e = rdtsc(); + a += e - s; + } + agp = a / (r * keys_length); + + fclose(fp); + + for (i = 0; i < keys_length; i++) { + free(keys[i]); + } + + printf("Get to put: %" PRIu64 " ticks\n", gp); + printf(" Apply: %" PRIu64 " ticks\n", agp); + + free(keys); + keys_length = 0; + set_destroy(); + return; +} + +int +main(int argc, char *argv[]) +{ + unsigned int r, size; + + common_srand48((long int)time(NULL)); + if (argc < 2) { + ck_error("Usage: ck_hs [ ]\n"); + } + + r = 16; + if (argc >= 3) + r = atoi(argv[2]); + + size = 8; + if (argc >= 4) + size = atoi(argv[3]); + + global_seed = common_lrand48(); + run_test(argv[1], r, size, 0); + + printf("\n==============================================\n" + "Delete mode\n" + "==============================================\n"); + run_test(argv[1], r, size, CK_HS_MODE_DELETE); + return 0; +} + From d167c417a491e2d7d8a7f7b9d734cbc67e2ad65a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 19:40:19 -0400 Subject: [PATCH 22/49] ck_hs: Merge post-insertion logic into one function. --- src/ck_hs.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/ck_hs.c b/src/ck_hs.c index a4eb423..7db1354 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -369,6 +369,17 @@ restart: return true; } +static void +ck_hs_map_postinsert(struct ck_hs *hs, struct ck_hs_map *map) +{ + + map->n_entries++; + if ((map->n_entries << 1) > map->capacity) + ck_hs_grow(hs, map->capacity << 1); + + return; +} + bool ck_hs_rebuild(struct ck_hs *hs) { @@ -706,11 +717,8 @@ restart: ck_pr_store_ptr(slot, insert); } - if (object == NULL) { - map->n_entries++; - if ((map->n_entries << 1) > map->capacity) - ck_hs_grow(hs, map->capacity << 1); - } + if (object == NULL) + ck_hs_map_postinsert(hs, map); return true; } @@ -765,11 +773,8 @@ restart: ck_pr_store_ptr(slot, insert); } - if (object == NULL) { - map->n_entries++; - if ((map->n_entries << 1) > map->capacity) - ck_hs_grow(hs, map->capacity << 1); - } + if (object == NULL) + ck_hs_map_postinsert(hs, map); *previous = object; return true; @@ -813,10 +818,7 @@ restart: ck_pr_store_ptr(slot, insert); } - map->n_entries++; - if ((map->n_entries << 1) > map->capacity) - ck_hs_grow(hs, map->capacity << 1); - + ck_hs_map_postinsert(hs, map); return true; } From 29db80432f0042cb0ce37b0e8b3be070b36978dd Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 19:40:45 -0400 Subject: [PATCH 23/49] ck_hs: Remove redundant whitespace (whitespace). --- src/ck_hs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ck_hs.c b/src/ck_hs.c index 7db1354..76bf832 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -929,4 +929,3 @@ ck_hs_init(struct ck_hs *hs, hs->map = ck_hs_map_create(hs, n_entries); return hs->map != NULL; } - From d6ba2a627331dc38b8791af9801ee50e975ca64f Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 19:45:57 -0400 Subject: [PATCH 24/49] whitespace: Sweeping whitespace changes. Removing trailing whitespaces and newlines. --- include/ck_array.h | 1 - include/ck_backoff.h | 1 - include/ck_barrier.h | 1 - include/ck_brlock.h | 1 - include/ck_bytelock.h | 1 - include/ck_cohort.h | 1 - include/ck_elide.h | 3 +- include/ck_epoch.h | 1 - include/ck_fifo.h | 1 - include/ck_hp.h | 1 - include/ck_hp_fifo.h | 1 - include/ck_hp_stack.h | 1 - include/ck_hs.h | 3 +- include/ck_ht.h | 1 - include/ck_limits.h | 1 - include/ck_malloc.h | 1 - include/ck_pflock.h | 1 - include/ck_pr.h | 1 - include/ck_queue.h | 1 - include/ck_rhs.h | 2 +- include/ck_ring.h | 3 +- include/ck_rwcohort.h | 1 - include/ck_rwlock.h | 1 - include/ck_sequence.h | 1 - include/ck_spinlock.h | 1 - include/ck_stack.h | 1 - include/ck_stdint.h | 1 - include/ck_swlock.h | 1 - include/ck_tflock.h | 4 +-- include/gcc/arm/ck_pr.h | 6 ++-- include/spinlock/hclh.h | 2 +- .../ck_hp/validate/ck_hp_fifo_donner.c | 8 ++--- .../ck_hs/benchmark/parallel_bytestring.c | 2 +- regressions/ck_ring/validate/ck_ring_spmc.c | 4 +-- .../ck_ring/validate/ck_ring_spmc_template.c | 2 +- regressions/common.h | 3 +- src/ck_epoch.c | 4 +-- src/ck_hs.c | 4 +-- src/ck_ht.c | 2 +- src/ck_ht_hash.h | 2 +- src/ck_rhs.c | 32 +++++++++---------- 41 files changed, 41 insertions(+), 69 deletions(-) diff --git a/include/ck_array.h b/include/ck_array.h index e8e366b..dcde6bc 100644 --- a/include/ck_array.h +++ b/include/ck_array.h @@ -98,4 +98,3 @@ ck_array_initialized(struct ck_array *array) _ck_i++) #endif /* _CK_ARRAY_H */ - diff --git a/include/ck_backoff.h b/include/ck_backoff.h index f43c564..9e43847 100644 --- a/include/ck_backoff.h +++ b/include/ck_backoff.h @@ -55,4 +55,3 @@ ck_backoff_eb(volatile unsigned int *c) } #endif /* _CK_BACKOFF_H */ - diff --git a/include/ck_barrier.h b/include/ck_barrier.h index 52d3973..2f7acdd 100644 --- a/include/ck_barrier.h +++ b/include/ck_barrier.h @@ -162,4 +162,3 @@ void ck_barrier_mcs_subscribe(ck_barrier_mcs_t *, ck_barrier_mcs_state_t *); void ck_barrier_mcs(ck_barrier_mcs_t *, ck_barrier_mcs_state_t *); #endif /* _CK_BARRIER_H */ - diff --git a/include/ck_brlock.h b/include/ck_brlock.h index d59f0e9..b45e1b8 100644 --- a/include/ck_brlock.h +++ b/include/ck_brlock.h @@ -277,4 +277,3 @@ ck_brlock_read_unlock(struct ck_brlock_reader *reader) } #endif /* _CK_BRLOCK_H */ - diff --git a/include/ck_bytelock.h b/include/ck_bytelock.h index cd855cf..6755762 100644 --- a/include/ck_bytelock.h +++ b/include/ck_bytelock.h @@ -184,4 +184,3 @@ ck_bytelock_read_unlock(struct ck_bytelock *bytelock, unsigned int slot) } #endif /* _CK_BYTELOCK_H */ - diff --git a/include/ck_cohort.h b/include/ck_cohort.h index 5bc8baa..4bfcfe2 100644 --- a/include/ck_cohort.h +++ b/include/ck_cohort.h @@ -159,4 +159,3 @@ enum ck_cohort_state { } #endif /* _CK_COHORT_H */ - diff --git a/include/ck_elide.h b/include/ck_elide.h index 8ffff40..59d17c5 100644 --- a/include/ck_elide.h +++ b/include/ck_elide.h @@ -303,7 +303,7 @@ _ck_elide_fallback(int *retry, * semantics. In environments where jitter is low, this may yield a tighter * fast path. */ -#define CK_ELIDE_LOCK(NAME, LOCK) ck_elide_##NAME##_lock(LOCK) +#define CK_ELIDE_LOCK(NAME, LOCK) ck_elide_##NAME##_lock(LOCK) #define CK_ELIDE_UNLOCK(NAME, LOCK) ck_elide_##NAME##_unlock(LOCK) #define CK_ELIDE_TRYLOCK(NAME, LOCK) ck_elide_##NAME##_trylock(LOCK) @@ -319,4 +319,3 @@ _ck_elide_fallback(int *retry, ck_elide_##NAME##_unlock_adaptive(STAT, LOCK) #endif /* _CK_ELIDE_H */ - diff --git a/include/ck_epoch.h b/include/ck_epoch.h index 2e71599..ecfd173 100644 --- a/include/ck_epoch.h +++ b/include/ck_epoch.h @@ -160,4 +160,3 @@ void ck_epoch_barrier(ck_epoch_t *, ck_epoch_record_t *); void ck_epoch_reclaim(ck_epoch_record_t *); #endif /* _CK_EPOCH_H */ - diff --git a/include/ck_fifo.h b/include/ck_fifo.h index a65bcfc..a09a80d 100644 --- a/include/ck_fifo.h +++ b/include/ck_fifo.h @@ -472,4 +472,3 @@ ck_fifo_mpmc_trydequeue(struct ck_fifo_mpmc *fifo, #endif /* CK_F_PR_CAS_PTR_2 */ #endif /* _CK_FIFO_H */ - diff --git a/include/ck_hp.h b/include/ck_hp.h index 505de5b..7f503de 100644 --- a/include/ck_hp.h +++ b/include/ck_hp.h @@ -104,4 +104,3 @@ void ck_hp_retire(ck_hp_record_t *, ck_hp_hazard_t *, void *, void *); void ck_hp_purge(ck_hp_record_t *); #endif /* _CK_HP_H */ - diff --git a/include/ck_hp_fifo.h b/include/ck_hp_fifo.h index 59bf0e4..96ffa5e 100644 --- a/include/ck_hp_fifo.h +++ b/include/ck_hp_fifo.h @@ -219,4 +219,3 @@ ck_hp_fifo_trydequeue_mpmc(ck_hp_record_t *record, (entry) = (T)) #endif /* _CK_HP_FIFO_H */ - diff --git a/include/ck_hp_stack.h b/include/ck_hp_stack.h index 3b67fc4..3a14faa 100644 --- a/include/ck_hp_stack.h +++ b/include/ck_hp_stack.h @@ -111,4 +111,3 @@ leave: } #endif /* _CK_HP_STACK_H */ - diff --git a/include/ck_hs.h b/include/ck_hs.h index 564e9b6..e37918c 100644 --- a/include/ck_hs.h +++ b/include/ck_hs.h @@ -48,7 +48,7 @@ */ #define CK_HS_MODE_DIRECT 2 -/* +/* * Indicates that the values to be stored are pointers. * Allows for space optimizations in the presence of pointer * packing. Mutually exclusive with CK_HS_MODE_DIRECT. @@ -132,4 +132,3 @@ bool ck_hs_reset_size(ck_hs_t *, unsigned long); void ck_hs_stat(ck_hs_t *, struct ck_hs_stat *); #endif /* _CK_HS_H */ - diff --git a/include/ck_ht.h b/include/ck_ht.h index 86fb7f0..cb8e67d 100644 --- a/include/ck_ht.h +++ b/include/ck_ht.h @@ -259,4 +259,3 @@ uint64_t ck_ht_count(ck_ht_t *); #endif /* CK_F_PR_LOAD_64 && CK_F_PR_STORE_64 */ #endif /* _CK_HT_H */ - diff --git a/include/ck_limits.h b/include/ck_limits.h index c597763..b08e4a7 100644 --- a/include/ck_limits.h +++ b/include/ck_limits.h @@ -29,4 +29,3 @@ #else #include #endif /* __linux__ && __KERNEL__ */ - diff --git a/include/ck_malloc.h b/include/ck_malloc.h index 40f1898..a623e1a 100644 --- a/include/ck_malloc.h +++ b/include/ck_malloc.h @@ -37,4 +37,3 @@ struct ck_malloc { }; #endif /* _CK_MALLOC_H */ - diff --git a/include/ck_pflock.h b/include/ck_pflock.h index 58963e8..52c232a 100644 --- a/include/ck_pflock.h +++ b/include/ck_pflock.h @@ -140,4 +140,3 @@ leave: } #endif /* _CK_PFLOCK_H */ - diff --git a/include/ck_pr.h b/include/ck_pr.h index eb198f5..af4159e 100644 --- a/include/ck_pr.h +++ b/include/ck_pr.h @@ -1149,4 +1149,3 @@ CK_PR_FAS_S(8, uint8_t) #undef CK_PR_FAS #endif /* _CK_PR_H */ - diff --git a/include/ck_queue.h b/include/ck_queue.h index 3d8824f..f617b97 100644 --- a/include/ck_queue.h +++ b/include/ck_queue.h @@ -415,4 +415,3 @@ struct { \ } while (0) #endif /* _CK_QUEUE_H */ - diff --git a/include/ck_rhs.h b/include/ck_rhs.h index 7a28f7d..edf852f 100644 --- a/include/ck_rhs.h +++ b/include/ck_rhs.h @@ -48,7 +48,7 @@ */ #define CK_RHS_MODE_DIRECT 2 -/* +/* * Indicates that the values to be stored are pointers. * Allows for space optimizations in the presence of pointer * packing. Mutually exclusive with CK_RHS_MODE_DIRECT. diff --git a/include/ck_ring.h b/include/ck_ring.h index 88bb837..c70915c 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -307,7 +307,7 @@ _ck_ring_dequeue_spmc(struct ck_ring *ring, return false; ck_pr_fence_load(); - + target = (char *)buffer + size * (consumer & mask); memcpy(data, target, size); @@ -432,4 +432,3 @@ ck_ring_dequeue_spmc_##name(struct ck_ring *a, \ ck_ring_dequeue_spmc_##name(a, b, c) #endif /* _CK_RING_H */ - diff --git a/include/ck_rwcohort.h b/include/ck_rwcohort.h index e8e014e..c9b5d2a 100644 --- a/include/ck_rwcohort.h +++ b/include/ck_rwcohort.h @@ -315,4 +315,3 @@ } #endif /* _CK_RWCOHORT_H */ - diff --git a/include/ck_rwlock.h b/include/ck_rwlock.h index 63cb549..89a006a 100644 --- a/include/ck_rwlock.h +++ b/include/ck_rwlock.h @@ -295,4 +295,3 @@ ck_rwlock_recursive_read_unlock(ck_rwlock_recursive_t *rw) } #endif /* _CK_RWLOCK_H */ - diff --git a/include/ck_sequence.h b/include/ck_sequence.h index 14138ff..b7fcb48 100644 --- a/include/ck_sequence.h +++ b/include/ck_sequence.h @@ -123,4 +123,3 @@ ck_sequence_write_end(struct ck_sequence *sq) } #endif /* _CK_SEQUENCE_H */ - diff --git a/include/ck_spinlock.h b/include/ck_spinlock.h index 03f9900..3e07b77 100644 --- a/include/ck_spinlock.h +++ b/include/ck_spinlock.h @@ -59,4 +59,3 @@ CK_ELIDE_TRYLOCK_PROTOTYPE(ck_spinlock, ck_spinlock_t, ck_spinlock_locked, ck_spinlock_trylock) #endif /* _CK_SPINLOCK_H */ - diff --git a/include/ck_stack.h b/include/ck_stack.h index ac89a95..21d3f0f 100644 --- a/include/ck_stack.h +++ b/include/ck_stack.h @@ -352,4 +352,3 @@ ck_stack_init(struct ck_stack *stack) (entry) = (T)) #endif /* _CK_STACK_H */ - diff --git a/include/ck_stdint.h b/include/ck_stdint.h index 1dfd373..e62cafa 100644 --- a/include/ck_stdint.h +++ b/include/ck_stdint.h @@ -30,4 +30,3 @@ #else #include #endif /* __linux__ && __KERNEL__ */ - diff --git a/include/ck_swlock.h b/include/ck_swlock.h index 134df6c..d880aaf 100644 --- a/include/ck_swlock.h +++ b/include/ck_swlock.h @@ -215,4 +215,3 @@ CK_ELIDE_PROTOTYPE(ck_swlock_read, ck_swlock_t, ck_swlock_locked_reader, ck_swlock_read_unlock) #endif /* _CK_SWLOCK_H */ - diff --git a/include/ck_tflock.h b/include/ck_tflock.h index 391fb73..3bb43d5 100644 --- a/include/ck_tflock.h +++ b/include/ck_tflock.h @@ -32,7 +32,7 @@ * described in: * John M. Mellor-Crummey and Michael L. Scott. 1991. * Scalable reader-writer synchronization for shared-memory - * multiprocessors. SIGPLAN Not. 26, 7 (April 1991), 106-113. + * multiprocessors. SIGPLAN Not. 26, 7 (April 1991), 106-113. */ #include @@ -65,7 +65,7 @@ ck_tflock_ticket_fca_32(uint32_t *target, uint32_t mask, uint32_t delta) ck_pr_stall(); } - + return snapshot; } diff --git a/include/gcc/arm/ck_pr.h b/include/gcc/arm/ck_pr.h index 0c2400c..7222680 100644 --- a/include/gcc/arm/ck_pr.h +++ b/include/gcc/arm/ck_pr.h @@ -135,7 +135,7 @@ ck_pr_load_64(const uint64_t *target) register uint64_t ret asm("r0"); __asm __volatile("ldrd %0, [%1]" : "+r" (ret) - : "r" (target) + : "r" (target) : "memory", "cc"); return (ret); } @@ -262,7 +262,7 @@ ck_pr_cas_ptr_value(void *target, void *compare, void *set, void *value) "=&r" (tmp) : "r" (target), "r" (set), - "r" (compare) + "r" (compare) : "memory", "cc"); *(void **)value = previous; return (previous == compare); @@ -283,7 +283,7 @@ ck_pr_cas_ptr(void *target, void *compare, void *set) "=&r" (tmp) : "r" (target), "r" (set), - "r" (compare) + "r" (compare) : "memory", "cc"); return (previous == compare); } diff --git a/include/spinlock/hclh.h b/include/spinlock/hclh.h index edaeaca..0eac6b9 100644 --- a/include/spinlock/hclh.h +++ b/include/spinlock/hclh.h @@ -98,7 +98,7 @@ ck_spinlock_hclh_lock(struct ck_spinlock_hclh **glob_queue, /* We're head of the global queue, we're done */ if (ck_pr_load_uint(&previous->splice) == false) return; - } + } /* Now we need to splice the local queue into the global queue. */ local_tail = ck_pr_load_ptr(local_queue); diff --git a/regressions/ck_hp/validate/ck_hp_fifo_donner.c b/regressions/ck_hp/validate/ck_hp_fifo_donner.c index 43e00ae..a2f31c9 100644 --- a/regressions/ck_hp/validate/ck_hp_fifo_donner.c +++ b/regressions/ck_hp/validate/ck_hp_fifo_donner.c @@ -43,7 +43,7 @@ static ck_hp_fifo_t fifo; static ck_hp_t fifo_hp; /* thread local element count */ -static unsigned long *count; +static unsigned long *count; static unsigned long thread_count; @@ -77,10 +77,10 @@ queue_50_50(void *elements) record = malloc(sizeof(ck_hp_record_t)); assert(record); - + slots = malloc(CK_HP_FIFO_SLOTS_SIZE); assert(slots); - + /* different seed for each thread */ seed = 1337; /*(unsigned int) pthread_self(); */ @@ -166,7 +166,7 @@ main(int argc, char** argv) /* array for local operation count */ count = malloc(sizeof(unsigned long *) * thread_count); - + /* * Initialize global hazard pointer safe memory reclamation to execute free() * when a fifo_entry is safe to be deleted. diff --git a/regressions/ck_hs/benchmark/parallel_bytestring.c b/regressions/ck_hs/benchmark/parallel_bytestring.c index ea2eaec..e2e15c9 100644 --- a/regressions/ck_hs/benchmark/parallel_bytestring.c +++ b/regressions/ck_hs/benchmark/parallel_bytestring.c @@ -144,7 +144,7 @@ set_init(void) #ifdef HS_DELETE mode |= CK_HS_MODE_DELETE; -#endif +#endif ck_epoch_init(&epoch_hs); ck_epoch_register(&epoch_hs, &epoch_wr); diff --git a/regressions/ck_ring/validate/ck_ring_spmc.c b/regressions/ck_ring/validate/ck_ring_spmc.c index 23fe0fa..9563a8f 100644 --- a/regressions/ck_ring/validate/ck_ring_spmc.c +++ b/regressions/ck_ring/validate/ck_ring_spmc.c @@ -197,7 +197,7 @@ test(void *c) for (i = 0; i < ITERATIONS; i++) { for (j = 0; j < size; j++) { buffer = _context[context->previous].buffer; - while (ck_ring_dequeue_spmc(ring + context->previous, + while (ck_ring_dequeue_spmc(ring + context->previous, buffer, &entry) == false); if (context->previous != (unsigned int)entry->tid) { @@ -315,7 +315,7 @@ main(int argc, char *argv[]) /* Wait until queue is not full. */ if (l & 1) { while (ck_ring_enqueue_spmc(&ring_spmc, - buffer, + buffer, entry) == false) ck_pr_stall(); } else { diff --git a/regressions/ck_ring/validate/ck_ring_spmc_template.c b/regressions/ck_ring/validate/ck_ring_spmc_template.c index 9facbc7..456fb97 100644 --- a/regressions/ck_ring/validate/ck_ring_spmc_template.c +++ b/regressions/ck_ring/validate/ck_ring_spmc_template.c @@ -200,7 +200,7 @@ test(void *c) for (j = 0; j < size; j++) { buffer = _context[context->previous].buffer; while (CK_RING_DEQUEUE_SPMC(entry, - ring + context->previous, + ring + context->previous, buffer, &entry) == false); if (context->previous != (unsigned int)entry->tid) { diff --git a/regressions/common.h b/regressions/common.h index f100e89..4322a07 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -289,7 +289,7 @@ CK_CC_UNUSED static int aff_iterate_core(struct affinity *acb, unsigned int *core) { cpu_set_t s; - + *core = ck_pr_faa_uint(&acb->request, acb->delta); CPU_ZERO(&s); CPU_SET((*core) % CORES, &s); @@ -454,4 +454,3 @@ ck_error(const char *message, ...) va_end(ap); exit(EXIT_FAILURE); } - diff --git a/src/ck_epoch.c b/src/ck_epoch.c index 343667c..ebb0aaa 100644 --- a/src/ck_epoch.c +++ b/src/ck_epoch.c @@ -87,7 +87,7 @@ * at e_g - 1 to still be accessed at e_g as threads are "active" * at the same time (real-world time) mutating shared objects. * - * Now, if the epoch counter is ticked to e_g + 1, then no new + * Now, if the epoch counter is ticked to e_g + 1, then no new * hazardous references could exist to objects logically deleted at * e_g - 1. The reason for this is that at e_g + 1, all epoch read-side * critical sections started at e_g - 1 must have been completed. If @@ -118,7 +118,7 @@ * sufficient to represent e_g using only the values 0, 1 or 2. Every time * a thread re-visits a e_g (which can be determined with a non-empty deferral * list) it can assume objects in the e_g deferral list involved at least - * three e_g transitions and are thus, safe, for physical deletion. + * three e_g transitions and are thus, safe, for physical deletion. * * Blocking semantics for epoch reclamation have additional restrictions. * Though we only require three deferral lists, reasonable blocking semantics diff --git a/src/ck_hs.c b/src/ck_hs.c index 76bf832..ea77b9a 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -598,7 +598,7 @@ ck_hs_gc(struct ck_hs *hs, unsigned long cycles, unsigned long seed) if (maximum != map->probe_maximum) ck_pr_store_uint(&map->probe_maximum, maximum); - if (bounds != NULL) { + if (bounds != NULL) { for (i = 0; i < map->capacity; i++) CK_HS_STORE(&map->probe_bound[i], bounds[i]); @@ -851,7 +851,7 @@ ck_hs_get(struct ck_hs *hs, unsigned int g, g_p, probe; unsigned int *generation; - do { + do { map = ck_pr_load_ptr(&hs->map); generation = &map->generation[h & CK_HS_G_MASK]; g = ck_pr_load_uint(generation); diff --git a/src/ck_ht.c b/src/ck_ht.c index ea9de1e..b6d74c1 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -395,7 +395,7 @@ ck_ht_gc(struct ck_ht *ht, unsigned long cycles, unsigned long seed) return true; } - + if (cycles == 0) { maximum = 0; diff --git a/src/ck_ht_hash.h b/src/ck_ht_hash.h index 254e3b8..075c2c1 100644 --- a/src/ck_ht_hash.h +++ b/src/ck_ht_hash.h @@ -175,7 +175,7 @@ static inline uint64_t MurmurHash64A ( const void * key, int len, uint64_t seed while(data != end) { uint64_t k; - + if (!((uintptr_t)data & 0x7)) k = *data++; else { diff --git a/src/ck_rhs.c b/src/ck_rhs.c index 962a94c..a043ac6 100644 --- a/src/ck_rhs.c +++ b/src/ck_rhs.c @@ -327,11 +327,11 @@ ck_rhs_map_create(struct ck_rhs *hs, unsigned long entries) if (hs->mode & CK_RHS_MODE_READ_MOSTLY) size = sizeof(struct ck_rhs_map) + (sizeof(void *) * n_entries + - sizeof(struct ck_rhs_no_entry_desc) * n_entries + + sizeof(struct ck_rhs_no_entry_desc) * n_entries + 2 * CK_MD_CACHELINE - 1); else size = sizeof(struct ck_rhs_map) + - (sizeof(struct ck_rhs_entry_desc) * n_entries + + (sizeof(struct ck_rhs_entry_desc) * n_entries + CK_MD_CACHELINE - 1); map = hs->m->malloc(size); if (map == NULL) @@ -408,7 +408,7 @@ ck_rhs_map_probe_next(struct ck_rhs_map *map, { if (probes & map->offset_mask) { - offset = (offset &~ map->offset_mask) + + offset = (offset &~ map->offset_mask) + ((offset + 1) & map->offset_mask); return offset; } else @@ -421,10 +421,10 @@ ck_rhs_map_probe_prev(struct ck_rhs_map *map, unsigned long offset, { if (probes & map->offset_mask) { - offset = (offset &~ map->offset_mask) + ((offset - 1) & + offset = (offset &~ map->offset_mask) + ((offset - 1) & map->offset_mask); return offset; - } else + } else return ((offset - probes) & map->mask); } @@ -616,7 +616,7 @@ ck_rhs_map_probe_rm(struct ck_rhs *hs, if (behavior != CK_RHS_PROBE_NO_RH) { struct ck_rhs_entry_desc *desc = (void *)&map->entries.no_entries.descs[offset]; - if (pr == -1 && + if (pr == -1 && desc->in_rh == false && desc->probes < probes) { pr = offset; *n_probes = probes; @@ -730,7 +730,7 @@ ck_rhs_map_probe(struct ck_rhs *hs, if ((behavior != CK_RHS_PROBE_NO_RH)) { struct ck_rhs_entry_desc *desc = &map->entries.descs[offset]; - if (pr == -1 && + if (pr == -1 && desc->in_rh == false && desc->probes < probes) { pr = offset; *n_probes = probes; @@ -818,7 +818,7 @@ ck_rhs_gc(struct ck_rhs *hs) } static void -ck_rhs_add_wanted(struct ck_rhs *hs, long end_offset, long old_slot, +ck_rhs_add_wanted(struct ck_rhs *hs, long end_offset, long old_slot, unsigned long h) { struct ck_rhs_map *map = hs->map; @@ -872,7 +872,7 @@ ck_rhs_get_first_offset(struct ck_rhs_map *map, unsigned long offset, unsigned i while (probes > (unsigned long)map->offset_mask + 1) { offset -= ((probes - 1) &~ map->offset_mask); offset &= map->mask; - offset = (offset &~ map->offset_mask) + + offset = (offset &~ map->offset_mask) + ((offset - map->offset_mask) & map->offset_mask); probes -= map->offset_mask + 1; } @@ -948,7 +948,7 @@ restart: prev = prevs[--prevs_nb]; ck_pr_store_ptr(ck_rhs_entry_addr(map, orig_slot), ck_rhs_entry(map, prev)); - h = ck_rhs_get_first_offset(map, orig_slot, + h = ck_rhs_get_first_offset(map, orig_slot, desc->probes); ck_rhs_add_wanted(hs, orig_slot, prev, h); ck_pr_inc_uint(&map->generation[h & CK_RHS_G_MASK]); @@ -966,7 +966,7 @@ ck_rhs_do_backward_shift_delete(struct ck_rhs *hs, long slot) struct ck_rhs_map *map = hs->map; struct ck_rhs_entry_desc *desc, *new_desc = NULL; unsigned long h; - + desc = ck_rhs_desc(map, slot); h = ck_rhs_remove_wanted(hs, slot, -1); while (desc->wanted > 0) { @@ -1140,7 +1140,7 @@ restart: * period if we can guarantee earlier position of * duplicate key. */ - ck_rhs_add_wanted(hs, first, -1, h); + ck_rhs_add_wanted(hs, first, -1, h); if (object != NULL) { ck_pr_inc_uint(&map->generation[h & CK_RHS_G_MASK]); ck_pr_fence_atomic_store(); @@ -1155,7 +1155,7 @@ restart: ck_pr_store_ptr(ck_rhs_entry_addr(map, slot), insert); ck_rhs_set_probes(map, slot, n_probes); if (object == NULL) - ck_rhs_add_wanted(hs, slot, -1, h); + ck_rhs_add_wanted(hs, slot, -1, h); } if (object == NULL) { @@ -1209,12 +1209,12 @@ restart: /* Insert key into first bucket in probe sequence. */ ck_pr_store_ptr(ck_rhs_entry_addr(map, first), insert); desc->probes = n_probes; - ck_rhs_add_wanted(hs, first, -1, h); + ck_rhs_add_wanted(hs, first, -1, h); } else { /* An empty slot was found. */ ck_pr_store_ptr(ck_rhs_entry_addr(map, slot), insert); ck_rhs_set_probes(map, slot, n_probes); - ck_rhs_add_wanted(hs, slot, -1, h); + ck_rhs_add_wanted(hs, slot, -1, h); } map->n_entries++; @@ -1253,7 +1253,7 @@ ck_rhs_get(struct ck_rhs *hs, unsigned int g, g_p, probe; unsigned int *generation; - do { + do { map = ck_pr_load_ptr(&hs->map); generation = &map->generation[h & CK_RHS_G_MASK]; g = ck_pr_load_uint(generation); From 744b525528a9a386c0357451751d39a7e2de5d62 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 20:01:27 -0400 Subject: [PATCH 25/49] ck_hs: Account for deletions in apply accounting. --- src/ck_hs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ck_hs.c b/src/ck_hs.c index ea77b9a..5808876 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -686,6 +686,8 @@ restart: /* Otherwise, mark slot as deleted. */ ck_pr_store_ptr(slot, CK_HS_TOMBSTONE); + map->n_entries--; + map->tombstones++; return true; } From 80a556e4fc22d988eb8f39badd7ddfbb7afd318e Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 20:13:31 -0400 Subject: [PATCH 26/49] doc: Add ck_hs_apply manual page. --- doc/Makefile.in | 1 + doc/ck_hs_apply | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 doc/ck_hs_apply diff --git a/doc/Makefile.in b/doc/Makefile.in index 3f90ddb..0c2dc26 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -74,6 +74,7 @@ OBJECTS=CK_ARRAY_FOREACH \ ck_hs_init \ ck_hs_destroy \ CK_HS_HASH \ + ck_hs_apply \ ck_hs_iterator_init \ ck_hs_next \ ck_hs_get \ diff --git a/doc/ck_hs_apply b/doc/ck_hs_apply new file mode 100644 index 0000000..5664f73 --- /dev/null +++ b/doc/ck_hs_apply @@ -0,0 +1,86 @@ +.\" +.\" Copyright 2014 Samy Al Bahra. +.\" Copyright 2014 Backtrace I/O, Inc. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 1, 2014 +.Dt CK_HS_APPLY 3 +.Sh NAME +.Nm ck_hs_apply +.Nd apply a function to hash set value +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_hs.h +.Ft void * +.Fn ck_hs_apply_fn_t "void *key" "void *closure" +.Ft bool +.Fn ck_hs_apply "ck_hs_t *hs" "unsigned long hash" "const void *key" "ck_hs_apply_fn_t *function" "void *argument" +.Sh DESCRIPTION +The +.Fn ck_hs_apply 3 +function will lookup the hash set slot associated with +.Fa key +and pass it to function pointed to by +.Fa function +for further action. This callback may remove or replace +the value by respectively returning NULL or a pointer to +another object with an identical key. The first argument +passed to +.Fa function +is a pointer to the object found in the hash set and +the second argument is the +.Fa argument +pointer passed to +.Fn ck_hs_apply 3 . +If the pointer returned by +.Fa function +is equivalent to the first argument then no modification +is made to the hash set. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_hs_apply 3 +returns true and otherwise returns false on failure. +.Sh SEE ALSO +.Xr ck_hs_init 3 , +.Xr ck_hs_move 3 , +.Xr ck_hs_destroy 3 , +.Xr ck_hs_fas 3 , +.Xr CK_HS_HASH 3 , +.Xr ck_hs_iterator_init 3 , +.Xr ck_hs_next 3 , +.Xr ck_hs_get 3 , +.Xr ck_hs_put 3 , +.Xr ck_hs_put_unique 3 , +.Xr ck_hs_remove 3 , +.Xr ck_hs_grow 3 , +.Xr ck_hs_rebuild 3 , +.Xr ck_hs_gc 3 , +.Xr ck_hs_count 3 , +.Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , +.Xr ck_hs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ From e0f56ea1135af29ebefd7a69ee8477e71f34e82b Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 20:14:26 -0400 Subject: [PATCH 27/49] whitespace: Whitespace clean-up of manual pages. --- doc/CK_COHORT_INIT | 6 +++--- doc/CK_COHORT_LOCK | 6 +++--- doc/CK_COHORT_PROTOTYPE | 2 +- doc/CK_COHORT_TRYLOCK | 10 +++++----- doc/CK_COHORT_TRYLOCK_PROTOTYPE | 4 ++-- doc/CK_COHORT_UNLOCK | 6 +++--- doc/CK_RWCOHORT_INIT | 4 ++-- doc/CK_RWCOHORT_INSTANCE | 4 ++-- doc/CK_RWCOHORT_PROTOTYPE | 4 ++-- doc/CK_RWCOHORT_READ_LOCK | 18 +++++++++--------- doc/CK_RWCOHORT_READ_UNLOCK | 16 ++++++++-------- doc/CK_RWCOHORT_WRITE_LOCK | 18 +++++++++--------- doc/CK_RWCOHORT_WRITE_UNLOCK | 16 ++++++++-------- doc/ck_cohort | 6 +++--- doc/ck_elide | 4 ++-- doc/ck_epoch_call | 2 +- doc/ck_epoch_init | 2 +- doc/ck_hs_fas | 4 ++-- doc/ck_hs_move | 2 +- doc/ck_hs_next | 2 +- doc/ck_hs_set | 2 +- doc/ck_pr | 4 ++-- doc/ck_pr_add | 4 ++-- doc/ck_pr_and | 6 +++--- doc/ck_pr_barrier | 4 ++-- doc/ck_pr_btc | 6 +++--- doc/ck_pr_btr | 6 +++--- doc/ck_pr_bts | 6 +++--- doc/ck_pr_cas | 6 +++--- doc/ck_pr_dec | 4 ++-- doc/ck_pr_faa | 4 ++-- doc/ck_pr_fas | 4 ++-- doc/ck_pr_fence_acquire | 2 +- doc/ck_pr_fence_atomic | 8 ++++---- doc/ck_pr_fence_atomic_load | 8 ++++---- doc/ck_pr_fence_atomic_store | 8 ++++---- doc/ck_pr_fence_load | 2 +- doc/ck_pr_fence_load_atomic | 2 +- doc/ck_pr_fence_load_depends | 4 ++-- doc/ck_pr_fence_load_store | 2 +- doc/ck_pr_fence_memory | 4 ++-- doc/ck_pr_fence_release | 2 +- doc/ck_pr_fence_store | 4 ++-- doc/ck_pr_fence_store_atomic | 6 +++--- doc/ck_pr_fence_store_load | 6 +++--- doc/ck_pr_inc | 4 ++-- doc/ck_pr_load | 4 ++-- doc/ck_pr_neg | 4 ++-- doc/ck_pr_not | 4 ++-- doc/ck_pr_or | 6 +++--- doc/ck_pr_rtm | 2 +- doc/ck_pr_stall | 6 +++--- doc/ck_pr_store | 4 ++-- doc/ck_pr_sub | 4 ++-- doc/ck_pr_xor | 6 +++--- doc/ck_ring_dequeue_spmc | 2 +- doc/ck_ring_dequeue_spsc | 2 +- doc/ck_ring_enqueue_spmc | 6 +++--- doc/ck_ring_enqueue_spmc_size | 6 +++--- doc/ck_ring_enqueue_spsc | 6 +++--- doc/ck_ring_enqueue_spsc_size | 6 +++--- doc/ck_ring_trydequeue_spmc | 4 ++-- doc/ck_rwcohort | 4 ++-- doc/ck_spinlock | 2 +- 64 files changed, 166 insertions(+), 166 deletions(-) diff --git a/doc/CK_COHORT_INIT b/doc/CK_COHORT_INIT index 42a2294..94454d9 100644 --- a/doc/CK_COHORT_INIT +++ b/doc/CK_COHORT_INIT @@ -38,7 +38,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION Until a cohort instance is initialized using the CK_COHORT_INIT macro, any operations involving it will have undefined behavior. After this macro has been called, the cohort -pointed to by the +pointed to by the .Fa cohort argument will use the lock pointed to by .Fa global_lock @@ -48,8 +48,8 @@ as its local lock. .Pp The cohort will relinquish its global lock after .Fa pass_limit -consecutive acquisitions of its local lock, even if there are other threads waiting. -If you are unsure of a value to use for the +consecutive acquisitions of its local lock, even if there are other threads waiting. +If you are unsure of a value to use for the .Fa pass_limit argument, you should use CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT. .Sh SEE ALSO diff --git a/doc/CK_COHORT_LOCK b/doc/CK_COHORT_LOCK index df39ad4..22475f8 100644 --- a/doc/CK_COHORT_LOCK +++ b/doc/CK_COHORT_LOCK @@ -38,11 +38,11 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION This call attempts to acquire both the local and global (if necessary) locks from .Fa cohort . -The call will block until both locks have been acquired. +The call will block until both locks have been acquired. .Fa global_context -will be passed as the second argument to the function that was provided as the +will be passed as the second argument to the function that was provided as the .Fa global_lock_method -argument to CK_COHORT_PROTOTYPE if that method is called, and +argument to CK_COHORT_PROTOTYPE if that method is called, and .Fa local_context will be passed to the function specified by .Fa local_lock_method diff --git a/doc/CK_COHORT_PROTOTYPE b/doc/CK_COHORT_PROTOTYPE index f058fb8..7a7b1a7 100644 --- a/doc/CK_COHORT_PROTOTYPE +++ b/doc/CK_COHORT_PROTOTYPE @@ -37,7 +37,7 @@ Concurrency Kit (libck, \-lck) "LOCK_FXN global_unlock_method" "LOCK_FXN local_lock_method" "LOCK_FXN local_unlock_method" .Sh DESCRIPTION The ck_cohort.h header file does not define any cohort types. Instead, the user must use -the CK_COHORT_PROTOTYPE or +the CK_COHORT_PROTOTYPE or .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 macros to define any types they want to use. They must use CK_COHORT_TRYLOCK_PROTOTYPE if they want their cohort type to support trylock operations. diff --git a/doc/CK_COHORT_TRYLOCK b/doc/CK_COHORT_TRYLOCK index fd9306e..22bb4b5 100644 --- a/doc/CK_COHORT_TRYLOCK +++ b/doc/CK_COHORT_TRYLOCK @@ -38,18 +38,18 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION This call attempts to acquire both the local and global (if necessary) locks from .Fa cohort . -It can only be used with cohort types that were defined using the +It can only be used with cohort types that were defined using the .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 macro. The call will not block and will return a bool that will evaluate to true iff -the cohort was successfully acquired. +the cohort was successfully acquired. .Fa global_trylock_context -will be passed as the second argument to the function that was provided as the +will be passed as the second argument to the function that was provided as the .Fa global_trylock_method -argument to CK_COHORT_TRYLOCK_PROTOTYPE if that method is called, and +argument to CK_COHORT_TRYLOCK_PROTOTYPE if that method is called, and .Fa local_trylock_context will be passed to the function specified by .Fa local_trylock_method . -If the global lock acquisition fails, then the cohort will immediately release its +If the global lock acquisition fails, then the cohort will immediately release its local lock as well, and .Fa local_unlock_context will be passed to the function specified by diff --git a/doc/CK_COHORT_TRYLOCK_PROTOTYPE b/doc/CK_COHORT_TRYLOCK_PROTOTYPE index 7edc032..dd97ad4 100644 --- a/doc/CK_COHORT_TRYLOCK_PROTOTYPE +++ b/doc/CK_COHORT_TRYLOCK_PROTOTYPE @@ -57,7 +57,7 @@ of the other CK_COHORT macros. : This method should return true iff the global lock is acquired by a thread. .br .Fa global_trylock_method -: The method that should be called to try to acquire the global lock. +: The method that should be called to try to acquire the global lock. It should not block and return true iff the lock was successfully acquired. .br .Fa local_lock_method @@ -70,7 +70,7 @@ It should not block and return true iff the lock was successfully acquired. : This method should return true iff the global lock is acquired by a thread. .br .Fa local_trylock_method -: The method that should be called to try to acquire the local lock. +: The method that should be called to try to acquire the local lock. It should not block and return true iff the lock was successfully acquired. .Pp Instances of the defined cohort type can be declared as: diff --git a/doc/CK_COHORT_UNLOCK b/doc/CK_COHORT_UNLOCK index 6c5440a..a9f302f 100644 --- a/doc/CK_COHORT_UNLOCK +++ b/doc/CK_COHORT_UNLOCK @@ -38,11 +38,11 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION This call instructs .Fa cohort -to relinquish its local lock and potentially its global lock as well. +to relinquish its local lock and potentially its global lock as well. .Fa global_context -will be passed as the second argument to the function that was provided as the +will be passed as the second argument to the function that was provided as the .Fa global_lock_method -argument to CK_COHORT_PROTOTYPE if that method is called, and +argument to CK_COHORT_PROTOTYPE if that method is called, and .Fa local_context will be passed to the function specified by .Fa local_lock_method diff --git a/doc/CK_RWCOHORT_INIT b/doc/CK_RWCOHORT_INIT index e097039..18d1b33 100644 --- a/doc/CK_RWCOHORT_INIT +++ b/doc/CK_RWCOHORT_INIT @@ -40,11 +40,11 @@ Concurrency Kit (libck, \-lck) This macro initializes the lock instance pointed to by the .Fa lock argument. Until a lock instance is initialized using the CK_RWCOHORT_INIT macro, any operations -involving it will have undefined behavior. Note that the +involving it will have undefined behavior. Note that the .Fa wait_limit argument should only be used with reader-preference or writer-preference locks. For neutral locks, this argument should be excluded. -If you are unsure of a value to use for the +If you are unsure of a value to use for the .Fa wait_limit argument, you should use CK_RWCOHORT_STRATEGY_DEFAULT_LOCAL_WAIT_LIMIT. .Sh SEE ALSO diff --git a/doc/CK_RWCOHORT_INSTANCE b/doc/CK_RWCOHORT_INSTANCE index fcdfeea..10251a3 100644 --- a/doc/CK_RWCOHORT_INSTANCE +++ b/doc/CK_RWCOHORT_INSTANCE @@ -38,9 +38,9 @@ Concurrency Kit (libck, \-lck) .Fn CK_RWCOHORT_WP_INSTANCE "COHORT_NAME cohort_name" .Sh DESCRIPTION The user must use this macro to declare instances of lock types that they have -defined using the +defined using the .Xr CK_RWCOHORT_PROTOTYPE 3 -macro. The cohort_name must be the same as the one used in the prototype macro. +macro. The cohort_name must be the same as the one used in the prototype macro. For instance, if CK_RWCOHORT_PROTOTYPE was called with the name "foo", the CK_RWCOHORT_INSTANCE macro should be called as .br diff --git a/doc/CK_RWCOHORT_PROTOTYPE b/doc/CK_RWCOHORT_PROTOTYPE index fb4d25a..a2705b6 100644 --- a/doc/CK_RWCOHORT_PROTOTYPE +++ b/doc/CK_RWCOHORT_PROTOTYPE @@ -41,9 +41,9 @@ The ck_rwcohort.h header file does not define any cohort types. Instead, the us the CK_RWCOHORT_PROTOTYPE macro to define any types they want to use. This macro takes a single argument which corresponds to the type of the cohort lock that the reader-writer lock should use. A cohort type must have already been defined with that name -using the +using the .Xr CK_COHORT_PROTOTYPE 3 -or +or .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 macros. .Pp diff --git a/doc/CK_RWCOHORT_READ_LOCK b/doc/CK_RWCOHORT_READ_LOCK index bf65853..62831ea 100644 --- a/doc/CK_RWCOHORT_READ_LOCK +++ b/doc/CK_RWCOHORT_READ_LOCK @@ -33,24 +33,24 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_NEUTRAL_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_RP_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_WP_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" .Sh DESCRIPTION This call will acquire read-only permission from .Fa lock . -The call will block until this permission has been acquired. -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with +The call will block until this permission has been acquired. +.Fa cohort +must point to a cohort whose global lock is the same as all other cohorts used with .Fa lock . The -.Fa global_context +.Fa global_context and -.Fa local_context -arguments will be passed along as the context arguments to any calls to +.Fa local_context +arguments will be passed along as the context arguments to any calls to .Fa cohort . . .Sh SEE ALSO diff --git a/doc/CK_RWCOHORT_READ_UNLOCK b/doc/CK_RWCOHORT_READ_UNLOCK index 4dd26e1..1c81801 100644 --- a/doc/CK_RWCOHORT_READ_UNLOCK +++ b/doc/CK_RWCOHORT_READ_UNLOCK @@ -33,23 +33,23 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_NEUTRAL_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_RP_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_WP_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" .Sh DESCRIPTION This call will relinquish read-only permission to .Fa lock . -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with +.Fa cohort +must point to a cohort whose global lock is the same as all other cohorts used with .Fa lock . The -.Fa global_context +.Fa global_context and -.Fa local_context -arguments will be passed along as the context arguments to any calls to +.Fa local_context +arguments will be passed along as the context arguments to any calls to .Fa cohort . . .Sh SEE ALSO diff --git a/doc/CK_RWCOHORT_WRITE_LOCK b/doc/CK_RWCOHORT_WRITE_LOCK index 0977cb7..161c7bb 100644 --- a/doc/CK_RWCOHORT_WRITE_LOCK +++ b/doc/CK_RWCOHORT_WRITE_LOCK @@ -33,24 +33,24 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_NEUTRAL_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_RP_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_WP_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" .Sh DESCRIPTION This call will acquire write permission for .Fa lock . -The call will block until this permission has been acquired. -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with +The call will block until this permission has been acquired. +.Fa cohort +must point to a cohort whose global lock is the same as all other cohorts used with .Fa lock . The -.Fa global_context +.Fa global_context and -.Fa local_context -arguments will be passed along as the context arguments to any calls to +.Fa local_context +arguments will be passed along as the context arguments to any calls to .Fa cohort . . .Sh SEE ALSO diff --git a/doc/CK_RWCOHORT_WRITE_UNLOCK b/doc/CK_RWCOHORT_WRITE_UNLOCK index c3537bf..5772a9f 100644 --- a/doc/CK_RWCOHORT_WRITE_UNLOCK +++ b/doc/CK_RWCOHORT_WRITE_UNLOCK @@ -33,23 +33,23 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_NEUTRAL_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_RP_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ +.Fn CK_RWCOHORT_WP_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ "void *global_context" "void *local_context" .Sh DESCRIPTION This call will relinquish write permission for .Fa lock . -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with +.Fa cohort +must point to a cohort whose global lock is the same as all other cohorts used with .Fa lock . The -.Fa global_context +.Fa global_context and -.Fa local_context -arguments will be passed along as the context arguments to any calls to +.Fa local_context +arguments will be passed along as the context arguments to any calls to .Fa cohort . . .Sh SEE ALSO diff --git a/doc/ck_cohort b/doc/ck_cohort index b033c91..4905418 100644 --- a/doc/ck_cohort +++ b/doc/ck_cohort @@ -57,7 +57,7 @@ BOOL_LOCK_FXN refers to a method with the signature bool(void *lock, void *context) .Pp The -.Fa context +.Fa context argument in each signature is used to pass along any additional information that the lock might need for its lock, unlock and trylock methods. The values for this argument are provided to each call to @@ -94,7 +94,7 @@ man pages for more details. #include #include -/* +/* * Create cohort methods with signatures that match * the required signature */ @@ -169,7 +169,7 @@ main(void) calloc(n_cohorts, sizeof(CK_COHORT_INSTANCE(test_cohort))); /* create local locks to use with each cohort */ - ck_spinlock_t *local_locks = + ck_spinlock_t *local_locks = calloc(n_cohorts, sizeof(ck_spinlock_t)); pthread_t *threads = diff --git a/doc/ck_elide b/doc/ck_elide index 3a63e74..c068567 100644 --- a/doc/ck_elide +++ b/doc/ck_elide @@ -100,7 +100,7 @@ returns true, then the .Fa UNLOCK_FUNCTION is executed. If RTM is unsupported (no CK_F_PR_RTM macro) then .Fn CK_ELIDE_LOCK -and +and .Fn CK_ELIDE_LOCK_ADAPTIVE will immediately call .Fn LOCK_FUNCTION . @@ -118,7 +118,7 @@ Elision is attempted if the .Fa LOCK_PREDICATE function returns false. If .Fa LOCK_PREDICATE -returns true or if elision fails then the +returns true or if elision fails then the operation is aborted. If RTM is unsupported (no CK_F_PR_RTM macro) then .Fn CK_ELIDE_TRYLOCK diff --git a/doc/ck_epoch_call b/doc/ck_epoch_call index 4f6286e..288814e 100644 --- a/doc/ck_epoch_call +++ b/doc/ck_epoch_call @@ -46,7 +46,7 @@ function will defer the execution of the function pointed to by until a grace-period has been detected in .Fa epoch . The function will be provided -the pointer specified by +the pointer specified by .Fa entry . The function will execute at some time in the future via calls to .Fn ck_epoch_reclaim 3 , diff --git a/doc/ck_epoch_init b/doc/ck_epoch_init index e22294d..51a3e2a 100644 --- a/doc/ck_epoch_init +++ b/doc/ck_epoch_init @@ -52,7 +52,7 @@ is undefined if .Fa epoch is not a pointer to a .Tn ck_epoch_t -object. +object. .El .Sh SEE ALSO .Xr ck_epoch_register 3 , diff --git a/doc/ck_hs_fas b/doc/ck_hs_fas index 213cef6..69760b5 100644 --- a/doc/ck_hs_fas +++ b/doc/ck_hs_fas @@ -57,7 +57,7 @@ was successful then the key specified by was successfully stored in the hash set pointed to by .Fa hs . The key must already exist in the hash set, and is -replaced by +replaced by .Fa key and the previous value is stored into the void pointer pointed to by the @@ -75,7 +75,7 @@ Behavior is undefined if .Fa key or .Fa hs -are uninitialized. +are uninitialized. .Sh SEE ALSO .Xr ck_hs_init 3 , .Xr ck_hs_move 3 , diff --git a/doc/ck_hs_move b/doc/ck_hs_move index e843ea7..1d30195 100644 --- a/doc/ck_hs_move +++ b/doc/ck_hs_move @@ -38,7 +38,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_hs_move 3 -function will initialize +function will initialize .Fa source from .Fa destination . diff --git a/doc/ck_hs_next b/doc/ck_hs_next index 1e41301..67e083e 100644 --- a/doc/ck_hs_next +++ b/doc/ck_hs_next @@ -33,7 +33,7 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_hs.h -.Ft bool +.Ft bool .Fn ck_hs_next "ck_hs_t *hs" "ck_hs_iterator_t *iterator" "void **entry" .Sh DESCRIPTION The diff --git a/doc/ck_hs_set b/doc/ck_hs_set index 0df792a..e9ba9f1 100644 --- a/doc/ck_hs_set +++ b/doc/ck_hs_set @@ -57,7 +57,7 @@ was successful then the key specified by was successfully stored in the hash set pointed to by .Fa hs . If the key already exists in the hash set, then it is -replaced by +replaced by .Fa key and the previous value is stored into the void pointer pointed to by the diff --git a/doc/ck_pr b/doc/ck_pr index df7ce91..67c726f 100644 --- a/doc/ck_pr +++ b/doc/ck_pr @@ -38,7 +38,7 @@ ck_pr.h provides an interface to volatile atomic instructions, memory barriers and busy-wait facilities as provided by the underlying processor. The presence of an atomic operation is detected by the presence of a corresponding CK_F_PR macro. -For example, the availability of +For example, the availability of .Xr ck_pr_add_16 3 would be determined by the presence of CK_F_PR_ADD_16. .Sh SEE ALSO @@ -56,7 +56,7 @@ would be determined by the presence of CK_F_PR_ADD_16. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_add b/doc/ck_pr_add index 77a3ad2..b4d394a 100644 --- a/doc/ck_pr_add +++ b/doc/ck_pr_add @@ -60,7 +60,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_add_8 "uint8_t *target" "uint8_t delta" .Sh DESCRIPTION -The +The .Fn ck_pr_add 3 family of functions atomically add the value specified by .Fa delta @@ -79,7 +79,7 @@ This family of functions does not have a return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_and b/doc/ck_pr_and index bd40252..56ce5af 100644 --- a/doc/ck_pr_and +++ b/doc/ck_pr_and @@ -57,9 +57,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_and_8 "uint8_t *target" "uint8_t delta" .Sh DESCRIPTION -The +The .Fn ck_pr_and 3 -family of functions atomically compute and store the +family of functions atomically compute and store the result of a bitwise-and of the value pointed to by .Fa target and @@ -79,7 +79,7 @@ This family of functions does not have a return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_barrier b/doc/ck_pr_barrier index 128bf38..3886729 100644 --- a/doc/ck_pr_barrier +++ b/doc/ck_pr_barrier @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_barrier void .Sh DESCRIPTION -The +The .Fn ck_pr_barrier 3 function is used to disable code movement optimizations across the invocation of the function. @@ -51,7 +51,7 @@ across the invocation of the function. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_btc b/doc/ck_pr_btc index bbf226f..5956221 100644 --- a/doc/ck_pr_btc +++ b/doc/ck_pr_btc @@ -51,13 +51,13 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_pr_btc_16 "uint16_t *target" "unsigned int bit_index" .Sh DESCRIPTION -The +The .Fn ck_pr_btc 3 family of functions atomically fetch the value of the bit in .Fa target at index -.Fa bit_index +.Fa bit_index and set that bit to its complement. .Sh RETURN VALUES These family of functions return the original value of @@ -76,7 +76,7 @@ that is in the value pointed to by .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_btr b/doc/ck_pr_btr index 1c7760b..d5e03fd 100644 --- a/doc/ck_pr_btr +++ b/doc/ck_pr_btr @@ -51,13 +51,13 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_pr_btr_16 "uint16_t *target" "unsigned int bit_index" .Sh DESCRIPTION -The +The .Fn ck_pr_btr 3 family of functions atomically fetch the value of the bit in .Fa target at index -.Fa bit_index +.Fa bit_index and set that bit to 0. .Sh RETURN VALUES This family of functions returns the original value of @@ -76,7 +76,7 @@ that is in the value pointed to by .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_bts b/doc/ck_pr_bts index 4ee6163..955855d 100644 --- a/doc/ck_pr_bts +++ b/doc/ck_pr_bts @@ -51,13 +51,13 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_pr_bts_16 "uint16_t *target" "unsigned int bit_index" .Sh DESCRIPTION -The +The .Fn ck_pr_bts 3 family of functions atomically fetch the value of the bit in .Fa target at index -.Fa bit_index +.Fa bit_index and set that bit to 1. .Sh RETURN VALUES This family of functions returns the original value of @@ -76,7 +76,7 @@ that is in the value pointed to by .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_cas b/doc/ck_pr_cas index e0b4674..1fa3a88 100644 --- a/doc/ck_pr_cas +++ b/doc/ck_pr_cas @@ -99,9 +99,9 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_pr_cas_8_value "uint8_t *target" "uint8_t old_value" "uint8_t new_value" "uint8_t *original_value" .Sh DESCRIPTION -The +The .Fn ck_pr_cas 3 -family of functions atomically compare the value in +family of functions atomically compare the value in .Fa target for equality with .Fa old_value @@ -133,7 +133,7 @@ return false. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_dec b/doc/ck_pr_dec index c3bc7b4..f3d34dd 100644 --- a/doc/ck_pr_dec +++ b/doc/ck_pr_dec @@ -87,7 +87,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_dec_8_zero "uint8_t *target" "bool *z" .Sh DESCRIPTION -The +The .Fn ck_pr_dec 3 family of functions atomically decrement the value pointed to by @@ -109,7 +109,7 @@ to false otherwise. .Xr ck_pr_fas 3 , .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_faa b/doc/ck_pr_faa index 06e0761..fbeff01 100644 --- a/doc/ck_pr_faa +++ b/doc/ck_pr_faa @@ -60,7 +60,7 @@ Concurrency Kit (libck, \-lck) .Ft uint8_t .Fn ck_pr_faa_8 "uint8_t *target" "uint8_t delta" .Sh DESCRIPTION -The +The .Fn ck_pr_faa 3 family of functions atomically fetch the value pointed to by @@ -84,7 +84,7 @@ addition operation is applied. .Xr ck_pr_fas 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fas b/doc/ck_pr_fas index 5059151..037b104 100644 --- a/doc/ck_pr_fas +++ b/doc/ck_pr_fas @@ -60,7 +60,7 @@ Concurrency Kit (libck, \-lck) .Ft uint8_t .Fn ck_pr_fas_8 "uint8_t *target" "uint8_t new_value" .Sh DESCRIPTION -The +The .Fn ck_pr_fas 3 family of functions atomically fetch the value pointed to by @@ -85,7 +85,7 @@ atomically replaced with .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_acquire b/doc/ck_pr_fence_acquire index 9da53c0..2d6b997 100644 --- a/doc/ck_pr_fence_acquire +++ b/doc/ck_pr_fence_acquire @@ -57,7 +57,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_atomic b/doc/ck_pr_fence_atomic index 452606b..65ed270 100644 --- a/doc/ck_pr_fence_atomic +++ b/doc/ck_pr_fence_atomic @@ -25,7 +25,7 @@ .\" .\" .Dd May 16, 2013 -.Dt CK_PR_FENCE_ATOMIC 3 +.Dt CK_PR_FENCE_ATOMIC 3 .Sh NAME .Nm ck_pr_fence_atomic .Nd enforce partial ordering of atomic read-modify-write operations @@ -38,9 +38,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_atomic void .Sh DESCRIPTION -The +The .Fn ck_pr_fence_atomic -function enfores the ordering of any +function enfores the ordering of any atomic read-modify-write operations relative to the invocation of the function. This function always serve as an implicit compiler barrier. On @@ -96,7 +96,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_atomic_load b/doc/ck_pr_fence_atomic_load index cbefdaa..22925ea 100644 --- a/doc/ck_pr_fence_atomic_load +++ b/doc/ck_pr_fence_atomic_load @@ -25,7 +25,7 @@ .\" .\" .Dd May 16, 2013 -.Dt CK_PR_FENCE_ATOMIC_LOAD 3 +.Dt CK_PR_FENCE_ATOMIC_LOAD 3 .Sh NAME .Nm ck_pr_fence_atomic_load .Nd enforce ordering of atomic read-modify-write operations to load operations @@ -38,9 +38,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_atomic_load void .Sh DESCRIPTION -The +The .Fn ck_pr_fence_atomic_load -function enfores the ordering of any +function enfores the ordering of any atomic read-modify-write operations relative to any load operations following the function invocation. This function always serve as an implicit compiler barrier. On @@ -93,7 +93,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_atomic_store b/doc/ck_pr_fence_atomic_store index a14867c..ad1735b 100644 --- a/doc/ck_pr_fence_atomic_store +++ b/doc/ck_pr_fence_atomic_store @@ -25,7 +25,7 @@ .\" .\" .Dd May 16, 2013 -.Dt CK_PR_FENCE_ATOMIC_STORE 3 +.Dt CK_PR_FENCE_ATOMIC_STORE 3 .Sh NAME .Nm ck_pr_fence_atomic_store .Nd enforce ordering of atomic read-modify-write operations to store operations @@ -38,9 +38,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_atomic_store void .Sh DESCRIPTION -The +The .Fn ck_pr_fence_atomic_store -function enfores the ordering of any +function enfores the ordering of any atomic read-modify-write operations relative to any load operations following the function invocation. This function always serve as an implicit compiler barrier. On @@ -94,7 +94,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_load b/doc/ck_pr_fence_load index da8e6d4..b6e778d 100644 --- a/doc/ck_pr_fence_load +++ b/doc/ck_pr_fence_load @@ -98,7 +98,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_load_atomic b/doc/ck_pr_fence_load_atomic index 774a263..c935491 100644 --- a/doc/ck_pr_fence_load_atomic +++ b/doc/ck_pr_fence_load_atomic @@ -98,7 +98,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_load_depends b/doc/ck_pr_fence_load_depends index 38718ec..0c0ecfa 100644 --- a/doc/ck_pr_fence_load_depends +++ b/doc/ck_pr_fence_load_depends @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_load_depends void .Sh DESCRIPTION -The +The .Fn ck_pr_fence_load_depends 3 emits necessary fences for pure data-dependent loads. It currently only serves as a compiler barrier for Concurrency Kit's supported platforms. Unless you're on architecture @@ -60,7 +60,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_load_store b/doc/ck_pr_fence_load_store index 378903e..4abce99 100644 --- a/doc/ck_pr_fence_load_store +++ b/doc/ck_pr_fence_load_store @@ -98,7 +98,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_memory b/doc/ck_pr_fence_memory index f223527..0dfc81b 100644 --- a/doc/ck_pr_fence_memory +++ b/doc/ck_pr_fence_memory @@ -38,7 +38,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_memory .Sh DESCRIPTION -The +The .Fn ck_pr_fence_memory 3 function enforces the ordering of any memory operations with respect to the invocation of the function. This function @@ -98,7 +98,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_release b/doc/ck_pr_fence_release index 6794bbf..214917c 100644 --- a/doc/ck_pr_fence_release +++ b/doc/ck_pr_fence_release @@ -56,7 +56,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_store b/doc/ck_pr_fence_store index 5bb8f00..c5c5223 100644 --- a/doc/ck_pr_fence_store +++ b/doc/ck_pr_fence_store @@ -38,7 +38,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_store void .Sh DESCRIPTION -The +The .Fn ck_pr_fence_store function enfores the ordering of any memory store, .Fn ck_pr_store @@ -97,7 +97,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_store_atomic b/doc/ck_pr_fence_store_atomic index a559f22..d53d2ae 100644 --- a/doc/ck_pr_fence_store_atomic +++ b/doc/ck_pr_fence_store_atomic @@ -38,13 +38,13 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_store_atomic void .Sh DESCRIPTION -The +The .Fn ck_pr_fence_store_atomic function enfores the ordering of any memory store, .Fn ck_pr_store and atomic read-modify-write operations to atomic read-modify-write operations relative to the invocation of the function. This function -always serve as an implicit compiler barrier. +always serve as an implicit compiler barrier. This functions will emit a fence for PSO and RMO targets. In order to force the emission of a fence use the .Fn ck_pr_fence_strict_store_atomic @@ -93,7 +93,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_fence_store_load b/doc/ck_pr_fence_store_load index 40d1875..485bbcf 100644 --- a/doc/ck_pr_fence_store_load +++ b/doc/ck_pr_fence_store_load @@ -38,13 +38,13 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_store_load void .Sh DESCRIPTION -The +The .Fn ck_pr_fence_store_load function enfores the ordering of any memory store, .Fn ck_pr_store and atomic read-modify-write operations to load operations relative to the invocation of the function. This function -always serve as an implicit compiler barrier. +always serve as an implicit compiler barrier. A fence will currently always be emitted for this operation, including for TSO memory model targets. .Sh EXAMPLE @@ -92,7 +92,7 @@ This function has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_inc b/doc/ck_pr_inc index 0b8f449..72a3e70 100644 --- a/doc/ck_pr_inc +++ b/doc/ck_pr_inc @@ -87,7 +87,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_inc_8_zero "uint8_t *target" "bool *z" .Sh DESCRIPTION -The +The .Fn ck_pr_inc 3 family of functions atomically increment the value pointed to by @@ -109,7 +109,7 @@ false otherwise. .Xr ck_pr_fas 3 , .Xr ck_pr_faa 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_load b/doc/ck_pr_load index f0ab96d..ed615d3 100644 --- a/doc/ck_pr_load +++ b/doc/ck_pr_load @@ -60,7 +60,7 @@ Concurrency Kit (libck, \-lck) .Ft uint8_t .Fn ck_pr_load_8 "const uint8_t *target" .Sh DESCRIPTION -The +The .Fn ck_pr_load 3 family of functions atomically loads the value pointed to by @@ -82,7 +82,7 @@ in the location pointed to by the first argument. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_neg b/doc/ck_pr_neg index 6654856..38f9a0a 100644 --- a/doc/ck_pr_neg +++ b/doc/ck_pr_neg @@ -87,7 +87,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_neg_8_zero "uint8_t *target" "bool *z" .Sh DESCRIPTION -The +The .Fn ck_pr_neg 3 family of functions atomically negate the value pointed to by @@ -107,7 +107,7 @@ pointed to value to false otherwise. .Xr ck_pr_fas 3 , .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , +.Xr ck_pr_dec 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_not b/doc/ck_pr_not index d6eb51c..b0a38b2 100644 --- a/doc/ck_pr_not +++ b/doc/ck_pr_not @@ -60,7 +60,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_not_8 "uint8_t *target" .Sh DESCRIPTION -The +The .Fn ck_pr_not 3 family of functions atomically complement the value pointed to by @@ -78,7 +78,7 @@ These functions have no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_not 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_or b/doc/ck_pr_or index 9ceddc5..2a68330 100644 --- a/doc/ck_pr_or +++ b/doc/ck_pr_or @@ -57,9 +57,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_or_8 "uint8_t *target" "uint8_t delta" .Sh DESCRIPTION -The +The .Fn ck_pr_or 3 -family of functions atomically compute and store the +family of functions atomically compute and store the result of a bitwise-or of the value pointed to by .Fa target and @@ -79,7 +79,7 @@ This family of functions does not have a return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_rtm b/doc/ck_pr_rtm index a15aa91..53c31b6 100644 --- a/doc/ck_pr_rtm +++ b/doc/ck_pr_rtm @@ -98,7 +98,7 @@ set manuals. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_stall b/doc/ck_pr_stall index 762a739..bc46647 100644 --- a/doc/ck_pr_stall +++ b/doc/ck_pr_stall @@ -36,9 +36,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_stall void .Sh DESCRIPTION -The +The .Fn ck_pr_stall 3 -function should be used inside retry paths of busy-wait loops. +function should be used inside retry paths of busy-wait loops. It not only serves as a compiler barrier, but on some architectures it emits cycle-saving instructions. .Sh EXAMPLE @@ -71,7 +71,7 @@ function(void) .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_pr_store b/doc/ck_pr_store index 5cc7053..462cf7b 100644 --- a/doc/ck_pr_store +++ b/doc/ck_pr_store @@ -60,7 +60,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_store_8 "uint8_t *target" "uint8_t value" .Sh DESCRIPTION -The +The .Fn ck_pr_store 3 family of functions atomically stores the value specified by @@ -82,7 +82,7 @@ This family of functions has no return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_sub 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_sub b/doc/ck_pr_sub index 697ea1b..5eee170 100644 --- a/doc/ck_pr_sub +++ b/doc/ck_pr_sub @@ -60,7 +60,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_sub_8 "uint8_t *target" "uint8_t delta" .Sh DESCRIPTION -The +The .Fn ck_pr_sub 3 family of functions atomically subtract the value specified by .Fa delta @@ -79,7 +79,7 @@ This family of functions does not have a return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_and 3 , diff --git a/doc/ck_pr_xor b/doc/ck_pr_xor index cda38cb..509f60d 100644 --- a/doc/ck_pr_xor +++ b/doc/ck_pr_xor @@ -57,9 +57,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_xor_8 "uint8_t *target" "uint8_t delta" .Sh DESCRIPTION -The +The .Fn ck_pr_xor 3 -family of functions atomically compute and store the +family of functions atomically compute and store the result of a bitwise-xor of the value pointed to by .Fa target and @@ -79,7 +79,7 @@ This family of functions does not have a return value. .Xr ck_pr_faa 3 , .Xr ck_pr_inc 3 , .Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , +.Xr ck_pr_neg 3 , .Xr ck_pr_not 3 , .Xr ck_pr_add 3 , .Xr ck_pr_sub 3 , diff --git a/doc/ck_ring_dequeue_spmc b/doc/ck_ring_dequeue_spmc index 82fc2fb..7fd7d9b 100644 --- a/doc/ck_ring_dequeue_spmc +++ b/doc/ck_ring_dequeue_spmc @@ -91,7 +91,7 @@ dequeue(void) } /* An empty ring was encountered, leave. */ - return; + return; } .Ed .Sh RETURN VALUES diff --git a/doc/ck_ring_dequeue_spsc b/doc/ck_ring_dequeue_spsc index 75b36ac..069dc7f 100644 --- a/doc/ck_ring_dequeue_spsc +++ b/doc/ck_ring_dequeue_spsc @@ -89,7 +89,7 @@ dequeue(void) } /* An empty ring was encountered, leave. */ - return; + return; } .Ed .Sh RETURN VALUES diff --git a/doc/ck_ring_enqueue_spmc b/doc/ck_ring_enqueue_spmc index 20fd6a8..ba99199 100644 --- a/doc/ck_ring_enqueue_spmc +++ b/doc/ck_ring_enqueue_spmc @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -88,11 +88,11 @@ enqueue(void) } /* Enqueue operation completed successfully. */ - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . diff --git a/doc/ck_ring_enqueue_spmc_size b/doc/ck_ring_enqueue_spmc_size index 900bd28..eb30cab 100644 --- a/doc/ck_ring_enqueue_spmc_size +++ b/doc/ck_ring_enqueue_spmc_size @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -96,11 +96,11 @@ enqueue(void) do_something; } - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . diff --git a/doc/ck_ring_enqueue_spsc b/doc/ck_ring_enqueue_spsc index e5fbbec..2493059 100644 --- a/doc/ck_ring_enqueue_spsc +++ b/doc/ck_ring_enqueue_spsc @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -86,11 +86,11 @@ enqueue(void) } /* Enqueue operation completed successfully. */ - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . diff --git a/doc/ck_ring_enqueue_spsc_size b/doc/ck_ring_enqueue_spsc_size index 90bdf12..7048ea1 100644 --- a/doc/ck_ring_enqueue_spsc_size +++ b/doc/ck_ring_enqueue_spsc_size @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -94,11 +94,11 @@ enqueue(void) do_something; } - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . diff --git a/doc/ck_ring_trydequeue_spmc b/doc/ck_ring_trydequeue_spmc index 52a92b6..16f83ee 100644 --- a/doc/ck_ring_trydequeue_spmc +++ b/doc/ck_ring_trydequeue_spmc @@ -71,7 +71,7 @@ in a bounded number of steps. It is possible for the function to return false even if .Fa ring -is non-empty. This +is non-empty. This .Sh EXAMPLE .Bd -literal -offset indent #include @@ -97,7 +97,7 @@ dequeue(void) } /* An empty ring was encountered, leave. */ - return; + return; } .Ed .Sh RETURN VALUES diff --git a/doc/ck_rwcohort b/doc/ck_rwcohort index 673261d..ba2b5f9 100644 --- a/doc/ck_rwcohort +++ b/doc/ck_rwcohort @@ -69,7 +69,7 @@ either the .Xr CK_COHORT_PROTOTYPE 3 or the .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 -macros, and define a reader-writer lock type using the +macros, and define a reader-writer lock type using the .Xr CK_RWCOHORT_PROTOTYPE 3 macro. .Pp @@ -161,7 +161,7 @@ main(void) calloc(n_cohorts, sizeof(CK_COHORT_INSTANCE(test_cohort))); /* create local locks to use with each cohort */ - ck_spinlock_t *local_locks = + ck_spinlock_t *local_locks = calloc(n_cohorts, sizeof(ck_spinlock_t)); pthread_t *threads = diff --git a/doc/ck_spinlock b/doc/ck_spinlock index 67d4555..564d185 100644 --- a/doc/ck_spinlock +++ b/doc/ck_spinlock @@ -200,7 +200,7 @@ provides a summary of the current implementations. ck_spinlock_ticket Ticket Centralized None Yes .Ed .Pp -* Hierarchical CLH only offers weak fairness for threads accross cluster +* Hierarchical CLH only offers weak fairness for threads accross cluster nodes. .Pp If contention is low and there is no hard requirement for starvation-freedom From d8f8b4a6c6b99a595b9f31f1cb7116bdbdcadc78 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 20:22:34 -0400 Subject: [PATCH 28/49] regressions: Deletion coverage for ck_hs_apply. --- regressions/ck_hs/validate/serial.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/regressions/ck_hs/validate/serial.c b/regressions/ck_hs/validate/serial.c index ed3002a..d6f6c0a 100644 --- a/regressions/ck_hs/validate/serial.c +++ b/regressions/ck_hs/validate/serial.c @@ -118,6 +118,16 @@ test_unique(void *key, void *closure) return closure; } +static void * +test_remove(void *key, void *closure) +{ + + (void)key; + (void)closure; + + return NULL; +} + static void run_test(unsigned int is, unsigned int ad) { @@ -144,8 +154,12 @@ run_test(unsigned int is, unsigned int ad) ck_error("ERROR: Failed to apply for insertion.\n"); } - if (ck_hs_remove(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to remove unique (%s)\n", j, test[i]); + if (i & 1) { + if (ck_hs_remove(&hs[j], h, test[i]) == false) + ck_error("ERROR [%zu]: Failed to remove unique (%s)\n", j, test[i]); + } else if (ck_hs_apply(&hs[j], h, test[i], test_remove, NULL) == false) { + ck_error("ERROR: Failed to remove apply.\n"); + } if (ck_hs_apply(&hs[j], h, test[i], test_negative, (char *)test[i]) == false) ck_error("ERROR: Failed to apply.\n"); From 5465f7325f8a6c3fbfd86f43467df12fbb0f9249 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 20:42:00 -0400 Subject: [PATCH 29/49] build: Bump version for next release. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 1b31294..150a4a8 100755 --- a/configure +++ b/configure @@ -34,7 +34,7 @@ WANT_PIC=yes P_PWD=`pwd` MAINTAINER='sbahra@repnop.org' -VERSION=${VERSION:-'0.4.3'} +VERSION=${VERSION:-'0.4.4'} VERSION_MAJOR='0' BUILD="$PWD/build/ck.build" PREFIX=${PREFIX:-"/usr/local"} From 384e8048eb23e766dae04404d102523a26bcb5f1 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 1 Sep 2014 22:48:38 -0400 Subject: [PATCH 30/49] whitespace: Remove extraneous lines. --- src/ck_array.c | 1 - src/ck_barrier_centralized.c | 1 - src/ck_barrier_combining.c | 1 - src/ck_barrier_dissemination.c | 1 - src/ck_barrier_mcs.c | 1 - src/ck_barrier_tournament.c | 1 - src/ck_epoch.c | 1 - src/ck_hp.c | 1 - src/ck_ht.c | 1 - src/ck_rhs.c | 1 - 10 files changed, 10 deletions(-) diff --git a/src/ck_array.c b/src/ck_array.c index 238ce0b..f7bb87a 100644 --- a/src/ck_array.c +++ b/src/ck_array.c @@ -238,4 +238,3 @@ ck_array_deinit(struct ck_array *array, bool defer) array->transaction = array->active = NULL; return; } - diff --git a/src/ck_barrier_centralized.c b/src/ck_barrier_centralized.c index f0604a0..a21ef3e 100644 --- a/src/ck_barrier_centralized.c +++ b/src/ck_barrier_centralized.c @@ -57,4 +57,3 @@ ck_barrier_centralized(struct ck_barrier_centralized *barrier, ck_pr_fence_memory(); return; } - diff --git a/src/ck_barrier_combining.c b/src/ck_barrier_combining.c index b9df1d4..41291bb 100644 --- a/src/ck_barrier_combining.c +++ b/src/ck_barrier_combining.c @@ -205,4 +205,3 @@ ck_barrier_combining(struct ck_barrier_combining *barrier, state->sense = ~state->sense; return; } - diff --git a/src/ck_barrier_dissemination.c b/src/ck_barrier_dissemination.c index 867e224..dd08923 100644 --- a/src/ck_barrier_dissemination.c +++ b/src/ck_barrier_dissemination.c @@ -121,4 +121,3 @@ ck_barrier_dissemination(struct ck_barrier_dissemination *barrier, state->parity = 1 - state->parity; return; } - diff --git a/src/ck_barrier_mcs.c b/src/ck_barrier_mcs.c index ed5959c..4dc8502 100644 --- a/src/ck_barrier_mcs.c +++ b/src/ck_barrier_mcs.c @@ -138,4 +138,3 @@ ck_barrier_mcs(struct ck_barrier_mcs *barrier, state->sense = ~state->sense; return; } - diff --git a/src/ck_barrier_tournament.c b/src/ck_barrier_tournament.c index e505890..0f76c6f 100644 --- a/src/ck_barrier_tournament.c +++ b/src/ck_barrier_tournament.c @@ -181,4 +181,3 @@ leave: state->sense = ~state->sense; return; } - diff --git a/src/ck_epoch.c b/src/ck_epoch.c index ebb0aaa..1a51059 100644 --- a/src/ck_epoch.c +++ b/src/ck_epoch.c @@ -426,4 +426,3 @@ ck_epoch_poll(struct ck_epoch *global, struct ck_epoch_record *record) ck_epoch_dispatch(record, epoch + 1); return true; } - diff --git a/src/ck_hp.c b/src/ck_hp.c index 634d94d..a39ff58 100644 --- a/src/ck_hp.c +++ b/src/ck_hp.c @@ -321,4 +321,3 @@ ck_hp_purge(struct ck_hp_record *thread) return; } - diff --git a/src/ck_ht.c b/src/ck_ht.c index b6d74c1..324a03d 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -1027,4 +1027,3 @@ ck_ht_destroy(struct ck_ht *table) } #endif /* CK_F_HT */ - diff --git a/src/ck_rhs.c b/src/ck_rhs.c index a043ac6..73ea9a2 100644 --- a/src/ck_rhs.c +++ b/src/ck_rhs.c @@ -1332,4 +1332,3 @@ ck_rhs_init(struct ck_rhs *hs, hs->map = ck_rhs_map_create(hs, n_entries); return hs->map != NULL; } - From e39223da44b4eb98107400e07ac3acff07afefe2 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 3 Sep 2014 13:06:55 -0400 Subject: [PATCH 31/49] ck_sequence: Constify read-only operations. --- include/ck_sequence.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ck_sequence.h b/include/ck_sequence.h index b7fcb48..c5ca193 100644 --- a/include/ck_sequence.h +++ b/include/ck_sequence.h @@ -47,7 +47,7 @@ ck_sequence_init(struct ck_sequence *sq) } CK_CC_INLINE static unsigned int -ck_sequence_read_begin(struct ck_sequence *sq) +ck_sequence_read_begin(const struct ck_sequence *sq) { unsigned int version; @@ -74,7 +74,7 @@ ck_sequence_read_begin(struct ck_sequence *sq) } CK_CC_INLINE static bool -ck_sequence_read_retry(struct ck_sequence *sq, unsigned int version) +ck_sequence_read_retry(const struct ck_sequence *sq, unsigned int version) { /* From bfad9c509797bd75e235569acc26d8572ac2e208 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 3 Sep 2014 13:07:36 -0400 Subject: [PATCH 32/49] doc: Update ck_sequence manual page. --- doc/ck_sequence | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ck_sequence b/doc/ck_sequence index ad06dbe..faa1631 100644 --- a/doc/ck_sequence +++ b/doc/ck_sequence @@ -43,9 +43,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_sequence_init "ck_sequence_t *sq" .Ft unsigned int -.Fn ck_sequence_read_begin "ck_sequence_t *sq" +.Fn ck_sequence_read_begin "const ck_sequence_t *sq" .Ft bool -.Fn ck_sequence_read_retry "ck_sequence_t *sq" "unsigned int version" +.Fn ck_sequence_read_retry "const ck_sequence_t *sq" "unsigned int version" .Ft void .Fn ck_sequence_write_begin "ck_sequence_t *sq" .Ft void From b6bd963a7ea4ce3a76885b34d71634d5291d4bcd Mon Sep 17 00:00:00 2001 From: James Cowgill Date: Thu, 4 Sep 2014 23:15:53 +0100 Subject: [PATCH 33/49] regressions/ck_spinlock: add ck_hclh to clean target --- regressions/ck_spinlock/validate/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regressions/ck_spinlock/validate/Makefile b/regressions/ck_spinlock/validate/Makefile index 731b68b..0d78e09 100644 --- a/regressions/ck_spinlock/validate/Makefile +++ b/regressions/ck_spinlock/validate/Makefile @@ -50,7 +50,7 @@ ck_dec: ck_dec.c clean: rm -rf ck_ticket ck_mcs ck_dec ck_cas ck_fas ck_clh linux_spinlock ck_ticket_pb \ - ck_anderson ck_spinlock *.dSYM *.exe + ck_anderson ck_spinlock ck_hclh *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm From 3aa63b3912e506f02422535a67f273dc1e73fafb Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Mon, 29 Sep 2014 22:00:16 +0200 Subject: [PATCH 34/49] ck_rhs: Implement ck_rhs_apply, similarly to what has been done in ck_hs. --- include/ck_rhs.h | 2 + src/ck_rhs.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/include/ck_rhs.h b/include/ck_rhs.h index edf852f..4754da6 100644 --- a/include/ck_rhs.h +++ b/include/ck_rhs.h @@ -106,6 +106,8 @@ typedef struct ck_rhs_iterator ck_rhs_iterator_t; /* Convenience wrapper to table hash function. */ #define CK_RHS_HASH(T, F, K) F((K), (T)->seed) +typedef void *ck_rhs_apply_fn_t(void *, void *); +bool ck_rhs_apply(ck_rhs_t *, unsigned long, const void *, ck_rhs_apply_fn_t *, void *); void ck_rhs_iterator_init(ck_rhs_iterator_t *); bool ck_rhs_next(ck_rhs_t *, ck_rhs_iterator_t *, void **); bool ck_rhs_move(ck_rhs_t *, ck_rhs_t *, ck_rhs_hash_cb_t *, diff --git a/src/ck_rhs.c b/src/ck_rhs.c index 73ea9a2..2d177cc 100644 --- a/src/ck_rhs.c +++ b/src/ck_rhs.c @@ -1089,6 +1089,121 @@ restart: return true; } +/* + * An apply function takes two arguments. The first argument is a pointer to a + * pre-existing object. The second argument is a pointer to the fifth argument + * passed to ck_hs_apply. If a non-NULL pointer is passed to the first argument + * and the return value of the apply function is NULL, then the pre-existing + * value is deleted. If the return pointer is the same as the one passed to the + * apply function then no changes are made to the hash table. If the first + * argument is non-NULL and the return pointer is different than that passed to + * the apply function, then the pre-existing value is replaced. For + * replacement, it is required that the value itself is identical to the + * previous value. + */ +bool +ck_rhs_apply(struct ck_rhs *hs, + unsigned long h, + const void *key, + ck_rhs_apply_fn_t *fn, + void *cl) +{ + void *object, *insert, *delta = false; + unsigned long n_probes; + long slot, first; + struct ck_rhs_map *map; + bool delta_set = false; + +restart: + map = hs->map; + + slot = map->probe_func(hs, map, &n_probes, &first, h, key, &object, map->probe_limit, CK_RHS_PROBE_INSERT); + if (slot == -1 && first == -1) { + if (ck_rhs_grow(hs, map->capacity << 1) == false) + return false; + + goto restart; + } + if (!delta_set) { + delta = fn(object, cl); + delta_set = true; + } + + if (delta == NULL) { + /* + * The apply function has requested deletion. If the object doesn't exist, + * then exit early. + */ + if (CK_CC_UNLIKELY(object == NULL)) + return true; + + /* Otherwise, delete it. */ + ck_rhs_do_backward_shift_delete(hs, slot); + return true; + } + + /* The apply function has not requested hash set modification so exit early. */ + if (delta == object) + return true; + + /* A modification or insertion has been requested. */ + ck_rhs_map_bound_set(map, h, n_probes); + + insert = ck_rhs_marshal(hs->mode, delta, h); + if (first != -1) { + /* + * This follows the same semantics as ck_hs_set, please refer to that + * function for documentation. + */ + struct ck_rhs_entry_desc *desc = NULL, *desc2; + if (slot != -1) { + desc = ck_rhs_desc(map, slot); + desc->in_rh = true; + } + desc2 = ck_rhs_desc(map, first); + int ret = ck_rhs_put_robin_hood(hs, first, desc2); + if (slot != -1) + desc->in_rh = false; + + if (CK_CC_UNLIKELY(ret == 1)) + goto restart; + if (CK_CC_UNLIKELY(ret == -1)) + return false; + /* If an earlier bucket was found, then store entry there. */ + ck_pr_store_ptr(ck_rhs_entry_addr(map, first), insert); + desc2->probes = n_probes; + /* + * If a duplicate key was found, then delete it after + * signaling concurrent probes to restart. Optionally, + * it is possible to install tombstone after grace + * period if we can guarantee earlier position of + * duplicate key. + */ + ck_rhs_add_wanted(hs, first, -1, h); + if (object != NULL) { + ck_pr_inc_uint(&map->generation[h & CK_RHS_G_MASK]); + ck_pr_fence_atomic_store(); + ck_rhs_do_backward_shift_delete(hs, slot); + } + } else { + /* + * If we are storing into same slot, then atomic store is sufficient + * for replacement. + */ + ck_pr_store_ptr(ck_rhs_entry_addr(map, slot), insert); + ck_rhs_set_probes(map, slot, n_probes); + if (object == NULL) + ck_rhs_add_wanted(hs, slot, -1, h); + } + + if (object == NULL) { + map->n_entries++; + if ((map->n_entries ) > ((map->capacity * CK_RHS_LOAD_FACTOR) / 100)) + ck_rhs_grow(hs, map->capacity << 1); + } + return true; +} + bool ck_rhs_set(struct ck_rhs *hs, unsigned long h, From 0422a23f62e916b738f60203b83fcec5df2777ae Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Mon, 29 Sep 2014 22:01:50 +0200 Subject: [PATCH 35/49] regressions: Test ck_rhs_apply. --- regressions/ck_rhs/validate/serial.c | 69 ++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/regressions/ck_rhs/validate/serial.c b/regressions/ck_rhs/validate/serial.c index 1dc4db1..d11b4e4 100644 --- a/regressions/ck_rhs/validate/serial.c +++ b/regressions/ck_rhs/validate/serial.c @@ -85,6 +85,49 @@ hs_compare(const void *previous, const void *compare) return strcmp(previous, compare) == 0; } +static void * +test_ip(void *key, void *closure) +{ + const char *a = key; + const char *b = closure; + + if (strcmp(a, b) != 0) + ck_error("Mismatch: %s != %s\n", a, b); + + return closure; +} + +static void * +test_negative(void *key, void *closure) +{ + + (void)closure; + if (key != NULL) + ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); + + return NULL; +} + +static void * +test_unique(void *key, void *closure) +{ + + if (key != NULL) + ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); + + return closure; +} + +static void * +test_remove(void *key, void *closure) +{ + + (void)key; + (void)closure; + + return NULL; +} + static void run_test(unsigned int is, unsigned int ad) { @@ -104,11 +147,22 @@ run_test(unsigned int is, unsigned int ad) continue; } - if (ck_rhs_put_unique(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]); + if (i & 1) { + if (ck_rhs_put_unique(&hs[j], h, test[i]) == false) + ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]); + } else if (ck_rhs_apply(&hs[j], h, test[i], test_unique, (char *)test[i]) == false) { + ck_error("ERROR: Failed to apply for insertion.\n"); + } - if (ck_rhs_remove(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to remove unique (%s)\n", j, test[i]); + if (i & 1) { + if (ck_rhs_remove(&hs[j], h, test[i]) == false) + ck_error("ERROR [%zu]: Failed to remove unique (%s)\n", j, test[i]); + } else if (ck_rhs_apply(&hs[j], h, test[i], test_remove, NULL) == false) { + ck_error("ERROR: Failed to remove apply.\n"); + } + + if (ck_rhs_apply(&hs[j], h, test[i], test_negative, (char *)test[i]) == false) + ck_error("ERROR: Failed to apply.\n"); break; } @@ -213,6 +267,13 @@ run_test(unsigned int is, unsigned int ad) if (strcmp(r, test[i]) != 0) { ck_error("ERROR [%u]: Invalid &hs[j]: %s != %s\n", (char *)r, test[i], is); } + /* Attempt in-place mutation. */ + if (ck_rhs_apply(&hs[j], h, test[i], test_ip, (void *)test[i]) == false) + ck_error("ERROR [%u]: Failed to apply: %s != %s\n", is, (char *)r, test[i]); + + d = ck_rhs_get(&hs[j], h, test[i]) != NULL; + if (d == false) + ck_error("ERROR [%u]: Expected [%s] to exist.\n", is, test[i]); } if (j == size - 1) From 0f7827f479f706f66741cbd6d37e71701ac78401 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Mon, 29 Sep 2014 21:15:41 +0000 Subject: [PATCH 36/49] ck_pr: Prettify the arm bits. gcc is smart enough to use an even register for 64bits operations, and provide a way to access the first and the second words, so use that instead of hardcoding registers. --- include/gcc/arm/ck_pr.h | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/include/gcc/arm/ck_pr.h b/include/gcc/arm/ck_pr.h index 7222680..d2a34e1 100644 --- a/include/gcc/arm/ck_pr.h +++ b/include/gcc/arm/ck_pr.h @@ -170,33 +170,32 @@ CK_PR_STORE_S(char, char, "strb") CK_CC_INLINE static void ck_pr_store_64(const uint64_t *target, uint64_t value) { - register uint64_t tmp asm("r0") = value; __asm __volatile("strd %0, [%1]" : - : "r" (tmp), "r" (target) + : "r" (value), "r" (target) : "memory", "cc"); } CK_CC_INLINE static bool ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *value) { - register uint64_t __compare asm("r0") = compare; - register uint64_t __set asm("r2") = set; + uint64_t previous; + int tmp; __asm__ __volatile__("1:" - "ldrexd r4, [%3];" - "cmp r4, r0;" + "ldrexd %0, [%4];" + "cmp %Q0, %Q2;" "ittt eq;" - "cmpeq r5, r1;" - "strexdeq r6, r2, [%3];" - "cmpeq r6, #1;" + "cmpeq %R0, %R2;" + "strexdeq %1, %3, [%4];" + "cmpeq %1, #1;" "beq 1b;" - "strd r4, [%0];" - : "+r" (value) - : "r" (__compare), "r" (__set) , + :"=&r" (previous), "=&r" (tmp) + : "r" (compare), "r" (set) , "r"(target) : "memory", "cc", "r4", "r5", "r6"); + *value = previous; return (*value == compare); } @@ -215,22 +214,21 @@ ck_pr_cas_ptr_2_value(void *target, void *compare, void *set, void *value) CK_CC_INLINE static bool ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set) { - register uint64_t __compare asm("r0") = compare; - register uint64_t __set asm("r2") = set; int ret; + uint64_t tmp; __asm__ __volatile__("1:" "mov %0, #0;" - "ldrexd r4, [%3];" - "cmp r4, r0;" + "ldrexd %1, [%4];" + "cmp %Q1, %Q2;" "itttt eq;" - "cmpeq r5, r1;" - "strexdeq r6, r2, [%3];" + "cmpeq %R1, %R2;" + "strexdeq %1, %3, [%4];" "moveq %0, #1;" - "cmpeq r6, #1;" + "cmpeq %1, #1;" "beq 1b;" - : "=&r" (ret) - : "r" (__compare), "r" (__set) , + : "=&r" (ret), "=&r" (tmp) + : "r" (compare), "r" (set) , "r"(target) : "memory", "cc", "r4", "r5", "r6"); From b3f374cb5589a52900ea207fa9f977ff6e5e39c6 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 5 Nov 2014 18:30:31 -0500 Subject: [PATCH 37/49] ck_epoch: Allow for deferral from callbacks. This makes things much easier in cases where deferral is mixed with other reclamation mechanisms such as reference counters. --- regressions/ck_epoch/validate/Makefile | 5 +- regressions/ck_epoch/validate/ck_epoch_call.c | 64 +++++++++++++++++++ src/ck_epoch.c | 9 ++- 3 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 regressions/ck_epoch/validate/ck_epoch_call.c diff --git a/regressions/ck_epoch/validate/Makefile b/regressions/ck_epoch/validate/Makefile index 73f8e5d..c053d22 100644 --- a/regressions/ck_epoch/validate/Makefile +++ b/regressions/ck_epoch/validate/Makefile @@ -1,6 +1,6 @@ .PHONY: check clean distribution -OBJECTS=ck_stack ck_epoch_synchronize ck_epoch_poll +OBJECTS=ck_stack ck_epoch_synchronize ck_epoch_poll ck_epoch_call HALF=`expr $(CORES) / 2` all: $(OBJECTS) @@ -16,6 +16,9 @@ ck_epoch_synchronize: ck_epoch_synchronize.c ../../../include/ck_stack.h ../../. ck_epoch_poll: ck_epoch_poll.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c $(CC) $(CFLAGS) -o ck_epoch_poll ck_epoch_poll.c ../../../src/ck_epoch.c +ck_epoch_call: ck_epoch_call.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c + $(CC) $(CFLAGS) -o ck_epoch_call ck_epoch_call.c ../../../src/ck_epoch.c + ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c diff --git a/regressions/ck_epoch/validate/ck_epoch_call.c b/regressions/ck_epoch/validate/ck_epoch_call.c new file mode 100644 index 0000000..9219ddd --- /dev/null +++ b/regressions/ck_epoch/validate/ck_epoch_call.c @@ -0,0 +1,64 @@ +/* + * Copyright 2014 Samy Al Bahra. + * All rights reserved. + * + * 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 AUTHOR 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 AUTHOR 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. + */ + +#include +#include + +#include "../../common.h" + +static ck_epoch_t epoch; +static unsigned int counter; +static ck_epoch_record_t record[2]; + +static void +cb(ck_epoch_entry_t *p) +{ + + if (counter == 0) + ck_epoch_call(&epoch, &record[1], p, cb); + + printf("Counter value: %u -> %u\n", + counter, counter + 1); + counter++; + return; +} + +int +main(void) +{ + static ck_epoch_entry_t entry; + + ck_epoch_register(&epoch, &record[0]); + ck_epoch_register(&epoch, &record[1]); + + ck_epoch_call(&epoch, &record[1], &entry, cb); + ck_epoch_barrier(&epoch, &record[1]); + ck_epoch_barrier(&epoch, &record[1]); + if (counter != 2) + ck_error("Expected counter value 2, read %u.\n", counter); + + return 0; +} diff --git a/src/ck_epoch.c b/src/ck_epoch.c index 1a51059..01320ee 100644 --- a/src/ck_epoch.c +++ b/src/ck_epoch.c @@ -257,12 +257,16 @@ static void ck_epoch_dispatch(struct ck_epoch_record *record, unsigned int e) { unsigned int epoch = e & (CK_EPOCH_LENGTH - 1); - ck_stack_entry_t *next, *cursor; + ck_stack_entry_t *head, *next, *cursor; unsigned int i = 0; - CK_STACK_FOREACH_SAFE(&record->pending[epoch], cursor, next) { + head = CK_STACK_FIRST(&record->pending[epoch]); + ck_stack_init(&record->pending[epoch]); + + for (cursor = head; cursor != NULL; cursor = next) { struct ck_epoch_entry *entry = ck_epoch_entry_container(cursor); + next = CK_STACK_NEXT(cursor); entry->function(entry); i++; } @@ -272,7 +276,6 @@ ck_epoch_dispatch(struct ck_epoch_record *record, unsigned int e) record->n_dispatch += i; record->n_pending -= i; - ck_stack_init(&record->pending[epoch]); return; } From 6ecd7347575c588ba469e3035ae5ea550a3ecc4d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 5 Nov 2014 18:33:04 -0500 Subject: [PATCH 38/49] ck_epoch: Remove unnecessary keyword. --- regressions/ck_epoch/validate/ck_epoch_call.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regressions/ck_epoch/validate/ck_epoch_call.c b/regressions/ck_epoch/validate/ck_epoch_call.c index 9219ddd..dc501fd 100644 --- a/regressions/ck_epoch/validate/ck_epoch_call.c +++ b/regressions/ck_epoch/validate/ck_epoch_call.c @@ -49,7 +49,7 @@ cb(ck_epoch_entry_t *p) int main(void) { - static ck_epoch_entry_t entry; + ck_epoch_entry_t entry; ck_epoch_register(&epoch, &record[0]); ck_epoch_register(&epoch, &record[1]); From 8937ec84c3c423526edbad613810cd0d3e8ac7aa Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Dec 2014 11:56:16 -0500 Subject: [PATCH 39/49] regressions: Use correct regression for ck_ring_spmc_template. We were previously building the wrong target. This was found out due to Phil Sorber pointing out that _template.c would have had compilation issues. --- regressions/ck_ring/validate/Makefile | 5 +-- .../ck_ring/validate/ck_ring_spmc_template.c | 41 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile index 8c00d80..d8beb77 100644 --- a/regressions/ck_ring/validate/Makefile +++ b/regressions/ck_ring/validate/Makefile @@ -2,7 +2,6 @@ OBJECTS=ck_ring_spsc ck_ring_spmc ck_ring_spmc_template SIZE=16384 -CFLAGS += -g2 all: $(OBJECTS) @@ -15,11 +14,11 @@ ck_ring_spsc: ck_ring_spsc.c ../../../include/ck_ring.h ../../../src/ck_barrier_centralized.c ck_ring_spmc: ck_ring_spmc.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -g2 -o ck_ring_spmc ck_ring_spmc.c \ + $(CC) $(CFLAGS) -o ck_ring_spmc ck_ring_spmc.c \ ../../../src/ck_barrier_centralized.c ck_ring_spmc_template: ck_ring_spmc_template.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -g2 -o ck_ring_spmc_template ck_ring_spmc.c \ + $(CC) $(CFLAGS) -o ck_ring_spmc_template ck_ring_spmc_template.c \ ../../../src/ck_barrier_centralized.c clean: diff --git a/regressions/ck_ring/validate/ck_ring_spmc_template.c b/regressions/ck_ring/validate/ck_ring_spmc_template.c index 456fb97..8840653 100644 --- a/regressions/ck_ring/validate/ck_ring_spmc_template.c +++ b/regressions/ck_ring/validate/ck_ring_spmc_template.c @@ -43,7 +43,7 @@ struct context { unsigned int tid; unsigned int previous; unsigned int next; - struct entry *buffer; + struct entry **buffer; }; struct entry { @@ -54,7 +54,7 @@ struct entry { int value; }; -CK_RING_PROTOTYPE(entry, entry) +CK_RING_PROTOTYPE(entry, entry *) static int nthr; static ck_ring_t *ring; @@ -73,7 +73,7 @@ test_spmc(void *c) unsigned int seed; int i, k, j, tid; struct context *context = c; - struct entry *buffer; + struct entry **buffer; buffer = context->buffer; if (aff_iterate(&a)) { @@ -136,11 +136,11 @@ static void * test(void *c) { struct context *context = c; - struct entry entry; + struct entry *entry; unsigned int s; int i, j; bool r; - ck_ring_buffer_t *buffer = context->buffer; + struct entry **buffer = context->buffer; ck_barrier_centralized_state_t sense = CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; @@ -150,9 +150,9 @@ test(void *c) } if (context->tid == 0) { - struct entry *entries; + struct entry **entries; - entries = malloc(sizeof(struct entry) * size); + entries = malloc(sizeof(struct entry *) * size); assert(entries != NULL); if (ck_ring_size(ring) != 0) { @@ -161,15 +161,18 @@ test(void *c) } for (i = 0; i < size; i++) { - entries[i].value = i; - entries[i].tid = 0; + entries[i] = malloc(sizeof(struct entry)); + assert(entries[i] != NULL); + + entries[i]->value = i; + entries[i]->tid = 0; if (i & 1) { r = CK_RING_ENQUEUE_SPMC(entry, ring, buffer, - entries + i); + &entries[i]); } else { r = CK_RING_ENQUEUE_SPMC_SIZE(entry, ring, - buffer, entries + i, &s); + buffer, &entries[i], &s); if ((int)s != i) { ck_error("Size is %u, expected %d.\n", @@ -245,7 +248,7 @@ main(int argc, char *argv[]) int i, r; unsigned long l; pthread_t *thread; - struct entry *buffer; + struct entry **buffer; if (argc != 4) { ck_error("Usage: validate \n"); @@ -284,9 +287,9 @@ main(int argc, char *argv[]) _context[i].previous = i - 1; } - buffer = malloc(sizeof(struct entry) * (size + 1)); + buffer = malloc(sizeof(struct entry *) * (size + 1)); assert(buffer); - memset(buffer, 0, sizeof(struct entry) * (size + 1)); + memset(buffer, 0, sizeof(struct entry *) * (size + 1)); _context[i].buffer = buffer; ck_ring_init(ring + i, size + 1); r = pthread_create(thread + i, NULL, test, _context + i); @@ -299,9 +302,9 @@ main(int argc, char *argv[]) fprintf(stderr, " done\n"); fprintf(stderr, "SPMC test:\n"); - buffer = malloc(sizeof(ck_ring_buffer_t) * (size + 1)); + buffer = malloc(sizeof(struct entry *) * (size + 1)); assert(buffer); - memset(buffer, 0, sizeof(void *) * (size + 1)); + memset(buffer, 0, sizeof(struct entry *) * (size + 1)); ck_ring_init(&ring_spmc, size + 1); for (i = 0; i < nthr - 1; i++) { _context[i].buffer = buffer; @@ -322,14 +325,14 @@ main(int argc, char *argv[]) /* Wait until queue is not full. */ if (l & 1) { while (CK_RING_ENQUEUE_SPMC(entry, &ring_spmc, - buffer, entry) == false) { + buffer, &entry) == false) { ck_pr_stall(); } } else { unsigned int s; while (CK_RING_ENQUEUE_SPMC_SIZE(entry, &ring_spmc, - buffer, entry, &s) == false) { + buffer, &entry, &s) == false) { ck_pr_stall(); } @@ -342,6 +345,6 @@ main(int argc, char *argv[]) for (i = 0; i < nthr - 1; i++) pthread_join(thread[i], NULL); - return (0); + return 0; } From f7ccd3dbb26fbe3b984682d9454626142f0179b6 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 18 Dec 2014 11:16:16 -0500 Subject: [PATCH 40/49] build: Default to 64-bit on 32-bit/64-bit userspace. --- build/ck.build.ppc64 | 1 + build/ck.build.x86 | 1 + build/ck.build.x86_64 | 1 + 3 files changed, 3 insertions(+) diff --git a/build/ck.build.ppc64 b/build/ck.build.ppc64 index 7dcb4f4..51003f4 100644 --- a/build/ck.build.ppc64 +++ b/build/ck.build.ppc64 @@ -1 +1,2 @@ CFLAGS+=-m64 -D__ppc64__ +LDFLAGS+=-m64 diff --git a/build/ck.build.x86 b/build/ck.build.x86 index 2758c8a..6e12783 100644 --- a/build/ck.build.x86 +++ b/build/ck.build.x86 @@ -1 +1,2 @@ CFLAGS+=-m32 -D__x86__ -msse -msse2 +LDFLAGS+=-m32 diff --git a/build/ck.build.x86_64 b/build/ck.build.x86_64 index 54643ef..81b378a 100644 --- a/build/ck.build.x86_64 +++ b/build/ck.build.x86_64 @@ -1 +1,2 @@ CFLAGS+=-m64 -D__x86_64__ +LDFLAGS+=-m64 From 428401a1bd8db068e87e7e16af0d20054f4444ac Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 18 Dec 2014 11:19:02 -0500 Subject: [PATCH 41/49] build: Do not conditionally set variables. make implementations should be overriding variable values. This change was made to support ATS build environment, which fails to override variable values. --- build/ck.build.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/ck.build.in b/build/ck.build.in index 3ddf999..1d6bfe3 100644 --- a/build/ck.build.in +++ b/build/ck.build.in @@ -1,5 +1,5 @@ -CC?=@CC@ -MAKE?=make +CC=@CC@ +MAKE=make SRC_DIR=@SRC_DIR@ BUILD_DIR=@BUILD_DIR@ CFLAGS+=@CFLAGS@ -I$(SRC_DIR)/include -I$(BUILD_DIR)/include From 1a84d49c3ca794356f015a3391e6d10be98f6a6a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 18 Dec 2014 11:22:43 -0500 Subject: [PATCH 42/49] build: Bump version for next release. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 150a4a8..f88c876 100755 --- a/configure +++ b/configure @@ -34,7 +34,7 @@ WANT_PIC=yes P_PWD=`pwd` MAINTAINER='sbahra@repnop.org' -VERSION=${VERSION:-'0.4.4'} +VERSION=${VERSION:-'0.4.5'} VERSION_MAJOR='0' BUILD="$PWD/build/ck.build" PREFIX=${PREFIX:-"/usr/local"} From ea16b6522554747b2ad7809f01e5f231d04e814e Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Thu, 1 Jan 2015 23:11:55 +0100 Subject: [PATCH 43/49] doc: Document ck_rhs. --- doc/Makefile.in | 19 +++++ doc/ck_rhs_apply | 86 ++++++++++++++++++++ doc/ck_rhs_count | 70 +++++++++++++++++ doc/ck_rhs_destroy | 77 ++++++++++++++++++ doc/ck_rhs_fas | 98 +++++++++++++++++++++++ doc/ck_rhs_gc | 73 +++++++++++++++++ doc/ck_rhs_get | 88 +++++++++++++++++++++ doc/ck_rhs_grow | 81 +++++++++++++++++++ doc/ck_rhs_init | 166 +++++++++++++++++++++++++++++++++++++++ doc/ck_rhs_iterator_init | 78 ++++++++++++++++++ doc/ck_rhs_move | 90 +++++++++++++++++++++ doc/ck_rhs_next | 92 ++++++++++++++++++++++ doc/ck_rhs_put | 98 +++++++++++++++++++++++ doc/ck_rhs_put_unique | 98 +++++++++++++++++++++++ doc/ck_rhs_rebuild | 76 ++++++++++++++++++ doc/ck_rhs_remove | 92 ++++++++++++++++++++++ doc/ck_rhs_reset | 77 ++++++++++++++++++ doc/ck_rhs_reset_size | 80 +++++++++++++++++++ doc/ck_rhs_set | 102 ++++++++++++++++++++++++ doc/ck_rhs_stat | 80 +++++++++++++++++++ 20 files changed, 1721 insertions(+) create mode 100644 doc/ck_rhs_apply create mode 100644 doc/ck_rhs_count create mode 100644 doc/ck_rhs_destroy create mode 100644 doc/ck_rhs_fas create mode 100644 doc/ck_rhs_gc create mode 100644 doc/ck_rhs_get create mode 100644 doc/ck_rhs_grow create mode 100644 doc/ck_rhs_init create mode 100644 doc/ck_rhs_iterator_init create mode 100644 doc/ck_rhs_move create mode 100644 doc/ck_rhs_next create mode 100644 doc/ck_rhs_put create mode 100644 doc/ck_rhs_put_unique create mode 100644 doc/ck_rhs_rebuild create mode 100644 doc/ck_rhs_remove create mode 100644 doc/ck_rhs_reset create mode 100644 doc/ck_rhs_reset_size create mode 100644 doc/ck_rhs_set create mode 100644 doc/ck_rhs_stat diff --git a/doc/Makefile.in b/doc/Makefile.in index 0c2dc26..dbd9daa 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -89,6 +89,25 @@ OBJECTS=CK_ARRAY_FOREACH \ ck_hs_reset \ ck_hs_reset_size \ ck_hs_stat \ + ck_rhs_gc \ + ck_rhs_init \ + ck_rhs_destroy \ + CK_RHS_HASH \ + ck_rhs_apply \ + ck_rhs_iterator_init \ + ck_rhs_next \ + ck_rhs_get \ + ck_rhs_put \ + ck_rhs_set \ + ck_rhs_fas \ + ck_rhs_remove \ + ck_rhs_move \ + ck_rhs_grow \ + ck_rhs_rebuild \ + ck_rhs_count \ + ck_rhs_reset \ + ck_rhs_reset_size \ + ck_rhs_stat \ ck_rwcohort \ CK_RWCOHORT_INIT \ CK_RWCOHORT_INSTANCE \ diff --git a/doc/ck_rhs_apply b/doc/ck_rhs_apply new file mode 100644 index 0000000..80b1da7 --- /dev/null +++ b/doc/ck_rhs_apply @@ -0,0 +1,86 @@ +.\" +.\" Copyright 2014 Samy Al Bahra. +.\" Copyright 2014 Backtrace I/O, Inc. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 1, 2014 +.Dt CK_RHS_APPLY 3 +.Sh NAME +.Nm ck_rhs_apply +.Nd apply a function to hash set value +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft void * +.Fn ck_rhs_apply_fn_t "void *key" "void *closure" +.Ft bool +.Fn ck_rhs_apply "ck_rhs_t *hs" "unsigned long hash" "const void *key" "ck_rhs_apply_fn_t *function" "void *argument" +.Sh DESCRIPTION +The +.Fn ck_rhs_apply 3 +function will lookup the hash set slot associated with +.Fa key +and pass it to function pointed to by +.Fa function +for further action. This callback may remove or replace +the value by respectively returning NULL or a pointer to +another object with an identical key. The first argument +passed to +.Fa function +is a pointer to the object found in the hash set and +the second argument is the +.Fa argument +pointer passed to +.Fn ck_rhs_apply 3 . +If the pointer returned by +.Fa function +is equivalent to the first argument then no modification +is made to the hash set. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_apply 3 +returns true and otherwise returns false on failure. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr ck_rhs_fas 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_count b/doc/ck_rhs_count new file mode 100644 index 0000000..3a42b12 --- /dev/null +++ b/doc/ck_rhs_count @@ -0,0 +1,70 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_COUNT 3 +.Sh NAME +.Nm ck_rhs_count +.Nd returns number of entries in hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft unsigned long +.Fn ck_rhs_count "ck_rhs_t *hs" +.Sh DESCRIPTION +The +.Fn ck_rhs_count 3 +function returns the number of keys currently +stored in +.Fa hs . +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_destroy b/doc/ck_rhs_destroy new file mode 100644 index 0000000..68de27e --- /dev/null +++ b/doc/ck_rhs_destroy @@ -0,0 +1,77 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_DESTROY 3 +.Sh NAME +.Nm ck_rhs_destroy +.Nd destroy hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft void +.Fn ck_rhs_destroy "ck_rhs_t *hs" +.Sh DESCRIPTION +The +.Fn ck_rhs_destroy 3 +function will request that the underlying allocator, as specified by the +.Xr ck_rhs_init 3 +function, immediately destroy the object pointed to by the +.Fa hs +argument. +The user must guarantee that no threads are accessing the object pointed to +by +.Fa hs +when +.Fn ck_rhs_destroy 3 +is called. +.Sh RETURN VALUES +.Fn ck_rhs_destroy 3 +has no return value. +.Sh ERRORS +This function is guaranteed not to fail. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_fas b/doc/ck_rhs_fas new file mode 100644 index 0000000..453c40b --- /dev/null +++ b/doc/ck_rhs_fas @@ -0,0 +1,98 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd June 20, 2013 +.Dt CK_RHS_FAS 3 +.Sh NAME +.Nm ck_rhs_fas +.Nd fetch and store key in hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_fas "ck_rhs_t *hs" "unsigned long hash" "const void *key" "void **previous" +.Sh DESCRIPTION +The +.Fn ck_rhs_fas 3 +function will fetch and store the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_fas 3 +was successful then the key specified by +.Fa key +was successfully stored in the hash set pointed to by +.Fa hs . +The key must already exist in the hash set, and is +replaced by +.Fa key +and the previous value is stored into the void pointer +pointed to by the +.Fa previous +argument. If the key does not exist in the hash set +then the function will return false and the hash set +is unchanged. This function +is guaranteed to be stable with respect to memory usage. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_fas 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_gc b/doc/ck_rhs_gc new file mode 100644 index 0000000..0ad5324 --- /dev/null +++ b/doc/ck_rhs_gc @@ -0,0 +1,73 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd December 17, 2013 +.Dt CK_RHS_GC 3 +.Sh NAME +.Nm ck_rhs_gc +.Nd perform maintenance on a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_gc "ck_rhs_t *hs" +.Sh DESCRIPTION +The +.Fn ck_rhs_gc 3 +function will perform various maintenance routines on the hash set +pointed to by +.Fa hs , +including recalculating the maximum number of probes. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_gc 3 +returns true and otherwise returns false on failure due to memory allocation +failure. +.Sh ERRORS +This function will only return false if there are internal memory allocation +failures. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_get b/doc/ck_rhs_get new file mode 100644 index 0000000..51c6e2f --- /dev/null +++ b/doc/ck_rhs_get @@ -0,0 +1,88 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_GET 3 +.Sh NAME +.Nm ck_rhs_get +.Nd load a key from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft void * +.Fn ck_rhs_get "ck_rhs_t *hs" "unsigned long hash" "const void *key" +.Sh DESCRIPTION +The +.Fn ck_rhs_get 3 +function will return a pointer to a key in the hash set +.Fa hs +that is of equivalent value to the object pointed to by +.Fa key . +The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which is to have been previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Sh RETURN VALUES +If the provided key is a member of +.Fa hs +then a pointer to the key as stored in +.Fa hs +is returned. If the key was not found in +.Fa hs +then a value of +.Dv NULL +is returned. +.Sh ERRORS +Behavior is undefined if +.Fa entry +or +.Fa hs +are uninitialized. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_grow b/doc/ck_rhs_grow new file mode 100644 index 0000000..f1cac26 --- /dev/null +++ b/doc/ck_rhs_grow @@ -0,0 +1,81 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_GROW 3 +.Sh NAME +.Nm ck_rhs_grow +.Nd enlarge hash set capacity +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_grow "ck_rhs_t *hs" "unsigned long capacity" +.Sh DESCRIPTION +The +.Fn ck_rhs_grow 3 +function will resize the hash set in order to be +able to store at least the number of entries specified by +.Fa capacity +at a load factor of one. The default hash set load factor +is 0.5. If you wish to minimize the likelihood of memory allocations +for a hash set meant to store n entries, then specify a +.Fa capacity +of 2n. The default behavior of ck_rhs is to round +.Fa capacity +to the next power of two if it is not already a power of two. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_grow 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. This function will only +return false if there are internal memory allocation +failures. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_init b/doc/ck_rhs_init new file mode 100644 index 0000000..17c5097 --- /dev/null +++ b/doc/ck_rhs_init @@ -0,0 +1,166 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_INIT 3 +.Sh NAME +.Nm ck_rhs_init +.Nd initialize a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft typedef unsigned long +.Fn ck_rhs_hash_cb_t "const void *key" "unsigned long seed" +.Ft typedef bool +.Fn ck_rhs_compare_cb_t "const void *c1" "const void *c2" +.Ft bool +.Fn ck_rhs_init "ck_rhs_t *hs" "unsigned int mode" "ck_rhs_hash_cb_t *hash_function" "ck_rhs_compare_cb_t *compare" "struct ck_malloc *allocator" "unsigned long capacity" "unsigned long seed" +.Sh DESCRIPTION +The +.Fn ck_rhs_init +function initializes the hash set pointed to by the +.Fa hs +pointer. +.Pp +The argument +.Fa mode +specifies the type of key-value pairs to be stored in the +hash set as well as the expected concurrent access model. +The value of +.Fa mode +consists of a bitfield of one of the following: +.Bl -tag -width indent +.It CK_RHS_MODE_OBJECT +The hash set is meant to store pointers to objects. This provides +a hint that only CK_MD_VMA_BITS are necessary to encode the key +argument. Any unused pointer bits are leveraged for internal +optimizations. +.It CK_RHS_MODE_DIRECT +The hash set is meant to directly store key values and that all +bits of the key are used to encode values. +.It CK_RHS_MODE_READ_MOSTLY +Optimize read operations over put/delete. +.El +.Pp +The concurrent access model is specified by: +.Bl -tag -width indent +.It CK_RHS_MODE_SPMC +The hash set should allow for concurrent readers in the +presence of a single writer. +.It CK_RHS_MODE_MPMC +The hash set should allow for concurrent readers in the +presence of concurrent writers. This is currently unsupported. +.El +.Pp +The developer is free to specify additional workload hints. +These hints are one of: +.Bl -tag -width indent +.El +.Pp +The argument +.Fa hash_function +is a mandatory pointer to a user-specified hash function. +A user-specified hash function takes two arguments. The +.Fa key +argument is a pointer to a key. The +.Fa seed +argument is the initial seed associated with the hash set. +This initial seed is specified by the user in +.Xr ck_rhs_init 3 . +.Pp +The +.Fa compare +argument is an optional pointer to a user-specified +key comparison function. If NULL is specified in this +argument, then pointer equality will be used to determine +key equality. A user-specified comparison function takes +two arguments representing pointers to the objects being +compared for equality. It is expected to return true +if the keys are of equal value and false otherwise. +.Pp +The +.Fa allocator +argument is a pointer to a structure containing +.Fa malloc +and +.Fa free +function pointers which respectively define the memory allocation and +destruction functions to be used by the hash set being initialized. +.Pp +The argument +.Fa capacity +represents the initial number of keys the hash +set is expected to contain. This argument is simply a hint +and the underlying implementation is free to allocate more +or less memory than necessary to contain the number of entries +.Fa capacity +specifies. +.Pp +The argument +.Fa seed +specifies the initial seed used by the underlying hash function. +The user is free to choose a value of their choice. +.Sh RETURN VALUES +Upon successful completion +.Fn ck_rhs_init +returns a value of +.Dv true +and otherwise returns a value of +.Dv false +to indicate an error. +.Sh ERRORS +.Bl -tag -width Er +.Pp +The behavior of +.Fn ck_rhs_init +is undefined if +.Fa hs +is not a pointer to a +.Tn ck_rhs_t +object. +.El +.Sh SEE ALSO +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_iterator_init b/doc/ck_rhs_iterator_init new file mode 100644 index 0000000..4cfd083 --- /dev/null +++ b/doc/ck_rhs_iterator_init @@ -0,0 +1,78 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_ITERATOR_INIT 3 +.Sh NAME +.Nm ck_rhs_iterator_init +.Nd initialize hash set iterator +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Pp +.Dv ck_rhs_iterator_t iterator = CK_RHS_ITERATOR_INITIALIZER +.Pp +.Ft void +.Fn ck_rhs_iterator_init "ck_rhs_iterator_t *iterator" +.Sh DESCRIPTION +The +.Fn ck_rhs_iterator_init 3 +function will initialize the object pointed to +by the +.Fa iterator +argument. Alternatively, an iterator may be statically +initialized by assigning it to the CK_RHS_ITERATOR_INITIALIZER value. +.Pp +An iterator is used to iterate through hash set entries with the +.Xr ck_rhs_next 3 +function. +.Sh RETURN VALUES +.Fn ck_rhs_iterator_init 3 +has no return value. +.Sh ERRORS +This function will not fail. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_move b/doc/ck_rhs_move new file mode 100644 index 0000000..45e38e7 --- /dev/null +++ b/doc/ck_rhs_move @@ -0,0 +1,90 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd July 18, 2013 +.Dt CK_RHS_MOVE 3 +.Sh NAME +.Nm ck_rhs_move +.Nd move one from hash set to another +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_move "ck_rhs_t *destination" "ck_rhs_t *source" "ck_rhs_hash_cb_t *hash_cb" "ck_rhs_compare_cb_t *compare_cb" "struct ck_malloc *m" +.Sh DESCRIPTION +The +.Fn ck_rhs_move 3 +function will initialize +.Fa source +from +.Fa destination . +The hash function is set to +.Fa hash_cb , +comparison function to +.Fa compare_cb +and the allocator callbacks to +.Fa m . +Further modifications to +.Fa source +will result in undefined behavior. Concurrent +.Xr ck_rhs_get 3 +and +.Xr ck_rhs_fas 3 +operations to +.Fa source +are legal until the next write operation to +.Fa destination . +.Pp +This operation moves ownership from one hash set object +to another and re-assigns callback functions to developer-specified +values. This allows for dynamic configuration of allocation +callbacks and is necessary for use-cases involving executable code +which may be unmapped underneath the hash set. +.Sh RETURN VALUES +Upon successful completion +.Fn ck_rhs_move 3 +returns true and otherwise returns false to indicate an error. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_next b/doc/ck_rhs_next new file mode 100644 index 0000000..c90a7d6 --- /dev/null +++ b/doc/ck_rhs_next @@ -0,0 +1,92 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_NEXT 3 +.Sh NAME +.Nm ck_rhs_next +.Nd iterate to next entry in hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_next "ck_rhs_t *hs" "ck_rhs_iterator_t *iterator" "void **entry" +.Sh DESCRIPTION +The +.Fn ck_rhs_next 3 +function will increment the iterator object pointed to by +.Fa iterator +to point to the next non-empty hash set entry. If +.Fn ck_rhs_next 3 +returns true then the pointer pointed to by +.Fa entry +is initialized to the current hash set key pointed to by the +.Fa iterator +object. +.Pp +It is expected that +.Fa iterator +has been initialized using the +.Xr ck_rhs_iterator_init 3 +function or statically initialized using CK_RHS_ITERATOR_INITIALIZER. +.Sh RETURN VALUES +If +.Fn ck_rhs_next 3 +returns true then the object pointed to by +.Fa entry +points to a valid hash set key. If +.Fn ck_rhs_next 3 +returns false then the value of the object pointed to by +.Fa entry +is undefined. +.Sh ERRORS +Behavior is undefined if +.Fa iterator +or +.Fa hs +are uninitialized. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_put b/doc/ck_rhs_put new file mode 100644 index 0000000..8df9b65 --- /dev/null +++ b/doc/ck_rhs_put @@ -0,0 +1,98 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_PUT 3 +.Sh NAME +.Nm ck_rhs_put +.Nd store unique key into a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_put "ck_rhs_t *hs" "unsigned long hash" "const void *key" +.Sh DESCRIPTION +The +.Fn ck_rhs_put 3 +function will store the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_put 3 +was successful then the key specified by +.Fa key +was successfully stored in the hash set pointed to by +.Fa hs . +The function will fail if a key with an +equivalent value to +.Fa key +is already present in the hash set. For replacement +semantics, please see the +.Xr ck_rhs_set 3 +function. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_put 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. The function will also +return false if the hash set could not be enlarged +to accomodate key insertion. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_put_unique b/doc/ck_rhs_put_unique new file mode 100644 index 0000000..4f941ab --- /dev/null +++ b/doc/ck_rhs_put_unique @@ -0,0 +1,98 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd December 7, 2013 +.Dt CK_RHS_PUT_UNIQUE 3 +.Sh NAME +.Nm ck_rhs_put_unique +.Nd unconditionally store unique key into a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_put_unique "ck_rhs_t *hs" "unsigned long hash" "const void *key" +.Sh DESCRIPTION +The +.Fn ck_rhs_put_unique 3 +function will store the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_put 3 +was successful then the key specified by +.Fa key +was successfully stored in the hash set pointed to by +.Fa hs . +The function will cause undefined behavior if a key with an +equivalent value is already present in the hash set. For replacement +semantics, please see the +.Xr ck_rhs_set 3 +function. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_put_unique 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. The function will also +return false if the hash set could not be enlarged +to accomodate key insertion. The function will +result in undefined behavior if called for an +already inserted key value. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_rebuild b/doc/ck_rhs_rebuild new file mode 100644 index 0000000..8ab9b50 --- /dev/null +++ b/doc/ck_rhs_rebuild @@ -0,0 +1,76 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd December 7, 2013 +.Dt CK_RHS_REBUILD 3 +.Sh NAME +.Nm ck_rhs_rebuild +.Nd rebuild a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_rebuild "ck_rhs_t *hs" +.Sh DESCRIPTION +The +.Fn ck_rhs_rebuild 3 +function will regenerate the hash set pointed to by +.Fa hs . +This has the side-effect of pruning degradatory side-effects +of workloads that are delete heavy. The regenerated hash +set should have shorter probe sequences on average. This +operation will require a significant amount of memory +and is free to allocate a duplicate hash set in the +rebuild process. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_rebuild 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +This function will only return false if there are internal memory allocation +failures. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_remove b/doc/ck_rhs_remove new file mode 100644 index 0000000..c83bf38 --- /dev/null +++ b/doc/ck_rhs_remove @@ -0,0 +1,92 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_REMOVE 3 +.Sh NAME +.Nm ck_rhs_remove +.Nd remove key from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft void * +.Fn ck_rhs_remove "ck_rhs_t *hs" "unsigned long hash" "const void *key" +.Sh DESCRIPTION +The +.Fn ck_rhs_remove 3 +function will attempt to remove the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_remove 3 +was successful then the key contained in the hash +set is returned. If the key was not a member of the hash +set then +.Dv NULL +is returned. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_remove 3 +returns a pointer to a key and otherwise returns +.Dv NULL +on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_reset b/doc/ck_rhs_reset new file mode 100644 index 0000000..a750d85 --- /dev/null +++ b/doc/ck_rhs_reset @@ -0,0 +1,77 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_RESET 3 +.Sh NAME +.Nm ck_rhs_reset +.Nd remove all keys from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_reset "ck_rhs_t *hs" +.Sh DESCRIPTION +The +.Fn ck_rhs_reset 3 +function will remove all keys stored in the hash +set pointed to by the +.Fa hs +argument. +.Sh RETURN VALUES +If successful, +.Fn ck_rhs_reset 3 +will return true and will otherwise return false on failure. This +function will only fail if a replacement hash set could not be +allocated internally. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_reset_size b/doc/ck_rhs_reset_size new file mode 100644 index 0000000..6e9913e --- /dev/null +++ b/doc/ck_rhs_reset_size @@ -0,0 +1,80 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd May 5, 2013 +.Dt CK_RHS_RESET_SIZE 3 +.Sh NAME +.Nm ck_rhs_reset_size +.Nd remove all keys from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_reset_size "ck_rhs_t *hs" "unsigned long size" +.Sh DESCRIPTION +The +.Fn ck_rhs_reset_size 3 +function will remove all keys stored in the hash +set pointed to by the +.Fa hs +argument and create a new generation of the hash set that +is preallocated for +.Fa size +entries. +.Sh RETURN VALUES +If successful, +.Fn ck_rhs_reset_size 3 +will return true and will otherwise return false on failure. This +function will only fail if a replacement hash set could not be +allocated internally. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_set b/doc/ck_rhs_set new file mode 100644 index 0000000..6f3e280 --- /dev/null +++ b/doc/ck_rhs_set @@ -0,0 +1,102 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_SET 3 +.Sh NAME +.Nm ck_rhs_set +.Nd store key into a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_set "ck_rhs_t *hs" "unsigned long hash" "const void *key" "void **previous" +.Sh DESCRIPTION +The +.Fn ck_rhs_set 3 +function will store the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_set 3 +was successful then the key specified by +.Fa key +was successfully stored in the hash set pointed to by +.Fa hs . +If the key already exists in the hash set, then it is +replaced by +.Fa key +and the previous value is stored into the void pointer +pointed to by the +.Fa previous +argument. If previous is set to +.Dv NULL +then +.Fa key +was not a replacement for an existing entry in the hash set. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_set 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. The function will also +return false if the hash set could not be enlarged +to accomodate key insertion. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_stat b/doc/ck_rhs_stat new file mode 100644 index 0000000..df45672 --- /dev/null +++ b/doc/ck_rhs_stat @@ -0,0 +1,80 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_STAT 3 +.Sh NAME +.Nm ck_rhs_stat +.Nd get hash set status +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft void +.Fn ck_rhs_stat "ck_rhs_t *hs" "struct ck_rhs_stat *st" +.Sh DESCRIPTION +The +.Fn ck_rhs_stat 3 +function will store various hash set statistics in +the object pointed to by +.Fa st . +The ck_rhs_stat structure is defined as follows: +.Bd -literal -offset indent +struct ck_rhs_stat { + unsigned long n_entries; /* Current number of keys in hash set. */ + unsigned int probe_maximum; /* Longest read-side probe sequence. */ +}; +.Ed +.Sh RETURN VALUES +.Fn ck_rhs_stat 3 +has no return value. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 +.Pp +Additional information available at http://concurrencykit.org/ From 70e59219bc062b6f9c413cfcc90b0ff9c64dc95a Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Wed, 7 Jan 2015 21:03:39 +0100 Subject: [PATCH 44/49] ck_rhs: Use CK_RHS_MAX_RH instead of hardcoding 512. --- src/ck_rhs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ck_rhs.c b/src/ck_rhs.c index 2d177cc..76043ea 100644 --- a/src/ck_rhs.c +++ b/src/ck_rhs.c @@ -892,7 +892,7 @@ ck_rhs_put_robin_hood(struct ck_rhs *hs, unsigned long h = 0; long prev; void *key; - long prevs[512]; + long prevs[CK_RHS_MAX_RH]; unsigned int prevs_nb = 0; map = hs->map; From 508e92d2fca2606a530421032a468f91a39e43ae Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 26 Jan 2015 18:51:15 -0500 Subject: [PATCH 45/49] ck_backoff: Remove usage of volatile. This avoids memory traffic in busy-wait loops. Been on TODO list for a while, may as well bite the bullet. No regressions introduced in recent versions of GCC, clang and ICC. --- include/ck_backoff.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/ck_backoff.h b/include/ck_backoff.h index 9e43847..cf3045c 100644 --- a/include/ck_backoff.h +++ b/include/ck_backoff.h @@ -28,6 +28,7 @@ #define _CK_BACKOFF_H #include +#include #ifndef CK_BACKOFF_CEILING #define CK_BACKOFF_CEILING ((1 << 20) - 1) @@ -35,20 +36,19 @@ #define CK_BACKOFF_INITIALIZER (1 << 9) -typedef volatile unsigned int ck_backoff_t; +typedef unsigned int ck_backoff_t; /* * This is a exponential back-off implementation. */ CK_CC_INLINE static void -ck_backoff_eb(volatile unsigned int *c) +ck_backoff_eb(unsigned int *c) { - volatile unsigned int i; - unsigned int ceiling; + unsigned int i, ceiling; ceiling = *c; - - for (i = 0; i < ceiling; i++); + for (i = 0; i < ceiling; i++) + ck_pr_barrier(); *c = ceiling <<= ceiling < CK_BACKOFF_CEILING; return; From 5c298bd0e5e2c586e7e291fd26bdcfb89da1dd3a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Tue, 27 Jan 2015 12:47:28 -0500 Subject: [PATCH 46/49] build: Use _DEFAULT_SOURCE. _BSD_SOURCE is now deprecated in favor of _DEFAULT_SOURCE. Use _DEFAULT_SOURCE, but retain _BSD_SOURCE for backwards compatibility. Thanks to Phil Sorber (PSUdaemon) for patch and investigation. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 150a4a8..db3bdda 100755 --- a/configure +++ b/configure @@ -599,7 +599,7 @@ elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER" INSTALL_LIBS="install-lib" fi - CFLAGS="-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99 -pedantic -Wall -W -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -fstrict-aliasing -O2 -pipe -Wno-parentheses $CFLAGS" + CFLAGS="-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -std=gnu99 -pedantic -Wall -W -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -fstrict-aliasing -O2 -pipe -Wno-parentheses $CFLAGS" PTHREAD_CFLAGS="-pthread" if test "$COMPILER" = "mingw64"; then ENVIRONMENT=64 From 677a901ded1bf4962556d6c73d6786d84e255303 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Mon, 2 Feb 2015 01:19:09 +0100 Subject: [PATCH 47/49] ck_rhs: Realign comments correctly. --- src/ck_rhs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ck_rhs.c b/src/ck_rhs.c index 76043ea..657ee20 100644 --- a/src/ck_rhs.c +++ b/src/ck_rhs.c @@ -78,10 +78,10 @@ enum ck_rhs_probe_behavior { CK_RHS_PROBE = 0, /* Default behavior. */ - CK_RHS_PROBE_RH, /* Short-circuit if RH slot found. */ + CK_RHS_PROBE_RH, /* Short-circuit if RH slot found. */ CK_RHS_PROBE_INSERT, /* Short-circuit on probe bound if tombstone found. */ - CK_RHS_PROBE_ROBIN_HOOD, /* Look for the first slot available for the entry we are about to replace, only used to internally implement Robin Hood */ + CK_RHS_PROBE_ROBIN_HOOD,/* Look for the first slot available for the entry we are about to replace, only used to internally implement Robin Hood */ CK_RHS_PROBE_NO_RH, /* Don't do the RH dance */ }; struct ck_rhs_entry_desc { From d2c26d60f3c1e8243aca0002478f9f1913b2564e Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Mon, 2 Feb 2015 01:21:49 +0100 Subject: [PATCH 48/49] doc: Forgot to add CK_RHS_HASH --- doc/CK_RHS_HASH | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 doc/CK_RHS_HASH diff --git a/doc/CK_RHS_HASH b/doc/CK_RHS_HASH new file mode 100644 index 0000000..43b8859 --- /dev/null +++ b/doc/CK_RHS_HASH @@ -0,0 +1,71 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" 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 REGENTS 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 REGENTS 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. +.\" +.\" +.Dd March 28, 2012 +.Dt CK_RHS_HASH 3 +.Sh NAME +.Nm CK_RHS_HASH +.Nd invoke hash function with hash set seed +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft unsigned long +.Fn CK_RHS_HASH "ck_rhs_t *hs" "ck_rhs_hash_cb_t *hf" "const void *key" +.Sh DESCRIPTION +The +.Fn CK_RHS_HASH 3 +macro will invoke the hash function pointed to by the +.Fa hf +argument with the seed value associated with +.Fa hs +and the key pointer specified by the +.Fa key +argument. +.Sh RETURN VALUES +This function will return the value returned by the +.Fa hf +function. +.Sh ERRORS +It is expected +.Fa hs +was previously initialized via +.Fn ck_rhs_init 3 . +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_destroy 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ From 7996e0456078d5757e604fe410fc8e2777a1709b Mon Sep 17 00:00:00 2001 From: Theo Schlossnagle Date: Mon, 23 Feb 2015 16:56:06 +0000 Subject: [PATCH 49/49] Support 32bit builds on Illumos/Solaris via ISA=i386 --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 57da1bb..f5934f3 100755 --- a/configure +++ b/configure @@ -418,7 +418,7 @@ case $PLATFORM in "i86pc") RTM_ENABLE="CK_MD_RTM_DISABLE" MM="${MM:-"CK_MD_TSO"}" - ISA=`isainfo -n 2> /dev/null || echo i386` + if test -z "$ISA"; then ISA=`isainfo -n 2> /dev/null || echo i386` ; fi case "$ISA" in "amd64") RTM_ENABLE=${RTM_ENABLE_SET:-"CK_MD_RTM_DISABLE"}