all: Strip trailing whitespaces.

ck_pring
Samy Al Bahra 13 years ago
parent 7d3464bd86
commit 3cf265cba0

@ -47,7 +47,7 @@ install: all install-headers
@echo @echo
@echo ---[ Concurrency Kit has installed successfully. @echo ---[ Concurrency Kit has installed successfully.
uninstall: uninstall:
$(MAKE) -C doc uninstall $(MAKE) -C doc uninstall
rm -f $(DESTDIR)/$(LIBRARY)/libck.so* rm -f $(DESTDIR)/$(LIBRARY)/libck.so*
rm -f $(DESTDIR)/$(LIBRARY)/libck.a rm -f $(DESTDIR)/$(LIBRARY)/libck.a

@ -3,7 +3,7 @@ includedir=@HEADERS@
libdir=@LIBRARY@ libdir=@LIBRARY@
Name: Concurrency Kit Name: Concurrency Kit
Description: Toolkit for well-specified design and implementation of concurrent systems Description: Toolkit for well-specified design and implementation of concurrent systems
URL: http://concurrencykit.org/ URL: http://concurrencykit.org/
Version: @VERSION@ Version: @VERSION@
Libs: -L${libdir} -lck Libs: -L${libdir} -lck

@ -30,7 +30,7 @@ is designed to minimize dependencies on operating system-specific interfaces
and most of the interface relies only on a strict subset of the standard and most of the interface relies only on a strict subset of the standard
library and more popular compiler extensions. library and more popular compiler extensions.
This package provides the libraries, include files, and other This package provides the libraries, include files, and other
resources needed for developing Concurrency Kit applications. resources needed for developing Concurrency Kit applications.
%prep %prep

2
configure vendored

@ -271,7 +271,7 @@ case $PLATFORM in
PLATFORM=x86 PLATFORM=x86
ENVIRONMENT=32 ENVIRONMENT=32
;; ;;
*) *)
PLATFORM=x86 PLATFORM=x86
ENVIRONMENT=32 ENVIRONMENT=32

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft unsigned int .Ft unsigned int
.Fn ck_bitmap_base "unsigned int n_bits" .Fn ck_bitmap_base "unsigned int n_bits"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_base .Fn ck_bitmap_base
function returns the number of bytes that would be used function returns the number of bytes that would be used
to store the number of bits specified by to store the number of bits specified by

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft unsigned int .Ft unsigned int
.Fn ck_bitmap_bits "ck_bitmap_t *bitmap" .Fn ck_bitmap_bits "ck_bitmap_t *bitmap"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_bits .Fn ck_bitmap_bits
function returns the maximum number of addressable bits in function returns the maximum number of addressable bits in
the object pointed to by the object pointed to by

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void * .Ft void *
.Fn ck_bitmap_buffer "ck_bitmap_t *bitmap" .Fn ck_bitmap_buffer "ck_bitmap_t *bitmap"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_buffer .Fn ck_bitmap_buffer
functions returns a pointer to the actual bit array. functions returns a pointer to the actual bit array.
For ck_bitmap pointers, the bit array is of type For ck_bitmap pointers, the bit array is of type
@ -47,7 +47,7 @@ On currently supported 64-bit platforms
is is
.Dv uint64_t . .Dv uint64_t .
On currently supported 32-bit platforms On currently supported 32-bit platforms
.Dv CK_BITMAP_WORD .Dv CK_BITMAP_WORD
is is
.Dv uint32_t . .Dv uint32_t .
.Sh RETURN VALUES .Sh RETURN VALUES

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_bitmap_clear "ck_bitmap_t *bitmap" .Fn ck_bitmap_clear "ck_bitmap_t *bitmap"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_clear .Fn ck_bitmap_clear
function sets all bits in the bitmap pointed to by function sets all bits in the bitmap pointed to by
.Fa bitmap .Fa bitmap

@ -33,10 +33,10 @@
Concurrency Kit (libck, \-lck) Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_bitmap.h .In ck_bitmap.h
.Ft void .Ft void
.Fn ck_bitmap_init "ck_bitmap_t *bitmap" "unsigned int n_bits" "bool set" .Fn ck_bitmap_init "ck_bitmap_t *bitmap" "unsigned int n_bits" "bool set"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_init .Fn ck_bitmap_init
function initializes the bitmap pointed to by the function initializes the bitmap pointed to by the
.Fa bitmap .Fa bitmap

@ -33,10 +33,10 @@
Concurrency Kit (libck, \-lck) Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_bitmap.h .In ck_bitmap.h
.Ft void .Ft void
.Fn ck_bitmap_reset_mpmc "ck_bitmap_t *bitmap" "unsigned int n" .Fn ck_bitmap_reset_mpmc "ck_bitmap_t *bitmap" "unsigned int n"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_reset_mpmc .Fn ck_bitmap_reset_mpmc
resets the bit at offset specified by the argument resets the bit at offset specified by the argument
.Fa n .Fa n

@ -33,10 +33,10 @@
Concurrency Kit (libck, \-lck) Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_bitmap.h .In ck_bitmap.h
.Ft void .Ft void
.Fn ck_bitmap_set_mpmc "ck_bitmap_t *bitmap" "unsigned int n" .Fn ck_bitmap_set_mpmc "ck_bitmap_t *bitmap" "unsigned int n"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_set_mpmc .Fn ck_bitmap_set_mpmc
sets the bit at offset specified by the argument sets the bit at offset specified by the argument
.Fa n .Fa n

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft unsigned int .Ft unsigned int
.Fn ck_bitmap_size "unsigned int n_bits" .Fn ck_bitmap_size "unsigned int n_bits"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_size .Fn ck_bitmap_size
function returns the number of bytes that are necessary function returns the number of bytes that are necessary
to allocate for a bitmap that will contain the number to allocate for a bitmap that will contain the number
@ -45,7 +45,7 @@ of bits specified by
.Pp .Pp
This function is used to determine how many bytes to This function is used to determine how many bytes to
allocate for dynamically created bitmap objects. The allocate for dynamically created bitmap objects. The
allocated object must still be initialized using allocated object must still be initialized using
.Xr ck_bitmap_init 3 . .Xr ck_bitmap_init 3 .
.Sh RETURN VALUES .Sh RETURN VALUES
This function returns a non-zero value. This function returns a non-zero value.

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_bitmap_test "ck_bitmap_t *bitmap" "unsigned int n" .Fn ck_bitmap_test "ck_bitmap_t *bitmap" "unsigned int n"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_bitmap_test .Fn ck_bitmap_test
determines if the bit at the offset specified by the argument determines if the bit at the offset specified by the argument
.Fa n .Fa n

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_allocator_set "struct ck_malloc *allocator" .Fn ck_ht_allocator_set "struct ck_malloc *allocator"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_allocator_set .Fn ck_ht_allocator_set
function initializes the memory allocation functions used by the hash function initializes the memory allocation functions used by the hash
table implementation according to the function pointers specified table implementation according to the function pointers specified

@ -33,10 +33,10 @@
Concurrency Kit (libck, \-lck) Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS .Sh SYNOPSIS
.In ck_ht.h .In ck_ht.h
.Ft uint64_t .Ft uint64_t
.Fn ck_ht_count "ck_ht_t *ht" .Fn ck_ht_count "ck_ht_t *ht"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_count .Fn ck_ht_count
function will return the number of entries in the hash table function will return the number of entries in the hash table
pointed to be the pointed to be the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_destroy "ck_ht_t *ht" .Fn ck_ht_destroy "ck_ht_t *ht"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_destroy .Fn ck_ht_destroy
function will request that the underlying allocator, as specified by the function will request that the underlying allocator, as specified by the
.Xr ck_ht_allocator_set 3 .Xr ck_ht_allocator_set 3

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_entry_empty "ck_ht_entry_t *entry" .Fn ck_ht_entry_empty "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_empty .Fn ck_ht_entry_empty
function will return function will return
.Dv false .Dv false

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void * .Ft void *
.Fn ck_ht_entry_key "ck_ht_entry_t *entry" .Fn ck_ht_entry_key "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_key .Fn ck_ht_entry_key
function will return the key pointer as specified in the function will return the key pointer as specified in the
object pointed to by the object pointed to by the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft uintptr_t .Ft uintptr_t
.Fn ck_ht_entry_key_direct "ck_ht_entry_t *entry" .Fn ck_ht_entry_key_direct "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_key_direct .Fn ck_ht_entry_key_direct
function will return the key value as specified in the function will return the key value as specified in the
object pointed to by the object pointed to by the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft uint16_t .Ft uint16_t
.Fn ck_ht_entry_key_length "ck_ht_entry_t *entry" .Fn ck_ht_entry_key_length "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_key_length .Fn ck_ht_entry_key_length
function will return the length of the key associated with the function will return the length of the key associated with the
object pointed to by the object pointed to by the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_entry_key_set "ck_ht_entry_t *entry" "const void *key" "uint16_t key_length" .Fn ck_ht_entry_key_set "ck_ht_entry_t *entry" "const void *key" "uint16_t key_length"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_key_set .Fn ck_ht_entry_key_set
function will initialize the object pointed to by function will initialize the object pointed to by
.Fa entry .Fa entry

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_entry_key_set_direct "ck_ht_entry_t *entry" "uintptr_t key" .Fn ck_ht_entry_key_set_direct "ck_ht_entry_t *entry" "uintptr_t key"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_key_set_direct .Fn ck_ht_entry_key_set_direct
function will initialize the object pointed to by function will initialize the object pointed to by
.Fa entry .Fa entry

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_entry_set "ck_ht_entry_t *entry" "ck_ht_hash_t h" "const void *key" "uint16_t key_length" "const void *value" .Fn ck_ht_entry_set "ck_ht_entry_t *entry" "ck_ht_hash_t h" "const void *key" "uint16_t key_length" "const void *value"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_set .Fn ck_ht_entry_set
function will initialize the object pointed to by function will initialize the object pointed to by
.Fa entry .Fa entry

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_entry_set "ck_ht_entry_t *entry" "uintptr_t key" "uintptr_t value" .Fn ck_ht_entry_set "ck_ht_entry_t *entry" "uintptr_t key" "uintptr_t value"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_set .Fn ck_ht_entry_set
function will initialize the object pointed to by function will initialize the object pointed to by
.Fa entry .Fa entry
@ -44,7 +44,7 @@ with the key value specified in the
.Fa key .Fa key
argument and a value specified by the argument and a value specified by the
.Fa value .Fa value
argument. argument.
.Pp .Pp
This function is typically used to initialize an This function is typically used to initialize an
entry for entry for

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void * .Ft void *
.Fn ck_ht_entry_value "ck_ht_entry_t *entry" .Fn ck_ht_entry_value "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_value .Fn ck_ht_entry_value
function will return the value pointer as specified in the function will return the value pointer as specified in the
object pointed to by the object pointed to by the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft uintptr_t .Ft uintptr_t
.Fn ck_ht_entry_value_direct "ck_ht_entry_t *entry" .Fn ck_ht_entry_value_direct "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_entry_value_direct .Fn ck_ht_entry_value_direct
function will return the value of the key-value pair as specified in the function will return the value of the key-value pair as specified in the
object pointed to by the object pointed to by the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_get_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Fn ck_ht_get_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_get_spmc .Fn ck_ht_get_spmc
function will return the value associated with the key specified in the function will return the value associated with the key specified in the
.Fa entry .Fa entry
@ -75,7 +75,7 @@ if
was created with CK_HT_MODE_BYTESTRING. If was created with CK_HT_MODE_BYTESTRING. If
.Fa ht .Fa ht
was initialized with CK_HT_MODE_DIRECT then it is was initialized with CK_HT_MODE_DIRECT then it is
expected that expected that
.Fa h .Fa h
was initialized with the was initialized with the
.Xr ck_ht_hash_direct 3 .Xr ck_ht_hash_direct 3

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_grow_spmc "ck_ht_t *ht" "uint64_t capacity" .Fn ck_ht_grow_spmc "ck_ht_t *ht" "uint64_t capacity"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_grow_spmc .Fn ck_ht_grow_spmc
function will resize the hash table in order to be able to function will resize the hash table in order to be able to
at least store the number of entries specified by at least store the number of entries specified by

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_hash "ck_ht_hash_t *h" "ck_ht_t *ht" "const void *key" "uint16_t key_length" .Fn ck_ht_hash "ck_ht_hash_t *h" "ck_ht_t *ht" "const void *key" "uint16_t key_length"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_hash .Fn ck_ht_hash
function will generate a hash value in the object pointed to by the function will generate a hash value in the object pointed to by the
.Fa h .Fa h

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_hash_direct "ck_ht_hash_t *h" "ck_ht_t *ht" "uintptr_t key" .Fn ck_ht_hash_direct "ck_ht_hash_t *h" "ck_ht_t *ht" "uintptr_t key"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_hash_direct .Fn ck_ht_hash_direct
function will generate a hash value in the object pointed to by the function will generate a hash value in the object pointed to by the
.Fa h .Fa h

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_init "ck_ht_t *ht" "enum ck_ht_mode mode" "uint64_t capacity" "uint64_t seed" .Fn ck_ht_init "ck_ht_t *ht" "enum ck_ht_mode mode" "uint64_t capacity" "uint64_t seed"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_init .Fn ck_ht_init
function initializes the hash table pointed to by the function initializes the hash table pointed to by the
.Fa ht .Fa ht
@ -78,7 +78,7 @@ functions.
.El .El
.Pp .Pp
The argument The argument
.Fa capacity .Fa capacity
represents the initial number of key-value pairs the hash represents the initial number of key-value pairs the hash
table is expected to contain. This argument is simply a hint table is expected to contain. This argument is simply a hint
and the underlying implementation is free to allocate more and the underlying implementation is free to allocate more

@ -39,7 +39,7 @@ Concurrency Kit (libck, \-lck)
.Ft void .Ft void
.Fn ck_ht_iterator_init "ck_ht_iterator_t *iterator" .Fn ck_ht_iterator_init "ck_ht_iterator_t *iterator"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_iterator_init .Fn ck_ht_iterator_init
function will initialize the object pointed to by function will initialize the object pointed to by
the the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_next "ck_ht_t *ht" "ck_ht_iterator_t *iterator" "ck_ht_entry_t **entry" .Fn ck_ht_next "ck_ht_t *ht" "ck_ht_iterator_t *iterator" "ck_ht_entry_t **entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_next .Fn ck_ht_next
function will increment the iterator object pointed to by function will increment the iterator object pointed to by
.Fa iterator .Fa iterator

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_put_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Fn ck_ht_put_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_put_spmc .Fn ck_ht_put_spmc
function will store the key-value pair specified in the function will store the key-value pair specified in the
.Fa entry .Fa entry
@ -71,7 +71,7 @@ if
was created with CK_HT_MODE_BYTESTRING. If was created with CK_HT_MODE_BYTESTRING. If
.Fa ht .Fa ht
was initialized with CK_HT_MODE_DIRECT then it is was initialized with CK_HT_MODE_DIRECT then it is
expected that expected that
.Fa h .Fa h
was initialized with the was initialized with the
.Xr ck_ht_hash_direct 3 .Xr ck_ht_hash_direct 3

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_remove_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Fn ck_ht_remove_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_remove_spmc .Fn ck_ht_remove_spmc
function will remove the key-value pair associated with the function will remove the key-value pair associated with the
key specified by the key specified by the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_reset_spmc "ck_ht_t *ht" .Fn ck_ht_reset_spmc "ck_ht_t *ht"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_reset_spmc .Fn ck_ht_reset_spmc
function will remove all key-value pairs stored in the hash function will remove all key-value pairs stored in the hash
table pointed to by the table pointed to by the

@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck)
.Ft bool .Ft bool
.Fn ck_ht_set_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Fn ck_ht_set_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ck_ht_set_spmc .Fn ck_ht_set_spmc
function will store the key-value pair specified in the function will store the key-value pair specified in the
.Fa entry .Fa entry
@ -71,7 +71,7 @@ if
was created with CK_HT_MODE_BYTESTRING. If was created with CK_HT_MODE_BYTESTRING. If
.Fa ht .Fa ht
was initialized with CK_HT_MODE_DIRECT then it is was initialized with CK_HT_MODE_DIRECT then it is
expected that expected that
.Fa h .Fa h
was initialized with the was initialized with the
.Xr ck_ht_hash_direct 3 .Xr ck_ht_hash_direct 3

@ -33,7 +33,7 @@
#define CK_BACKOFF_CEILING ((1 << 21) - 1) #define CK_BACKOFF_CEILING ((1 << 21) - 1)
#endif #endif
#define CK_BACKOFF_INITIALIZER ((1 << 9) - 1) #define CK_BACKOFF_INITIALIZER ((1 << 9) - 1)
typedef volatile unsigned int ck_backoff_t; typedef volatile unsigned int ck_backoff_t;
@ -45,7 +45,7 @@ ck_backoff_eb(volatile unsigned int *c)
{ {
volatile unsigned int i; volatile unsigned int i;
unsigned int ceiling; unsigned int ceiling;
ceiling = *c; ceiling = *c;
for (i = 0; i < ceiling; i++); for (i = 0; i < ceiling; i++);

@ -93,13 +93,13 @@ ck_bytelock_write_lock(struct ck_bytelock *bytelock, unsigned int slot)
} }
/* If we are slotted, we might be upgrading from a read lock. */ /* If we are slotted, we might be upgrading from a read lock. */
if (slot < sizeof bytelock->readers) if (slot < sizeof bytelock->readers)
ck_pr_store_8(&bytelock->readers[slot - 1], false); ck_pr_store_8(&bytelock->readers[slot - 1], false);
/* Wait for slotted readers to drain out. */ /* Wait for slotted readers to drain out. */
ck_pr_fence_strict_load(); ck_pr_fence_strict_load();
for (i = 0; i < sizeof(bytelock->readers) / CK_BYTELOCK_LENGTH; i++) { for (i = 0; i < sizeof(bytelock->readers) / CK_BYTELOCK_LENGTH; i++) {
while (CK_BYTELOCK_LOAD((CK_BYTELOCK_TYPE *)&readers[i]) != false) while (CK_BYTELOCK_LOAD((CK_BYTELOCK_TYPE *)&readers[i]) != false)
ck_pr_stall(); ck_pr_stall();
} }

@ -128,7 +128,7 @@ ck_fifo_spsc_enqueue(struct ck_fifo_spsc *fifo,
return; return;
} }
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_fifo_spsc_dequeue(struct ck_fifo_spsc *fifo, void *value) ck_fifo_spsc_dequeue(struct ck_fifo_spsc *fifo, void *value)
{ {
struct ck_fifo_spsc_entry *stub, *entry; struct ck_fifo_spsc_entry *stub, *entry;
@ -155,7 +155,7 @@ ck_fifo_spsc_dequeue(struct ck_fifo_spsc *fifo, void *value)
* Recycle a node. This technique for recycling nodes is based on * Recycle a node. This technique for recycling nodes is based on
* Dmitriy Vyukov's work. * Dmitriy Vyukov's work.
*/ */
CK_CC_INLINE static struct ck_fifo_spsc_entry * CK_CC_INLINE static struct ck_fifo_spsc_entry *
ck_fifo_spsc_recycle(struct ck_fifo_spsc *fifo) ck_fifo_spsc_recycle(struct ck_fifo_spsc *fifo)
{ {
struct ck_fifo_spsc_entry *p, *garbage; struct ck_fifo_spsc_entry *p, *garbage;

@ -32,7 +32,7 @@
#include <ck_stack.h> #include <ck_stack.h>
#ifndef CK_HP_CACHE #ifndef CK_HP_CACHE
#define CK_HP_CACHE 512 #define CK_HP_CACHE 512
#endif #endif
struct ck_hp_hazard; struct ck_hp_hazard;

@ -101,7 +101,7 @@ ck_hp_fifo_enqueue_mpmc(ck_hp_record_t *record,
return; return;
} }
CK_CC_INLINE static struct ck_hp_fifo_entry * CK_CC_INLINE static struct ck_hp_fifo_entry *
ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record,
struct ck_hp_fifo *fifo, struct ck_hp_fifo *fifo,
void *value) void *value)

@ -35,7 +35,7 @@
#include <stddef.h> #include <stddef.h>
#define CK_HP_STACK_SLOTS_COUNT 1 #define CK_HP_STACK_SLOTS_COUNT 1
#define CK_HP_STACK_SLOTS_SIZE sizeof(void *) #define CK_HP_STACK_SLOTS_SIZE sizeof(void *)
CK_CC_INLINE static void CK_CC_INLINE static void
ck_hp_stack_push_mpmc(struct ck_stack *target, struct ck_stack_entry *entry) ck_hp_stack_push_mpmc(struct ck_stack *target, struct ck_stack_entry *entry)

@ -33,6 +33,6 @@
#ifndef CK_MD_PAGESIZE #ifndef CK_MD_PAGESIZE
#define CK_MD_PAGESIZE (4096) #define CK_MD_PAGESIZE (4096)
#endif #endif
#endif /* _CK_MD_H */ #endif /* _CK_MD_H */

@ -908,7 +908,7 @@ CK_PR_N_Z_S(8, uint8_t)
ck_pr_stall(); \ ck_pr_stall(); \
\ \
return ((C)previous); \ return ((C)previous); \
} }
#define CK_PR_FAS(S, M, C) \ #define CK_PR_FAS(S, M, C) \
CK_CC_INLINE static C \ CK_CC_INLINE static C \

@ -127,7 +127,7 @@
#define CK_RING_DEQUEUE_SPSC(name, object, value) \ #define CK_RING_DEQUEUE_SPSC(name, object, value) \
ck_ring_dequeue_spsc_##name(object, value) ck_ring_dequeue_spsc_##name(object, value)
struct ck_ring { struct ck_ring {
unsigned int c_head; unsigned int c_head;
char pad[CK_MD_CACHELINE - sizeof(unsigned int)]; char pad[CK_MD_CACHELINE - sizeof(unsigned int)];
unsigned int p_tail; unsigned int p_tail;
@ -158,7 +158,7 @@ ck_ring_capacity(struct ck_ring *ring)
return ck_pr_load_uint(&ring->size); return ck_pr_load_uint(&ring->size);
} }
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_ring_enqueue_spsc(struct ck_ring *ring, void *entry) ck_ring_enqueue_spsc(struct ck_ring *ring, void *entry)
{ {
unsigned int consumer, producer, size; unsigned int consumer, producer, size;
@ -180,7 +180,7 @@ ck_ring_enqueue_spsc(struct ck_ring *ring, void *entry)
/* /*
* Single consumer and single producer ring buffer dequeue (consumer). * Single consumer and single producer ring buffer dequeue (consumer).
*/ */
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_ring_dequeue_spsc(struct ck_ring *ring, void *data) ck_ring_dequeue_spsc(struct ck_ring *ring, void *data)
{ {
unsigned int consumer, producer; unsigned int consumer, producer;

@ -57,7 +57,7 @@ ck_sequence_read_begin(struct ck_sequence *sq)
* If a sequence is even then associated data may be in a * If a sequence is even then associated data may be in a
* consistent state. * consistent state.
*/ */
if ((version & 1) == 0) if ((version & 1) == 0)
break; break;
/* /*
@ -71,7 +71,7 @@ ck_sequence_read_begin(struct ck_sequence *sq)
return version; return version;
} }
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_sequence_read_retry(struct ck_sequence *sq, uint32_t version) ck_sequence_read_retry(struct ck_sequence *sq, uint32_t version)
{ {

@ -95,11 +95,11 @@ ck_spinlock_anderson_init(struct ck_spinlock_anderson *lock,
* appropriate wrap-around value in the case of next slot counter * appropriate wrap-around value in the case of next slot counter
* overflow. * overflow.
*/ */
if (count & (count - 1)) if (count & (count - 1))
lock->wrap = (UINT_MAX % count) + 1; lock->wrap = (UINT_MAX % count) + 1;
else else
lock->wrap = 0; lock->wrap = 0;
ck_pr_fence_store(); ck_pr_fence_store();
return; return;
} }
@ -135,7 +135,7 @@ ck_spinlock_anderson_lock(struct ck_spinlock_anderson *lock,
/* Spin until slot is marked as unlocked. First slot is initialized to false. */ /* Spin until slot is marked as unlocked. First slot is initialized to false. */
while (ck_pr_load_uint(&lock->slots[position].locked) == true) while (ck_pr_load_uint(&lock->slots[position].locked) == true)
ck_pr_stall(); ck_pr_stall();
/* Prepare slot for potential re-use by another thread. */ /* Prepare slot for potential re-use by another thread. */
ck_pr_store_uint(&lock->slots[position].locked, true); ck_pr_store_uint(&lock->slots[position].locked, true);
@ -252,7 +252,7 @@ ck_spinlock_cas_init(struct ck_spinlock_cas *lock)
return; return;
} }
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_spinlock_cas_trylock(struct ck_spinlock_cas *lock) ck_spinlock_cas_trylock(struct ck_spinlock_cas *lock)
{ {
unsigned int value; unsigned int value;
@ -273,7 +273,7 @@ ck_spinlock_cas_lock(struct ck_spinlock_cas *lock)
{ {
while (ck_pr_cas_uint(&lock->value, false, true) == false) { while (ck_pr_cas_uint(&lock->value, false, true) == false) {
while (ck_pr_load_uint(&lock->value) == true) while (ck_pr_load_uint(&lock->value) == true)
ck_pr_stall(); ck_pr_stall();
} }
@ -316,7 +316,7 @@ typedef struct ck_spinlock_dec ck_spinlock_dec_t;
#define CK_SPINLOCK_DEC_INITIALIZER {1} #define CK_SPINLOCK_DEC_INITIALIZER {1}
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_spinlock_dec_trylock(struct ck_spinlock_dec *lock) ck_spinlock_dec_trylock(struct ck_spinlock_dec *lock)
{ {
unsigned int value; unsigned int value;
@ -350,7 +350,7 @@ ck_spinlock_dec_lock(struct ck_spinlock_dec *lock)
break; break;
/* Load value without generating write cycles. */ /* Load value without generating write cycles. */
while (ck_pr_load_uint(&lock->value) != 1) while (ck_pr_load_uint(&lock->value) != 1)
ck_pr_stall(); ck_pr_stall();
} }
@ -420,7 +420,7 @@ ck_spinlock_ticket_lock(struct ck_spinlock_ticket *ticket)
request = ck_pr_faa_uint(&ticket->next, 1); request = ck_pr_faa_uint(&ticket->next, 1);
/* Busy-wait until our ticket number is current. */ /* Busy-wait until our ticket number is current. */
while (ck_pr_load_uint(&ticket->position) != request) while (ck_pr_load_uint(&ticket->position) != request)
ck_pr_stall(); ck_pr_stall();
return; return;
@ -448,7 +448,7 @@ ck_spinlock_ticket_lock_pb(struct ck_spinlock_ticket *ticket)
* the amount of time necessary for the number of pending lock * the amount of time necessary for the number of pending lock
* acquisition and relinquish operations (assuming an empty * acquisition and relinquish operations (assuming an empty
* critical section). * critical section).
*/ */
ck_backoff_eb(&backoff); ck_backoff_eb(&backoff);
} }

@ -64,7 +64,7 @@ ck_stack_push_upmc(struct ck_stack *target, struct ck_stack_entry *entry)
ck_pr_store_ptr(&entry->next, stack); ck_pr_store_ptr(&entry->next, stack);
ck_backoff_eb(&backoff); ck_backoff_eb(&backoff);
} }
return; return;
} }
#endif /* CK_F_STACK_PUSH_UPMC */ #endif /* CK_F_STACK_PUSH_UPMC */
@ -90,7 +90,7 @@ ck_stack_pop_upmc(struct ck_stack *target)
ck_backoff_eb(&backoff); ck_backoff_eb(&backoff);
} }
return (entry); return (entry);
} }
#endif #endif

@ -45,7 +45,7 @@
#ifdef __OPTIMIZE__ #ifdef __OPTIMIZE__
#define CK_CC_INLINE CK_CC_UNUSED inline #define CK_CC_INLINE CK_CC_UNUSED inline
#else #else
#define CK_CC_INLINE CK_CC_UNUSED #define CK_CC_INLINE CK_CC_UNUSED
#endif #endif
/* /*

@ -1,78 +1,78 @@
/* DO NOT EDIT. This is auto-generated from feature.sh */ /* DO NOT EDIT. This is auto-generated from feature.sh */
#define CK_F_PR_ADD_32 #define CK_F_PR_ADD_32
#define CK_F_PR_ADD_INT #define CK_F_PR_ADD_INT
#define CK_F_PR_ADD_PTR #define CK_F_PR_ADD_PTR
#define CK_F_PR_ADD_UINT #define CK_F_PR_ADD_UINT
#define CK_F_PR_AND_32 #define CK_F_PR_AND_32
#define CK_F_PR_AND_INT #define CK_F_PR_AND_INT
#define CK_F_PR_AND_PTR #define CK_F_PR_AND_PTR
#define CK_F_PR_AND_UINT #define CK_F_PR_AND_UINT
#define CK_F_PR_CAS_32 #define CK_F_PR_CAS_32
#define CK_F_PR_CAS_32_VALUE #define CK_F_PR_CAS_32_VALUE
#define CK_F_PR_CAS_INT #define CK_F_PR_CAS_INT
#define CK_F_PR_CAS_INT_VALUE #define CK_F_PR_CAS_INT_VALUE
#define CK_F_PR_CAS_PTR #define CK_F_PR_CAS_PTR
#define CK_F_PR_CAS_PTR_VALUE #define CK_F_PR_CAS_PTR_VALUE
#define CK_F_PR_CAS_UINT #define CK_F_PR_CAS_UINT
#define CK_F_PR_CAS_UINT_VALUE #define CK_F_PR_CAS_UINT_VALUE
#define CK_F_PR_DEC_32 #define CK_F_PR_DEC_32
#define CK_F_PR_DEC_INT #define CK_F_PR_DEC_INT
#define CK_F_PR_DEC_PTR #define CK_F_PR_DEC_PTR
#define CK_F_PR_DEC_UINT #define CK_F_PR_DEC_UINT
#define CK_F_PR_FAA_32 #define CK_F_PR_FAA_32
#define CK_F_PR_FAA_INT #define CK_F_PR_FAA_INT
#define CK_F_PR_FAA_PTR #define CK_F_PR_FAA_PTR
#define CK_F_PR_FAA_UINT #define CK_F_PR_FAA_UINT
#define CK_F_PR_FAS_32 #define CK_F_PR_FAS_32
#define CK_F_PR_FAS_INT #define CK_F_PR_FAS_INT
#define CK_F_PR_FAS_PTR #define CK_F_PR_FAS_PTR
#define CK_F_PR_FAS_UINT #define CK_F_PR_FAS_UINT
#define CK_F_PR_FENCE_LOAD #define CK_F_PR_FENCE_LOAD
#define CK_F_PR_FENCE_LOAD_DEPENDS #define CK_F_PR_FENCE_LOAD_DEPENDS
#define CK_F_PR_FENCE_MEMORY #define CK_F_PR_FENCE_MEMORY
#define CK_F_PR_FENCE_STORE #define CK_F_PR_FENCE_STORE
#define CK_F_PR_FENCE_STRICT_LOAD #define CK_F_PR_FENCE_STRICT_LOAD
#define CK_F_PR_FENCE_STRICT_LOAD_DEPENDS #define CK_F_PR_FENCE_STRICT_LOAD_DEPENDS
#define CK_F_PR_FENCE_STRICT_MEMORY #define CK_F_PR_FENCE_STRICT_MEMORY
#define CK_F_PR_FENCE_STRICT_STORE #define CK_F_PR_FENCE_STRICT_STORE
#define CK_F_PR_INC_32 #define CK_F_PR_INC_32
#define CK_F_PR_INC_INT #define CK_F_PR_INC_INT
#define CK_F_PR_INC_PTR #define CK_F_PR_INC_PTR
#define CK_F_PR_INC_UINT #define CK_F_PR_INC_UINT
#define CK_F_PR_LOAD_16 #define CK_F_PR_LOAD_16
#define CK_F_PR_LOAD_32 #define CK_F_PR_LOAD_32
#define CK_F_PR_LOAD_8 #define CK_F_PR_LOAD_8
#define CK_F_PR_LOAD_CHAR #define CK_F_PR_LOAD_CHAR
#define CK_F_PR_LOAD_INT #define CK_F_PR_LOAD_INT
#define CK_F_PR_LOAD_PTR #define CK_F_PR_LOAD_PTR
#define CK_F_PR_LOAD_SHORT #define CK_F_PR_LOAD_SHORT
#define CK_F_PR_LOAD_UINT #define CK_F_PR_LOAD_UINT
#define CK_F_PR_NEG_32 #define CK_F_PR_NEG_32
#define CK_F_PR_NEG_INT #define CK_F_PR_NEG_INT
#define CK_F_PR_NEG_PTR #define CK_F_PR_NEG_PTR
#define CK_F_PR_NEG_UINT #define CK_F_PR_NEG_UINT
#define CK_F_PR_NOT_32 #define CK_F_PR_NOT_32
#define CK_F_PR_NOT_INT #define CK_F_PR_NOT_INT
#define CK_F_PR_NOT_PTR #define CK_F_PR_NOT_PTR
#define CK_F_PR_NOT_UINT #define CK_F_PR_NOT_UINT
#define CK_F_PR_OR_32 #define CK_F_PR_OR_32
#define CK_F_PR_OR_INT #define CK_F_PR_OR_INT
#define CK_F_PR_OR_PTR #define CK_F_PR_OR_PTR
#define CK_F_PR_OR_UINT #define CK_F_PR_OR_UINT
#define CK_F_PR_STALL #define CK_F_PR_STALL
#define CK_F_PR_STORE_16 #define CK_F_PR_STORE_16
#define CK_F_PR_STORE_32 #define CK_F_PR_STORE_32
#define CK_F_PR_STORE_8 #define CK_F_PR_STORE_8
#define CK_F_PR_STORE_CHAR #define CK_F_PR_STORE_CHAR
#define CK_F_PR_STORE_INT #define CK_F_PR_STORE_INT
#define CK_F_PR_STORE_PTR #define CK_F_PR_STORE_PTR
#define CK_F_PR_STORE_SHORT #define CK_F_PR_STORE_SHORT
#define CK_F_PR_STORE_UINT #define CK_F_PR_STORE_UINT
#define CK_F_PR_SUB_32 #define CK_F_PR_SUB_32
#define CK_F_PR_SUB_INT #define CK_F_PR_SUB_INT
#define CK_F_PR_SUB_PTR #define CK_F_PR_SUB_PTR
#define CK_F_PR_SUB_UINT #define CK_F_PR_SUB_UINT
#define CK_F_PR_XOR_32 #define CK_F_PR_XOR_32
#define CK_F_PR_XOR_INT #define CK_F_PR_XOR_INT
#define CK_F_PR_XOR_PTR #define CK_F_PR_XOR_PTR
#define CK_F_PR_XOR_UINT #define CK_F_PR_XOR_UINT

@ -1,324 +1,324 @@
/* /*
* Copyright 2009-2011 Samy Al Bahra. * Copyright 2009-2011 Samy Al Bahra.
* Copyright 2012 João Fernandes. * Copyright 2012 João Fernandes.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifndef _CK_PR_PPC_H #ifndef _CK_PR_PPC_H
#define _CK_PR_PPC_H #define _CK_PR_PPC_H
#ifndef _CK_PR_H #ifndef _CK_PR_H
#error Do not include this file directly, use ck_pr.h #error Do not include this file directly, use ck_pr.h
#endif #endif
#include <ck_cc.h> #include <ck_cc.h>
/* /*
* The following represent supported atomic operations. * The following represent supported atomic operations.
* These operations may be emulated. * These operations may be emulated.
*/ */
#include "ck_f_pr.h" #include "ck_f_pr.h"
/* /*
* This bounces the hardware thread from low to medium * This bounces the hardware thread from low to medium
* priority. I am unsure of the benefits of this approach * priority. I am unsure of the benefits of this approach
* but it is used by the Linux kernel. * but it is used by the Linux kernel.
*/ */
CK_CC_INLINE static void CK_CC_INLINE static void
ck_pr_stall(void) ck_pr_stall(void)
{ {
__asm__ __volatile__("or 1, 1, 1;" __asm__ __volatile__("or 1, 1, 1;"
"or 2, 2, 2;" ::: "memory"); "or 2, 2, 2;" ::: "memory");
return; return;
} }
/* /*
* We must assume RMO. * We must assume RMO.
*/ */
#define CK_PR_FENCE(T, I) \ #define CK_PR_FENCE(T, I) \
CK_CC_INLINE static void \ CK_CC_INLINE static void \
ck_pr_fence_strict_##T(void) \ ck_pr_fence_strict_##T(void) \
{ \ { \
__asm__ __volatile__(I ::: "memory"); \ __asm__ __volatile__(I ::: "memory"); \
} \ } \
CK_CC_INLINE static void ck_pr_fence_##T(void) \ CK_CC_INLINE static void ck_pr_fence_##T(void) \
{ \ { \
__asm__ __volatile__(I ::: "memory"); \ __asm__ __volatile__(I ::: "memory"); \
} }
CK_PR_FENCE(load_depends, "") CK_PR_FENCE(load_depends, "")
CK_PR_FENCE(store, "eieio") CK_PR_FENCE(store, "eieio")
CK_PR_FENCE(load, "lwsync") CK_PR_FENCE(load, "lwsync")
CK_PR_FENCE(memory, "sync") CK_PR_FENCE(memory, "sync")
#undef CK_PR_FENCE #undef CK_PR_FENCE
#define CK_PR_LOAD(S, M, T, C, I) \ #define CK_PR_LOAD(S, M, T, C, I) \
CK_CC_INLINE static T \ CK_CC_INLINE static T \
ck_pr_load_##S(M *target) \ ck_pr_load_##S(M *target) \
{ \ { \
T r; \ T r; \
__asm__ __volatile__(I "%U1%X1 %0, %1" \ __asm__ __volatile__(I "%U1%X1 %0, %1" \
: "=r" (r) \ : "=r" (r) \
: "m" (*(C *)target) \ : "m" (*(C *)target) \
: "memory"); \ : "memory"); \
return (r); \ return (r); \
} }
CK_PR_LOAD(ptr, void, void *, uint32_t, "lwz") CK_PR_LOAD(ptr, void, void *, uint32_t, "lwz")
#define CK_PR_LOAD_S(S, T, I) CK_PR_LOAD(S, T, T, T, I) #define CK_PR_LOAD_S(S, T, I) CK_PR_LOAD(S, T, T, T, I)
CK_PR_LOAD_S(32, uint32_t, "lwz") CK_PR_LOAD_S(32, uint32_t, "lwz")
CK_PR_LOAD_S(16, uint16_t, "lhz") CK_PR_LOAD_S(16, uint16_t, "lhz")
CK_PR_LOAD_S(8, uint8_t, "lbz") CK_PR_LOAD_S(8, uint8_t, "lbz")
CK_PR_LOAD_S(uint, unsigned int, "lwz") CK_PR_LOAD_S(uint, unsigned int, "lwz")
CK_PR_LOAD_S(int, int, "lwz") CK_PR_LOAD_S(int, int, "lwz")
CK_PR_LOAD_S(short, short, "lhz") CK_PR_LOAD_S(short, short, "lhz")
CK_PR_LOAD_S(char, char, "lbz") CK_PR_LOAD_S(char, char, "lbz")
#undef CK_PR_LOAD_S #undef CK_PR_LOAD_S
#undef CK_PR_LOAD #undef CK_PR_LOAD
#define CK_PR_STORE(S, M, T, C, I) \ #define CK_PR_STORE(S, M, T, C, I) \
CK_CC_INLINE static void \ CK_CC_INLINE static void \
ck_pr_store_##S(M *target, T v) \ ck_pr_store_##S(M *target, T v) \
{ \ { \
__asm__ __volatile__(I "%U0%X0 %1, %0" \ __asm__ __volatile__(I "%U0%X0 %1, %0" \
: "=m" (*(C *)target) \ : "=m" (*(C *)target) \
: "r" (v) \ : "r" (v) \
: "memory"); \ : "memory"); \
return; \ return; \
} }
CK_PR_STORE(ptr, void, void *, uint32_t, "stw") CK_PR_STORE(ptr, void, void *, uint32_t, "stw")
#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I) #define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I)
CK_PR_STORE_S(32, uint32_t, "stw") CK_PR_STORE_S(32, uint32_t, "stw")
CK_PR_STORE_S(16, uint16_t, "sth") CK_PR_STORE_S(16, uint16_t, "sth")
CK_PR_STORE_S(8, uint8_t, "stb") CK_PR_STORE_S(8, uint8_t, "stb")
CK_PR_STORE_S(uint, unsigned int, "stw") CK_PR_STORE_S(uint, unsigned int, "stw")
CK_PR_STORE_S(int, int, "stw") CK_PR_STORE_S(int, int, "stw")
CK_PR_STORE_S(short, short, "sth") CK_PR_STORE_S(short, short, "sth")
CK_PR_STORE_S(char, char, "stb") CK_PR_STORE_S(char, char, "stb")
#undef CK_PR_STORE_S #undef CK_PR_STORE_S
#undef CK_PR_STORE #undef CK_PR_STORE
#define CK_PR_CAS(N, T) \ #define CK_PR_CAS(N, T) \
CK_CC_INLINE static bool \ CK_CC_INLINE static bool \
ck_pr_cas_##N##_value(T *target, T compare, T set, T *value) \ ck_pr_cas_##N##_value(T *target, T compare, T set, T *value) \
{ \ { \
T previous; \ T previous; \
__asm__ __volatile__("isync;" \ __asm__ __volatile__("isync;" \
"1:" \ "1:" \
"lwarx %0, 0, %1;" \ "lwarx %0, 0, %1;" \
"cmpw 0, %0, %3;" \ "cmpw 0, %0, %3;" \
"bne- 2f;" \ "bne- 2f;" \
"stwcx. %2, 0, %1;" \ "stwcx. %2, 0, %1;" \
"bne- 1b;" \ "bne- 1b;" \
"2:" \ "2:" \
"lwsync;" \ "lwsync;" \
: "=&r" (previous) \ : "=&r" (previous) \
: "r" (target), \ : "r" (target), \
"r" (set), \ "r" (set), \
"r" (compare) \ "r" (compare) \
: "memory", "cc"); \ : "memory", "cc"); \
*value = previous; \ *value = previous; \
return (previous == compare); \ return (previous == compare); \
} \ } \
CK_CC_INLINE static bool \ CK_CC_INLINE static bool \
ck_pr_cas_##N(T *target, T compare, T set) \ ck_pr_cas_##N(T *target, T compare, T set) \
{ \ { \
T previous; \ T previous; \
__asm__ __volatile__("isync;" \ __asm__ __volatile__("isync;" \
"1:" \ "1:" \
"lwarx %0, 0, %1;" \ "lwarx %0, 0, %1;" \
"cmpw 0, %0, %3;" \ "cmpw 0, %0, %3;" \
"bne- 2f;" \ "bne- 2f;" \
"stwcx. %2, 0, %1;" \ "stwcx. %2, 0, %1;" \
"bne- 1b;" \ "bne- 1b;" \
"2:" \ "2:" \
"lwsync;" \ "lwsync;" \
: "=&r" (previous) \ : "=&r" (previous) \
: "r" (target), \ : "r" (target), \
"r" (set), \ "r" (set), \
"r" (compare) \ "r" (compare) \
: "memory", "cc"); \ : "memory", "cc"); \
return (previous == compare); \ return (previous == compare); \
} }
CK_PR_CAS(ptr, void *) CK_PR_CAS(ptr, void *)
CK_PR_CAS(32, uint32_t) CK_PR_CAS(32, uint32_t)
CK_PR_CAS(uint, unsigned int) CK_PR_CAS(uint, unsigned int)
CK_PR_CAS(int, int) CK_PR_CAS(int, int)
#undef CK_PR_CAS #undef CK_PR_CAS
#define CK_PR_FAS(N, M, T, W) \ #define CK_PR_FAS(N, M, T, W) \
CK_CC_INLINE static T \ CK_CC_INLINE static T \
ck_pr_fas_##N(M *target, T v) \ ck_pr_fas_##N(M *target, T v) \
{ \ { \
T previous; \ T previous; \
__asm__ __volatile__("isync;" \ __asm__ __volatile__("isync;" \
"1:" \ "1:" \
"l" W "arx %0, 0, %1;" \ "l" W "arx %0, 0, %1;" \
"st" W "cx. %2, 0, %1;" \ "st" W "cx. %2, 0, %1;" \
"bne- 1b;" \ "bne- 1b;" \
"lwsync;" \ "lwsync;" \
: "=&r" (previous) \ : "=&r" (previous) \
: "r" (target), \ : "r" (target), \
"r" (v) \ "r" (v) \
: "memory", "cc"); \ : "memory", "cc"); \
return (previous); \ return (previous); \
} }
CK_PR_FAS(32, uint32_t, uint32_t, "w") CK_PR_FAS(32, uint32_t, uint32_t, "w")
CK_PR_FAS(ptr, void, void *, "w") CK_PR_FAS(ptr, void, void *, "w")
CK_PR_FAS(int, int, int, "w") CK_PR_FAS(int, int, int, "w")
CK_PR_FAS(uint, unsigned int, unsigned int, "w") CK_PR_FAS(uint, unsigned int, unsigned int, "w")
#undef CK_PR_FAS #undef CK_PR_FAS
#define CK_PR_UNARY(O, N, M, T, I, W) \ #define CK_PR_UNARY(O, N, M, T, I, W) \
CK_CC_INLINE static void \ CK_CC_INLINE static void \
ck_pr_##O##_##N(M *target) \ ck_pr_##O##_##N(M *target) \
{ \ { \
T previous; \ T previous; \
__asm__ __volatile__("1:" \ __asm__ __volatile__("1:" \
"l" W "arx %0, 0, %1;" \ "l" W "arx %0, 0, %1;" \
I ";" \ I ";" \
"st" W "cx. %0, 0, %1;" \ "st" W "cx. %0, 0, %1;" \
"bne- 1b;" \ "bne- 1b;" \
: "=&r" (previous) \ : "=&r" (previous) \
: "r" (target) \ : "r" (target) \
: "memory", "cc"); \ : "memory", "cc"); \
return; \ return; \
} }
CK_PR_UNARY(inc, ptr, void, void *, "addic %0, %0, 1", "w") CK_PR_UNARY(inc, ptr, void, void *, "addic %0, %0, 1", "w")
CK_PR_UNARY(dec, ptr, void, void *, "addic %0, %0, -1", "w") CK_PR_UNARY(dec, ptr, void, void *, "addic %0, %0, -1", "w")
CK_PR_UNARY(not, ptr, void, void *, "not %0, %0", "w") CK_PR_UNARY(not, ptr, void, void *, "not %0, %0", "w")
CK_PR_UNARY(neg, ptr, void, void *, "neg %0, %0", "w") CK_PR_UNARY(neg, ptr, void, void *, "neg %0, %0", "w")
#define CK_PR_UNARY_S(S, T, W) \ #define CK_PR_UNARY_S(S, T, W) \
CK_PR_UNARY(inc, S, T, T, "addic %0, %0, 1", W) \ CK_PR_UNARY(inc, S, T, T, "addic %0, %0, 1", W) \
CK_PR_UNARY(dec, S, T, T, "addic %0, %0, -1", W) \ CK_PR_UNARY(dec, S, T, T, "addic %0, %0, -1", W) \
CK_PR_UNARY(not, S, T, T, "not %0, %0", W) \ CK_PR_UNARY(not, S, T, T, "not %0, %0", W) \
CK_PR_UNARY(neg, S, T, T, "neg %0, %0", W) CK_PR_UNARY(neg, S, T, T, "neg %0, %0", W)
CK_PR_UNARY_S(32, uint32_t, "w") CK_PR_UNARY_S(32, uint32_t, "w")
CK_PR_UNARY_S(uint, unsigned int, "w") CK_PR_UNARY_S(uint, unsigned int, "w")
CK_PR_UNARY_S(int, int, "w") CK_PR_UNARY_S(int, int, "w")
#undef CK_PR_UNARY_S #undef CK_PR_UNARY_S
#undef CK_PR_UNARY #undef CK_PR_UNARY
#define CK_PR_BINARY(O, N, M, T, I, W) \ #define CK_PR_BINARY(O, N, M, T, I, W) \
CK_CC_INLINE static void \ CK_CC_INLINE static void \
ck_pr_##O##_##N(M *target, T delta) \ ck_pr_##O##_##N(M *target, T delta) \
{ \ { \
T previous; \ T previous; \
__asm__ __volatile__("1:" \ __asm__ __volatile__("1:" \
"l" W "arx %0, 0, %1;" \ "l" W "arx %0, 0, %1;" \
I " %0, %2, %0;" \ I " %0, %2, %0;" \
"st" W "cx. %0, 0, %1;" \ "st" W "cx. %0, 0, %1;" \
"bne- 1b;" \ "bne- 1b;" \
: "=&r" (previous) \ : "=&r" (previous) \
: "r" (target), \ : "r" (target), \
"r" (delta) \ "r" (delta) \
: "memory", "cc"); \ : "memory", "cc"); \
return; \ return; \
} }
CK_PR_BINARY(and, ptr, void, uintptr_t, "and", "w") CK_PR_BINARY(and, ptr, void, uintptr_t, "and", "w")
CK_PR_BINARY(add, ptr, void, uintptr_t, "add", "w") CK_PR_BINARY(add, ptr, void, uintptr_t, "add", "w")
CK_PR_BINARY(or, ptr, void, uintptr_t, "or", "w") CK_PR_BINARY(or, ptr, void, uintptr_t, "or", "w")
CK_PR_BINARY(sub, ptr, void, uintptr_t, "sub", "w") CK_PR_BINARY(sub, ptr, void, uintptr_t, "sub", "w")
CK_PR_BINARY(xor, ptr, void, uintptr_t, "xor", "w") CK_PR_BINARY(xor, ptr, void, uintptr_t, "xor", "w")
#define CK_PR_BINARY_S(S, T, W) \ #define CK_PR_BINARY_S(S, T, W) \
CK_PR_BINARY(and, S, T, T, "and", W) \ CK_PR_BINARY(and, S, T, T, "and", W) \
CK_PR_BINARY(add, S, T, T, "add", W) \ CK_PR_BINARY(add, S, T, T, "add", W) \
CK_PR_BINARY(or, S, T, T, "or", W) \ CK_PR_BINARY(or, S, T, T, "or", W) \
CK_PR_BINARY(sub, S, T, T, "subf", W) \ CK_PR_BINARY(sub, S, T, T, "subf", W) \
CK_PR_BINARY(xor, S, T, T, "xor", W) CK_PR_BINARY(xor, S, T, T, "xor", W)
CK_PR_BINARY_S(32, uint32_t, "w") CK_PR_BINARY_S(32, uint32_t, "w")
CK_PR_BINARY_S(uint, unsigned int, "w") CK_PR_BINARY_S(uint, unsigned int, "w")
CK_PR_BINARY_S(int, int, "w") CK_PR_BINARY_S(int, int, "w")
#undef CK_PR_BINARY_S #undef CK_PR_BINARY_S
#undef CK_PR_BINARY #undef CK_PR_BINARY
CK_CC_INLINE static void * CK_CC_INLINE static void *
ck_pr_faa_ptr(void *target, uintptr_t delta) ck_pr_faa_ptr(void *target, uintptr_t delta)
{ {
uintptr_t previous, r; uintptr_t previous, r;
__asm__ __volatile__("isync;" __asm__ __volatile__("isync;"
"1:" "1:"
"lwarx %0, 0, %2;" "lwarx %0, 0, %2;"
"add %1, %3, %0;" "add %1, %3, %0;"
"stwcx. %1, 0, %2;" "stwcx. %1, 0, %2;"
"bne- 1b;" "bne- 1b;"
"lwsync;" "lwsync;"
: "=&r" (previous), : "=&r" (previous),
"=&r" (r) "=&r" (r)
: "r" (target), : "r" (target),
"r" (delta) "r" (delta)
: "memory", "cc"); : "memory", "cc");
return (void *)(previous); return (void *)(previous);
} }
#define CK_PR_FAA(S, T, W) \ #define CK_PR_FAA(S, T, W) \
CK_CC_INLINE static T \ CK_CC_INLINE static T \
ck_pr_faa_##S(T *target, T delta) \ ck_pr_faa_##S(T *target, T delta) \
{ \ { \
T previous, r; \ T previous, r; \
__asm__ __volatile__("isync;" \ __asm__ __volatile__("isync;" \
"1:" \ "1:" \
"l" W "arx %0, 0, %2;" \ "l" W "arx %0, 0, %2;" \
"add %1, %3, %0;" \ "add %1, %3, %0;" \
"st" W "cx. %1, 0, %2;" \ "st" W "cx. %1, 0, %2;" \
"bne- 1b;" \ "bne- 1b;" \
"lwsync;" \ "lwsync;" \
: "=&r" (previous), \ : "=&r" (previous), \
"=&r" (r) \ "=&r" (r) \
: "r" (target), \ : "r" (target), \
"r" (delta) \ "r" (delta) \
: "memory", "cc"); \ : "memory", "cc"); \
return (previous); \ return (previous); \
} }
CK_PR_FAA(32, uint32_t, "w") CK_PR_FAA(32, uint32_t, "w")
CK_PR_FAA(uint, unsigned int, "w") CK_PR_FAA(uint, unsigned int, "w")
CK_PR_FAA(int, int, "w") CK_PR_FAA(int, int, "w")
#undef CK_PR_FAA #undef CK_PR_FAA
#endif /* _CK_PR_PPC_H */ #endif /* _CK_PR_PPC_H */

@ -151,7 +151,7 @@ ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *v
"r" (compare) "r" (compare)
: "memory", "cc"); : "memory", "cc");
*value = previous; *value = previous;
return (previous == compare); return (previous == compare);
} }
@ -389,7 +389,7 @@ ck_pr_faa_ptr(void *target, uintptr_t delta)
: "=&r" (previous), : "=&r" (previous),
"=&r" (r) "=&r" (r)
: "r" (target), : "r" (target),
"r" (delta) "r" (delta)
: "memory", "cc"); : "memory", "cc");
return (void *)(previous); return (void *)(previous);

@ -134,14 +134,14 @@ ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *v
*value = set; *value = set;
return (compare == set); return (compare == set);
} }
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set) ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set)
{ {
__asm__ __volatile__("casx [%1], %2, %0" __asm__ __volatile__("casx [%1], %2, %0"
: "+&r" (set) : "+&r" (set)
: "r" (target), : "r" (target),
"r" (compare) "r" (compare)
: "memory"); : "memory");
@ -161,7 +161,7 @@ ck_pr_cas_ptr_value(void *target, void *compare, void *set, void *previous)
{ {
return ck_pr_cas_64_value(target, (uint64_t)compare, (uint64_t)set, previous); return ck_pr_cas_64_value(target, (uint64_t)compare, (uint64_t)set, previous);
} }
#define CK_PR_CAS(N, T) \ #define CK_PR_CAS(N, T) \
CK_CC_INLINE static bool \ CK_CC_INLINE static bool \

@ -40,7 +40,7 @@
/* /*
* The following represent supported atomic operations. * The following represent supported atomic operations.
* These operations may be emulated. * These operations may be emulated.
*/ */
#include "ck_f_pr.h" #include "ck_f_pr.h"
/* Minimum requirements for the CK_PR interface are met. */ /* Minimum requirements for the CK_PR interface are met. */

@ -39,7 +39,7 @@
/* /*
* The following represent supported atomic operations. * The following represent supported atomic operations.
* These operations may be emulated. * These operations may be emulated.
*/ */
#include "ck_f_pr.h" #include "ck_f_pr.h"
/* Minimum requirements for the CK_PR interface are met. */ /* Minimum requirements for the CK_PR interface are met. */
@ -149,7 +149,7 @@ CK_PR_LOAD_S(8, uint8_t, "movb")
#undef CK_PR_LOAD_S #undef CK_PR_LOAD_S
#undef CK_PR_LOAD #undef CK_PR_LOAD
CK_CC_INLINE static void CK_CC_INLINE static void
ck_pr_load_64_2(uint64_t target[2], uint64_t v[2]) ck_pr_load_64_2(uint64_t target[2], uint64_t v[2])
{ {
__asm__ __volatile__("movq %%rdx, %%rcx;" __asm__ __volatile__("movq %%rdx, %%rcx;"
@ -167,7 +167,7 @@ CK_CC_INLINE static void
ck_pr_load_ptr_2(void *t, void *v) ck_pr_load_ptr_2(void *t, void *v)
{ {
ck_pr_load_64_2(t, v); ck_pr_load_64_2(t, v);
return; return;
} }
#define CK_PR_LOAD_2(S, W, T) \ #define CK_PR_LOAD_2(S, W, T) \

@ -11,7 +11,7 @@ all:
$(MAKE) -C ./ck_spinlock/benchmark all $(MAKE) -C ./ck_spinlock/benchmark all
$(MAKE) -C ./ck_fifo/validate all $(MAKE) -C ./ck_fifo/validate all
$(MAKE) -C ./ck_fifo/benchmark all $(MAKE) -C ./ck_fifo/benchmark all
$(MAKE) -C ./ck_pr/validate all $(MAKE) -C ./ck_pr/validate all
$(MAKE) -C ./ck_pr/benchmark all $(MAKE) -C ./ck_pr/benchmark all
$(MAKE) -C ./ck_barrier/validate all $(MAKE) -C ./ck_barrier/validate all
$(MAKE) -C ./ck_barrier/benchmark all $(MAKE) -C ./ck_barrier/benchmark all

@ -53,7 +53,7 @@ thread(void *null CK_CC_UNUSED)
ck_barrier_centralized_state_t state = CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; ck_barrier_centralized_state_t state = CK_BARRIER_CENTRALIZED_STATE_INITIALIZER;
int id; int id;
id = ck_pr_faa_int(&tid, 1); id = ck_pr_faa_int(&tid, 1);
aff_iterate(&a); aff_iterate(&a);
while (ck_pr_load_int(&done) == 0) { while (ck_pr_load_int(&done) == 0) {
@ -91,39 +91,39 @@ main(int argc, char *argv[])
} }
nthr = atoi(argv[1]); nthr = atoi(argv[1]);
if (nthr <= 0) { if (nthr <= 0) {
fprintf(stderr, "ERROR: Number of threads must be greater than 0\n"); fprintf(stderr, "ERROR: Number of threads must be greater than 0\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
threads = malloc(sizeof(pthread_t) * nthr); threads = malloc(sizeof(pthread_t) * nthr);
if (threads == NULL) { if (threads == NULL) {
fprintf(stderr, "ERROR: Could not allocate thread structures\n"); fprintf(stderr, "ERROR: Could not allocate thread structures\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
counters = calloc(sizeof(struct counter), nthr); counters = calloc(sizeof(struct counter), nthr);
if (counters == NULL) { if (counters == NULL) {
fprintf(stderr, "ERROR: Could not allocate counters\n"); fprintf(stderr, "ERROR: Could not allocate counters\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
a.delta = atoi(argv[2]); a.delta = atoi(argv[2]);
fprintf(stderr, "Creating threads (barrier)..."); fprintf(stderr, "Creating threads (barrier)...");
for (i = 0; i < nthr; ++i) { for (i = 0; i < nthr; ++i) {
if (pthread_create(&threads[i], NULL, thread, NULL)) { if (pthread_create(&threads[i], NULL, thread, NULL)) {
fprintf(stderr, "ERROR: Could not create thread %d\n", i); fprintf(stderr, "ERROR: Could not create thread %d\n", i);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
fprintf(stderr, "done\n"); fprintf(stderr, "done\n");
sleep(10); sleep(10);
count = 0; count = 0;
ck_pr_store_int(&done, 1); ck_pr_store_int(&done, 1);
for (i = 0; i < nthr; ++i) for (i = 0; i < nthr; ++i)
count += ck_pr_load_64(&counters[i].value); count += ck_pr_load_64(&counters[i].value);
printf("%d %16" PRIu64 "\n", nthr, count); printf("%d %16" PRIu64 "\n", nthr, count);

@ -95,7 +95,7 @@ main(int argc, char *argv[])
if (init_root == NULL) { if (init_root == NULL) {
fprintf(stderr, "ERROR: Could not allocate initial barrier structure\n"); fprintf(stderr, "ERROR: Could not allocate initial barrier structure\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ck_barrier_combining_init(&barrier, init_root); ck_barrier_combining_init(&barrier, init_root);
if (argc != 4) { if (argc != 4) {

@ -31,7 +31,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef STEPS #ifndef STEPS
#define STEPS 1000000 #define STEPS 1000000
#endif #endif

@ -34,7 +34,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef STEPS #ifndef STEPS
#define STEPS 1000000 #define STEPS 1000000
#endif #endif

@ -1,6 +1,6 @@
.PHONY: clean distribution .PHONY: clean distribution
OBJECTS=validate OBJECTS=validate
all: $(OBJECTS) all: $(OBJECTS)

@ -31,7 +31,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef STEPS #ifndef STEPS
#define STEPS 1000000 #define STEPS 1000000
#endif #endif

@ -1,6 +1,6 @@
.PHONY: clean distribution .PHONY: clean distribution
OBJECTS=validate OBJECTS=validate
all: $(OBJECTS) all: $(OBJECTS)

@ -50,7 +50,7 @@ static unsigned int barrier;
static unsigned int e_barrier; static unsigned int e_barrier;
#ifndef PAIRS #ifndef PAIRS
#define PAIRS 5000000 #define PAIRS 5000000
#endif #endif
struct node { struct node {
@ -160,10 +160,10 @@ main(int argc, char *argv[])
ck_epoch_init(&stack_epoch, threshold); ck_epoch_init(&stack_epoch, threshold);
for (i = 0; i < n_threads; i++) for (i = 0; i < n_threads; i++)
pthread_create(threads + i, NULL, thread, NULL); pthread_create(threads + i, NULL, thread, NULL);
for (i = 0; i < n_threads; i++) for (i = 0; i < n_threads; i++)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
return (0); return (0);

@ -51,7 +51,7 @@ static unsigned int e_barrier;
static unsigned int readers; static unsigned int readers;
#ifndef PAIRS #ifndef PAIRS
#define PAIRS 5000000 #define PAIRS 5000000
#endif #endif
#ifndef ITERATE #ifndef ITERATE
@ -217,12 +217,12 @@ main(int argc, char *argv[])
ck_epoch_init(&stack_epoch, threshold); ck_epoch_init(&stack_epoch, threshold);
for (i = 0; i < n_threads - 1; i++) for (i = 0; i < n_threads - 1; i++)
pthread_create(threads + i, NULL, read_thread, NULL); pthread_create(threads + i, NULL, read_thread, NULL);
pthread_create(threads + i, NULL, thread, NULL); pthread_create(threads + i, NULL, thread, NULL);
for (i = 0; i < n_threads; i++) for (i = 0; i < n_threads; i++)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
return (0); return (0);

@ -2,7 +2,7 @@
OBJECTS=latency OBJECTS=latency
all: $(OBJECTS) all: $(OBJECTS)
latency: latency.c latency: latency.c
$(CC) $(CFLAGS) -o latency latency.c $(CC) $(CFLAGS) -o latency latency.c

@ -33,7 +33,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef ENTRIES #ifndef ENTRIES
#define ENTRIES 4096 #define ENTRIES 4096
#endif #endif
#ifndef STEPS #ifndef STEPS

@ -34,7 +34,7 @@
#ifdef CK_F_FIFO_MPMC #ifdef CK_F_FIFO_MPMC
#ifndef ITERATIONS #ifndef ITERATIONS
#define ITERATIONS 128 #define ITERATIONS 128
#endif #endif
struct context { struct context {

@ -46,7 +46,7 @@ main(void)
stub = malloc(sizeof(ck_fifo_mpmc_entry_t)); stub = malloc(sizeof(ck_fifo_mpmc_entry_t));
if (stub == NULL) if (stub == NULL)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
ck_fifo_mpmc_init(&mpmc_fifo, stub); ck_fifo_mpmc_init(&mpmc_fifo, stub);
entries = malloc(sizeof(ck_fifo_mpmc_entry_t) * length); entries = malloc(sizeof(ck_fifo_mpmc_entry_t) * length);

@ -34,7 +34,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef ITERATIONS #ifndef ITERATIONS
#define ITERATIONS 128 #define ITERATIONS 128
#endif #endif
struct context { struct context {

@ -1,5 +1,5 @@
/* /*
* Copyright 2011 David Joseph. * Copyright 2011 David Joseph.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -45,7 +45,7 @@ main(void)
stub = malloc(sizeof(ck_fifo_spsc_entry_t)); stub = malloc(sizeof(ck_fifo_spsc_entry_t));
if (stub == NULL) if (stub == NULL)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
ck_fifo_spsc_init(&spsc_fifo, stub); ck_fifo_spsc_init(&spsc_fifo, stub);
entries = malloc(sizeof(ck_fifo_spsc_entry_t) * length); entries = malloc(sizeof(ck_fifo_spsc_entry_t) * length);

@ -2,7 +2,7 @@
OBJECTS=fifo_latency stack_latency OBJECTS=fifo_latency stack_latency
all: $(OBJECTS) all: $(OBJECTS)
fifo_latency: fifo_latency.c fifo_latency: fifo_latency.c
$(CC) $(CFLAGS) -o fifo_latency ../../../src/ck_hp.c fifo_latency.c $(CC) $(CFLAGS) -o fifo_latency ../../../src/ck_hp.c fifo_latency.c

@ -34,7 +34,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef ENTRIES #ifndef ENTRIES
#define ENTRIES 4096 #define ENTRIES 4096
#endif #endif
#ifndef STEPS #ifndef STEPS

@ -35,7 +35,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef ENTRIES #ifndef ENTRIES
#define ENTRIES 4096 #define ENTRIES 4096
#endif #endif
#ifndef STEPS #ifndef STEPS

@ -5,19 +5,19 @@ OBJECTS=ck_hp_stack nbds_haz_test serial ck_hp_fifo
all: $(OBJECTS) all: $(OBJECTS)
ck_hp_stack: ../../../src/ck_hp.c ck_hp_stack.c ../../../include/ck_hp_stack.h ck_hp_stack: ../../../src/ck_hp.c ck_hp_stack.c ../../../include/ck_hp_stack.h
$(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_stack ck_hp_stack.c $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_stack ck_hp_stack.c
ck_hp_fifo: ../../../src/ck_hp.c ck_hp_fifo.c ../../../include/ck_hp_fifo.h ck_hp_fifo: ../../../src/ck_hp.c ck_hp_fifo.c ../../../include/ck_hp_fifo.h
$(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_fifo ck_hp_fifo.c $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_fifo ck_hp_fifo.c
serial: ../../../src/ck_hp.c serial.c ../../../include/ck_hp_stack.h serial: ../../../src/ck_hp.c serial.c ../../../include/ck_hp_stack.h
$(CC) $(CFLAGS) ../../../src/ck_hp.c -o serial serial.c $(CC) $(CFLAGS) ../../../src/ck_hp.c -o serial serial.c
nbds_haz_test: ../../../src/ck_hp.c nbds_haz_test.c nbds_haz_test: ../../../src/ck_hp.c nbds_haz_test.c
$(CC) $(CFLAGS) ../../../src/ck_hp.c -o nbds_haz_test nbds_haz_test.c $(CC) $(CFLAGS) ../../../src/ck_hp.c -o nbds_haz_test nbds_haz_test.c
clean: clean:
rm -rf *~ *.o *.dSYM $(OBJECTS) rm -rf *~ *.o *.dSYM $(OBJECTS)
include ../../../build/regressions.build include ../../../build/regressions.build
CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE

@ -33,7 +33,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef ITERATIONS #ifndef ITERATIONS
#define ITERATIONS 128 #define ITERATIONS 128
#endif #endif
struct context { struct context {

@ -51,7 +51,7 @@ static unsigned int barrier;
static unsigned int e_barrier; static unsigned int e_barrier;
#ifndef PAIRS #ifndef PAIRS
#define PAIRS 5000000 #define PAIRS 5000000
#endif #endif
struct node { struct node {
@ -157,10 +157,10 @@ main(int argc, char *argv[])
ck_hp_init(&stack_hp, 1, threshold, destructor); ck_hp_init(&stack_hp, 1, threshold, destructor);
for (i = 0; i < n_threads; i++) for (i = 0; i < n_threads; i++)
pthread_create(threads + i, NULL, thread, NULL); pthread_create(threads + i, NULL, thread, NULL);
for (i = 0; i < n_threads; i++) for (i = 0; i < n_threads; i++)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
return (0); return (0);

@ -73,7 +73,7 @@ static unsigned int pops;
static unsigned int pushs; static unsigned int pushs;
#ifndef PAIRS #ifndef PAIRS
#define PAIRS 1000000 #define PAIRS 1000000
#endif #endif
struct node { struct node {
@ -103,7 +103,7 @@ stack_push_mpmc(struct stack *target, struct stack_entry *entry)
ck_pr_store_ptr(&entry->next, lstack); ck_pr_store_ptr(&entry->next, lstack);
ck_backoff_eb(&backoff); ck_backoff_eb(&backoff);
} }
return; return;
} }
@ -134,7 +134,7 @@ stack_pop_mpmc(ck_hp_record_t *record, struct stack *target)
ck_backoff_eb(&backoff); ck_backoff_eb(&backoff);
} }
return (entry); return (entry);
} }
@ -159,7 +159,7 @@ thread(void *unused CK_CC_UNUSED)
} }
ck_pr_inc_uint(&barrier); ck_pr_inc_uint(&barrier);
while (ck_pr_load_uint(&barrier) < n_threads) while (ck_pr_load_uint(&barrier) < n_threads)
ck_pr_stall(); ck_pr_stall();
for (i = 0; i < PAIRS; i++) { for (i = 0; i < PAIRS; i++) {
@ -214,10 +214,10 @@ main(int argc, char *argv[])
ck_hp_init(&stack_hp, 1, threshold, destructor); ck_hp_init(&stack_hp, 1, threshold, destructor);
for (i = 0; i < n_threads; i++) for (i = 0; i < n_threads; i++)
pthread_create(threads + i, NULL, thread, NULL); pthread_create(threads + i, NULL, thread, NULL);
for (i = 0; i < n_threads; i++) for (i = 0; i < n_threads; i++)
pthread_join(threads[i], NULL); pthread_join(threads[i], NULL);
fprintf(stderr, "Push: %u\nPop: %u\n", pushs, pops); fprintf(stderr, "Push: %u\nPop: %u\n", pushs, pops);

@ -122,6 +122,6 @@ main(int argc, char *argv[])
ck_hp_set(&record[1], 0, NULL); ck_hp_set(&record[1], 0, NULL);
ck_hp_reclaim(&record[0]); ck_hp_reclaim(&record[0]);
ck_hp_reclaim(&record[1]); ck_hp_reclaim(&record[1]);
return 0; return 0;
} }

@ -280,7 +280,7 @@ main(int argc, char *argv[])
if (argc >= 3) if (argc >= 3)
r = atoi(argv[2]); r = atoi(argv[2]);
if (argc >= 4) if (argc >= 4)
s = (uint64_t)atoi(argv[3]); s = (uint64_t)atoi(argv[3]);
if (argc >= 5) { if (argc >= 5) {
@ -410,7 +410,7 @@ main(int argc, char *argv[])
for (i = 0; i < keys_length; i++) for (i = 0; i < keys_length; i++)
table_insert(keys[i]); table_insert(keys[i]);
ck_epoch_write_end(&epoch_wr); ck_epoch_write_end(&epoch_wr);
} }
fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length));
fprintf(stderr, " | Executing negative look-up test..."); fprintf(stderr, " | Executing negative look-up test...");
@ -450,7 +450,7 @@ main(int argc, char *argv[])
accumulator[HT_STATE_GET] / n_threads); accumulator[HT_STATE_GET] / n_threads);
fprintf(stderr, " | Executing strict replacement test..."); fprintf(stderr, " | Executing strict replacement test...");
a = repeated = 0; a = repeated = 0;
signal(SIGALRM, alarm_handler); signal(SIGALRM, alarm_handler);
alarm(r); alarm(r);

@ -273,7 +273,7 @@ main(int argc, char *argv[])
if (argc >= 3) if (argc >= 3)
r = atoi(argv[2]); r = atoi(argv[2]);
if (argc >= 4) if (argc >= 4)
s = (uint64_t)atoi(argv[3]); s = (uint64_t)atoi(argv[3]);
if (argc >= 5) { if (argc >= 5) {
@ -391,7 +391,7 @@ main(int argc, char *argv[])
for (i = 0; i < keys_length; i++) for (i = 0; i < keys_length; i++)
table_insert(keys[i]); table_insert(keys[i]);
ck_epoch_write_end(&epoch_wr); ck_epoch_write_end(&epoch_wr);
} }
fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length));
fprintf(stderr, " | Executing negative look-up test..."); fprintf(stderr, " | Executing negative look-up test...");
@ -431,7 +431,7 @@ main(int argc, char *argv[])
accumulator[HT_STATE_GET] / n_threads); accumulator[HT_STATE_GET] / n_threads);
fprintf(stderr, " | Executing strict replacement test..."); fprintf(stderr, " | Executing strict replacement test...");
a = repeated = 0; a = repeated = 0;
signal(SIGALRM, alarm_handler); signal(SIGALRM, alarm_handler);
alarm(r); alarm(r);

@ -168,7 +168,7 @@ main(int argc, char *argv[])
if (argc >= 3) if (argc >= 3)
r = atoi(argv[2]); r = atoi(argv[2]);
if (argc >= 4) if (argc >= 4)
s = (uint64_t)atoi(argv[3]); s = (uint64_t)atoi(argv[3]);
keys = malloc(sizeof(char *) * keys_capacity); keys = malloc(sizeof(char *) * keys_capacity);

@ -3,13 +3,13 @@
all: ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 all: ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2
ck_pr_cas_64_2: ck_pr_cas_64_2.c ck_pr_cas_64_2: ck_pr_cas_64_2.c
$(CC) $(CFLAGS) -o ck_pr_cas_64_2 ck_pr_cas_64_2.c $(CC) $(CFLAGS) -o ck_pr_cas_64_2 ck_pr_cas_64_2.c
ck_pr_cas_64: ck_pr_cas_64.c ck_pr_cas_64: ck_pr_cas_64.c
$(CC) $(CFLAGS) -o ck_pr_cas_64 ck_pr_cas_64.c $(CC) $(CFLAGS) -o ck_pr_cas_64 ck_pr_cas_64.c
ck_pr_fas_64: ck_pr_fas_64.c ck_pr_fas_64: ck_pr_fas_64.c
$(CC) $(CFLAGS) -o ck_pr_fas_64 ck_pr_fas_64.c $(CC) $(CFLAGS) -o ck_pr_fas_64 ck_pr_fas_64.c
clean: clean:
rm -rf ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 *.dSYM rm -rf ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 *.dSYM

@ -32,7 +32,7 @@ static void *
fairness(void *null) fairness(void *null)
{ {
struct block *context = null; struct block *context = null;
unsigned int i = context->tid; unsigned int i = context->tid;
if (aff_iterate(&a)) { if (aff_iterate(&a)) {
perror("ERROR: Could not affine thread"); perror("ERROR: Could not affine thread");

@ -67,7 +67,7 @@
run_test_##K##_uint(); \ run_test_##K##_uint(); \
\ \
return; \ return; \
} }
GENERATE_TEST(add, +) GENERATE_TEST(add, +)
GENERATE_TEST(sub, -) GENERATE_TEST(sub, -)
@ -89,4 +89,4 @@ main(void)
return (0); return (0);
} }

@ -74,7 +74,7 @@
x, y); \ x, y); \
\ \
return; \ return; \
} }
#define TEST_BTX_S(K, S, T, P, D, R) TEST_BTX(K, S, T, T, T, P, D, R) #define TEST_BTX_S(K, S, T, P, D, R) TEST_BTX(K, S, T, T, T, P, D, R)

@ -47,7 +47,7 @@
*target = update; \ *target = update; \
\ \
return (previous); \ return (previous); \
} }
#define TEST_FAX_FN_S(S, T) TEST_FAX_FN(S, T, T) #define TEST_FAX_FN_S(S, T) TEST_FAX_FN(S, T, T)

@ -69,7 +69,7 @@
run_test_##K##_uint(); \ run_test_##K##_uint(); \
\ \
return; \ return; \
} }
GENERATE_TEST(not, ~) GENERATE_TEST(not, ~)
GENERATE_TEST(neg, -) GENERATE_TEST(neg, -)

@ -86,8 +86,8 @@
x, y); \ x, y); \
\ \
return; \ return; \
} }
#define GENERATE_TEST(K, P, Y, Z) \ #define GENERATE_TEST(K, P, Y, Z) \
TEST_UNARY(K, int, int, int, P, d, Y) \ TEST_UNARY(K, int, int, int, P, d, Y) \
TEST_UNARY(K, uint, unsigned int, unsigned int, P, u, Z) \ TEST_UNARY(K, uint, unsigned int, unsigned int, P, u, Z) \

@ -151,7 +151,7 @@ main(int argc, char *argv[])
n = malloc(sizeof *n); n = malloc(sizeof *n);
assert(n != NULL); assert(n != NULL);
n->value = i; n->value = i;
CK_LIST_INSERT_HEAD(&head, n, list_entry); CK_LIST_INSERT_HEAD(&head, n, list_entry);
} }
test_foreach(); test_foreach();
@ -187,7 +187,7 @@ main(int argc, char *argv[])
n = malloc(sizeof *n); n = malloc(sizeof *n);
assert(n != NULL); assert(n != NULL);
n->value = i; n->value = i;
CK_LIST_INSERT_HEAD(&head, n, list_entry); CK_LIST_INSERT_HEAD(&head, n, list_entry);
for (j = 0; j <= 1000; j++); for (j = 0; j <= 1000; j++);
} }

@ -151,7 +151,7 @@ main(int argc, char *argv[])
n = malloc(sizeof *n); n = malloc(sizeof *n);
assert(n != NULL); assert(n != NULL);
n->value = i; n->value = i;
CK_SLIST_INSERT_HEAD(&head, n, list_entry); CK_SLIST_INSERT_HEAD(&head, n, list_entry);
} }
test_foreach(); test_foreach();
@ -187,7 +187,7 @@ main(int argc, char *argv[])
n = malloc(sizeof *n); n = malloc(sizeof *n);
assert(n != NULL); assert(n != NULL);
n->value = i; n->value = i;
CK_SLIST_INSERT_HEAD(&head, n, list_entry); CK_SLIST_INSERT_HEAD(&head, n, list_entry);
for (j = 0; j <= 1000; j++); for (j = 0; j <= 1000; j++);
} }

@ -5,7 +5,7 @@ OBJECTS=latency
all: $(OBJECTS) all: $(OBJECTS)
latency: latency.c ../../../include/ck_ring.h latency: latency.c ../../../include/ck_ring.h
$(CC) $(CFLAGS) -o latency latency.c $(CC) $(CFLAGS) -o latency latency.c
clean: clean:
rm -rf *~ *.o $(OBJECTS) *.dSYM rm -rf *~ *.o $(OBJECTS) *.dSYM

@ -14,4 +14,4 @@ clean:
rm -rf *~ *.o $(OBJECTS) *.dSYM rm -rf *~ *.o $(OBJECTS) *.dSYM
include ../../../build/regressions.build include ../../../build/regressions.build
CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE

@ -33,7 +33,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef ITERATIONS #ifndef ITERATIONS
#define ITERATIONS 128 #define ITERATIONS 128
#endif #endif
struct context { struct context {

@ -33,7 +33,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef ITERATIONS #ifndef ITERATIONS
#define ITERATIONS 128 #define ITERATIONS 128
#endif #endif
struct context { struct context {

@ -30,7 +30,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef STEPS #ifndef STEPS
#define STEPS 1000000 #define STEPS 1000000
#endif #endif

@ -34,7 +34,7 @@
#include "../../common.h" #include "../../common.h"
#ifndef STEPS #ifndef STEPS
#define STEPS 1000000 #define STEPS 1000000
#endif #endif

@ -1,6 +1,6 @@
/* /*
* Copyright 2011-2012 Samy Al Bahra. * Copyright 2011-2012 Samy Al Bahra.
* Copyright 2011 David Joseph. * Copyright 2011 David Joseph.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -25,17 +25,17 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <ck_bytelock.h> #include <ck_bytelock.h>
#include <ck_spinlock.h> #include <ck_spinlock.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "../../common.h" #include "../../common.h"
#ifndef STEPS #ifndef STEPS
#define STEPS 30000000 #define STEPS 30000000
#endif #endif
LOCK_DEFINE; LOCK_DEFINE;

@ -98,7 +98,7 @@ fairness(void *null)
LOCK_STATE; LOCK_STATE;
#endif #endif
struct block *context = null; struct block *context = null;
unsigned int i = context->tid; unsigned int i = context->tid;
volatile int j; volatile int j;
long int base; long int base;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save