http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_grow ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_grow b/lib/ck/doc/ck_rhs_grow new file mode 100644 index 0000000..f1cac26 --- /dev/null +++ b/lib/ck/doc/ck_rhs_grow @@ -0,0 +1,81 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_GROW 3 +.Sh NAME +.Nm ck_rhs_grow +.Nd enlarge hash set capacity +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_grow "ck_rhs_t *hs" "unsigned long capacity" +.Sh DESCRIPTION +The +.Fn ck_rhs_grow 3 +function will resize the hash set in order to be +able to store at least the number of entries specified by +.Fa capacity +at a load factor of one. The default hash set load factor +is 0.5. If you wish to minimize the likelihood of memory allocations +for a hash set meant to store n entries, then specify a +.Fa capacity +of 2n. The default behavior of ck_rhs is to round +.Fa capacity +to the next power of two if it is not already a power of two. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_grow 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. This function will only +return false if there are internal memory allocation +failures. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_init ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_init b/lib/ck/doc/ck_rhs_init new file mode 100644 index 0000000..17c5097 --- /dev/null +++ b/lib/ck/doc/ck_rhs_init @@ -0,0 +1,166 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_INIT 3 +.Sh NAME +.Nm ck_rhs_init +.Nd initialize a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft typedef unsigned long +.Fn ck_rhs_hash_cb_t "const void *key" "unsigned long seed" +.Ft typedef bool +.Fn ck_rhs_compare_cb_t "const void *c1" "const void *c2" +.Ft bool +.Fn ck_rhs_init "ck_rhs_t *hs" "unsigned int mode" "ck_rhs_hash_cb_t *hash_function" "ck_rhs_compare_cb_t *compare" "struct ck_malloc *allocator" "unsigned long capacity" "unsigned long seed" +.Sh DESCRIPTION +The +.Fn ck_rhs_init +function initializes the hash set pointed to by the +.Fa hs +pointer. +.Pp +The argument +.Fa mode +specifies the type of key-value pairs to be stored in the +hash set as well as the expected concurrent access model. +The value of +.Fa mode +consists of a bitfield of one of the following: +.Bl -tag -width indent +.It CK_RHS_MODE_OBJECT +The hash set is meant to store pointers to objects. This provides +a hint that only CK_MD_VMA_BITS are necessary to encode the key +argument. Any unused pointer bits are leveraged for internal +optimizations. +.It CK_RHS_MODE_DIRECT +The hash set is meant to directly store key values and that all +bits of the key are used to encode values. +.It CK_RHS_MODE_READ_MOSTLY +Optimize read operations over put/delete. +.El +.Pp +The concurrent access model is specified by: +.Bl -tag -width indent +.It CK_RHS_MODE_SPMC +The hash set should allow for concurrent readers in the +presence of a single writer. +.It CK_RHS_MODE_MPMC +The hash set should allow for concurrent readers in the +presence of concurrent writers. This is currently unsupported. +.El +.Pp +The developer is free to specify additional workload hints. +These hints are one of: +.Bl -tag -width indent +.El +.Pp +The argument +.Fa hash_function +is a mandatory pointer to a user-specified hash function. +A user-specified hash function takes two arguments. The +.Fa key +argument is a pointer to a key. The +.Fa seed +argument is the initial seed associated with the hash set. +This initial seed is specified by the user in +.Xr ck_rhs_init 3 . +.Pp +The +.Fa compare +argument is an optional pointer to a user-specified +key comparison function. If NULL is specified in this +argument, then pointer equality will be used to determine +key equality. A user-specified comparison function takes +two arguments representing pointers to the objects being +compared for equality. It is expected to return true +if the keys are of equal value and false otherwise. +.Pp +The +.Fa allocator +argument is a pointer to a structure containing +.Fa malloc +and +.Fa free +function pointers which respectively define the memory allocation and +destruction functions to be used by the hash set being initialized. +.Pp +The argument +.Fa capacity +represents the initial number of keys the hash +set is expected to contain. This argument is simply a hint +and the underlying implementation is free to allocate more +or less memory than necessary to contain the number of entries +.Fa capacity +specifies. +.Pp +The argument +.Fa seed +specifies the initial seed used by the underlying hash function. +The user is free to choose a value of their choice. +.Sh RETURN VALUES +Upon successful completion +.Fn ck_rhs_init +returns a value of +.Dv true +and otherwise returns a value of +.Dv false +to indicate an error. +.Sh ERRORS +.Bl -tag -width Er +.Pp +The behavior of +.Fn ck_rhs_init +is undefined if +.Fa hs +is not a pointer to a +.Tn ck_rhs_t +object. +.El +.Sh SEE ALSO +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_iterator_init ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_iterator_init b/lib/ck/doc/ck_rhs_iterator_init new file mode 100644 index 0000000..4cfd083 --- /dev/null +++ b/lib/ck/doc/ck_rhs_iterator_init @@ -0,0 +1,78 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_ITERATOR_INIT 3 +.Sh NAME +.Nm ck_rhs_iterator_init +.Nd initialize hash set iterator +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Pp +.Dv ck_rhs_iterator_t iterator = CK_RHS_ITERATOR_INITIALIZER +.Pp +.Ft void +.Fn ck_rhs_iterator_init "ck_rhs_iterator_t *iterator" +.Sh DESCRIPTION +The +.Fn ck_rhs_iterator_init 3 +function will initialize the object pointed to +by the +.Fa iterator +argument. Alternatively, an iterator may be statically +initialized by assigning it to the CK_RHS_ITERATOR_INITIALIZER value. +.Pp +An iterator is used to iterate through hash set entries with the +.Xr ck_rhs_next 3 +function. +.Sh RETURN VALUES +.Fn ck_rhs_iterator_init 3 +has no return value. +.Sh ERRORS +This function will not fail. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_move ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_move b/lib/ck/doc/ck_rhs_move new file mode 100644 index 0000000..45e38e7 --- /dev/null +++ b/lib/ck/doc/ck_rhs_move @@ -0,0 +1,90 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd July 18, 2013 +.Dt CK_RHS_MOVE 3 +.Sh NAME +.Nm ck_rhs_move +.Nd move one from hash set to another +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_move "ck_rhs_t *destination" "ck_rhs_t *source" "ck_rhs_hash_cb_t *hash_cb" "ck_rhs_compare_cb_t *compare_cb" "struct ck_malloc *m" +.Sh DESCRIPTION +The +.Fn ck_rhs_move 3 +function will initialize +.Fa source +from +.Fa destination . +The hash function is set to +.Fa hash_cb , +comparison function to +.Fa compare_cb +and the allocator callbacks to +.Fa m . +Further modifications to +.Fa source +will result in undefined behavior. Concurrent +.Xr ck_rhs_get 3 +and +.Xr ck_rhs_fas 3 +operations to +.Fa source +are legal until the next write operation to +.Fa destination . +.Pp +This operation moves ownership from one hash set object +to another and re-assigns callback functions to developer-specified +values. This allows for dynamic configuration of allocation +callbacks and is necessary for use-cases involving executable code +which may be unmapped underneath the hash set. +.Sh RETURN VALUES +Upon successful completion +.Fn ck_rhs_move 3 +returns true and otherwise returns false to indicate an error. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_next ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_next b/lib/ck/doc/ck_rhs_next new file mode 100644 index 0000000..c90a7d6 --- /dev/null +++ b/lib/ck/doc/ck_rhs_next @@ -0,0 +1,92 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_NEXT 3 +.Sh NAME +.Nm ck_rhs_next +.Nd iterate to next entry in hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_next "ck_rhs_t *hs" "ck_rhs_iterator_t *iterator" "void **entry" +.Sh DESCRIPTION +The +.Fn ck_rhs_next 3 +function will increment the iterator object pointed to by +.Fa iterator +to point to the next non-empty hash set entry. If +.Fn ck_rhs_next 3 +returns true then the pointer pointed to by +.Fa entry +is initialized to the current hash set key pointed to by the +.Fa iterator +object. +.Pp +It is expected that +.Fa iterator +has been initialized using the +.Xr ck_rhs_iterator_init 3 +function or statically initialized using CK_RHS_ITERATOR_INITIALIZER. +.Sh RETURN VALUES +If +.Fn ck_rhs_next 3 +returns true then the object pointed to by +.Fa entry +points to a valid hash set key. If +.Fn ck_rhs_next 3 +returns false then the value of the object pointed to by +.Fa entry +is undefined. +.Sh ERRORS +Behavior is undefined if +.Fa iterator +or +.Fa hs +are uninitialized. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_put ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_put b/lib/ck/doc/ck_rhs_put new file mode 100644 index 0000000..8df9b65 --- /dev/null +++ b/lib/ck/doc/ck_rhs_put @@ -0,0 +1,98 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_PUT 3 +.Sh NAME +.Nm ck_rhs_put +.Nd store unique key into a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_put "ck_rhs_t *hs" "unsigned long hash" "const void *key" +.Sh DESCRIPTION +The +.Fn ck_rhs_put 3 +function will store the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_put 3 +was successful then the key specified by +.Fa key +was successfully stored in the hash set pointed to by +.Fa hs . +The function will fail if a key with an +equivalent value to +.Fa key +is already present in the hash set. For replacement +semantics, please see the +.Xr ck_rhs_set 3 +function. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_put 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. The function will also +return false if the hash set could not be enlarged +to accomodate key insertion. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_put_unique ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_put_unique b/lib/ck/doc/ck_rhs_put_unique new file mode 100644 index 0000000..4f941ab --- /dev/null +++ b/lib/ck/doc/ck_rhs_put_unique @@ -0,0 +1,98 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd December 7, 2013 +.Dt CK_RHS_PUT_UNIQUE 3 +.Sh NAME +.Nm ck_rhs_put_unique +.Nd unconditionally store unique key into a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_put_unique "ck_rhs_t *hs" "unsigned long hash" "const void *key" +.Sh DESCRIPTION +The +.Fn ck_rhs_put_unique 3 +function will store the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_put 3 +was successful then the key specified by +.Fa key +was successfully stored in the hash set pointed to by +.Fa hs . +The function will cause undefined behavior if a key with an +equivalent value is already present in the hash set. For replacement +semantics, please see the +.Xr ck_rhs_set 3 +function. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_put_unique 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. The function will also +return false if the hash set could not be enlarged +to accomodate key insertion. The function will +result in undefined behavior if called for an +already inserted key value. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_rebuild ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_rebuild b/lib/ck/doc/ck_rhs_rebuild new file mode 100644 index 0000000..8ab9b50 --- /dev/null +++ b/lib/ck/doc/ck_rhs_rebuild @@ -0,0 +1,76 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd December 7, 2013 +.Dt CK_RHS_REBUILD 3 +.Sh NAME +.Nm ck_rhs_rebuild +.Nd rebuild a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_rebuild "ck_rhs_t *hs" +.Sh DESCRIPTION +The +.Fn ck_rhs_rebuild 3 +function will regenerate the hash set pointed to by +.Fa hs . +This has the side-effect of pruning degradatory side-effects +of workloads that are delete heavy. The regenerated hash +set should have shorter probe sequences on average. This +operation will require a significant amount of memory +and is free to allocate a duplicate hash set in the +rebuild process. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_rebuild 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +This function will only return false if there are internal memory allocation +failures. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_remove ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_remove b/lib/ck/doc/ck_rhs_remove new file mode 100644 index 0000000..c83bf38 --- /dev/null +++ b/lib/ck/doc/ck_rhs_remove @@ -0,0 +1,92 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_REMOVE 3 +.Sh NAME +.Nm ck_rhs_remove +.Nd remove key from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft void * +.Fn ck_rhs_remove "ck_rhs_t *hs" "unsigned long hash" "const void *key" +.Sh DESCRIPTION +The +.Fn ck_rhs_remove 3 +function will attempt to remove the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_remove 3 +was successful then the key contained in the hash +set is returned. If the key was not a member of the hash +set then +.Dv NULL +is returned. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_remove 3 +returns a pointer to a key and otherwise returns +.Dv NULL +on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_reset ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_reset b/lib/ck/doc/ck_rhs_reset new file mode 100644 index 0000000..a750d85 --- /dev/null +++ b/lib/ck/doc/ck_rhs_reset @@ -0,0 +1,77 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_RESET 3 +.Sh NAME +.Nm ck_rhs_reset +.Nd remove all keys from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_reset "ck_rhs_t *hs" +.Sh DESCRIPTION +The +.Fn ck_rhs_reset 3 +function will remove all keys stored in the hash +set pointed to by the +.Fa hs +argument. +.Sh RETURN VALUES +If successful, +.Fn ck_rhs_reset 3 +will return true and will otherwise return false on failure. This +function will only fail if a replacement hash set could not be +allocated internally. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_reset_size ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_reset_size b/lib/ck/doc/ck_rhs_reset_size new file mode 100644 index 0000000..6e9913e --- /dev/null +++ b/lib/ck/doc/ck_rhs_reset_size @@ -0,0 +1,80 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd May 5, 2013 +.Dt CK_RHS_RESET_SIZE 3 +.Sh NAME +.Nm ck_rhs_reset_size +.Nd remove all keys from a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_reset_size "ck_rhs_t *hs" "unsigned long size" +.Sh DESCRIPTION +The +.Fn ck_rhs_reset_size 3 +function will remove all keys stored in the hash +set pointed to by the +.Fa hs +argument and create a new generation of the hash set that +is preallocated for +.Fa size +entries. +.Sh RETURN VALUES +If successful, +.Fn ck_rhs_reset_size 3 +will return true and will otherwise return false on failure. This +function will only fail if a replacement hash set could not be +allocated internally. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_set ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_set b/lib/ck/doc/ck_rhs_set new file mode 100644 index 0000000..6f3e280 --- /dev/null +++ b/lib/ck/doc/ck_rhs_set @@ -0,0 +1,102 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_SET 3 +.Sh NAME +.Nm ck_rhs_set +.Nd store key into a hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft bool +.Fn ck_rhs_set "ck_rhs_t *hs" "unsigned long hash" "const void *key" "void **previous" +.Sh DESCRIPTION +The +.Fn ck_rhs_set 3 +function will store the key specified by the +.Fa key +argument in the hash set pointed to by the +.Fa hs +argument. The key specified by +.Fa key +is expected to have the hash value specified by the +.Fa hash +argument (which was previously generated using the +.Xr CK_RHS_HASH 3 +macro). +.Pp +If the call to +.Fn ck_rhs_set 3 +was successful then the key specified by +.Fa key +was successfully stored in the hash set pointed to by +.Fa hs . +If the key already exists in the hash set, then it is +replaced by +.Fa key +and the previous value is stored into the void pointer +pointed to by the +.Fa previous +argument. If previous is set to +.Dv NULL +then +.Fa key +was not a replacement for an existing entry in the hash set. +.Sh RETURN VALUES +Upon successful completion, +.Fn ck_rhs_set 3 +returns true and otherwise returns false on failure. +.Sh ERRORS +Behavior is undefined if +.Fa key +or +.Fa hs +are uninitialized. The function will also +return false if the hash set could not be enlarged +to accomodate key insertion. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 , +.Xr ck_rhs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rhs_stat ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rhs_stat b/lib/ck/doc/ck_rhs_stat new file mode 100644 index 0000000..df45672 --- /dev/null +++ b/lib/ck/doc/ck_rhs_stat @@ -0,0 +1,80 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd September 17, 2012 +.Dt CK_RHS_STAT 3 +.Sh NAME +.Nm ck_rhs_stat +.Nd get hash set status +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_rhs.h +.Ft void +.Fn ck_rhs_stat "ck_rhs_t *hs" "struct ck_rhs_stat *st" +.Sh DESCRIPTION +The +.Fn ck_rhs_stat 3 +function will store various hash set statistics in +the object pointed to by +.Fa st . +The ck_rhs_stat structure is defined as follows: +.Bd -literal -offset indent +struct ck_rhs_stat { + unsigned long n_entries; /* Current number of keys in hash set. */ + unsigned int probe_maximum; /* Longest read-side probe sequence. */ +}; +.Ed +.Sh RETURN VALUES +.Fn ck_rhs_stat 3 +has no return value. +.Sh ERRORS +Behavior is undefined if +.Fa hs +is uninitialized. Behavior is +undefined if this function is called by a non-writer +thread. +.Sh SEE ALSO +.Xr ck_rhs_init 3 , +.Xr ck_rhs_move 3 , +.Xr ck_rhs_destroy 3 , +.Xr CK_RHS_HASH 3 , +.Xr ck_rhs_iterator_init 3 , +.Xr ck_rhs_next 3 , +.Xr ck_rhs_get 3 , +.Xr ck_rhs_put 3 , +.Xr ck_rhs_put_unique 3 , +.Xr ck_rhs_set 3 , +.Xr ck_rhs_fas 3 , +.Xr ck_rhs_remove 3 , +.Xr ck_rhs_grow 3 , +.Xr ck_rhs_gc 3 , +.Xr ck_rhs_rebuild 3 , +.Xr ck_rhs_count 3 , +.Xr ck_rhs_reset 3 , +.Xr ck_rhs_reset_size 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_ring_dequeue_spmc ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_ring_dequeue_spmc b/lib/ck/doc/ck_ring_dequeue_spmc index 82fc2fb..7fd7d9b 100644 --- a/lib/ck/doc/ck_ring_dequeue_spmc +++ b/lib/ck/doc/ck_ring_dequeue_spmc @@ -91,7 +91,7 @@ dequeue(void) } /* An empty ring was encountered, leave. */ - return; + return; } .Ed .Sh RETURN VALUES http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_ring_dequeue_spsc ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_ring_dequeue_spsc b/lib/ck/doc/ck_ring_dequeue_spsc index 75b36ac..069dc7f 100644 --- a/lib/ck/doc/ck_ring_dequeue_spsc +++ b/lib/ck/doc/ck_ring_dequeue_spsc @@ -89,7 +89,7 @@ dequeue(void) } /* An empty ring was encountered, leave. */ - return; + return; } .Ed .Sh RETURN VALUES http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_ring_enqueue_spmc ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_ring_enqueue_spmc b/lib/ck/doc/ck_ring_enqueue_spmc index 20fd6a8..ba99199 100644 --- a/lib/ck/doc/ck_ring_enqueue_spmc +++ b/lib/ck/doc/ck_ring_enqueue_spmc @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -88,11 +88,11 @@ enqueue(void) } /* Enqueue operation completed successfully. */ - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_ring_enqueue_spmc_size ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_ring_enqueue_spmc_size b/lib/ck/doc/ck_ring_enqueue_spmc_size index 900bd28..eb30cab 100644 --- a/lib/ck/doc/ck_ring_enqueue_spmc_size +++ b/lib/ck/doc/ck_ring_enqueue_spmc_size @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -96,11 +96,11 @@ enqueue(void) do_something; } - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_ring_enqueue_spsc ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_ring_enqueue_spsc b/lib/ck/doc/ck_ring_enqueue_spsc index e5fbbec..2493059 100644 --- a/lib/ck/doc/ck_ring_enqueue_spsc +++ b/lib/ck/doc/ck_ring_enqueue_spsc @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -86,11 +86,11 @@ enqueue(void) } /* Enqueue operation completed successfully. */ - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_ring_enqueue_spsc_size ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_ring_enqueue_spsc_size b/lib/ck/doc/ck_ring_enqueue_spsc_size index 90bdf12..7048ea1 100644 --- a/lib/ck/doc/ck_ring_enqueue_spsc_size +++ b/lib/ck/doc/ck_ring_enqueue_spsc_size @@ -42,7 +42,7 @@ function enqueues the pointer .Fa entry into the bounded buffer pointed to by .Fa ring -in FIFO fashion. +in FIFO fashion. The buffer pointed to by .Fa buffer must be unique to @@ -94,11 +94,11 @@ enqueue(void) do_something; } - return; + return; } .Ed .Sh RETURN VALUES -The function returns true if the value of +The function returns true if the value of .Fa entry was successfully enqueued into .Fa ring . http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_ring_trydequeue_spmc ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_ring_trydequeue_spmc b/lib/ck/doc/ck_ring_trydequeue_spmc index 52a92b6..16f83ee 100644 --- a/lib/ck/doc/ck_ring_trydequeue_spmc +++ b/lib/ck/doc/ck_ring_trydequeue_spmc @@ -71,7 +71,7 @@ in a bounded number of steps. It is possible for the function to return false even if .Fa ring -is non-empty. This +is non-empty. This .Sh EXAMPLE .Bd -literal -offset indent #include <ck_ring.h> @@ -97,7 +97,7 @@ dequeue(void) } /* An empty ring was encountered, leave. */ - return; + return; } .Ed .Sh RETURN VALUES http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_rwcohort ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_rwcohort b/lib/ck/doc/ck_rwcohort index 673261d..ba2b5f9 100644 --- a/lib/ck/doc/ck_rwcohort +++ b/lib/ck/doc/ck_rwcohort @@ -69,7 +69,7 @@ either the .Xr CK_COHORT_PROTOTYPE 3 or the .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 -macros, and define a reader-writer lock type using the +macros, and define a reader-writer lock type using the .Xr CK_RWCOHORT_PROTOTYPE 3 macro. .Pp @@ -161,7 +161,7 @@ main(void) calloc(n_cohorts, sizeof(CK_COHORT_INSTANCE(test_cohort))); /* create local locks to use with each cohort */ - ck_spinlock_t *local_locks = + ck_spinlock_t *local_locks = calloc(n_cohorts, sizeof(ck_spinlock_t)); pthread_t *threads = http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_sequence ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_sequence b/lib/ck/doc/ck_sequence index ad06dbe..faa1631 100644 --- a/lib/ck/doc/ck_sequence +++ b/lib/ck/doc/ck_sequence @@ -43,9 +43,9 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_sequence_init "ck_sequence_t *sq" .Ft unsigned int -.Fn ck_sequence_read_begin "ck_sequence_t *sq" +.Fn ck_sequence_read_begin "const ck_sequence_t *sq" .Ft bool -.Fn ck_sequence_read_retry "ck_sequence_t *sq" "unsigned int version" +.Fn ck_sequence_read_retry "const ck_sequence_t *sq" "unsigned int version" .Ft void .Fn ck_sequence_write_begin "ck_sequence_t *sq" .Ft void http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/doc/ck_spinlock ---------------------------------------------------------------------- diff --git a/lib/ck/doc/ck_spinlock b/lib/ck/doc/ck_spinlock index 67d4555..564d185 100644 --- a/lib/ck/doc/ck_spinlock +++ b/lib/ck/doc/ck_spinlock @@ -200,7 +200,7 @@ provides a summary of the current implementations. ck_spinlock_ticket Ticket Centralized None Yes .Ed .Pp -* Hierarchical CLH only offers weak fairness for threads accross cluster +* Hierarchical CLH only offers weak fairness for threads accross cluster nodes. .Pp If contention is low and there is no hard requirement for starvation-freedom http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_array.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_array.h b/lib/ck/include/ck_array.h index e8e366b..dcde6bc 100644 --- a/lib/ck/include/ck_array.h +++ b/lib/ck/include/ck_array.h @@ -98,4 +98,3 @@ ck_array_initialized(struct ck_array *array) _ck_i++) #endif /* _CK_ARRAY_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_backoff.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_backoff.h b/lib/ck/include/ck_backoff.h index f43c564..cf3045c 100644 --- a/lib/ck/include/ck_backoff.h +++ b/lib/ck/include/ck_backoff.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 */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_barrier.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_barrier.h b/lib/ck/include/ck_barrier.h index 52d3973..2f7acdd 100644 --- a/lib/ck/include/ck_barrier.h +++ b/lib/ck/include/ck_barrier.h @@ -162,4 +162,3 @@ void ck_barrier_mcs_subscribe(ck_barrier_mcs_t *, ck_barrier_mcs_state_t *); void ck_barrier_mcs(ck_barrier_mcs_t *, ck_barrier_mcs_state_t *); #endif /* _CK_BARRIER_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_bitmap.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_bitmap.h b/lib/ck/include/ck_bitmap.h index 3c0105e..96a8fe9 100644 --- a/lib/ck/include/ck_bitmap.h +++ b/lib/ck/include/ck_bitmap.h @@ -44,6 +44,7 @@ #endif #define CK_BITMAP_BLOCK (sizeof(unsigned int) * CHAR_BIT) +#define CK_BITMAP_OFFSET(i) ((i) % CK_BITMAP_BLOCK) #define CK_BITMAP_BIT(i) (1U << ((i) % CK_BITMAP_BLOCK)) #define CK_BITMAP_PTR(x, i) ((x) + ((i) / CK_BITMAP_BLOCK)) #define CK_BITMAP_BLOCKS(n) (((n) + CK_BITMAP_BLOCK - 1) / CK_BITMAP_BLOCK) @@ -69,6 +70,9 @@ #define CK_BITMAP_SET(a, b) \ ck_bitmap_set(&(a)->bitmap, (b)) +#define CK_BITMAP_BTS(a, b) \ + ck_bitmap_bts(&(a)->bitmap, (b)) + #define CK_BITMAP_RESET(a, b) \ ck_bitmap_reset(&(a)->bitmap, (b)) @@ -172,6 +176,20 @@ ck_bitmap_set(struct ck_bitmap *bitmap, unsigned int n) } /* + * 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. */ CK_CC_INLINE static void @@ -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; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_brlock.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_brlock.h b/lib/ck/include/ck_brlock.h index d59f0e9..b45e1b8 100644 --- a/lib/ck/include/ck_brlock.h +++ b/lib/ck/include/ck_brlock.h @@ -277,4 +277,3 @@ ck_brlock_read_unlock(struct ck_brlock_reader *reader) } #endif /* _CK_BRLOCK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_bytelock.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_bytelock.h b/lib/ck/include/ck_bytelock.h index cd855cf..6755762 100644 --- a/lib/ck/include/ck_bytelock.h +++ b/lib/ck/include/ck_bytelock.h @@ -184,4 +184,3 @@ ck_bytelock_read_unlock(struct ck_bytelock *bytelock, unsigned int slot) } #endif /* _CK_BYTELOCK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_cohort.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_cohort.h b/lib/ck/include/ck_cohort.h index 5bc8baa..4bfcfe2 100644 --- a/lib/ck/include/ck_cohort.h +++ b/lib/ck/include/ck_cohort.h @@ -159,4 +159,3 @@ enum ck_cohort_state { } #endif /* _CK_COHORT_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_elide.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_elide.h b/lib/ck/include/ck_elide.h index 8ffff40..59d17c5 100644 --- a/lib/ck/include/ck_elide.h +++ b/lib/ck/include/ck_elide.h @@ -303,7 +303,7 @@ _ck_elide_fallback(int *retry, * semantics. In environments where jitter is low, this may yield a tighter * fast path. */ -#define CK_ELIDE_LOCK(NAME, LOCK) ck_elide_##NAME##_lock(LOCK) +#define CK_ELIDE_LOCK(NAME, LOCK) ck_elide_##NAME##_lock(LOCK) #define CK_ELIDE_UNLOCK(NAME, LOCK) ck_elide_##NAME##_unlock(LOCK) #define CK_ELIDE_TRYLOCK(NAME, LOCK) ck_elide_##NAME##_trylock(LOCK) @@ -319,4 +319,3 @@ _ck_elide_fallback(int *retry, ck_elide_##NAME##_unlock_adaptive(STAT, LOCK) #endif /* _CK_ELIDE_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_epoch.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_epoch.h b/lib/ck/include/ck_epoch.h index 2e71599..ecfd173 100644 --- a/lib/ck/include/ck_epoch.h +++ b/lib/ck/include/ck_epoch.h @@ -160,4 +160,3 @@ void ck_epoch_barrier(ck_epoch_t *, ck_epoch_record_t *); void ck_epoch_reclaim(ck_epoch_record_t *); #endif /* _CK_EPOCH_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_fifo.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_fifo.h b/lib/ck/include/ck_fifo.h index a65bcfc..a09a80d 100644 --- a/lib/ck/include/ck_fifo.h +++ b/lib/ck/include/ck_fifo.h @@ -472,4 +472,3 @@ ck_fifo_mpmc_trydequeue(struct ck_fifo_mpmc *fifo, #endif /* CK_F_PR_CAS_PTR_2 */ #endif /* _CK_FIFO_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_hp.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_hp.h b/lib/ck/include/ck_hp.h index 505de5b..7f503de 100644 --- a/lib/ck/include/ck_hp.h +++ b/lib/ck/include/ck_hp.h @@ -104,4 +104,3 @@ void ck_hp_retire(ck_hp_record_t *, ck_hp_hazard_t *, void *, void *); void ck_hp_purge(ck_hp_record_t *); #endif /* _CK_HP_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_hp_fifo.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_hp_fifo.h b/lib/ck/include/ck_hp_fifo.h index 59bf0e4..96ffa5e 100644 --- a/lib/ck/include/ck_hp_fifo.h +++ b/lib/ck/include/ck_hp_fifo.h @@ -219,4 +219,3 @@ ck_hp_fifo_trydequeue_mpmc(ck_hp_record_t *record, (entry) = (T)) #endif /* _CK_HP_FIFO_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_hp_stack.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_hp_stack.h b/lib/ck/include/ck_hp_stack.h index 3b67fc4..3a14faa 100644 --- a/lib/ck/include/ck_hp_stack.h +++ b/lib/ck/include/ck_hp_stack.h @@ -111,4 +111,3 @@ leave: } #endif /* _CK_HP_STACK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_hs.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_hs.h b/lib/ck/include/ck_hs.h index 91f990b..e37918c 100644 --- a/lib/ck/include/ck_hs.h +++ b/lib/ck/include/ck_hs.h @@ -48,7 +48,7 @@ */ #define CK_HS_MODE_DIRECT 2 -/* +/* * Indicates that the values to be stored are pointers. * Allows for space optimizations in the presence of pointer * packing. Mutually exclusive with CK_HS_MODE_DIRECT. @@ -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 */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_ht.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_ht.h b/lib/ck/include/ck_ht.h index 86fb7f0..cb8e67d 100644 --- a/lib/ck/include/ck_ht.h +++ b/lib/ck/include/ck_ht.h @@ -259,4 +259,3 @@ uint64_t ck_ht_count(ck_ht_t *); #endif /* CK_F_PR_LOAD_64 && CK_F_PR_STORE_64 */ #endif /* _CK_HT_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_limits.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_limits.h b/lib/ck/include/ck_limits.h index c597763..b08e4a7 100644 --- a/lib/ck/include/ck_limits.h +++ b/lib/ck/include/ck_limits.h @@ -29,4 +29,3 @@ #else #include <limits.h> #endif /* __linux__ && __KERNEL__ */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_malloc.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_malloc.h b/lib/ck/include/ck_malloc.h index 40f1898..a623e1a 100644 --- a/lib/ck/include/ck_malloc.h +++ b/lib/ck/include/ck_malloc.h @@ -37,4 +37,3 @@ struct ck_malloc { }; #endif /* _CK_MALLOC_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_pflock.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_pflock.h b/lib/ck/include/ck_pflock.h index 58963e8..52c232a 100644 --- a/lib/ck/include/ck_pflock.h +++ b/lib/ck/include/ck_pflock.h @@ -140,4 +140,3 @@ leave: } #endif /* _CK_PFLOCK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_pr.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_pr.h b/lib/ck/include/ck_pr.h index eb198f5..af4159e 100644 --- a/lib/ck/include/ck_pr.h +++ b/lib/ck/include/ck_pr.h @@ -1149,4 +1149,3 @@ CK_PR_FAS_S(8, uint8_t) #undef CK_PR_FAS #endif /* _CK_PR_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_queue.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_queue.h b/lib/ck/include/ck_queue.h index 3d8824f..f617b97 100644 --- a/lib/ck/include/ck_queue.h +++ b/lib/ck/include/ck_queue.h @@ -415,4 +415,3 @@ struct { \ } while (0) #endif /* _CK_QUEUE_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_rhs.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_rhs.h b/lib/ck/include/ck_rhs.h index 7a28f7d..4754da6 100644 --- a/lib/ck/include/ck_rhs.h +++ b/lib/ck/include/ck_rhs.h @@ -48,7 +48,7 @@ */ #define CK_RHS_MODE_DIRECT 2 -/* +/* * Indicates that the values to be stored are pointers. * Allows for space optimizations in the presence of pointer * packing. Mutually exclusive with CK_RHS_MODE_DIRECT. @@ -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 *, http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_ring.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_ring.h b/lib/ck/include/ck_ring.h index 88bb837..c70915c 100644 --- a/lib/ck/include/ck_ring.h +++ b/lib/ck/include/ck_ring.h @@ -307,7 +307,7 @@ _ck_ring_dequeue_spmc(struct ck_ring *ring, return false; ck_pr_fence_load(); - + target = (char *)buffer + size * (consumer & mask); memcpy(data, target, size); @@ -432,4 +432,3 @@ ck_ring_dequeue_spmc_##name(struct ck_ring *a, \ ck_ring_dequeue_spmc_##name(a, b, c) #endif /* _CK_RING_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_rwcohort.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_rwcohort.h b/lib/ck/include/ck_rwcohort.h index e8e014e..c9b5d2a 100644 --- a/lib/ck/include/ck_rwcohort.h +++ b/lib/ck/include/ck_rwcohort.h @@ -315,4 +315,3 @@ } #endif /* _CK_RWCOHORT_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_rwlock.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_rwlock.h b/lib/ck/include/ck_rwlock.h index 63cb549..89a006a 100644 --- a/lib/ck/include/ck_rwlock.h +++ b/lib/ck/include/ck_rwlock.h @@ -295,4 +295,3 @@ ck_rwlock_recursive_read_unlock(ck_rwlock_recursive_t *rw) } #endif /* _CK_RWLOCK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_sequence.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_sequence.h b/lib/ck/include/ck_sequence.h index 14138ff..c5ca193 100644 --- a/lib/ck/include/ck_sequence.h +++ b/lib/ck/include/ck_sequence.h @@ -47,7 +47,7 @@ ck_sequence_init(struct ck_sequence *sq) } CK_CC_INLINE static unsigned int -ck_sequence_read_begin(struct ck_sequence *sq) +ck_sequence_read_begin(const struct ck_sequence *sq) { unsigned int version; @@ -74,7 +74,7 @@ ck_sequence_read_begin(struct ck_sequence *sq) } CK_CC_INLINE static bool -ck_sequence_read_retry(struct ck_sequence *sq, unsigned int version) +ck_sequence_read_retry(const struct ck_sequence *sq, unsigned int version) { /* @@ -123,4 +123,3 @@ ck_sequence_write_end(struct ck_sequence *sq) } #endif /* _CK_SEQUENCE_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_spinlock.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_spinlock.h b/lib/ck/include/ck_spinlock.h index 03f9900..3e07b77 100644 --- a/lib/ck/include/ck_spinlock.h +++ b/lib/ck/include/ck_spinlock.h @@ -59,4 +59,3 @@ CK_ELIDE_TRYLOCK_PROTOTYPE(ck_spinlock, ck_spinlock_t, ck_spinlock_locked, ck_spinlock_trylock) #endif /* _CK_SPINLOCK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_stack.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_stack.h b/lib/ck/include/ck_stack.h index ac89a95..21d3f0f 100644 --- a/lib/ck/include/ck_stack.h +++ b/lib/ck/include/ck_stack.h @@ -352,4 +352,3 @@ ck_stack_init(struct ck_stack *stack) (entry) = (T)) #endif /* _CK_STACK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_stdint.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_stdint.h b/lib/ck/include/ck_stdint.h index 1dfd373..e62cafa 100644 --- a/lib/ck/include/ck_stdint.h +++ b/lib/ck/include/ck_stdint.h @@ -30,4 +30,3 @@ #else #include <stdint.h> #endif /* __linux__ && __KERNEL__ */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_swlock.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_swlock.h b/lib/ck/include/ck_swlock.h index 134df6c..d880aaf 100644 --- a/lib/ck/include/ck_swlock.h +++ b/lib/ck/include/ck_swlock.h @@ -215,4 +215,3 @@ CK_ELIDE_PROTOTYPE(ck_swlock_read, ck_swlock_t, ck_swlock_locked_reader, ck_swlock_read_unlock) #endif /* _CK_SWLOCK_H */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/ck_tflock.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/ck_tflock.h b/lib/ck/include/ck_tflock.h index 391fb73..3bb43d5 100644 --- a/lib/ck/include/ck_tflock.h +++ b/lib/ck/include/ck_tflock.h @@ -32,7 +32,7 @@ * described in: * John M. Mellor-Crummey and Michael L. Scott. 1991. * Scalable reader-writer synchronization for shared-memory - * multiprocessors. SIGPLAN Not. 26, 7 (April 1991), 106-113. + * multiprocessors. SIGPLAN Not. 26, 7 (April 1991), 106-113. */ #include <ck_cc.h> @@ -65,7 +65,7 @@ ck_tflock_ticket_fca_32(uint32_t *target, uint32_t mask, uint32_t delta) ck_pr_stall(); } - + return snapshot; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/gcc/arm/ck_pr.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/gcc/arm/ck_pr.h b/lib/ck/include/gcc/arm/ck_pr.h index 0c2400c..d2a34e1 100644 --- a/lib/ck/include/gcc/arm/ck_pr.h +++ b/lib/ck/include/gcc/arm/ck_pr.h @@ -135,7 +135,7 @@ ck_pr_load_64(const uint64_t *target) register uint64_t ret asm("r0"); __asm __volatile("ldrd %0, [%1]" : "+r" (ret) - : "r" (target) + : "r" (target) : "memory", "cc"); return (ret); } @@ -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"); @@ -262,7 +260,7 @@ ck_pr_cas_ptr_value(void *target, void *compare, void *set, void *value) "=&r" (tmp) : "r" (target), "r" (set), - "r" (compare) + "r" (compare) : "memory", "cc"); *(void **)value = previous; return (previous == compare); @@ -283,7 +281,7 @@ ck_pr_cas_ptr(void *target, void *compare, void *set) "=&r" (tmp) : "r" (target), "r" (set), - "r" (compare) + "r" (compare) : "memory", "cc"); return (previous == compare); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/include/spinlock/hclh.h ---------------------------------------------------------------------- diff --git a/lib/ck/include/spinlock/hclh.h b/lib/ck/include/spinlock/hclh.h index edaeaca..0eac6b9 100644 --- a/lib/ck/include/spinlock/hclh.h +++ b/lib/ck/include/spinlock/hclh.h @@ -98,7 +98,7 @@ ck_spinlock_hclh_lock(struct ck_spinlock_hclh **glob_queue, /* We're head of the global queue, we're done */ if (ck_pr_load_uint(&previous->splice) == false) return; - } + } /* Now we need to splice the local queue into the global queue. */ local_tail = ck_pr_load_ptr(local_queue); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/regressions/ck_bitmap/validate/serial.c ---------------------------------------------------------------------- diff --git a/lib/ck/regressions/ck_bitmap/validate/serial.c b/lib/ck/regressions/ck_bitmap/validate/serial.c index 79aca8d..ecc5258 100644 --- a/lib/ck/regressions/ck_bitmap/validate/serial.c +++ b/lib/ck/regressions/ck_bitmap/validate/serial.c @@ -73,6 +73,7 @@ check_iteration(ck_bitmap_t *bits, unsigned int len, bool initial) static void test(ck_bitmap_t *bits, unsigned int n_length, bool initial) { + bool r; unsigned int i; CK_BITMAP_INSTANCE(8) u; @@ -92,14 +93,35 @@ test(ck_bitmap_t *bits, unsigned int n_length, bool initial) if (ck_bitmap_test(bits, i) == false) { ck_error("[1] ERROR: Expected bit to be set: %u\n", i); } + ck_bitmap_reset(bits, i); if (ck_bitmap_test(bits, i) == true) { ck_error("[2] ERROR: Expected bit to be cleared: %u\n", i); } + r = ck_bitmap_bts(bits, i); + if (r == true) { + ck_error("[3] ERROR: Expected bit to be cleared before 1st bts: %u\n", i); + } + if (ck_bitmap_test(bits, i) == false) { + ck_error("[4] ERROR: Expected bit to be set: %u\n", i); + } + r = ck_bitmap_bts(bits, i); + if (r == false) { + ck_error("[5] ERROR: Expected bit to be set before 2nd bts: %u\n", i); + } + if (ck_bitmap_test(bits, i) == false) { + ck_error("[6] ERROR: Expected bit to be set: %u\n", i); + } + + ck_bitmap_reset(bits, i); + if (ck_bitmap_test(bits, i) == true) { + ck_error("[7] ERROR: Expected bit to be cleared: %u\n", i); + } + ck_bitmap_set(bits, i); if (ck_bitmap_test(bits, i) == false) { - ck_error("[3] ERROR: Expected bit to be set: %u\n", i); + ck_error("[8] ERROR: Expected bit to be set: %u\n", i); } check_iteration(bits, i, initial); @@ -107,7 +129,7 @@ test(ck_bitmap_t *bits, unsigned int n_length, bool initial) for (i = 0; i < n_length; i++) { if (ck_bitmap_test(bits, i) == false) { - ck_error("[4] ERROR: Expected bit to be set: %u\n", i); + ck_error("[9] ERROR: Expected bit to be set: %u\n", i); } } @@ -115,7 +137,7 @@ test(ck_bitmap_t *bits, unsigned int n_length, bool initial) for (i = 0; i < n_length; i++) { if (ck_bitmap_test(bits, i) == true) { - ck_error("[4] ERROR: Expected bit to be reset: %u\n", i); + ck_error("[10] ERROR: Expected bit to be reset: %u\n", i); } } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/regressions/ck_epoch/validate/Makefile ---------------------------------------------------------------------- diff --git a/lib/ck/regressions/ck_epoch/validate/Makefile b/lib/ck/regressions/ck_epoch/validate/Makefile index 73f8e5d..c053d22 100644 --- a/lib/ck/regressions/ck_epoch/validate/Makefile +++ b/lib/ck/regressions/ck_epoch/validate/Makefile @@ -1,6 +1,6 @@ .PHONY: check clean distribution -OBJECTS=ck_stack ck_epoch_synchronize ck_epoch_poll +OBJECTS=ck_stack ck_epoch_synchronize ck_epoch_poll ck_epoch_call HALF=`expr $(CORES) / 2` all: $(OBJECTS) @@ -16,6 +16,9 @@ ck_epoch_synchronize: ck_epoch_synchronize.c ../../../include/ck_stack.h ../../. ck_epoch_poll: ck_epoch_poll.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c $(CC) $(CFLAGS) -o ck_epoch_poll ck_epoch_poll.c ../../../src/ck_epoch.c +ck_epoch_call: ck_epoch_call.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c + $(CC) $(CFLAGS) -o ck_epoch_call ck_epoch_call.c ../../../src/ck_epoch.c + ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/regressions/ck_epoch/validate/ck_epoch_call.c ---------------------------------------------------------------------- diff --git a/lib/ck/regressions/ck_epoch/validate/ck_epoch_call.c b/lib/ck/regressions/ck_epoch/validate/ck_epoch_call.c new file mode 100644 index 0000000..dc501fd --- /dev/null +++ b/lib/ck/regressions/ck_epoch/validate/ck_epoch_call.c @@ -0,0 +1,64 @@ +/* + * Copyright 2014 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <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; +} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/regressions/ck_hp/validate/ck_hp_fifo_donner.c ---------------------------------------------------------------------- diff --git a/lib/ck/regressions/ck_hp/validate/ck_hp_fifo_donner.c b/lib/ck/regressions/ck_hp/validate/ck_hp_fifo_donner.c index 43e00ae..a2f31c9 100644 --- a/lib/ck/regressions/ck_hp/validate/ck_hp_fifo_donner.c +++ b/lib/ck/regressions/ck_hp/validate/ck_hp_fifo_donner.c @@ -43,7 +43,7 @@ static ck_hp_fifo_t fifo; static ck_hp_t fifo_hp; /* thread local element count */ -static unsigned long *count; +static unsigned long *count; static unsigned long thread_count; @@ -77,10 +77,10 @@ queue_50_50(void *elements) record = malloc(sizeof(ck_hp_record_t)); assert(record); - + slots = malloc(CK_HP_FIFO_SLOTS_SIZE); assert(slots); - + /* different seed for each thread */ seed = 1337; /*(unsigned int) pthread_self(); */ @@ -166,7 +166,7 @@ main(int argc, char** argv) /* array for local operation count */ count = malloc(sizeof(unsigned long *) * thread_count); - + /* * Initialize global hazard pointer safe memory reclamation to execute free() * when a fifo_entry is safe to be deleted. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0da17e96/lib/ck/regressions/ck_hs/benchmark/Makefile ---------------------------------------------------------------------- diff --git a/lib/ck/regressions/ck_hs/benchmark/Makefile b/lib/ck/regressions/ck_hs/benchmark/Makefile index ca20809..23b6745 100644 --- a/lib/ck/regressions/ck_hs/benchmark/Makefile +++ b/lib/ck/regressions/ck_hs/benchmark/Makefile @@ -1,12 +1,15 @@ .PHONY: clean distribution -OBJECTS=serial parallel_bytestring parallel_bytestring.delete +OBJECTS=serial parallel_bytestring parallel_bytestring.delete apply all: $(OBJECTS) serial: serial.c ../../../include/ck_hs.h ../../../src/ck_hs.c $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_hs.c +apply: apply.c ../../../include/ck_hs.h ../../../src/ck_hs.c + $(CC) $(CFLAGS) -o apply apply.c ../../../src/ck_hs.c + parallel_bytestring: parallel_bytestring.c ../../../include/ck_hs.h ../../../src/ck_hs.c ../../../src/ck_epoch.c $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c
