diff --git a/Makefile.in b/Makefile.in index 15592c7..7fe9a89 100644 --- a/Makefile.in +++ b/Makefile.in @@ -47,7 +47,7 @@ install: all install-headers @echo @echo ---[ Concurrency Kit has installed successfully. -uninstall: +uninstall: $(MAKE) -C doc uninstall rm -f $(DESTDIR)/$(LIBRARY)/libck.so* rm -f $(DESTDIR)/$(LIBRARY)/libck.a diff --git a/build/ck.pc.in b/build/ck.pc.in index 620f2c1..5f0e97a 100644 --- a/build/ck.pc.in +++ b/build/ck.pc.in @@ -3,7 +3,7 @@ includedir=@HEADERS@ libdir=@LIBRARY@ 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/ Version: @VERSION@ Libs: -L${libdir} -lck diff --git a/build/ck.spec.in b/build/ck.spec.in index ef11fd8..e4caace 100644 --- a/build/ck.spec.in +++ b/build/ck.spec.in @@ -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 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. %prep diff --git a/configure b/configure index a3de6d2..1659ec6 100755 --- a/configure +++ b/configure @@ -271,7 +271,7 @@ case $PLATFORM in PLATFORM=x86 ENVIRONMENT=32 ;; - + *) PLATFORM=x86 ENVIRONMENT=32 diff --git a/doc/ck_bitmap_base b/doc/ck_bitmap_base index 6cc004f..6435d1b 100644 --- a/doc/ck_bitmap_base +++ b/doc/ck_bitmap_base @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft unsigned int .Fn ck_bitmap_base "unsigned int n_bits" .Sh DESCRIPTION -The +The .Fn ck_bitmap_base function returns the number of bytes that would be used to store the number of bits specified by diff --git a/doc/ck_bitmap_bits b/doc/ck_bitmap_bits index 7ecf311..a372764 100644 --- a/doc/ck_bitmap_bits +++ b/doc/ck_bitmap_bits @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft unsigned int .Fn ck_bitmap_bits "ck_bitmap_t *bitmap" .Sh DESCRIPTION -The +The .Fn ck_bitmap_bits function returns the maximum number of addressable bits in the object pointed to by diff --git a/doc/ck_bitmap_buffer b/doc/ck_bitmap_buffer index 2b58d22..139de1a 100644 --- a/doc/ck_bitmap_buffer +++ b/doc/ck_bitmap_buffer @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void * .Fn ck_bitmap_buffer "ck_bitmap_t *bitmap" .Sh DESCRIPTION -The +The .Fn ck_bitmap_buffer functions returns a pointer to the actual bit array. For ck_bitmap pointers, the bit array is of type @@ -47,7 +47,7 @@ On currently supported 64-bit platforms is .Dv uint64_t . On currently supported 32-bit platforms -.Dv CK_BITMAP_WORD +.Dv CK_BITMAP_WORD is .Dv uint32_t . .Sh RETURN VALUES diff --git a/doc/ck_bitmap_clear b/doc/ck_bitmap_clear index 513fa14..f62b171 100644 --- a/doc/ck_bitmap_clear +++ b/doc/ck_bitmap_clear @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_bitmap_clear "ck_bitmap_t *bitmap" .Sh DESCRIPTION -The +The .Fn ck_bitmap_clear function sets all bits in the bitmap pointed to by .Fa bitmap diff --git a/doc/ck_bitmap_init b/doc/ck_bitmap_init index 2010de9..038b9ac 100644 --- a/doc/ck_bitmap_init +++ b/doc/ck_bitmap_init @@ -33,10 +33,10 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_bitmap.h -.Ft void +.Ft void .Fn ck_bitmap_init "ck_bitmap_t *bitmap" "unsigned int n_bits" "bool set" .Sh DESCRIPTION -The +The .Fn ck_bitmap_init function initializes the bitmap pointed to by the .Fa bitmap diff --git a/doc/ck_bitmap_reset_mpmc b/doc/ck_bitmap_reset_mpmc index 19c8774..8923fbd 100644 --- a/doc/ck_bitmap_reset_mpmc +++ b/doc/ck_bitmap_reset_mpmc @@ -33,10 +33,10 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_bitmap.h -.Ft void +.Ft void .Fn ck_bitmap_reset_mpmc "ck_bitmap_t *bitmap" "unsigned int n" .Sh DESCRIPTION -The +The .Fn ck_bitmap_reset_mpmc resets the bit at offset specified by the argument .Fa n diff --git a/doc/ck_bitmap_set_mpmc b/doc/ck_bitmap_set_mpmc index a450992..a92f21b 100644 --- a/doc/ck_bitmap_set_mpmc +++ b/doc/ck_bitmap_set_mpmc @@ -33,10 +33,10 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_bitmap.h -.Ft void +.Ft void .Fn ck_bitmap_set_mpmc "ck_bitmap_t *bitmap" "unsigned int n" .Sh DESCRIPTION -The +The .Fn ck_bitmap_set_mpmc sets the bit at offset specified by the argument .Fa n diff --git a/doc/ck_bitmap_size b/doc/ck_bitmap_size index 44d84a9..4076845 100644 --- a/doc/ck_bitmap_size +++ b/doc/ck_bitmap_size @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft unsigned int .Fn ck_bitmap_size "unsigned int n_bits" .Sh DESCRIPTION -The +The .Fn ck_bitmap_size function returns the number of bytes that are necessary to allocate for a bitmap that will contain the number @@ -45,7 +45,7 @@ of bits specified by .Pp This function is used to determine how many bytes to 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 . .Sh RETURN VALUES This function returns a non-zero value. diff --git a/doc/ck_bitmap_test b/doc/ck_bitmap_test index b0b8dea..43b020d 100644 --- a/doc/ck_bitmap_test +++ b/doc/ck_bitmap_test @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_bitmap_test "ck_bitmap_t *bitmap" "unsigned int n" .Sh DESCRIPTION -The +The .Fn ck_bitmap_test determines if the bit at the offset specified by the argument .Fa n diff --git a/doc/ck_ht_allocator_set b/doc/ck_ht_allocator_set index a9d9f84..f327c6f 100644 --- a/doc/ck_ht_allocator_set +++ b/doc/ck_ht_allocator_set @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_allocator_set "struct ck_malloc *allocator" .Sh DESCRIPTION -The +The .Fn ck_ht_allocator_set function initializes the memory allocation functions used by the hash table implementation according to the function pointers specified diff --git a/doc/ck_ht_count b/doc/ck_ht_count index cb9201c..f1f9615 100644 --- a/doc/ck_ht_count +++ b/doc/ck_ht_count @@ -33,10 +33,10 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_ht.h -.Ft uint64_t +.Ft uint64_t .Fn ck_ht_count "ck_ht_t *ht" .Sh DESCRIPTION -The +The .Fn ck_ht_count function will return the number of entries in the hash table pointed to be the diff --git a/doc/ck_ht_destroy b/doc/ck_ht_destroy index 76a06f6..8bd2369 100644 --- a/doc/ck_ht_destroy +++ b/doc/ck_ht_destroy @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_ht_destroy "ck_ht_t *ht" .Sh DESCRIPTION -The +The .Fn ck_ht_destroy function will request that the underlying allocator, as specified by the .Xr ck_ht_allocator_set 3 diff --git a/doc/ck_ht_entry_empty b/doc/ck_ht_entry_empty index 3394654..4b2f659 100644 --- a/doc/ck_ht_entry_empty +++ b/doc/ck_ht_entry_empty @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_entry_empty "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_empty function will return .Dv false diff --git a/doc/ck_ht_entry_key b/doc/ck_ht_entry_key index ee4e6bb..4fcc898 100644 --- a/doc/ck_ht_entry_key +++ b/doc/ck_ht_entry_key @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void * .Fn ck_ht_entry_key "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_key function will return the key pointer as specified in the object pointed to by the diff --git a/doc/ck_ht_entry_key_direct b/doc/ck_ht_entry_key_direct index 3070eec..a4a9019 100644 --- a/doc/ck_ht_entry_key_direct +++ b/doc/ck_ht_entry_key_direct @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft uintptr_t .Fn ck_ht_entry_key_direct "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_key_direct function will return the key value as specified in the object pointed to by the diff --git a/doc/ck_ht_entry_key_length b/doc/ck_ht_entry_key_length index f0d3b55..eb87265 100644 --- a/doc/ck_ht_entry_key_length +++ b/doc/ck_ht_entry_key_length @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft uint16_t .Fn ck_ht_entry_key_length "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_key_length function will return the length of the key associated with the object pointed to by the diff --git a/doc/ck_ht_entry_key_set b/doc/ck_ht_entry_key_set index 5035500..40774b9 100644 --- a/doc/ck_ht_entry_key_set +++ b/doc/ck_ht_entry_key_set @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_ht_entry_key_set "ck_ht_entry_t *entry" "const void *key" "uint16_t key_length" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_key_set function will initialize the object pointed to by .Fa entry diff --git a/doc/ck_ht_entry_key_set_direct b/doc/ck_ht_entry_key_set_direct index f4acf04..71cc763 100644 --- a/doc/ck_ht_entry_key_set_direct +++ b/doc/ck_ht_entry_key_set_direct @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_ht_entry_key_set_direct "ck_ht_entry_t *entry" "uintptr_t key" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_key_set_direct function will initialize the object pointed to by .Fa entry diff --git a/doc/ck_ht_entry_set b/doc/ck_ht_entry_set index e3da4fc..545f725 100644 --- a/doc/ck_ht_entry_set +++ b/doc/ck_ht_entry_set @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .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" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_set function will initialize the object pointed to by .Fa entry diff --git a/doc/ck_ht_entry_set_direct b/doc/ck_ht_entry_set_direct index a70b4d4..8042d33 100644 --- a/doc/ck_ht_entry_set_direct +++ b/doc/ck_ht_entry_set_direct @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_ht_entry_set "ck_ht_entry_t *entry" "uintptr_t key" "uintptr_t value" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_set function will initialize the object pointed to by .Fa entry @@ -44,7 +44,7 @@ with the key value specified in the .Fa key argument and a value specified by the .Fa value -argument. +argument. .Pp This function is typically used to initialize an entry for diff --git a/doc/ck_ht_entry_value b/doc/ck_ht_entry_value index 43b8378..7f668d2 100644 --- a/doc/ck_ht_entry_value +++ b/doc/ck_ht_entry_value @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void * .Fn ck_ht_entry_value "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_value function will return the value pointer as specified in the object pointed to by the diff --git a/doc/ck_ht_entry_value_direct b/doc/ck_ht_entry_value_direct index 6b7be2e..d67deaa 100644 --- a/doc/ck_ht_entry_value_direct +++ b/doc/ck_ht_entry_value_direct @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft uintptr_t .Fn ck_ht_entry_value_direct "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_entry_value_direct function will return the value of the key-value pair as specified in the object pointed to by the diff --git a/doc/ck_ht_get_spmc b/doc/ck_ht_get_spmc index e3d469c..a933320 100644 --- a/doc/ck_ht_get_spmc +++ b/doc/ck_ht_get_spmc @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_get_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_get_spmc function will return the value associated with the key specified in the .Fa entry @@ -75,7 +75,7 @@ if was created with CK_HT_MODE_BYTESTRING. If .Fa ht was initialized with CK_HT_MODE_DIRECT then it is -expected that +expected that .Fa h was initialized with the .Xr ck_ht_hash_direct 3 diff --git a/doc/ck_ht_grow_spmc b/doc/ck_ht_grow_spmc index 103c952..693282c 100644 --- a/doc/ck_ht_grow_spmc +++ b/doc/ck_ht_grow_spmc @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_grow_spmc "ck_ht_t *ht" "uint64_t capacity" .Sh DESCRIPTION -The +The .Fn ck_ht_grow_spmc function will resize the hash table in order to be able to at least store the number of entries specified by diff --git a/doc/ck_ht_hash b/doc/ck_ht_hash index 2187f11..183d60b 100644 --- a/doc/ck_ht_hash +++ b/doc/ck_ht_hash @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_ht_hash "ck_ht_hash_t *h" "ck_ht_t *ht" "const void *key" "uint16_t key_length" .Sh DESCRIPTION -The +The .Fn ck_ht_hash function will generate a hash value in the object pointed to by the .Fa h diff --git a/doc/ck_ht_hash_direct b/doc/ck_ht_hash_direct index 756f79e..9230bfb 100644 --- a/doc/ck_ht_hash_direct +++ b/doc/ck_ht_hash_direct @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_ht_hash_direct "ck_ht_hash_t *h" "ck_ht_t *ht" "uintptr_t key" .Sh DESCRIPTION -The +The .Fn ck_ht_hash_direct function will generate a hash value in the object pointed to by the .Fa h diff --git a/doc/ck_ht_init b/doc/ck_ht_init index cbe78df..9f8c057 100644 --- a/doc/ck_ht_init +++ b/doc/ck_ht_init @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_init "ck_ht_t *ht" "enum ck_ht_mode mode" "uint64_t capacity" "uint64_t seed" .Sh DESCRIPTION -The +The .Fn ck_ht_init function initializes the hash table pointed to by the .Fa ht @@ -78,7 +78,7 @@ functions. .El .Pp The argument -.Fa capacity +.Fa capacity represents the initial number of key-value pairs the hash table is expected to contain. This argument is simply a hint and the underlying implementation is free to allocate more diff --git a/doc/ck_ht_iterator_init b/doc/ck_ht_iterator_init index 196e759..97ddf89 100644 --- a/doc/ck_ht_iterator_init +++ b/doc/ck_ht_iterator_init @@ -39,7 +39,7 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_ht_iterator_init "ck_ht_iterator_t *iterator" .Sh DESCRIPTION -The +The .Fn ck_ht_iterator_init function will initialize the object pointed to by the diff --git a/doc/ck_ht_next b/doc/ck_ht_next index 5e9dbc5..97a82e0 100644 --- a/doc/ck_ht_next +++ b/doc/ck_ht_next @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_next "ck_ht_t *ht" "ck_ht_iterator_t *iterator" "ck_ht_entry_t **entry" .Sh DESCRIPTION -The +The .Fn ck_ht_next function will increment the iterator object pointed to by .Fa iterator diff --git a/doc/ck_ht_put_spmc b/doc/ck_ht_put_spmc index 355931e..4a3f554 100644 --- a/doc/ck_ht_put_spmc +++ b/doc/ck_ht_put_spmc @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_put_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_put_spmc function will store the key-value pair specified in the .Fa entry @@ -71,7 +71,7 @@ if was created with CK_HT_MODE_BYTESTRING. If .Fa ht was initialized with CK_HT_MODE_DIRECT then it is -expected that +expected that .Fa h was initialized with the .Xr ck_ht_hash_direct 3 diff --git a/doc/ck_ht_remove_spmc b/doc/ck_ht_remove_spmc index 57f9c8d..789f4f8 100644 --- a/doc/ck_ht_remove_spmc +++ b/doc/ck_ht_remove_spmc @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_remove_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_remove_spmc function will remove the key-value pair associated with the key specified by the diff --git a/doc/ck_ht_reset_spmc b/doc/ck_ht_reset_spmc index 3ce5d73..a10f5ea 100644 --- a/doc/ck_ht_reset_spmc +++ b/doc/ck_ht_reset_spmc @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_reset_spmc "ck_ht_t *ht" .Sh DESCRIPTION -The +The .Fn ck_ht_reset_spmc function will remove all key-value pairs stored in the hash table pointed to by the diff --git a/doc/ck_ht_set_spmc b/doc/ck_ht_set_spmc index 9e5fd7d..cbee99c 100644 --- a/doc/ck_ht_set_spmc +++ b/doc/ck_ht_set_spmc @@ -36,7 +36,7 @@ Concurrency Kit (libck, \-lck) .Ft bool .Fn ck_ht_set_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" .Sh DESCRIPTION -The +The .Fn ck_ht_set_spmc function will store the key-value pair specified in the .Fa entry @@ -71,7 +71,7 @@ if was created with CK_HT_MODE_BYTESTRING. If .Fa ht was initialized with CK_HT_MODE_DIRECT then it is -expected that +expected that .Fa h was initialized with the .Xr ck_ht_hash_direct 3 diff --git a/include/ck_backoff.h b/include/ck_backoff.h index 9373af5..44ff0ad 100644 --- a/include/ck_backoff.h +++ b/include/ck_backoff.h @@ -33,7 +33,7 @@ #define CK_BACKOFF_CEILING ((1 << 21) - 1) #endif -#define CK_BACKOFF_INITIALIZER ((1 << 9) - 1) +#define CK_BACKOFF_INITIALIZER ((1 << 9) - 1) typedef volatile unsigned int ck_backoff_t; @@ -45,7 +45,7 @@ ck_backoff_eb(volatile unsigned int *c) { volatile unsigned int i; unsigned int ceiling; - + ceiling = *c; for (i = 0; i < ceiling; i++); diff --git a/include/ck_bytelock.h b/include/ck_bytelock.h index efb7aea..f472956 100644 --- a/include/ck_bytelock.h +++ b/include/ck_bytelock.h @@ -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 (slot < sizeof bytelock->readers) + if (slot < sizeof bytelock->readers) ck_pr_store_8(&bytelock->readers[slot - 1], false); /* Wait for slotted readers to drain out. */ ck_pr_fence_strict_load(); 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(); } diff --git a/include/ck_fifo.h b/include/ck_fifo.h index 67fdc88..107a71e 100644 --- a/include/ck_fifo.h +++ b/include/ck_fifo.h @@ -128,7 +128,7 @@ ck_fifo_spsc_enqueue(struct ck_fifo_spsc *fifo, return; } -CK_CC_INLINE static bool +CK_CC_INLINE static bool ck_fifo_spsc_dequeue(struct ck_fifo_spsc *fifo, void *value) { 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 * 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) { struct ck_fifo_spsc_entry *p, *garbage; diff --git a/include/ck_hp.h b/include/ck_hp.h index 4990841..9bae95f 100644 --- a/include/ck_hp.h +++ b/include/ck_hp.h @@ -32,7 +32,7 @@ #include #ifndef CK_HP_CACHE -#define CK_HP_CACHE 512 +#define CK_HP_CACHE 512 #endif struct ck_hp_hazard; diff --git a/include/ck_hp_fifo.h b/include/ck_hp_fifo.h index d7b32e1..2aa2956 100644 --- a/include/ck_hp_fifo.h +++ b/include/ck_hp_fifo.h @@ -101,7 +101,7 @@ ck_hp_fifo_enqueue_mpmc(ck_hp_record_t *record, 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, struct ck_hp_fifo *fifo, void *value) diff --git a/include/ck_hp_stack.h b/include/ck_hp_stack.h index 8e65b49..3a0d3be 100644 --- a/include/ck_hp_stack.h +++ b/include/ck_hp_stack.h @@ -35,7 +35,7 @@ #include #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_hp_stack_push_mpmc(struct ck_stack *target, struct ck_stack_entry *entry) diff --git a/include/ck_md.h b/include/ck_md.h index 4e620df..1673d0f 100644 --- a/include/ck_md.h +++ b/include/ck_md.h @@ -33,6 +33,6 @@ #ifndef CK_MD_PAGESIZE #define CK_MD_PAGESIZE (4096) -#endif +#endif #endif /* _CK_MD_H */ diff --git a/include/ck_pr.h b/include/ck_pr.h index 6df4b05..f64213f 100644 --- a/include/ck_pr.h +++ b/include/ck_pr.h @@ -908,7 +908,7 @@ CK_PR_N_Z_S(8, uint8_t) ck_pr_stall(); \ \ return ((C)previous); \ - } + } #define CK_PR_FAS(S, M, C) \ CK_CC_INLINE static C \ diff --git a/include/ck_ring.h b/include/ck_ring.h index f4cce7a..615513b 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -127,7 +127,7 @@ #define CK_RING_DEQUEUE_SPSC(name, object, value) \ ck_ring_dequeue_spsc_##name(object, value) -struct ck_ring { +struct ck_ring { unsigned int c_head; char pad[CK_MD_CACHELINE - sizeof(unsigned int)]; unsigned int p_tail; @@ -158,7 +158,7 @@ ck_ring_capacity(struct ck_ring *ring) 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) { 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). */ -CK_CC_INLINE static bool +CK_CC_INLINE static bool ck_ring_dequeue_spsc(struct ck_ring *ring, void *data) { unsigned int consumer, producer; diff --git a/include/ck_sequence.h b/include/ck_sequence.h index 098f3d2..0f57802 100644 --- a/include/ck_sequence.h +++ b/include/ck_sequence.h @@ -57,7 +57,7 @@ ck_sequence_read_begin(struct ck_sequence *sq) * If a sequence is even then associated data may be in a * consistent state. */ - if ((version & 1) == 0) + if ((version & 1) == 0) break; /* @@ -71,7 +71,7 @@ ck_sequence_read_begin(struct ck_sequence *sq) return version; } -CK_CC_INLINE static bool +CK_CC_INLINE static bool ck_sequence_read_retry(struct ck_sequence *sq, uint32_t version) { diff --git a/include/ck_spinlock.h b/include/ck_spinlock.h index f7f0ad3..080b3bf 100644 --- a/include/ck_spinlock.h +++ b/include/ck_spinlock.h @@ -95,11 +95,11 @@ ck_spinlock_anderson_init(struct ck_spinlock_anderson *lock, * appropriate wrap-around value in the case of next slot counter * overflow. */ - if (count & (count - 1)) + if (count & (count - 1)) lock->wrap = (UINT_MAX % count) + 1; else lock->wrap = 0; - + ck_pr_fence_store(); 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. */ 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. */ ck_pr_store_uint(&lock->slots[position].locked, true); @@ -252,7 +252,7 @@ ck_spinlock_cas_init(struct ck_spinlock_cas *lock) return; } -CK_CC_INLINE static bool +CK_CC_INLINE static bool ck_spinlock_cas_trylock(struct ck_spinlock_cas *lock) { 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_load_uint(&lock->value) == true) + while (ck_pr_load_uint(&lock->value) == true) ck_pr_stall(); } @@ -316,7 +316,7 @@ typedef struct ck_spinlock_dec ck_spinlock_dec_t; #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) { unsigned int value; @@ -350,7 +350,7 @@ ck_spinlock_dec_lock(struct ck_spinlock_dec *lock) break; /* 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(); } @@ -420,7 +420,7 @@ ck_spinlock_ticket_lock(struct ck_spinlock_ticket *ticket) request = ck_pr_faa_uint(&ticket->next, 1); /* 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(); 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 * acquisition and relinquish operations (assuming an empty * critical section). - */ + */ ck_backoff_eb(&backoff); } diff --git a/include/ck_stack.h b/include/ck_stack.h index e24ffe6..87be0e2 100644 --- a/include/ck_stack.h +++ b/include/ck_stack.h @@ -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_backoff_eb(&backoff); } - + return; } #endif /* CK_F_STACK_PUSH_UPMC */ @@ -90,7 +90,7 @@ ck_stack_pop_upmc(struct ck_stack *target) ck_backoff_eb(&backoff); } - + return (entry); } #endif diff --git a/include/gcc/ck_cc.h b/include/gcc/ck_cc.h index f99ff64..15743e7 100644 --- a/include/gcc/ck_cc.h +++ b/include/gcc/ck_cc.h @@ -45,7 +45,7 @@ #ifdef __OPTIMIZE__ #define CK_CC_INLINE CK_CC_UNUSED inline #else -#define CK_CC_INLINE CK_CC_UNUSED +#define CK_CC_INLINE CK_CC_UNUSED #endif /* diff --git a/include/gcc/ppc/ck_f_pr.h b/include/gcc/ppc/ck_f_pr.h index 1196c4b..ad1c503 100644 --- a/include/gcc/ppc/ck_f_pr.h +++ b/include/gcc/ppc/ck_f_pr.h @@ -1,78 +1,78 @@ -/* DO NOT EDIT. This is auto-generated from feature.sh */ -#define CK_F_PR_ADD_32 -#define CK_F_PR_ADD_INT -#define CK_F_PR_ADD_PTR -#define CK_F_PR_ADD_UINT -#define CK_F_PR_AND_32 -#define CK_F_PR_AND_INT -#define CK_F_PR_AND_PTR -#define CK_F_PR_AND_UINT -#define CK_F_PR_CAS_32 -#define CK_F_PR_CAS_32_VALUE -#define CK_F_PR_CAS_INT -#define CK_F_PR_CAS_INT_VALUE -#define CK_F_PR_CAS_PTR -#define CK_F_PR_CAS_PTR_VALUE -#define CK_F_PR_CAS_UINT -#define CK_F_PR_CAS_UINT_VALUE -#define CK_F_PR_DEC_32 -#define CK_F_PR_DEC_INT -#define CK_F_PR_DEC_PTR -#define CK_F_PR_DEC_UINT -#define CK_F_PR_FAA_32 -#define CK_F_PR_FAA_INT -#define CK_F_PR_FAA_PTR -#define CK_F_PR_FAA_UINT -#define CK_F_PR_FAS_32 -#define CK_F_PR_FAS_INT -#define CK_F_PR_FAS_PTR -#define CK_F_PR_FAS_UINT -#define CK_F_PR_FENCE_LOAD -#define CK_F_PR_FENCE_LOAD_DEPENDS -#define CK_F_PR_FENCE_MEMORY -#define CK_F_PR_FENCE_STORE -#define CK_F_PR_FENCE_STRICT_LOAD -#define CK_F_PR_FENCE_STRICT_LOAD_DEPENDS -#define CK_F_PR_FENCE_STRICT_MEMORY -#define CK_F_PR_FENCE_STRICT_STORE -#define CK_F_PR_INC_32 -#define CK_F_PR_INC_INT -#define CK_F_PR_INC_PTR -#define CK_F_PR_INC_UINT -#define CK_F_PR_LOAD_16 -#define CK_F_PR_LOAD_32 -#define CK_F_PR_LOAD_8 -#define CK_F_PR_LOAD_CHAR -#define CK_F_PR_LOAD_INT -#define CK_F_PR_LOAD_PTR -#define CK_F_PR_LOAD_SHORT -#define CK_F_PR_LOAD_UINT -#define CK_F_PR_NEG_32 -#define CK_F_PR_NEG_INT -#define CK_F_PR_NEG_PTR -#define CK_F_PR_NEG_UINT -#define CK_F_PR_NOT_32 -#define CK_F_PR_NOT_INT -#define CK_F_PR_NOT_PTR -#define CK_F_PR_NOT_UINT -#define CK_F_PR_OR_32 -#define CK_F_PR_OR_INT -#define CK_F_PR_OR_PTR -#define CK_F_PR_OR_UINT -#define CK_F_PR_STALL -#define CK_F_PR_STORE_16 -#define CK_F_PR_STORE_32 -#define CK_F_PR_STORE_8 -#define CK_F_PR_STORE_CHAR -#define CK_F_PR_STORE_INT -#define CK_F_PR_STORE_PTR -#define CK_F_PR_STORE_SHORT -#define CK_F_PR_STORE_UINT -#define CK_F_PR_SUB_32 -#define CK_F_PR_SUB_INT -#define CK_F_PR_SUB_PTR -#define CK_F_PR_SUB_UINT -#define CK_F_PR_XOR_32 -#define CK_F_PR_XOR_INT -#define CK_F_PR_XOR_PTR -#define CK_F_PR_XOR_UINT +/* DO NOT EDIT. This is auto-generated from feature.sh */ +#define CK_F_PR_ADD_32 +#define CK_F_PR_ADD_INT +#define CK_F_PR_ADD_PTR +#define CK_F_PR_ADD_UINT +#define CK_F_PR_AND_32 +#define CK_F_PR_AND_INT +#define CK_F_PR_AND_PTR +#define CK_F_PR_AND_UINT +#define CK_F_PR_CAS_32 +#define CK_F_PR_CAS_32_VALUE +#define CK_F_PR_CAS_INT +#define CK_F_PR_CAS_INT_VALUE +#define CK_F_PR_CAS_PTR +#define CK_F_PR_CAS_PTR_VALUE +#define CK_F_PR_CAS_UINT +#define CK_F_PR_CAS_UINT_VALUE +#define CK_F_PR_DEC_32 +#define CK_F_PR_DEC_INT +#define CK_F_PR_DEC_PTR +#define CK_F_PR_DEC_UINT +#define CK_F_PR_FAA_32 +#define CK_F_PR_FAA_INT +#define CK_F_PR_FAA_PTR +#define CK_F_PR_FAA_UINT +#define CK_F_PR_FAS_32 +#define CK_F_PR_FAS_INT +#define CK_F_PR_FAS_PTR +#define CK_F_PR_FAS_UINT +#define CK_F_PR_FENCE_LOAD +#define CK_F_PR_FENCE_LOAD_DEPENDS +#define CK_F_PR_FENCE_MEMORY +#define CK_F_PR_FENCE_STORE +#define CK_F_PR_FENCE_STRICT_LOAD +#define CK_F_PR_FENCE_STRICT_LOAD_DEPENDS +#define CK_F_PR_FENCE_STRICT_MEMORY +#define CK_F_PR_FENCE_STRICT_STORE +#define CK_F_PR_INC_32 +#define CK_F_PR_INC_INT +#define CK_F_PR_INC_PTR +#define CK_F_PR_INC_UINT +#define CK_F_PR_LOAD_16 +#define CK_F_PR_LOAD_32 +#define CK_F_PR_LOAD_8 +#define CK_F_PR_LOAD_CHAR +#define CK_F_PR_LOAD_INT +#define CK_F_PR_LOAD_PTR +#define CK_F_PR_LOAD_SHORT +#define CK_F_PR_LOAD_UINT +#define CK_F_PR_NEG_32 +#define CK_F_PR_NEG_INT +#define CK_F_PR_NEG_PTR +#define CK_F_PR_NEG_UINT +#define CK_F_PR_NOT_32 +#define CK_F_PR_NOT_INT +#define CK_F_PR_NOT_PTR +#define CK_F_PR_NOT_UINT +#define CK_F_PR_OR_32 +#define CK_F_PR_OR_INT +#define CK_F_PR_OR_PTR +#define CK_F_PR_OR_UINT +#define CK_F_PR_STALL +#define CK_F_PR_STORE_16 +#define CK_F_PR_STORE_32 +#define CK_F_PR_STORE_8 +#define CK_F_PR_STORE_CHAR +#define CK_F_PR_STORE_INT +#define CK_F_PR_STORE_PTR +#define CK_F_PR_STORE_SHORT +#define CK_F_PR_STORE_UINT +#define CK_F_PR_SUB_32 +#define CK_F_PR_SUB_INT +#define CK_F_PR_SUB_PTR +#define CK_F_PR_SUB_UINT +#define CK_F_PR_XOR_32 +#define CK_F_PR_XOR_INT +#define CK_F_PR_XOR_PTR +#define CK_F_PR_XOR_UINT diff --git a/include/gcc/ppc/ck_pr.h b/include/gcc/ppc/ck_pr.h index 2c835bf..aaa9164 100644 --- a/include/gcc/ppc/ck_pr.h +++ b/include/gcc/ppc/ck_pr.h @@ -1,324 +1,324 @@ -/* - * Copyright 2009-2011 Samy Al Bahra. - * Copyright 2012 João Fernandes. - * 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. - */ - -#ifndef _CK_PR_PPC_H -#define _CK_PR_PPC_H - -#ifndef _CK_PR_H -#error Do not include this file directly, use ck_pr.h -#endif - -#include - -/* - * The following represent supported atomic operations. - * These operations may be emulated. - */ -#include "ck_f_pr.h" - -/* - * This bounces the hardware thread from low to medium - * priority. I am unsure of the benefits of this approach - * but it is used by the Linux kernel. - */ -CK_CC_INLINE static void -ck_pr_stall(void) -{ - - __asm__ __volatile__("or 1, 1, 1;" - "or 2, 2, 2;" ::: "memory"); - return; -} - -/* - * We must assume RMO. - */ -#define CK_PR_FENCE(T, I) \ - CK_CC_INLINE static void \ - ck_pr_fence_strict_##T(void) \ - { \ - __asm__ __volatile__(I ::: "memory"); \ - } \ - CK_CC_INLINE static void ck_pr_fence_##T(void) \ - { \ - __asm__ __volatile__(I ::: "memory"); \ - } - -CK_PR_FENCE(load_depends, "") -CK_PR_FENCE(store, "eieio") -CK_PR_FENCE(load, "lwsync") -CK_PR_FENCE(memory, "sync") - -#undef CK_PR_FENCE - -#define CK_PR_LOAD(S, M, T, C, I) \ - CK_CC_INLINE static T \ - ck_pr_load_##S(M *target) \ - { \ - T r; \ - __asm__ __volatile__(I "%U1%X1 %0, %1" \ - : "=r" (r) \ - : "m" (*(C *)target) \ - : "memory"); \ - return (r); \ - } - -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) - -CK_PR_LOAD_S(32, uint32_t, "lwz") -CK_PR_LOAD_S(16, uint16_t, "lhz") -CK_PR_LOAD_S(8, uint8_t, "lbz") -CK_PR_LOAD_S(uint, unsigned int, "lwz") -CK_PR_LOAD_S(int, int, "lwz") -CK_PR_LOAD_S(short, short, "lhz") -CK_PR_LOAD_S(char, char, "lbz") - -#undef CK_PR_LOAD_S -#undef CK_PR_LOAD - -#define CK_PR_STORE(S, M, T, C, I) \ - CK_CC_INLINE static void \ - ck_pr_store_##S(M *target, T v) \ - { \ - __asm__ __volatile__(I "%U0%X0 %1, %0" \ - : "=m" (*(C *)target) \ - : "r" (v) \ - : "memory"); \ - return; \ - } - -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) - -CK_PR_STORE_S(32, uint32_t, "stw") -CK_PR_STORE_S(16, uint16_t, "sth") -CK_PR_STORE_S(8, uint8_t, "stb") -CK_PR_STORE_S(uint, unsigned int, "stw") -CK_PR_STORE_S(int, int, "stw") -CK_PR_STORE_S(short, short, "sth") -CK_PR_STORE_S(char, char, "stb") - -#undef CK_PR_STORE_S -#undef CK_PR_STORE - -#define CK_PR_CAS(N, T) \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N##_value(T *target, T compare, T set, T *value) \ - { \ - T previous; \ - __asm__ __volatile__("isync;" \ - "1:" \ - "lwarx %0, 0, %1;" \ - "cmpw 0, %0, %3;" \ - "bne- 2f;" \ - "stwcx. %2, 0, %1;" \ - "bne- 1b;" \ - "2:" \ - "lwsync;" \ - : "=&r" (previous) \ - : "r" (target), \ - "r" (set), \ - "r" (compare) \ - : "memory", "cc"); \ - *value = previous; \ - return (previous == compare); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N(T *target, T compare, T set) \ - { \ - T previous; \ - __asm__ __volatile__("isync;" \ - "1:" \ - "lwarx %0, 0, %1;" \ - "cmpw 0, %0, %3;" \ - "bne- 2f;" \ - "stwcx. %2, 0, %1;" \ - "bne- 1b;" \ - "2:" \ - "lwsync;" \ - : "=&r" (previous) \ - : "r" (target), \ - "r" (set), \ - "r" (compare) \ - : "memory", "cc"); \ - return (previous == compare); \ - } - -CK_PR_CAS(ptr, void *) -CK_PR_CAS(32, uint32_t) -CK_PR_CAS(uint, unsigned int) -CK_PR_CAS(int, int) - -#undef CK_PR_CAS - -#define CK_PR_FAS(N, M, T, W) \ - CK_CC_INLINE static T \ - ck_pr_fas_##N(M *target, T v) \ - { \ - T previous; \ - __asm__ __volatile__("isync;" \ - "1:" \ - "l" W "arx %0, 0, %1;" \ - "st" W "cx. %2, 0, %1;" \ - "bne- 1b;" \ - "lwsync;" \ - : "=&r" (previous) \ - : "r" (target), \ - "r" (v) \ - : "memory", "cc"); \ - return (previous); \ - } - -CK_PR_FAS(32, uint32_t, uint32_t, "w") -CK_PR_FAS(ptr, void, void *, "w") -CK_PR_FAS(int, int, int, "w") -CK_PR_FAS(uint, unsigned int, unsigned int, "w") - -#undef CK_PR_FAS - -#define CK_PR_UNARY(O, N, M, T, I, W) \ - CK_CC_INLINE static void \ - ck_pr_##O##_##N(M *target) \ - { \ - T previous; \ - __asm__ __volatile__("1:" \ - "l" W "arx %0, 0, %1;" \ - I ";" \ - "st" W "cx. %0, 0, %1;" \ - "bne- 1b;" \ - : "=&r" (previous) \ - : "r" (target) \ - : "memory", "cc"); \ - return; \ - } - -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(not, ptr, void, void *, "not %0, %0", "w") -CK_PR_UNARY(neg, ptr, void, void *, "neg %0, %0", "w") - -#define CK_PR_UNARY_S(S, T, 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(not, S, T, T, "not %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(uint, unsigned int, "w") -CK_PR_UNARY_S(int, int, "w") - -#undef CK_PR_UNARY_S -#undef CK_PR_UNARY - -#define CK_PR_BINARY(O, N, M, T, I, W) \ - CK_CC_INLINE static void \ - ck_pr_##O##_##N(M *target, T delta) \ - { \ - T previous; \ - __asm__ __volatile__("1:" \ - "l" W "arx %0, 0, %1;" \ - I " %0, %2, %0;" \ - "st" W "cx. %0, 0, %1;" \ - "bne- 1b;" \ - : "=&r" (previous) \ - : "r" (target), \ - "r" (delta) \ - : "memory", "cc"); \ - return; \ - } - -CK_PR_BINARY(and, ptr, void, uintptr_t, "and", "w") -CK_PR_BINARY(add, ptr, void, uintptr_t, "add", "w") -CK_PR_BINARY(or, ptr, void, uintptr_t, "or", "w") -CK_PR_BINARY(sub, ptr, void, uintptr_t, "sub", "w") -CK_PR_BINARY(xor, ptr, void, uintptr_t, "xor", "w") - -#define CK_PR_BINARY_S(S, T, W) \ - CK_PR_BINARY(and, S, T, T, "and", W) \ - CK_PR_BINARY(add, S, T, T, "add", W) \ - CK_PR_BINARY(or, S, T, T, "or", W) \ - CK_PR_BINARY(sub, S, T, T, "subf", W) \ - CK_PR_BINARY(xor, S, T, T, "xor", W) - -CK_PR_BINARY_S(32, uint32_t, "w") -CK_PR_BINARY_S(uint, unsigned int, "w") -CK_PR_BINARY_S(int, int, "w") - -#undef CK_PR_BINARY_S -#undef CK_PR_BINARY - -CK_CC_INLINE static void * -ck_pr_faa_ptr(void *target, uintptr_t delta) -{ - uintptr_t previous, r; - - __asm__ __volatile__("isync;" - "1:" - "lwarx %0, 0, %2;" - "add %1, %3, %0;" - "stwcx. %1, 0, %2;" - "bne- 1b;" - "lwsync;" - : "=&r" (previous), - "=&r" (r) - : "r" (target), - "r" (delta) - : "memory", "cc"); - - return (void *)(previous); -} - -#define CK_PR_FAA(S, T, W) \ - CK_CC_INLINE static T \ - ck_pr_faa_##S(T *target, T delta) \ - { \ - T previous, r; \ - __asm__ __volatile__("isync;" \ - "1:" \ - "l" W "arx %0, 0, %2;" \ - "add %1, %3, %0;" \ - "st" W "cx. %1, 0, %2;" \ - "bne- 1b;" \ - "lwsync;" \ - : "=&r" (previous), \ - "=&r" (r) \ - : "r" (target), \ - "r" (delta) \ - : "memory", "cc"); \ - return (previous); \ - } - -CK_PR_FAA(32, uint32_t, "w") -CK_PR_FAA(uint, unsigned int, "w") -CK_PR_FAA(int, int, "w") - -#undef CK_PR_FAA - -#endif /* _CK_PR_PPC_H */ +/* + * Copyright 2009-2011 Samy Al Bahra. + * Copyright 2012 João Fernandes. + * 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. + */ + +#ifndef _CK_PR_PPC_H +#define _CK_PR_PPC_H + +#ifndef _CK_PR_H +#error Do not include this file directly, use ck_pr.h +#endif + +#include + +/* + * The following represent supported atomic operations. + * These operations may be emulated. + */ +#include "ck_f_pr.h" + +/* + * This bounces the hardware thread from low to medium + * priority. I am unsure of the benefits of this approach + * but it is used by the Linux kernel. + */ +CK_CC_INLINE static void +ck_pr_stall(void) +{ + + __asm__ __volatile__("or 1, 1, 1;" + "or 2, 2, 2;" ::: "memory"); + return; +} + +/* + * We must assume RMO. + */ +#define CK_PR_FENCE(T, I) \ + CK_CC_INLINE static void \ + ck_pr_fence_strict_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } \ + CK_CC_INLINE static void ck_pr_fence_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } + +CK_PR_FENCE(load_depends, "") +CK_PR_FENCE(store, "eieio") +CK_PR_FENCE(load, "lwsync") +CK_PR_FENCE(memory, "sync") + +#undef CK_PR_FENCE + +#define CK_PR_LOAD(S, M, T, C, I) \ + CK_CC_INLINE static T \ + ck_pr_load_##S(M *target) \ + { \ + T r; \ + __asm__ __volatile__(I "%U1%X1 %0, %1" \ + : "=r" (r) \ + : "m" (*(C *)target) \ + : "memory"); \ + return (r); \ + } + +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) + +CK_PR_LOAD_S(32, uint32_t, "lwz") +CK_PR_LOAD_S(16, uint16_t, "lhz") +CK_PR_LOAD_S(8, uint8_t, "lbz") +CK_PR_LOAD_S(uint, unsigned int, "lwz") +CK_PR_LOAD_S(int, int, "lwz") +CK_PR_LOAD_S(short, short, "lhz") +CK_PR_LOAD_S(char, char, "lbz") + +#undef CK_PR_LOAD_S +#undef CK_PR_LOAD + +#define CK_PR_STORE(S, M, T, C, I) \ + CK_CC_INLINE static void \ + ck_pr_store_##S(M *target, T v) \ + { \ + __asm__ __volatile__(I "%U0%X0 %1, %0" \ + : "=m" (*(C *)target) \ + : "r" (v) \ + : "memory"); \ + return; \ + } + +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) + +CK_PR_STORE_S(32, uint32_t, "stw") +CK_PR_STORE_S(16, uint16_t, "sth") +CK_PR_STORE_S(8, uint8_t, "stb") +CK_PR_STORE_S(uint, unsigned int, "stw") +CK_PR_STORE_S(int, int, "stw") +CK_PR_STORE_S(short, short, "sth") +CK_PR_STORE_S(char, char, "stb") + +#undef CK_PR_STORE_S +#undef CK_PR_STORE + +#define CK_PR_CAS(N, T) \ + CK_CC_INLINE static bool \ + ck_pr_cas_##N##_value(T *target, T compare, T set, T *value) \ + { \ + T previous; \ + __asm__ __volatile__("isync;" \ + "1:" \ + "lwarx %0, 0, %1;" \ + "cmpw 0, %0, %3;" \ + "bne- 2f;" \ + "stwcx. %2, 0, %1;" \ + "bne- 1b;" \ + "2:" \ + "lwsync;" \ + : "=&r" (previous) \ + : "r" (target), \ + "r" (set), \ + "r" (compare) \ + : "memory", "cc"); \ + *value = previous; \ + return (previous == compare); \ + } \ + CK_CC_INLINE static bool \ + ck_pr_cas_##N(T *target, T compare, T set) \ + { \ + T previous; \ + __asm__ __volatile__("isync;" \ + "1:" \ + "lwarx %0, 0, %1;" \ + "cmpw 0, %0, %3;" \ + "bne- 2f;" \ + "stwcx. %2, 0, %1;" \ + "bne- 1b;" \ + "2:" \ + "lwsync;" \ + : "=&r" (previous) \ + : "r" (target), \ + "r" (set), \ + "r" (compare) \ + : "memory", "cc"); \ + return (previous == compare); \ + } + +CK_PR_CAS(ptr, void *) +CK_PR_CAS(32, uint32_t) +CK_PR_CAS(uint, unsigned int) +CK_PR_CAS(int, int) + +#undef CK_PR_CAS + +#define CK_PR_FAS(N, M, T, W) \ + CK_CC_INLINE static T \ + ck_pr_fas_##N(M *target, T v) \ + { \ + T previous; \ + __asm__ __volatile__("isync;" \ + "1:" \ + "l" W "arx %0, 0, %1;" \ + "st" W "cx. %2, 0, %1;" \ + "bne- 1b;" \ + "lwsync;" \ + : "=&r" (previous) \ + : "r" (target), \ + "r" (v) \ + : "memory", "cc"); \ + return (previous); \ + } + +CK_PR_FAS(32, uint32_t, uint32_t, "w") +CK_PR_FAS(ptr, void, void *, "w") +CK_PR_FAS(int, int, int, "w") +CK_PR_FAS(uint, unsigned int, unsigned int, "w") + +#undef CK_PR_FAS + +#define CK_PR_UNARY(O, N, M, T, I, W) \ + CK_CC_INLINE static void \ + ck_pr_##O##_##N(M *target) \ + { \ + T previous; \ + __asm__ __volatile__("1:" \ + "l" W "arx %0, 0, %1;" \ + I ";" \ + "st" W "cx. %0, 0, %1;" \ + "bne- 1b;" \ + : "=&r" (previous) \ + : "r" (target) \ + : "memory", "cc"); \ + return; \ + } + +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(not, ptr, void, void *, "not %0, %0", "w") +CK_PR_UNARY(neg, ptr, void, void *, "neg %0, %0", "w") + +#define CK_PR_UNARY_S(S, T, 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(not, S, T, T, "not %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(uint, unsigned int, "w") +CK_PR_UNARY_S(int, int, "w") + +#undef CK_PR_UNARY_S +#undef CK_PR_UNARY + +#define CK_PR_BINARY(O, N, M, T, I, W) \ + CK_CC_INLINE static void \ + ck_pr_##O##_##N(M *target, T delta) \ + { \ + T previous; \ + __asm__ __volatile__("1:" \ + "l" W "arx %0, 0, %1;" \ + I " %0, %2, %0;" \ + "st" W "cx. %0, 0, %1;" \ + "bne- 1b;" \ + : "=&r" (previous) \ + : "r" (target), \ + "r" (delta) \ + : "memory", "cc"); \ + return; \ + } + +CK_PR_BINARY(and, ptr, void, uintptr_t, "and", "w") +CK_PR_BINARY(add, ptr, void, uintptr_t, "add", "w") +CK_PR_BINARY(or, ptr, void, uintptr_t, "or", "w") +CK_PR_BINARY(sub, ptr, void, uintptr_t, "sub", "w") +CK_PR_BINARY(xor, ptr, void, uintptr_t, "xor", "w") + +#define CK_PR_BINARY_S(S, T, W) \ + CK_PR_BINARY(and, S, T, T, "and", W) \ + CK_PR_BINARY(add, S, T, T, "add", W) \ + CK_PR_BINARY(or, S, T, T, "or", W) \ + CK_PR_BINARY(sub, S, T, T, "subf", W) \ + CK_PR_BINARY(xor, S, T, T, "xor", W) + +CK_PR_BINARY_S(32, uint32_t, "w") +CK_PR_BINARY_S(uint, unsigned int, "w") +CK_PR_BINARY_S(int, int, "w") + +#undef CK_PR_BINARY_S +#undef CK_PR_BINARY + +CK_CC_INLINE static void * +ck_pr_faa_ptr(void *target, uintptr_t delta) +{ + uintptr_t previous, r; + + __asm__ __volatile__("isync;" + "1:" + "lwarx %0, 0, %2;" + "add %1, %3, %0;" + "stwcx. %1, 0, %2;" + "bne- 1b;" + "lwsync;" + : "=&r" (previous), + "=&r" (r) + : "r" (target), + "r" (delta) + : "memory", "cc"); + + return (void *)(previous); +} + +#define CK_PR_FAA(S, T, W) \ + CK_CC_INLINE static T \ + ck_pr_faa_##S(T *target, T delta) \ + { \ + T previous, r; \ + __asm__ __volatile__("isync;" \ + "1:" \ + "l" W "arx %0, 0, %2;" \ + "add %1, %3, %0;" \ + "st" W "cx. %1, 0, %2;" \ + "bne- 1b;" \ + "lwsync;" \ + : "=&r" (previous), \ + "=&r" (r) \ + : "r" (target), \ + "r" (delta) \ + : "memory", "cc"); \ + return (previous); \ + } + +CK_PR_FAA(32, uint32_t, "w") +CK_PR_FAA(uint, unsigned int, "w") +CK_PR_FAA(int, int, "w") + +#undef CK_PR_FAA + +#endif /* _CK_PR_PPC_H */ diff --git a/include/gcc/ppc64/ck_pr.h b/include/gcc/ppc64/ck_pr.h index c099332..e0af716 100644 --- a/include/gcc/ppc64/ck_pr.h +++ b/include/gcc/ppc64/ck_pr.h @@ -151,7 +151,7 @@ ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *v "r" (compare) : "memory", "cc"); - *value = previous; + *value = previous; return (previous == compare); } @@ -389,7 +389,7 @@ ck_pr_faa_ptr(void *target, uintptr_t delta) : "=&r" (previous), "=&r" (r) : "r" (target), - "r" (delta) + "r" (delta) : "memory", "cc"); return (void *)(previous); diff --git a/include/gcc/sparcv9/ck_pr.h b/include/gcc/sparcv9/ck_pr.h index f5e66e6..83c5af4 100644 --- a/include/gcc/sparcv9/ck_pr.h +++ b/include/gcc/sparcv9/ck_pr.h @@ -134,14 +134,14 @@ ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *v *value = set; return (compare == set); -} +} CK_CC_INLINE static bool ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set) { __asm__ __volatile__("casx [%1], %2, %0" - : "+&r" (set) + : "+&r" (set) : "r" (target), "r" (compare) : "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); -} +} #define CK_PR_CAS(N, T) \ CK_CC_INLINE static bool \ diff --git a/include/gcc/x86/ck_pr.h b/include/gcc/x86/ck_pr.h index 3d91f9f..054d745 100644 --- a/include/gcc/x86/ck_pr.h +++ b/include/gcc/x86/ck_pr.h @@ -40,7 +40,7 @@ /* * The following represent supported atomic operations. * These operations may be emulated. - */ + */ #include "ck_f_pr.h" /* Minimum requirements for the CK_PR interface are met. */ diff --git a/include/gcc/x86_64/ck_pr.h b/include/gcc/x86_64/ck_pr.h index 231a487..bb7b079 100644 --- a/include/gcc/x86_64/ck_pr.h +++ b/include/gcc/x86_64/ck_pr.h @@ -39,7 +39,7 @@ /* * The following represent supported atomic operations. * These operations may be emulated. - */ + */ #include "ck_f_pr.h" /* 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 -CK_CC_INLINE static void +CK_CC_INLINE static void ck_pr_load_64_2(uint64_t target[2], uint64_t v[2]) { __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_64_2(t, v); - return; + return; } #define CK_PR_LOAD_2(S, W, T) \ diff --git a/regressions/Makefile b/regressions/Makefile index 5d1e4de..13f09a5 100644 --- a/regressions/Makefile +++ b/regressions/Makefile @@ -11,7 +11,7 @@ all: $(MAKE) -C ./ck_spinlock/benchmark all $(MAKE) -C ./ck_fifo/validate 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_barrier/validate all $(MAKE) -C ./ck_barrier/benchmark all diff --git a/regressions/ck_barrier/benchmark/throughput.c b/regressions/ck_barrier/benchmark/throughput.c index 4710250..cb771a2 100644 --- a/regressions/ck_barrier/benchmark/throughput.c +++ b/regressions/ck_barrier/benchmark/throughput.c @@ -53,7 +53,7 @@ thread(void *null CK_CC_UNUSED) ck_barrier_centralized_state_t state = CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; int id; - id = ck_pr_faa_int(&tid, 1); + id = ck_pr_faa_int(&tid, 1); aff_iterate(&a); while (ck_pr_load_int(&done) == 0) { @@ -91,39 +91,39 @@ main(int argc, char *argv[]) } nthr = atoi(argv[1]); - if (nthr <= 0) { - fprintf(stderr, "ERROR: Number of threads must be greater than 0\n"); - exit(EXIT_FAILURE); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - fprintf(stderr, "ERROR: Could not allocate thread structures\n"); - exit(EXIT_FAILURE); - } + if (nthr <= 0) { + fprintf(stderr, "ERROR: Number of threads must be greater than 0\n"); + exit(EXIT_FAILURE); + } + + threads = malloc(sizeof(pthread_t) * nthr); + if (threads == NULL) { + fprintf(stderr, "ERROR: Could not allocate thread structures\n"); + exit(EXIT_FAILURE); + } counters = calloc(sizeof(struct counter), nthr); if (counters == NULL) { fprintf(stderr, "ERROR: Could not allocate counters\n"); exit(EXIT_FAILURE); } - - a.delta = atoi(argv[2]); - - fprintf(stderr, "Creating threads (barrier)..."); - for (i = 0; i < nthr; ++i) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - fprintf(stderr, "ERROR: Could not create thread %d\n", i); - exit(EXIT_FAILURE); - } - } - fprintf(stderr, "done\n"); + + a.delta = atoi(argv[2]); + + fprintf(stderr, "Creating threads (barrier)..."); + for (i = 0; i < nthr; ++i) { + if (pthread_create(&threads[i], NULL, thread, NULL)) { + fprintf(stderr, "ERROR: Could not create thread %d\n", i); + exit(EXIT_FAILURE); + } + } + fprintf(stderr, "done\n"); sleep(10); count = 0; 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); printf("%d %16" PRIu64 "\n", nthr, count); diff --git a/regressions/ck_barrier/validate/barrier_combining.c b/regressions/ck_barrier/validate/barrier_combining.c index 28572aa..b990900 100644 --- a/regressions/ck_barrier/validate/barrier_combining.c +++ b/regressions/ck_barrier/validate/barrier_combining.c @@ -95,7 +95,7 @@ main(int argc, char *argv[]) if (init_root == NULL) { fprintf(stderr, "ERROR: Could not allocate initial barrier structure\n"); exit(EXIT_FAILURE); - } + } ck_barrier_combining_init(&barrier, init_root); if (argc != 4) { diff --git a/regressions/ck_brlock/benchmark/latency.c b/regressions/ck_brlock/benchmark/latency.c index fe803d0..bdeacaf 100644 --- a/regressions/ck_brlock/benchmark/latency.c +++ b/regressions/ck_brlock/benchmark/latency.c @@ -31,7 +31,7 @@ #include "../../common.h" -#ifndef STEPS +#ifndef STEPS #define STEPS 1000000 #endif diff --git a/regressions/ck_brlock/benchmark/throughput.c b/regressions/ck_brlock/benchmark/throughput.c index 6390a06..726aed7 100644 --- a/regressions/ck_brlock/benchmark/throughput.c +++ b/regressions/ck_brlock/benchmark/throughput.c @@ -34,7 +34,7 @@ #include "../../common.h" -#ifndef STEPS +#ifndef STEPS #define STEPS 1000000 #endif diff --git a/regressions/ck_brlock/validate/Makefile b/regressions/ck_brlock/validate/Makefile index 50c7657..491f4b8 100644 --- a/regressions/ck_brlock/validate/Makefile +++ b/regressions/ck_brlock/validate/Makefile @@ -1,6 +1,6 @@ .PHONY: clean distribution -OBJECTS=validate +OBJECTS=validate all: $(OBJECTS) diff --git a/regressions/ck_bytelock/benchmark/latency.c b/regressions/ck_bytelock/benchmark/latency.c index cc1e678..31959b7 100644 --- a/regressions/ck_bytelock/benchmark/latency.c +++ b/regressions/ck_bytelock/benchmark/latency.c @@ -31,7 +31,7 @@ #include "../../common.h" -#ifndef STEPS +#ifndef STEPS #define STEPS 1000000 #endif diff --git a/regressions/ck_bytelock/validate/Makefile b/regressions/ck_bytelock/validate/Makefile index c125160..d0ab180 100644 --- a/regressions/ck_bytelock/validate/Makefile +++ b/regressions/ck_bytelock/validate/Makefile @@ -1,6 +1,6 @@ .PHONY: clean distribution -OBJECTS=validate +OBJECTS=validate all: $(OBJECTS) diff --git a/regressions/ck_epoch/validate/ck_stack.c b/regressions/ck_epoch/validate/ck_stack.c index 96c6b97..f9ced5c 100644 --- a/regressions/ck_epoch/validate/ck_stack.c +++ b/regressions/ck_epoch/validate/ck_stack.c @@ -50,7 +50,7 @@ static unsigned int barrier; static unsigned int e_barrier; #ifndef PAIRS -#define PAIRS 5000000 +#define PAIRS 5000000 #endif struct node { @@ -160,10 +160,10 @@ main(int argc, char *argv[]) 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); - for (i = 0; i < n_threads; i++) + for (i = 0; i < n_threads; i++) pthread_join(threads[i], NULL); return (0); diff --git a/regressions/ck_epoch/validate/ck_stack_read.c b/regressions/ck_epoch/validate/ck_stack_read.c index f847f60..20a1055 100644 --- a/regressions/ck_epoch/validate/ck_stack_read.c +++ b/regressions/ck_epoch/validate/ck_stack_read.c @@ -51,7 +51,7 @@ static unsigned int e_barrier; static unsigned int readers; #ifndef PAIRS -#define PAIRS 5000000 +#define PAIRS 5000000 #endif #ifndef ITERATE @@ -217,12 +217,12 @@ main(int argc, char *argv[]) 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, thread, NULL); - for (i = 0; i < n_threads; i++) + for (i = 0; i < n_threads; i++) pthread_join(threads[i], NULL); return (0); diff --git a/regressions/ck_fifo/benchmark/Makefile b/regressions/ck_fifo/benchmark/Makefile index ddcdcd5..50e5a09 100644 --- a/regressions/ck_fifo/benchmark/Makefile +++ b/regressions/ck_fifo/benchmark/Makefile @@ -2,7 +2,7 @@ OBJECTS=latency -all: $(OBJECTS) +all: $(OBJECTS) latency: latency.c $(CC) $(CFLAGS) -o latency latency.c diff --git a/regressions/ck_fifo/benchmark/latency.c b/regressions/ck_fifo/benchmark/latency.c index 817b607..605d482 100644 --- a/regressions/ck_fifo/benchmark/latency.c +++ b/regressions/ck_fifo/benchmark/latency.c @@ -33,7 +33,7 @@ #include "../../common.h" #ifndef ENTRIES -#define ENTRIES 4096 +#define ENTRIES 4096 #endif #ifndef STEPS diff --git a/regressions/ck_fifo/validate/ck_fifo_mpmc.c b/regressions/ck_fifo/validate/ck_fifo_mpmc.c index f6ad660..ff08a2d 100644 --- a/regressions/ck_fifo/validate/ck_fifo_mpmc.c +++ b/regressions/ck_fifo/validate/ck_fifo_mpmc.c @@ -34,7 +34,7 @@ #ifdef CK_F_FIFO_MPMC #ifndef ITERATIONS -#define ITERATIONS 128 +#define ITERATIONS 128 #endif struct context { diff --git a/regressions/ck_fifo/validate/ck_fifo_mpmc_iterator.c b/regressions/ck_fifo/validate/ck_fifo_mpmc_iterator.c index 5f8f7c4..5ac8175 100644 --- a/regressions/ck_fifo/validate/ck_fifo_mpmc_iterator.c +++ b/regressions/ck_fifo/validate/ck_fifo_mpmc_iterator.c @@ -46,7 +46,7 @@ main(void) stub = malloc(sizeof(ck_fifo_mpmc_entry_t)); if (stub == NULL) exit(EXIT_FAILURE); - + ck_fifo_mpmc_init(&mpmc_fifo, stub); entries = malloc(sizeof(ck_fifo_mpmc_entry_t) * length); diff --git a/regressions/ck_fifo/validate/ck_fifo_spsc.c b/regressions/ck_fifo/validate/ck_fifo_spsc.c index 6cef10c..017f493 100644 --- a/regressions/ck_fifo/validate/ck_fifo_spsc.c +++ b/regressions/ck_fifo/validate/ck_fifo_spsc.c @@ -34,7 +34,7 @@ #include "../../common.h" #ifndef ITERATIONS -#define ITERATIONS 128 +#define ITERATIONS 128 #endif struct context { diff --git a/regressions/ck_fifo/validate/ck_fifo_spsc_iterator.c b/regressions/ck_fifo/validate/ck_fifo_spsc_iterator.c index a6afeac..97804de 100644 --- a/regressions/ck_fifo/validate/ck_fifo_spsc_iterator.c +++ b/regressions/ck_fifo/validate/ck_fifo_spsc_iterator.c @@ -1,5 +1,5 @@ /* - * Copyright 2011 David Joseph. + * Copyright 2011 David Joseph. * All rights reserved. * * 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)); if (stub == NULL) exit(EXIT_FAILURE); - + ck_fifo_spsc_init(&spsc_fifo, stub); entries = malloc(sizeof(ck_fifo_spsc_entry_t) * length); diff --git a/regressions/ck_hp/benchmark/Makefile b/regressions/ck_hp/benchmark/Makefile index 1e4236d..8ab5273 100644 --- a/regressions/ck_hp/benchmark/Makefile +++ b/regressions/ck_hp/benchmark/Makefile @@ -2,7 +2,7 @@ OBJECTS=fifo_latency stack_latency -all: $(OBJECTS) +all: $(OBJECTS) fifo_latency: fifo_latency.c $(CC) $(CFLAGS) -o fifo_latency ../../../src/ck_hp.c fifo_latency.c diff --git a/regressions/ck_hp/benchmark/fifo_latency.c b/regressions/ck_hp/benchmark/fifo_latency.c index dea6b79..fec18c6 100644 --- a/regressions/ck_hp/benchmark/fifo_latency.c +++ b/regressions/ck_hp/benchmark/fifo_latency.c @@ -34,7 +34,7 @@ #include "../../common.h" #ifndef ENTRIES -#define ENTRIES 4096 +#define ENTRIES 4096 #endif #ifndef STEPS diff --git a/regressions/ck_hp/benchmark/stack_latency.c b/regressions/ck_hp/benchmark/stack_latency.c index 450759b..8b65064 100644 --- a/regressions/ck_hp/benchmark/stack_latency.c +++ b/regressions/ck_hp/benchmark/stack_latency.c @@ -35,7 +35,7 @@ #include "../../common.h" #ifndef ENTRIES -#define ENTRIES 4096 +#define ENTRIES 4096 #endif #ifndef STEPS diff --git a/regressions/ck_hp/validate/Makefile b/regressions/ck_hp/validate/Makefile index 80e872f..a668bd3 100644 --- a/regressions/ck_hp/validate/Makefile +++ b/regressions/ck_hp/validate/Makefile @@ -5,19 +5,19 @@ OBJECTS=ck_hp_stack nbds_haz_test serial ck_hp_fifo all: $(OBJECTS) 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 - $(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 - $(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 - $(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: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/validate/ck_hp_fifo.c b/regressions/ck_hp/validate/ck_hp_fifo.c index 90c1c12..f324993 100644 --- a/regressions/ck_hp/validate/ck_hp_fifo.c +++ b/regressions/ck_hp/validate/ck_hp_fifo.c @@ -33,7 +33,7 @@ #include "../../common.h" #ifndef ITERATIONS -#define ITERATIONS 128 +#define ITERATIONS 128 #endif struct context { diff --git a/regressions/ck_hp/validate/ck_hp_stack.c b/regressions/ck_hp/validate/ck_hp_stack.c index 1b95384..4cc74df 100644 --- a/regressions/ck_hp/validate/ck_hp_stack.c +++ b/regressions/ck_hp/validate/ck_hp_stack.c @@ -51,7 +51,7 @@ static unsigned int barrier; static unsigned int e_barrier; #ifndef PAIRS -#define PAIRS 5000000 +#define PAIRS 5000000 #endif struct node { @@ -157,10 +157,10 @@ main(int argc, char *argv[]) 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); - for (i = 0; i < n_threads; i++) + for (i = 0; i < n_threads; i++) pthread_join(threads[i], NULL); return (0); diff --git a/regressions/ck_hp/validate/nbds_haz_test.c b/regressions/ck_hp/validate/nbds_haz_test.c index c903ee3..2f8d3d4 100644 --- a/regressions/ck_hp/validate/nbds_haz_test.c +++ b/regressions/ck_hp/validate/nbds_haz_test.c @@ -73,7 +73,7 @@ static unsigned int pops; static unsigned int pushs; #ifndef PAIRS -#define PAIRS 1000000 +#define PAIRS 1000000 #endif struct node { @@ -103,7 +103,7 @@ stack_push_mpmc(struct stack *target, struct stack_entry *entry) ck_pr_store_ptr(&entry->next, lstack); ck_backoff_eb(&backoff); } - + return; } @@ -134,7 +134,7 @@ stack_pop_mpmc(ck_hp_record_t *record, struct stack *target) ck_backoff_eb(&backoff); } - + return (entry); } @@ -159,7 +159,7 @@ thread(void *unused CK_CC_UNUSED) } ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads) + while (ck_pr_load_uint(&barrier) < n_threads) ck_pr_stall(); for (i = 0; i < PAIRS; i++) { @@ -214,10 +214,10 @@ main(int argc, char *argv[]) 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); - for (i = 0; i < n_threads; i++) + for (i = 0; i < n_threads; i++) pthread_join(threads[i], NULL); fprintf(stderr, "Push: %u\nPop: %u\n", pushs, pops); diff --git a/regressions/ck_hp/validate/serial.c b/regressions/ck_hp/validate/serial.c index 7df43ce..ab4614e 100644 --- a/regressions/ck_hp/validate/serial.c +++ b/regressions/ck_hp/validate/serial.c @@ -122,6 +122,6 @@ main(int argc, char *argv[]) ck_hp_set(&record[1], 0, NULL); ck_hp_reclaim(&record[0]); ck_hp_reclaim(&record[1]); - + return 0; } diff --git a/regressions/ck_ht/benchmark/parallel_bytestring.c b/regressions/ck_ht/benchmark/parallel_bytestring.c index b1657fd..b0cd551 100644 --- a/regressions/ck_ht/benchmark/parallel_bytestring.c +++ b/regressions/ck_ht/benchmark/parallel_bytestring.c @@ -280,7 +280,7 @@ main(int argc, char *argv[]) if (argc >= 3) r = atoi(argv[2]); - if (argc >= 4) + if (argc >= 4) s = (uint64_t)atoi(argv[3]); if (argc >= 5) { @@ -410,7 +410,7 @@ main(int argc, char *argv[]) for (i = 0; i < keys_length; i++) table_insert(keys[i]); ck_epoch_write_end(&epoch_wr); - } + } fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); fprintf(stderr, " | Executing negative look-up test..."); @@ -450,7 +450,7 @@ main(int argc, char *argv[]) accumulator[HT_STATE_GET] / n_threads); fprintf(stderr, " | Executing strict replacement test..."); - + a = repeated = 0; signal(SIGALRM, alarm_handler); alarm(r); diff --git a/regressions/ck_ht/benchmark/parallel_direct.c b/regressions/ck_ht/benchmark/parallel_direct.c index f4f0a76..3801bb7 100644 --- a/regressions/ck_ht/benchmark/parallel_direct.c +++ b/regressions/ck_ht/benchmark/parallel_direct.c @@ -273,7 +273,7 @@ main(int argc, char *argv[]) if (argc >= 3) r = atoi(argv[2]); - if (argc >= 4) + if (argc >= 4) s = (uint64_t)atoi(argv[3]); if (argc >= 5) { @@ -391,7 +391,7 @@ main(int argc, char *argv[]) for (i = 0; i < keys_length; i++) table_insert(keys[i]); ck_epoch_write_end(&epoch_wr); - } + } fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); fprintf(stderr, " | Executing negative look-up test..."); @@ -431,7 +431,7 @@ main(int argc, char *argv[]) accumulator[HT_STATE_GET] / n_threads); fprintf(stderr, " | Executing strict replacement test..."); - + a = repeated = 0; signal(SIGALRM, alarm_handler); alarm(r); diff --git a/regressions/ck_ht/benchmark/serial.c b/regressions/ck_ht/benchmark/serial.c index e6de2da..2085662 100644 --- a/regressions/ck_ht/benchmark/serial.c +++ b/regressions/ck_ht/benchmark/serial.c @@ -168,7 +168,7 @@ main(int argc, char *argv[]) if (argc >= 3) r = atoi(argv[2]); - if (argc >= 4) + if (argc >= 4) s = (uint64_t)atoi(argv[3]); keys = malloc(sizeof(char *) * keys_capacity); diff --git a/regressions/ck_pr/benchmark/Makefile b/regressions/ck_pr/benchmark/Makefile index c34afed..669b2a2 100644 --- a/regressions/ck_pr/benchmark/Makefile +++ b/regressions/ck_pr/benchmark/Makefile @@ -3,13 +3,13 @@ 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 - $(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 - $(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 - $(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: rm -rf ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 *.dSYM diff --git a/regressions/ck_pr/benchmark/benchmark.h b/regressions/ck_pr/benchmark/benchmark.h index 110ad44..26559cf 100644 --- a/regressions/ck_pr/benchmark/benchmark.h +++ b/regressions/ck_pr/benchmark/benchmark.h @@ -32,7 +32,7 @@ static void * fairness(void *null) { struct block *context = null; - unsigned int i = context->tid; + unsigned int i = context->tid; if (aff_iterate(&a)) { perror("ERROR: Could not affine thread"); diff --git a/regressions/ck_pr/validate/ck_pr_bin.c b/regressions/ck_pr/validate/ck_pr_bin.c index d94f851..ef3f7d2 100644 --- a/regressions/ck_pr/validate/ck_pr_bin.c +++ b/regressions/ck_pr/validate/ck_pr_bin.c @@ -67,7 +67,7 @@ run_test_##K##_uint(); \ \ return; \ - } + } GENERATE_TEST(add, +) GENERATE_TEST(sub, -) @@ -89,4 +89,4 @@ main(void) return (0); } - + diff --git a/regressions/ck_pr/validate/ck_pr_btx.c b/regressions/ck_pr/validate/ck_pr_btx.c index 2b13840..e0fb732 100644 --- a/regressions/ck_pr/validate/ck_pr_btx.c +++ b/regressions/ck_pr/validate/ck_pr_btx.c @@ -74,7 +74,7 @@ x, y); \ \ return; \ - } + } #define TEST_BTX_S(K, S, T, P, D, R) TEST_BTX(K, S, T, T, T, P, D, R) diff --git a/regressions/ck_pr/validate/ck_pr_fax.c b/regressions/ck_pr/validate/ck_pr_fax.c index 46d4d37..4a1aca5 100644 --- a/regressions/ck_pr/validate/ck_pr_fax.c +++ b/regressions/ck_pr/validate/ck_pr_fax.c @@ -47,7 +47,7 @@ *target = update; \ \ return (previous); \ - } + } #define TEST_FAX_FN_S(S, T) TEST_FAX_FN(S, T, T) diff --git a/regressions/ck_pr/validate/ck_pr_n.c b/regressions/ck_pr/validate/ck_pr_n.c index 4e6aa58..17ea1c6 100644 --- a/regressions/ck_pr/validate/ck_pr_n.c +++ b/regressions/ck_pr/validate/ck_pr_n.c @@ -69,7 +69,7 @@ run_test_##K##_uint(); \ \ return; \ - } + } GENERATE_TEST(not, ~) GENERATE_TEST(neg, -) diff --git a/regressions/ck_pr/validate/ck_pr_unary.c b/regressions/ck_pr/validate/ck_pr_unary.c index 4cc337b..b2300cd 100644 --- a/regressions/ck_pr/validate/ck_pr_unary.c +++ b/regressions/ck_pr/validate/ck_pr_unary.c @@ -86,8 +86,8 @@ x, y); \ \ return; \ - } - + } + #define GENERATE_TEST(K, P, Y, Z) \ TEST_UNARY(K, int, int, int, P, d, Y) \ TEST_UNARY(K, uint, unsigned int, unsigned int, P, u, Z) \ diff --git a/regressions/ck_queue/validate/ck_list.c b/regressions/ck_queue/validate/ck_list.c index b8beb9d..3ee762c 100644 --- a/regressions/ck_queue/validate/ck_list.c +++ b/regressions/ck_queue/validate/ck_list.c @@ -151,7 +151,7 @@ main(int argc, char *argv[]) n = malloc(sizeof *n); assert(n != NULL); n->value = i; - CK_LIST_INSERT_HEAD(&head, n, list_entry); + CK_LIST_INSERT_HEAD(&head, n, list_entry); } test_foreach(); @@ -187,7 +187,7 @@ main(int argc, char *argv[]) n = malloc(sizeof *n); assert(n != NULL); 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++); } diff --git a/regressions/ck_queue/validate/ck_slist.c b/regressions/ck_queue/validate/ck_slist.c index 7b98a49..6d167ca 100644 --- a/regressions/ck_queue/validate/ck_slist.c +++ b/regressions/ck_queue/validate/ck_slist.c @@ -151,7 +151,7 @@ main(int argc, char *argv[]) n = malloc(sizeof *n); assert(n != NULL); n->value = i; - CK_SLIST_INSERT_HEAD(&head, n, list_entry); + CK_SLIST_INSERT_HEAD(&head, n, list_entry); } test_foreach(); @@ -187,7 +187,7 @@ main(int argc, char *argv[]) n = malloc(sizeof *n); assert(n != NULL); 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++); } diff --git a/regressions/ck_ring/benchmark/Makefile b/regressions/ck_ring/benchmark/Makefile index 7fb5333..7457654 100644 --- a/regressions/ck_ring/benchmark/Makefile +++ b/regressions/ck_ring/benchmark/Makefile @@ -5,7 +5,7 @@ OBJECTS=latency all: $(OBJECTS) latency: latency.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -o latency latency.c + $(CC) $(CFLAGS) -o latency latency.c clean: rm -rf *~ *.o $(OBJECTS) *.dSYM diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile index 64c0046..ee694da 100644 --- a/regressions/ck_ring/validate/Makefile +++ b/regressions/ck_ring/validate/Makefile @@ -14,4 +14,4 @@ clean: rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE +CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_ring/validate/ck_ring_spsc.c b/regressions/ck_ring/validate/ck_ring_spsc.c index deb3aee..884ad01 100644 --- a/regressions/ck_ring/validate/ck_ring_spsc.c +++ b/regressions/ck_ring/validate/ck_ring_spsc.c @@ -33,7 +33,7 @@ #include "../../common.h" #ifndef ITERATIONS -#define ITERATIONS 128 +#define ITERATIONS 128 #endif struct context { diff --git a/regressions/ck_ring/validate/ck_ring_spsc_template.c b/regressions/ck_ring/validate/ck_ring_spsc_template.c index 0505b94..659e756 100644 --- a/regressions/ck_ring/validate/ck_ring_spsc_template.c +++ b/regressions/ck_ring/validate/ck_ring_spsc_template.c @@ -33,7 +33,7 @@ #include "../../common.h" #ifndef ITERATIONS -#define ITERATIONS 128 +#define ITERATIONS 128 #endif struct context { diff --git a/regressions/ck_rwlock/benchmark/latency.c b/regressions/ck_rwlock/benchmark/latency.c index 9a98d61..88896db 100644 --- a/regressions/ck_rwlock/benchmark/latency.c +++ b/regressions/ck_rwlock/benchmark/latency.c @@ -30,7 +30,7 @@ #include "../../common.h" -#ifndef STEPS +#ifndef STEPS #define STEPS 1000000 #endif diff --git a/regressions/ck_rwlock/benchmark/throughput.c b/regressions/ck_rwlock/benchmark/throughput.c index d278323..b9f3e26 100644 --- a/regressions/ck_rwlock/benchmark/throughput.c +++ b/regressions/ck_rwlock/benchmark/throughput.c @@ -34,7 +34,7 @@ #include "../../common.h" -#ifndef STEPS +#ifndef STEPS #define STEPS 1000000 #endif diff --git a/regressions/ck_spinlock/benchmark/latency.h b/regressions/ck_spinlock/benchmark/latency.h index df10b52..1be9b54 100644 --- a/regressions/ck_spinlock/benchmark/latency.h +++ b/regressions/ck_spinlock/benchmark/latency.h @@ -1,6 +1,6 @@ /* * Copyright 2011-2012 Samy Al Bahra. - * Copyright 2011 David Joseph. + * Copyright 2011 David Joseph. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,17 +25,17 @@ * SUCH DAMAGE. */ -#include -#include -#include +#include +#include +#include #include #include #include "../../common.h" - -#ifndef STEPS -#define STEPS 30000000 -#endif + +#ifndef STEPS +#define STEPS 30000000 +#endif LOCK_DEFINE; diff --git a/regressions/ck_spinlock/benchmark/throughput.h b/regressions/ck_spinlock/benchmark/throughput.h index 772ea6b..d0f72c0 100644 --- a/regressions/ck_spinlock/benchmark/throughput.h +++ b/regressions/ck_spinlock/benchmark/throughput.h @@ -98,7 +98,7 @@ fairness(void *null) LOCK_STATE; #endif struct block *context = null; - unsigned int i = context->tid; + unsigned int i = context->tid; volatile int j; long int base; diff --git a/regressions/ck_stack/benchmark/Makefile b/regressions/ck_stack/benchmark/Makefile index ddcdcd5..50e5a09 100644 --- a/regressions/ck_stack/benchmark/Makefile +++ b/regressions/ck_stack/benchmark/Makefile @@ -2,7 +2,7 @@ OBJECTS=latency -all: $(OBJECTS) +all: $(OBJECTS) latency: latency.c $(CC) $(CFLAGS) -o latency latency.c diff --git a/regressions/ck_stack/benchmark/latency.c b/regressions/ck_stack/benchmark/latency.c index 64774c6..a871ae3 100644 --- a/regressions/ck_stack/benchmark/latency.c +++ b/regressions/ck_stack/benchmark/latency.c @@ -33,7 +33,7 @@ #include "../../common.h" #ifndef ENTRIES -#define ENTRIES 4096 +#define ENTRIES 4096 #endif #ifndef STEPS diff --git a/regressions/ck_stack/validate/pair.c b/regressions/ck_stack/validate/pair.c index 67be5b4..fc25863 100644 --- a/regressions/ck_stack/validate/pair.c +++ b/regressions/ck_stack/validate/pair.c @@ -140,7 +140,7 @@ stack_thread(void *buffer) return (NULL); } -static void +static void stack_assert(void) { diff --git a/regressions/ck_stack/validate/pop.c b/regressions/ck_stack/validate/pop.c index ec957ac..873e54f 100644 --- a/regressions/ck_stack/validate/pop.c +++ b/regressions/ck_stack/validate/pop.c @@ -127,7 +127,7 @@ stack_thread(void *unused CK_CC_UNUSED) return (NULL); } -static void +static void stack_assert(void) { diff --git a/regressions/ck_stack/validate/push.c b/regressions/ck_stack/validate/push.c index 039cc13..e937a98 100644 --- a/regressions/ck_stack/validate/push.c +++ b/regressions/ck_stack/validate/push.c @@ -125,7 +125,7 @@ stack_thread(void *buffer) return (NULL); } -static void +static void stack_assert(void) { #ifndef SPINLOCK diff --git a/src/ck_barrier_combining.c b/src/ck_barrier_combining.c index 7dc5e78..6c10a61 100644 --- a/src/ck_barrier_combining.c +++ b/src/ck_barrier_combining.c @@ -68,7 +68,7 @@ ck_barrier_combining_insert(struct ck_barrier_combining_group *parent, /* * This implementation of software combining tree barriers - * uses level order traversal to insert new thread groups + * uses level order traversal to insert new thread groups * into the barrier's tree. We use a queue to implement this * traversal. */ @@ -127,7 +127,7 @@ ck_barrier_combining_group_init(struct ck_barrier_combining *root, goto leave; } - /* + /* * If unsuccessful, try inserting as a child of the children of the * current node. */ @@ -141,7 +141,7 @@ leave: } void -ck_barrier_combining_init(struct ck_barrier_combining *root, +ck_barrier_combining_init(struct ck_barrier_combining *root, struct ck_barrier_combining_group *init_root) { diff --git a/src/ck_barrier_dissemination.c b/src/ck_barrier_dissemination.c index 2f510f2..1f015cc 100644 --- a/src/ck_barrier_dissemination.c +++ b/src/ck_barrier_dissemination.c @@ -51,12 +51,12 @@ ck_barrier_dissemination_init(struct ck_barrier_dissemination *barrier, for (i = 0; i < nthr; ++i) { for (k = 0, offset = 1; k < size; ++k, offset <<= 1) { - /* + /* * Determine the thread's partner, j, for the current round, k. * Partners are chosen such that by the completion of the barrier, * every thread has been directly (having one of its flag set) or * indirectly (having one of its partners's flags set) signaled - * by every other thread in the barrier. + * by every other thread in the barrier. */ if (p == false) j = (i + offset) & (nthr - 1); @@ -112,7 +112,7 @@ ck_barrier_dissemination(struct ck_barrier_dissemination *barrier, /* * Dissemination barriers use two sets of flags to prevent race conditions * between successive calls to the barrier. Parity indicates which set will - * be used for the next barrier. They also use a sense reversal technique + * be used for the next barrier. They also use a sense reversal technique * to avoid re-initialization of the flags for every two calls to the barrier. */ if (state->parity == 1) diff --git a/src/ck_barrier_tournament.c b/src/ck_barrier_tournament.c index 8a74941..9a64085 100644 --- a/src/ck_barrier_tournament.c +++ b/src/ck_barrier_tournament.c @@ -90,7 +90,7 @@ ck_barrier_tournament_init(struct ck_barrier_tournament *barrier, rounds[i][k].opponent = &rounds[i - twokm1][k].flag; else if (rounds[i][k].role == CK_BARRIER_TOURNAMENT_WINNER || rounds[i][k].role == CK_BARRIER_TOURNAMENT_CHAMPION) - rounds[i][k].opponent = &rounds[i + twokm1][k].flag; + rounds[i][k].opponent = &rounds[i + twokm1][k].flag; } } @@ -165,7 +165,7 @@ wakeup: /* NOTREACHED */ break; case CK_BARRIER_TOURNAMENT_WINNER: - /* + /* * Winners inform their old opponents the tournament is over * by setting their flags. */ diff --git a/src/ck_epoch.c b/src/ck_epoch.c index 8b92bac..19f47b1 100644 --- a/src/ck_epoch.c +++ b/src/ck_epoch.c @@ -52,7 +52,7 @@ ck_epoch_init(struct ck_epoch *global, unsigned int threshold) global->epoch = 1; global->n_free = 0; global->threshold = threshold; - ck_pr_fence_store(); + ck_pr_fence_store(); return; } diff --git a/src/ck_hp.c b/src/ck_hp.c index d31637c..95942ee 100644 --- a/src/ck_hp.c +++ b/src/ck_hp.c @@ -47,7 +47,7 @@ * hazard pointers until it is safe to do so. Preventing arbitrary re-use * protects against the ABA problem and provides safe memory reclamation. * The implementation was derived from the Hazard Pointers implementation - * from the Amino CBBS project. It has been heavily modified for Concurrency + * from the Amino CBBS project. It has been heavily modified for Concurrency * Kit. */ @@ -174,7 +174,7 @@ ck_hp_member_scan(ck_stack_entry_t *entry, unsigned int degree, void *pointer) for (i = 0; i < degree; i++) { hazard = ck_pr_load_ptr(&record->pointers[i]); - if (hazard == pointer) + if (hazard == pointer) return (true); } } while ((entry = CK_STACK_NEXT(entry)) != NULL); diff --git a/src/ck_ht.c b/src/ck_ht.c index c022e49..ecb6e88 100644 --- a/src/ck_ht.c +++ b/src/ck_ht.c @@ -96,7 +96,7 @@ ck_ht_hash_direct(struct ck_ht_hash *h, ck_ht_hash(h, table, &key, sizeof(key)); return; } - + bool ck_ht_allocator_set(struct ck_malloc *m) diff --git a/src/ck_ht_hash.h b/src/ck_ht_hash.h index 5e6327c..3866e92 100644 --- a/src/ck_ht_hash.h +++ b/src/ck_ht_hash.h @@ -130,9 +130,9 @@ static inline void MurmurHash3_x86_32 ( const void * key, int len, k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; - + h1 ^= k1; - h1 = ROTL32(h1,13); + h1 = ROTL32(h1,13); h1 = h1*5+0xe6546b64; } @@ -159,7 +159,7 @@ static inline void MurmurHash3_x86_32 ( const void * key, int len, h1 = fmix(h1); *(uint32_t *)out = h1; -} +} static inline uint64_t MurmurHash64A ( const void * key, int len, uint64_t seed ) { @@ -175,12 +175,12 @@ static inline uint64_t MurmurHash64A ( const void * key, int len, uint64_t seed { uint64_t k = *data++; - k *= m; - k ^= k >> r; - k *= m; - + k *= m; + k ^= k >> r; + k *= m; + h ^= k; - h *= m; + h *= m; } const unsigned char * data2 = (const unsigned char*)data; @@ -196,13 +196,13 @@ static inline uint64_t MurmurHash64A ( const void * key, int len, uint64_t seed case 1: h ^= (uint64_t)(data2[0]); h *= m; }; - + h ^= h >> r; h *= m; h ^= h >> r; return h; -} +} // 64-bit hash for 32-bit platforms @@ -256,6 +256,6 @@ static inline uint64_t MurmurHash64B ( const void * key, int len, uint64_t seed h = (h << 32) | h2; return h; -} +} #endif /* _CK_HT_HASH_H */