Samy Al Bahra 10 years ago
commit d2c297deed

@ -1,4 +1,4 @@
Copyright 2010-2013 Samy Al Bahra.
Copyright 2010-2014 Samy Al Bahra.
Copyright 2011-2013 AppNexus, Inc.
All rights reserved.

@ -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@

@ -1 +1,2 @@
CFLAGS+=-m64 -D__ppc64__
LDFLAGS+=-m64

@ -1 +1,2 @@
CFLAGS+=-m32 -D__x86__ -msse -msse2
LDFLAGS+=-m32

@ -1 +1,2 @@
CFLAGS+=-m64 -D__x86_64__
LDFLAGS+=-m64

43
configure vendored

@ -34,7 +34,7 @@ WANT_PIC=yes
P_PWD=`pwd`
MAINTAINER='sbahra@repnop.org'
VERSION=${VERSION:-'0.4.2'}
VERSION=${VERSION:-'0.4.5'}
VERSION_MAJOR='0'
BUILD="$PWD/build/ck.build"
PREFIX=${PREFIX:-"/usr/local"}
@ -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
@ -142,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)
@ -224,21 +236,26 @@ 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
;;
--*)
if test "$OPTION_CHECKING" -eq 1; then
echo "$0 [--help]"
echo "Unknown option $option"
exit $EXIT_FAILURE
fi
;;
*=*)
NAME=`expr "$option" : '\([^=]*\)='`
VALUE=`echo "$value" | sed "s/'/'\\\\\\\\''/g"`
eval "$NAME='$VALUE'"
NAME=`expr -- "$option" : '\([^=]*\)='`
eval "$NAME='$value'"
export $NAME
;;
*)
@ -401,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"}
@ -415,7 +432,7 @@ case $PLATFORM in
;;
esac
;;
"ppc64")
"ppc64"|"ppc64le")
RTM_ENABLE="CK_MD_RTM_DISABLE"
MM="${MM:-"CK_MD_RMO"}"
PLATFORM=ppc64
@ -427,6 +444,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=
@ -576,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

@ -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/

@ -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 \
@ -73,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 \
@ -88,6 +90,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 \

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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/

@ -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

@ -98,4 +98,3 @@ ck_array_initialized(struct ck_array *array)
_ck_i++)
#endif /* _CK_ARRAY_H */

@ -28,6 +28,7 @@
#define _CK_BACKOFF_H
#include <ck_cc.h>
#include <ck_pr.h>
#ifndef CK_BACKOFF_CEILING
#define CK_BACKOFF_CEILING ((1 << 20) - 1)
@ -35,24 +36,22 @@
#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;
}
#endif /* _CK_BACKOFF_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 */

@ -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,20 @@ 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.
*/
@ -251,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;
@ -275,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);
@ -379,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;
@ -441,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;

@ -277,4 +277,3 @@ ck_brlock_read_unlock(struct ck_brlock_reader *reader)
}
#endif /* _CK_BRLOCK_H */

@ -184,4 +184,3 @@ ck_bytelock_read_unlock(struct ck_bytelock *bytelock, unsigned int slot)
}
#endif /* _CK_BYTELOCK_H */

@ -159,4 +159,3 @@ enum ck_cohort_state {
}
#endif /* _CK_COHORT_H */

@ -319,4 +319,3 @@ _ck_elide_fallback(int *retry,
ck_elide_##NAME##_unlock_adaptive(STAT, LOCK)
#endif /* _CK_ELIDE_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 */

@ -472,4 +472,3 @@ ck_fifo_mpmc_trydequeue(struct ck_fifo_mpmc *fifo,
#endif /* CK_F_PR_CAS_PTR_2 */
#endif /* _CK_FIFO_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 */

@ -219,4 +219,3 @@ ck_hp_fifo_trydequeue_mpmc(ck_hp_record_t *record,
(entry) = (T))
#endif /* _CK_HP_FIFO_H */

@ -111,4 +111,3 @@ leave:
}
#endif /* _CK_HP_STACK_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 *,
@ -130,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 */

@ -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 */

@ -29,4 +29,3 @@
#else
#include <limits.h>
#endif /* __linux__ && __KERNEL__ */

@ -37,4 +37,3 @@ struct ck_malloc {
};
#endif /* _CK_MALLOC_H */

@ -140,4 +140,3 @@ leave:
}
#endif /* _CK_PFLOCK_H */

@ -1149,4 +1149,3 @@ CK_PR_FAS_S(8, uint8_t)
#undef CK_PR_FAS
#endif /* _CK_PR_H */

@ -415,4 +415,3 @@ struct { \
} while (0)
#endif /* _CK_QUEUE_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 *,

@ -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 */

@ -315,4 +315,3 @@
}
#endif /* _CK_RWCOHORT_H */

@ -295,4 +295,3 @@ ck_rwlock_recursive_read_unlock(ck_rwlock_recursive_t *rw)
}
#endif /* _CK_RWLOCK_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)
{
/*
@ -123,4 +123,3 @@ ck_sequence_write_end(struct ck_sequence *sq)
}
#endif /* _CK_SEQUENCE_H */

@ -59,4 +59,3 @@ CK_ELIDE_TRYLOCK_PROTOTYPE(ck_spinlock, ck_spinlock_t,
ck_spinlock_locked, ck_spinlock_trylock)
#endif /* _CK_SPINLOCK_H */

@ -352,4 +352,3 @@ ck_stack_init(struct ck_stack *stack)
(entry) = (T))
#endif /* _CK_STACK_H */

@ -30,4 +30,3 @@
#else
#include <stdint.h>
#endif /* __linux__ && __KERNEL__ */

@ -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 */

@ -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");

@ -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

@ -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);
}
}

@ -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

@ -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 <stdio.h>
#include <ck_epoch.h>
#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)
{
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;
}

@ -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

@ -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 <ck_hs.h>
#include <assert.h>
#include <ck_malloc.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#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 <dictionary> [<repetitions> <initial size>]\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;
}

@ -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 *

@ -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 (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 (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");
break;
}
@ -214,8 +268,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)

@ -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 (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 (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)

@ -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:

@ -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 <threads> <affinity delta> <size>\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;
}

@ -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

@ -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);

@ -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,7 +377,30 @@ rdtsc(void)
return (((uint64_t)edx << 32) | eax);
#else
__asm__ __volatile__("cpuid;"
"rdtsc;"
: "+a" (eax), "=d" (edx)
:
: "%ebx", "%ecx", "memory");
__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;"
@ -431,4 +454,3 @@ ck_error(const char *message, ...)
va_end(ap);
exit(EXIT_FAILURE);
}

@ -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

@ -238,4 +238,3 @@ ck_array_deinit(struct ck_array *array, bool defer)
array->transaction = array->active = NULL;
return;
}

@ -57,4 +57,3 @@ ck_barrier_centralized(struct ck_barrier_centralized *barrier,
ck_pr_fence_memory();
return;
}

@ -205,4 +205,3 @@ ck_barrier_combining(struct ck_barrier_combining *barrier,
state->sense = ~state->sense;
return;
}

@ -121,4 +121,3 @@ ck_barrier_dissemination(struct ck_barrier_dissemination *barrier,
state->parity = 1 - state->parity;
return;
}

@ -138,4 +138,3 @@ ck_barrier_mcs(struct ck_barrier_mcs *barrier,
state->sense = ~state->sense;
return;
}

@ -181,4 +181,3 @@ leave:
state->sense = ~state->sense;
return;
}

@ -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;
}
@ -426,4 +429,3 @@ ck_epoch_poll(struct ck_epoch *global, struct ck_epoch_record *record)
ck_epoch_dispatch(record, epoch + 1);
return true;
}

@ -321,4 +321,3 @@ ck_hp_purge(struct ck_hp_record *thread)
return;
}

@ -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)
{
@ -630,6 +641,90 @@ 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);
map->n_entries--;
map->tombstones++;
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)
ck_hs_map_postinsert(hs, map);
return true;
}
bool
ck_hs_set(struct ck_hs *hs,
unsigned long h,
@ -680,11 +775,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;
@ -728,10 +820,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;
}
@ -842,4 +931,3 @@ ck_hs_init(struct ck_hs *hs,
hs->map = ck_hs_map_create(hs, n_entries);
return hs->map != NULL;
}

@ -1027,4 +1027,3 @@ ck_ht_destroy(struct ck_ht *table)
}
#endif /* CK_F_HT */

@ -81,7 +81,7 @@ enum ck_rhs_probe_behavior {
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 {
@ -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;
@ -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;
}
@ -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,
@ -1332,4 +1447,3 @@ ck_rhs_init(struct ck_rhs *hs,
hs->map = ck_rhs_map_create(hs, n_entries);
return hs->map != NULL;
}

Loading…
Cancel
Save