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 ---[ Concurrency Kit has installed successfully.
uninstall:
uninstall:
$(MAKE) -C doc uninstall
rm -f $(DESTDIR)/$(LIBRARY)/libck.so*
rm -f $(DESTDIR)/$(LIBRARY)/libck.a

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

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

2
configure vendored

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -35,7 +35,7 @@
#include <stddef.h>
#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)

@ -33,6 +33,6 @@
#ifndef CK_MD_PAGESIZE
#define CK_MD_PAGESIZE (4096)
#endif
#endif
#endif /* _CK_MD_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 \

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

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

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

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

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

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

@ -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 <ck_cc.h>
/*
* 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 <ck_cc.h>
/*
* 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 */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -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 <ck_bytelock.h>
#include <ck_spinlock.h>
#include <inttypes.h>
#include <ck_bytelock.h>
#include <ck_spinlock.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "../../common.h"
#ifndef STEPS
#define STEPS 30000000
#endif
#ifndef STEPS
#define STEPS 30000000
#endif
LOCK_DEFINE;

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

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

Loading…
Cancel
Save