From 3e469d7fb53b0e5e9b7ac8e7a62748fbac6860dc Mon Sep 17 00:00:00 2001 From: David Joseph Date: Mon, 18 Feb 2013 02:35:55 -0600 Subject: [PATCH 01/60] Namespace changes to regressions/common.h (alarm). Add "local_name" to COMMON_ALARM_DECLARE_LOCAL and COMMON_ALARM_DECLARE_INIT to avoid namespace conflicts. --- .../ck_hs/benchmark/parallel_bytestring.c | 4 +- .../ck_ht/benchmark/parallel_bytestring.c | 4 +- regressions/common.h | 84 +++++++++---------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/regressions/ck_hs/benchmark/parallel_bytestring.c b/regressions/ck_hs/benchmark/parallel_bytestring.c index fa52b85..5197923 100644 --- a/regressions/ck_hs/benchmark/parallel_bytestring.c +++ b/regressions/ck_hs/benchmark/parallel_bytestring.c @@ -287,7 +287,7 @@ main(int argc, char *argv[]) pthread_t *readers; double p_r, p_d; - COMMON_ALARM_DECLARE_LOCAL(alarm_event) + COMMON_ALARM_DECLARE_LOCAL(alarm_event, ck_hs) r = 20; s = 8; @@ -327,7 +327,7 @@ main(int argc, char *argv[]) } } - COMMON_ALARM_INIT(alarm_event, r) + COMMON_ALARM_INIT(alarm_event, r, ck_hs) affinerator.delta = 1; readers = malloc(sizeof(pthread_t) * n_threads); diff --git a/regressions/ck_ht/benchmark/parallel_bytestring.c b/regressions/ck_ht/benchmark/parallel_bytestring.c index 4f222ec..89a2551 100644 --- a/regressions/ck_ht/benchmark/parallel_bytestring.c +++ b/regressions/ck_ht/benchmark/parallel_bytestring.c @@ -265,7 +265,7 @@ main(int argc, char *argv[]) pthread_t *readers; double p_r, p_d; - COMMON_ALARM_DECLARE_LOCAL(alarm_event) + COMMON_ALARM_DECLARE_LOCAL(alarm_event, ck_ht) r = 20; s = 8; @@ -305,7 +305,7 @@ main(int argc, char *argv[]) } } - COMMON_ALARM_INIT(alarm_event, r) + COMMON_ALARM_INIT(alarm_event, r, ck_ht) affinerator.delta = 1; readers = malloc(sizeof(pthread_t) * n_threads); diff --git a/regressions/common.h b/regressions/common.h index 524c529..39a5548 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -146,53 +146,53 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) #ifndef SECOND_TIMER #define SECOND_TIMER 10000000 #endif -#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) \ -static HANDLE common_win_alarm_timer; \ -static HANDLE alarm_event_name; \ -static LARGE_INTEGER timer_length; \ - \ -static void CALLBACK \ -common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ -{ \ - (void)arg; \ - (void)timer_low_value; \ - (void)timer_high_value; \ - flag_name = true; \ - return; \ -} \ - \ -static void * \ -common_win_alarm(void *unused) \ -{ \ - (void)unused; \ - bool timer_success = false; \ - for (;;) { \ - WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \ - timer_success = SetWaitableTimer(common_win_alarm_timer, &timer_length, 0, common_win_alarm_handler, NULL, false); \ - assert(timer_success != false); \ - WaitForSingleObjectEx(common_win_alarm_timer, INFINITE, true); \ - } \ - \ - return NULL; \ +#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) \ +static HANDLE common_win_alarm_timer; \ +static HANDLE alarm_event_name; \ +static LARGE_INTEGER common_alarm_timer_length; \ + \ +static void CALLBACK \ +common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ +{ \ + (void)arg; \ + (void)timer_low_value; \ + (void)timer_high_value; \ + flag_name = true; \ + return; \ +} \ + \ +static void * \ +common_win_alarm(void *unused) \ +{ \ + (void)unused; \ + bool timer_success = false; \ + for (;;) { \ + WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \ + timer_success = SetWaitableTimer(common_win_alarm_timer, &common_alarm_timer_length, 0, common_win_alarm_handler, NULL, false); \ + assert(timer_success != false); \ + WaitForSingleObjectEx(common_win_alarm_timer, INFINITE, true); \ + } \ + \ + return NULL; \ } -#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name) \ - __int64 tl; \ - pthread_t common_win_alarm_thread; - -#define COMMON_ALARM_INIT(alarm_event_name, duration) \ - tl = -1 * duration * SECOND_TIMER; \ - timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ - timer_length.HighPart = (LONG) (tl >> 32); \ - alarm_event_name = CreateEvent(NULL, false, false, NULL); \ - assert(alarm_event_name != NULL); \ - common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ - assert(common_win_alarm_timer != NULL); \ - if (pthread_create(&common_win_alarm_thread, NULL, common_win_alarm, NULL) != 0) \ +#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \ + int64_t common_alarm_tl_#local_name; \ + pthread_t common_win_alarm_thread_#local_name; + +#define COMMON_ALARM_INIT(alarm_event_name, duration, local_name) \ + common_alarm_tl_#local_name = -1 * (duration) * SECOND_TIMER; \ + common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ + common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ + alarm_event_name = CreateEvent(NULL, false, false, NULL); \ + assert(alarm_event_name != NULL); \ + common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ + assert(common_win_alarm_timer != NULL); \ + if (pthread_create(&common_win_alarm_thread_#local_name, NULL, common_win_alarm, NULL) != 0) \ ck_error("ERROR: Failed to create common_win_alarm thread.\n"); #else #define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) -#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name) \ +#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \ int alarm_event_name = 0; #define COMMON_ALARM_INIT(alarm_event_name, duration) #endif From 8f1c31aa2c2690461717be0d0bd6b758bc42d1a8 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Mon, 18 Feb 2013 11:04:08 -0600 Subject: [PATCH 02/60] Style changes to common.h's alarm macros. --- regressions/common.h | 80 ++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index 39a5548..5b77e20 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -146,49 +146,55 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) #ifndef SECOND_TIMER #define SECOND_TIMER 10000000 #endif -#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) \ -static HANDLE common_win_alarm_timer; \ -static HANDLE alarm_event_name; \ -static LARGE_INTEGER common_alarm_timer_length; \ - \ -static void CALLBACK \ -common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ -{ \ - (void)arg; \ - (void)timer_low_value; \ - (void)timer_high_value; \ - flag_name = true; \ - return; \ -} \ - \ -static void * \ -common_win_alarm(void *unused) \ -{ \ - (void)unused; \ - bool timer_success = false; \ - for (;;) { \ - WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \ - timer_success = SetWaitableTimer(common_win_alarm_timer, &common_alarm_timer_length, 0, common_win_alarm_handler, NULL, false); \ - assert(timer_success != false); \ - WaitForSingleObjectEx(common_win_alarm_timer, INFINITE, true); \ - } \ - \ - return NULL; \ +#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) \ +static HANDLE common_win_alarm_timer; \ +static HANDLE alarm_event_name; \ +static LARGE_INTEGER common_alarm_timer_length; \ + \ +static void CALLBACK \ +common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ +{ \ + (void)arg; \ + (void)timer_low_value; \ + (void)timer_high_value; \ + flag_name = true; \ + return; \ +} \ + \ +static void * \ +common_win_alarm(void *unused) \ +{ \ + (void)unused; \ + bool timer_success = false; \ + for (;;) { \ + WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \ + timer_success = SetWaitableTimer(common_win_alarm_timer, \ + &common_alarm_timer_length, \ + 0, \ + common_win_alarm_handler, NULL, false); \ + assert(timer_success != false); \ + WaitForSingleObjectEx(common_win_alarm_timer, INFINITE, true); \ + } \ + \ + return NULL; \ } #define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \ int64_t common_alarm_tl_#local_name; \ pthread_t common_win_alarm_thread_#local_name; -#define COMMON_ALARM_INIT(alarm_event_name, duration, local_name) \ - common_alarm_tl_#local_name = -1 * (duration) * SECOND_TIMER; \ - common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ - common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ - alarm_event_name = CreateEvent(NULL, false, false, NULL); \ - assert(alarm_event_name != NULL); \ - common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ - assert(common_win_alarm_timer != NULL); \ - if (pthread_create(&common_win_alarm_thread_#local_name, NULL, common_win_alarm, NULL) != 0) \ +#define COMMON_ALARM_INIT(alarm_event_name, duration, local_name) \ + common_alarm_tl_#local_name = -1 * (duration) * SECOND_TIMER; \ + common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ + common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ + alarm_event_name = CreateEvent(NULL, false, false, NULL); \ + assert(alarm_event_name != NULL); \ + common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ + assert(common_win_alarm_timer != NULL); \ + if (pthread_create(&common_win_alarm_thread_#local_name, \ + NULL, \ + common_win_alarm, \ + NULL) != 0) \ ck_error("ERROR: Failed to create common_win_alarm thread.\n"); #else #define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) From 339a1bd639b48cd9fdcedb108669f33c80c064ce Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 18:26:55 -0600 Subject: [PATCH 03/60] regressions: Add prefix to common alarm interface. --- regressions/common.h | 53 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index ee6ce83..eccb853 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -37,7 +37,6 @@ #elif defined(__MACH__) #include #include -#include #endif #if defined(_WIN32) @@ -150,13 +149,13 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) #ifndef SECOND_TIMER #define SECOND_TIMER 10000000 #endif -#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) \ -static HANDLE common_win_alarm_timer; \ -static HANDLE alarm_event_name; \ -static LARGE_INTEGER common_alarm_timer_length; \ +#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \ +static HANDLE prefix##_common_win_alarm_timer; \ +static HANDLE prefix##_alarm_event_name; \ +static LARGE_INTEGER prefix##_common_alarm_timer_length; \ \ static void CALLBACK \ -common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ +prefix##_common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ { \ (void)arg; \ (void)timer_low_value; \ @@ -166,7 +165,7 @@ common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_val } \ \ static void * \ -common_win_alarm(void *unused) \ +prefix##_common_win_alarm(void *unused) \ { \ (void)unused; \ bool timer_success = false; \ @@ -183,28 +182,28 @@ common_win_alarm(void *unused) \ return NULL; \ } -#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \ - int64_t common_alarm_tl_#local_name; \ - pthread_t common_win_alarm_thread_#local_name; - -#define COMMON_ALARM_INIT(alarm_event_name, duration, local_name) \ - common_alarm_tl_#local_name = -1 * (duration) * SECOND_TIMER; \ - common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ - common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ - alarm_event_name = CreateEvent(NULL, false, false, NULL); \ - assert(alarm_event_name != NULL); \ - common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ - assert(common_win_alarm_timer != NULL); \ - if (pthread_create(&common_win_alarm_thread_#local_name, \ - NULL, \ - common_win_alarm, \ - NULL) != 0) \ +#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ + int64_t prefix##_common_alarm_tl; \ + pthread_t prefix##_common_win_alarm_thread; + +#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) \ + prefix##_common_alarm_tl = -1 * (duration) * SECOND_TIMER; \ + prefix##_common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ + prefix##_common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ + prefix##_alarm_event_name = CreateEvent(NULL, false, false, NULL); \ + assert(prefix##_alarm_event_name != NULL); \ + prefix##_common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ + assert(prefix##_common_win_alarm_timer != NULL); \ + if (pthread_create(&prefix##_common_win_alarm_thread, \ + NULL, \ + prefix##_common_win_alarm, \ + NULL) != 0) \ ck_error("ERROR: Failed to create common_win_alarm thread.\n"); #else -#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) -#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \ - int alarm_event_name = 0; -#define COMMON_ALARM_INIT(alarm_event_name, duration) +#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) +#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ + int prefix##_alarm_event_name = 0; +#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) #endif struct affinity { From c1cf0a7a537cfa0bab525a922014bb5a29eeb7c2 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 18:27:19 -0600 Subject: [PATCH 04/60] build: Add support for MinGW-w64. --- configure | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 19b6739..12ea6ad 100755 --- a/configure +++ b/configure @@ -419,10 +419,6 @@ else VMA_BITS_VALUE_R="${VMA_BITS}ULL" fi -# Platform will be used as a macro. -PROFILE="${PROFILE:-$PLATFORM}" -PLATFORM="__${PLATFORM}__" - # `which` on Solaris sucks pathsearch() { @@ -488,6 +484,9 @@ cat << EOF > .1.c #include int main(void) { #if defined(_WIN32) +#if defined(__MINGW64__) + puts("mingw64"); + return (0); #if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION >= 3) puts("mingw32"); return (0); @@ -525,7 +524,7 @@ if test "$COMPILER" = "suncc"; then LDFLAGS="-G -z text -h libck.so.$VERSION_MAJOR $LDFLAGS" CFLAGS="-xO5 $CFLAGS" PTHREAD_CFLAGS="-mt -lpthread" -elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER" = "mingw32"; then +elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER" = "mingw32" || test "$COMPILER" = "mingw64"; then LD=$CC if test "$SYSTEM" = "darwin"; then CC_WL_OPT="-install_name" @@ -535,6 +534,10 @@ elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER" LDFLAGS="-shared -fPIC -Wl,$CC_WL_OPT,libck.so.$VERSION_MAJOR $LDFLAGS" CFLAGS="-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99 -pedantic -Wall -W -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -fstrict-aliasing -O2 -pipe -Wno-parentheses $CFLAGS" PTHREAD_CFLAGS="-pthread" + if test "$COMPILER" = "mingw64"; then + ENVIRONMENT=64 + PLATFORM=x86_64 + fi else assert "" "unknown compiler" fi @@ -558,6 +561,10 @@ EOF fi done +# Platform will be used as a macro. +PROFILE="${PROFILE:-$PLATFORM}" +PLATFORM="__${PLATFORM}__" + printf "Generating header files.........." generate include/ck_md.h.in include/ck_md.h echo "success" From 0784be7ff01ea7270c5001862a867f2e8deb9e66 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 18:35:40 -0600 Subject: [PATCH 05/60] regressions: Fix tests that use common alarm. --- regressions/ck_hs/benchmark/parallel_bytestring.c | 6 +++--- regressions/ck_ht/benchmark/parallel_bytestring.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/regressions/ck_hs/benchmark/parallel_bytestring.c b/regressions/ck_hs/benchmark/parallel_bytestring.c index 5197923..7910ac2 100644 --- a/regressions/ck_hs/benchmark/parallel_bytestring.c +++ b/regressions/ck_hs/benchmark/parallel_bytestring.c @@ -70,7 +70,7 @@ struct hs_epoch { ck_epoch_entry_t epoch_entry; }; -COMMON_ALARM_DECLARE_GLOBAL(alarm_event, next_stage) +COMMON_ALARM_DECLARE_GLOBAL(hs_alarm, alarm_event, next_stage) static void alarm_handler(int s) @@ -287,7 +287,7 @@ main(int argc, char *argv[]) pthread_t *readers; double p_r, p_d; - COMMON_ALARM_DECLARE_LOCAL(alarm_event, ck_hs) + COMMON_ALARM_DECLARE_LOCAL(hs_alarm, alarm_event) r = 20; s = 8; @@ -327,7 +327,7 @@ main(int argc, char *argv[]) } } - COMMON_ALARM_INIT(alarm_event, r, ck_hs) + COMMON_ALARM_INIT(hs_alarm, alarm_event, r) affinerator.delta = 1; readers = malloc(sizeof(pthread_t) * n_threads); diff --git a/regressions/ck_ht/benchmark/parallel_bytestring.c b/regressions/ck_ht/benchmark/parallel_bytestring.c index 89a2551..f530788 100644 --- a/regressions/ck_ht/benchmark/parallel_bytestring.c +++ b/regressions/ck_ht/benchmark/parallel_bytestring.c @@ -71,7 +71,7 @@ struct ht_epoch { ck_epoch_entry_t epoch_entry; }; -COMMON_ALARM_DECLARE_GLOBAL(alarm_event, next_stage) +COMMON_ALARM_DECLARE_GLOBAL(ht_alarm, alarm_event, next_stage) static void alarm_handler(int s) @@ -265,7 +265,7 @@ main(int argc, char *argv[]) pthread_t *readers; double p_r, p_d; - COMMON_ALARM_DECLARE_LOCAL(alarm_event, ck_ht) + COMMON_ALARM_DECLARE_LOCAL(ht_alarm, alarm_event) r = 20; s = 8; @@ -305,7 +305,7 @@ main(int argc, char *argv[]) } } - COMMON_ALARM_INIT(alarm_event, r, ck_ht) + COMMON_ALARM_INIT(ht_alarm, alarm_event, r) affinerator.delta = 1; readers = malloc(sizeof(pthread_t) * n_threads); From d7c528694d8e0dc54800ed6d11aaa474bc6be137 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 18:43:08 -0600 Subject: [PATCH 06/60] build: Fix MINGW64 check. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 12ea6ad..16a937f 100755 --- a/configure +++ b/configure @@ -487,7 +487,7 @@ int main(void) { #if defined(__MINGW64__) puts("mingw64"); return (0); -#if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION >= 3) +#elif defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION >= 3) puts("mingw32"); return (0); #else From da23134615f86839bbdc5277150a32258f56b00b Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 18:55:10 -0600 Subject: [PATCH 07/60] regressions: Fix for alarm interface. --- regressions/ck_ht/benchmark/parallel_direct.c | 6 +++--- regressions/common.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/regressions/ck_ht/benchmark/parallel_direct.c b/regressions/ck_ht/benchmark/parallel_direct.c index 067e8f1..94e3e22 100644 --- a/regressions/ck_ht/benchmark/parallel_direct.c +++ b/regressions/ck_ht/benchmark/parallel_direct.c @@ -70,7 +70,7 @@ struct ht_epoch { ck_epoch_entry_t epoch_entry; }; -COMMON_ALARM_DECLARE_GLOBAL(alarm_event, next_stage) +COMMON_ALARM_DECLARE_GLOBAL(ht_alarm, alarm_event, next_stage) static void alarm_handler(int s) @@ -269,7 +269,7 @@ main(int argc, char *argv[]) pthread_t *readers; double p_r, p_d; - COMMON_ALARM_DECLARE_LOCAL(alarm_event) + COMMON_ALARM_DECLARE_LOCAL(ht_alarm, alarm_event) r = 20; s = 8; @@ -309,7 +309,7 @@ main(int argc, char *argv[]) } } - COMMON_ALARM_INIT(alarm_event, r) + COMMON_ALARM_INIT(ht_alarm, alarm_event, r) affinerator.delta = 1; readers = malloc(sizeof(pthread_t) * n_threads); diff --git a/regressions/common.h b/regressions/common.h index eccb853..1c84c59 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -151,7 +151,7 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) #endif #define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \ static HANDLE prefix##_common_win_alarm_timer; \ -static HANDLE prefix##_alarm_event_name; \ +static HANDLE alarm_event_name; \ static LARGE_INTEGER prefix##_common_alarm_timer_length; \ \ static void CALLBACK \ @@ -190,8 +190,8 @@ prefix##_common_win_alarm(void *unused) \ prefix##_common_alarm_tl = -1 * (duration) * SECOND_TIMER; \ prefix##_common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ prefix##_common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ - prefix##_alarm_event_name = CreateEvent(NULL, false, false, NULL); \ - assert(prefix##_alarm_event_name != NULL); \ + alarm_event_name = CreateEvent(NULL, false, false, NULL); \ + assert(alarm_event_name != NULL); \ prefix##_common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ assert(prefix##_common_win_alarm_timer != NULL); \ if (pthread_create(&prefix##_common_win_alarm_thread, \ @@ -202,7 +202,7 @@ prefix##_common_win_alarm(void *unused) \ #else #define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) #define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ - int prefix##_alarm_event_name = 0; + int alarm_event_name = 0; #define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) #endif From aaebc6b31bb251bab008a360ae550a6880af2163 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 19:16:53 -0600 Subject: [PATCH 08/60] regressions: Fix for common alarm prefixes. --- regressions/common.h | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index 1c84c59..aacd176 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -149,37 +149,37 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) #ifndef SECOND_TIMER #define SECOND_TIMER 10000000 #endif -#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \ -static HANDLE prefix##_common_win_alarm_timer; \ -static HANDLE alarm_event_name; \ -static LARGE_INTEGER prefix##_common_alarm_timer_length; \ - \ -static void CALLBACK \ -prefix##_common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ -{ \ - (void)arg; \ - (void)timer_low_value; \ - (void)timer_high_value; \ - flag_name = true; \ - return; \ -} \ - \ -static void * \ -prefix##_common_win_alarm(void *unused) \ -{ \ - (void)unused; \ - bool timer_success = false; \ - for (;;) { \ - WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \ - timer_success = SetWaitableTimer(common_win_alarm_timer, \ - &common_alarm_timer_length, \ - 0, \ - common_win_alarm_handler, NULL, false); \ - assert(timer_success != false); \ - WaitForSingleObjectEx(common_win_alarm_timer, INFINITE, true); \ - } \ - \ - return NULL; \ +#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \ +static HANDLE prefix##_common_win_alarm_timer; \ +static HANDLE alarm_event_name; \ +static LARGE_INTEGER prefix##_common_alarm_timer_length; \ + \ +static void CALLBACK \ +prefix##_common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ +{ \ + (void)arg; \ + (void)timer_low_value; \ + (void)timer_high_value; \ + flag_name = true; \ + return; \ +} \ + \ +static void * \ +prefix##_common_win_alarm(void *unused) \ +{ \ + (void)unused; \ + bool timer_success = false; \ + for (;;) { \ + WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \ + timer_success = SetWaitableTimer(prefix##_common_win_alarm_timer, \ + &prefix##_common_alarm_timer_length, \ + 0, \ + prefix##_common_win_alarm_handler, NULL, false); \ + assert(timer_success != false); \ + WaitForSingleObjectEx(prefix##_common_win_alarm_timer, INFINITE, true); \ + } \ + \ + return NULL; \ } #define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ From 9640eabba8492255000bb5a6d6a308257c50cf92 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 19:25:57 -0600 Subject: [PATCH 09/60] regressions: Fix for common alarm init. --- regressions/common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index aacd176..e1d8f15 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -188,8 +188,10 @@ prefix##_common_win_alarm(void *unused) \ #define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) \ prefix##_common_alarm_tl = -1 * (duration) * SECOND_TIMER; \ - prefix##_common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ - prefix##_common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ + prefix##_common_alarm_timer_length.LowPart = \ + (DWORD) (prefix##_common_alarm_tl & 0xFFFFFFFF); \ + prefix##_common_alarm_timer_length.HighPart = \ + (LONG) (prefix##_common_alarm_tl >> 32); \ alarm_event_name = CreateEvent(NULL, false, false, NULL); \ assert(alarm_event_name != NULL); \ prefix##_common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ From c4e50a193ad0b4cda495bf68fe3dfd6336f48407 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 10 Mar 2013 21:32:51 -0400 Subject: [PATCH 10/60] ck_fifo: Style fixes. --- include/ck_fifo.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/ck_fifo.h b/include/ck_fifo.h index c7e76aa..a787ded 100644 --- a/include/ck_fifo.h +++ b/include/ck_fifo.h @@ -139,13 +139,13 @@ ck_fifo_spsc_dequeue(struct ck_fifo_spsc *fifo, void *value) */ entry = ck_pr_load_ptr(&fifo->head->next); if (entry == NULL) - return (false); + return false; /* If entry is visible, guarantee store to value is visible. */ ck_pr_store_ptr(value, entry->value); ck_pr_fence_store(); ck_pr_store_ptr(&fifo->head, entry); - return (true); + return true; } /* @@ -165,14 +165,14 @@ ck_fifo_spsc_recycle(struct ck_fifo_spsc *fifo) garbage = fifo->garbage; fifo->garbage = garbage->next; - return (garbage); + return garbage; } CK_CC_INLINE static bool ck_fifo_spsc_isempty(struct ck_fifo_spsc *fifo) { struct ck_fifo_spsc_entry *head = ck_pr_load_ptr(&fifo->head); - return (ck_pr_load_ptr(&head->next) == NULL); + return ck_pr_load_ptr(&head->next) == NULL; } #define CK_FIFO_SPSC_ISEMPTY(f) ((f)->head->next == NULL) @@ -355,7 +355,7 @@ ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo, * queue is empty. */ if (next.pointer == NULL) - return (false); + return false; /* Forward the tail pointer if necessary. */ update.generation = tail.generation + 1; @@ -372,7 +372,7 @@ ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo, } *garbage = head.pointer; - return (true); + return true; } CK_CC_INLINE static bool From 86884ed574df1d073a7620ce18e62e7dbfff7476 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 10 Mar 2013 21:37:49 -0400 Subject: [PATCH 11/60] ck_fifo_mpmc: Fix NULL deference when re-using nodes. If a FIFO entry is being re-used, it is possible for NULL assignment to be triggered due to race with enqueue. --- include/ck_fifo.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/ck_fifo.h b/include/ck_fifo.h index a787ded..5805c49 100644 --- a/include/ck_fifo.h +++ b/include/ck_fifo.h @@ -361,6 +361,14 @@ ck_fifo_mpmc_dequeue(struct ck_fifo_mpmc *fifo, update.generation = tail.generation + 1; ck_pr_cas_ptr_2(&fifo->tail, &tail, &update); } else { + /* + * It is possible for head snapshot to have been + * re-used. Avoid deferencing during enqueue + * re-use. + */ + if (next.pointer == NULL) + continue; + /* Save value before commit. */ *(void **)value = ck_pr_load_ptr(&next.pointer->value); @@ -408,6 +416,13 @@ ck_fifo_mpmc_trydequeue(struct ck_fifo_mpmc *fifo, ck_pr_cas_ptr_2(&fifo->tail, &tail, &update); return false; } else { + /* + * It is possible for head snapshot to have been + * re-used. Avoid deferencing during enqueue. + */ + if (next.pointer == NULL) + return false; + /* Save value before commit. */ *(void **)value = ck_pr_load_ptr(&next.pointer->value); From 45f648bd3392e46a66e8a2d29f14c2cabf028485 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 27 Mar 2013 14:05:32 -0400 Subject: [PATCH 12/60] ck_ring: Add *_size_* ck_ring enqueue operations. These variants of ck_ring_enqueue_* return the snapshot of queue length with respect to the linearization point. This can be used to extract ring size without incurring additional cacheline invalidation overhead from the writer. --- include/ck_ring.h | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/include/ck_ring.h b/include/ck_ring.h index ffd06f1..4b9ffa7 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -75,6 +75,27 @@ return ring->size; \ } \ CK_CC_INLINE static bool \ + ck_ring_enqueue_spsc_size_##name(struct ck_ring_##name *ring, \ + struct type *entry, \ + unsigned int *size) \ + { \ + unsigned int consumer, producer, delta; \ + unsigned int mask = ring->mask; \ + \ + consumer = ck_pr_load_uint(&ring->c_head); \ + producer = ring->p_tail; \ + delta = producer + 1; \ + *size = (producer - consumer) & mask; \ + \ + if ((delta & mask) == (consumer & mask)) \ + return false; \ + \ + ring->ring[producer & mask] = *entry; \ + ck_pr_fence_store(); \ + ck_pr_store_uint(&ring->p_tail, delta); \ + return true; \ + } \ + CK_CC_INLINE static bool \ ck_ring_enqueue_spsc_##name(struct ck_ring_##name *ring, \ struct type *entry) \ { \ @@ -114,6 +135,13 @@ return true; \ } \ CK_CC_INLINE static bool \ + ck_ring_enqueue_spmc_size_##name(struct ck_ring_##name *ring, \ + void *entry, unsigned int *size) \ + { \ + \ + return ck_ring_enqueue_spsc_size_##name(ring, entry, size); \ + } \ + CK_CC_INLINE static bool \ ck_ring_enqueue_spmc_##name(struct ck_ring_##name *ring, void *entry) \ { \ \ @@ -217,6 +245,50 @@ ck_ring_capacity(struct ck_ring *ring) return ring->size; } +/* + * Atomically enqueues the specified entry. Returns true on success, returns + * false if the ck_ring is full. This operation only support one active + * invocation at a time and works in the presence of a concurrent invocation + * of ck_ring_dequeue_spsc. + * + * This variant of ck_ring_enqueue_spsc returns the snapshot of queue length + * with respect to the linearization point. This can be used to extract ring + * size without incurring additional cacheline invalidation overhead from the + * writer. + */ +CK_CC_INLINE static bool +ck_ring_enqueue_spsc_size(struct ck_ring *ring, + void *entry, + unsigned int *size) +{ + unsigned int consumer, producer, delta; + unsigned int mask = ring->mask; + + consumer = ck_pr_load_uint(&ring->c_head); + producer = ring->p_tail; + delta = producer + 1; + *size = (producer - consumer) & mask; + + if ((delta & mask) == (consumer & mask)) + return false; + + ring->ring[producer & mask] = entry; + + /* + * Make sure to update slot value before indicating + * that the slot is available for consumption. + */ + ck_pr_fence_store(); + ck_pr_store_uint(&ring->p_tail, delta); + return true; +} + +/* + * Atomically enqueues the specified entry. Returns true on success, returns + * false if the ck_ring is full. This operation only support one active + * invocation at a time and works in the presence of a concurrent invocation + * of ck_ring_dequeue_spsc. + */ CK_CC_INLINE static bool ck_ring_enqueue_spsc(struct ck_ring *ring, void *entry) { @@ -275,6 +347,32 @@ ck_ring_dequeue_spsc(struct ck_ring *ring, void *data) return true; } +/* + * Atomically enqueues the specified entry. Returns true on success, returns + * false if the ck_ring is full. This operation only support one active + * invocation at a time and works in the presence of up to UINT_MAX concurrent + * invocations of ck_ring_dequeue_spmc. + * + * This variant of ck_ring_enqueue_spmc returns the snapshot of queue length + * with respect to the linearization point. This can be used to extract ring + * size without incurring additional cacheline invalidation overhead from the + * writer. + */ +CK_CC_INLINE static bool +ck_ring_enqueue_spmc_size(struct ck_ring *ring, + void *entry, + unsigned int *size) +{ + + return ck_ring_enqueue_spsc_size(ring, entry, size); +} + +/* + * Atomically enqueues the specified entry. Returns true on success, returns + * false if the ck_ring is full. This operation only support one active + * invocation at a time and works in the presence of up to UINT_MAX concurrent + * invocations of ck_ring_dequeue_spmc. + */ CK_CC_INLINE static bool ck_ring_enqueue_spmc(struct ck_ring *ring, void *entry) { From 67381af3c5210c9c2443ad3ff11f38246d63644a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 28 Mar 2013 13:16:49 -0400 Subject: [PATCH 13/60] ck_ring: Expose *_size variants to type-specialized ck_ring. Added: - CK_RING_ENQUEUE_SPSC_SIZE - CK_RING_ENQUEUE_SPMC_SIZE --- include/ck_ring.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/include/ck_ring.h b/include/ck_ring.h index 4b9ffa7..8fe4ee5 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -195,23 +195,27 @@ } -#define CK_RING_INSTANCE(name) \ +#define CK_RING_INSTANCE(name) \ struct ck_ring_##name -#define CK_RING_INIT(name, object, buffer, size) \ +#define CK_RING_INIT(name, object, buffer, size) \ ck_ring_init_##name(object, buffer, size) -#define CK_RING_SIZE(name, object) \ +#define CK_RING_SIZE(name, object) \ ck_ring_size_##name(object) -#define CK_RING_CAPACITY(name, object) \ +#define CK_RING_CAPACITY(name, object) \ ck_ring_capacity_##name(object) -#define CK_RING_ENQUEUE_SPSC(name, object, value) \ +#define CK_RING_ENQUEUE_SPSC_SIZE(name, object, value, s) \ + ck_ring_enqueue_spsc_size_##name(object, value, s) +#define CK_RING_ENQUEUE_SPSC(name, object, value) \ ck_ring_enqueue_spsc_##name(object, value) -#define CK_RING_DEQUEUE_SPSC(name, object, value) \ +#define CK_RING_DEQUEUE_SPSC(name, object, value) \ ck_ring_dequeue_spsc_##name(object, value) -#define CK_RING_DEQUEUE_SPMC(name, object, value) \ +#define CK_RING_DEQUEUE_SPMC(name, object, value) \ ck_ring_dequeue_spmc_##name(object, value) -#define CK_RING_TRYDEQUEUE_SPMC(name, object, value) \ +#define CK_RING_TRYDEQUEUE_SPMC(name, object, value) \ ck_ring_trydequeue_spmc_##name(object, value) -#define CK_RING_ENQUEUE_SPMC(name, object, value) \ +#define CK_RING_ENQUEUE_SPMC_SIZE(name, object, value, s) \ + ck_ring_enqueue_spmc_##name(object, value, s) +#define CK_RING_ENQUEUE_SPMC(name, object, value) \ ck_ring_enqueue_spmc_##name(object, value) struct ck_ring { From 878b8e632190914abe98f616defcbe3f100ff257 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 28 Mar 2013 13:32:36 -0400 Subject: [PATCH 14/60] ck_ring: Correct CK_RING_SPMC_ENQUEUE_SIZE typo. --- include/ck_ring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ck_ring.h b/include/ck_ring.h index 8fe4ee5..e97e00b 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -214,7 +214,7 @@ #define CK_RING_TRYDEQUEUE_SPMC(name, object, value) \ ck_ring_trydequeue_spmc_##name(object, value) #define CK_RING_ENQUEUE_SPMC_SIZE(name, object, value, s) \ - ck_ring_enqueue_spmc_##name(object, value, s) + ck_ring_enqueue_spmc_size_##name(object, value, s) #define CK_RING_ENQUEUE_SPMC(name, object, value) \ ck_ring_enqueue_spmc_##name(object, value) From 5c90d917f76c628be3028c618ff1952e11370c8a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 28 Mar 2013 13:34:34 -0400 Subject: [PATCH 15/60] regressions/ck_ring: More improvements and _size coverage. SPMC path exercises random delays. Coverage exists for the new *_enqueue_*_size --- regressions/ck_ring/validate/Makefile | 2 +- regressions/ck_ring/validate/ck_ring_spmc.c | 56 +++++++++++++++++-- .../ck_ring/validate/ck_ring_spmc_template.c | 15 ++++- regressions/ck_ring/validate/ck_ring_spsc.c | 27 ++++++++- .../ck_ring/validate/ck_ring_spsc_template.c | 31 +++++++++- 5 files changed, 120 insertions(+), 11 deletions(-) diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile index a0b51cc..cd63556 100644 --- a/regressions/ck_ring/validate/Makefile +++ b/regressions/ck_ring/validate/Makefile @@ -1,7 +1,7 @@ .PHONY: check clean distribution OBJECTS=ck_ring_spsc ck_ring_spsc_template ck_ring_spmc ck_ring_spmc_template -SIZE=65536 +SIZE=16384 all: $(OBJECTS) diff --git a/regressions/ck_ring/validate/ck_ring_spmc.c b/regressions/ck_ring/validate/ck_ring_spmc.c index 3655a6c..259a8a1 100644 --- a/regressions/ck_ring/validate/ck_ring_spmc.c +++ b/regressions/ck_ring/validate/ck_ring_spmc.c @@ -66,7 +66,8 @@ test_spmc(void *c) { unsigned int observed = 0; unsigned long previous = 0; - int i, j, tid; + unsigned int seed; + int i, k, j, tid; (void)c; if (aff_iterate(&a)) { @@ -81,6 +82,7 @@ test_spmc(void *c) for (i = 0; i < ITERATIONS; i++) { for (j = 0; j < size; j++) { struct entry *o; + int spin; /* Keep trying until we encounter at least one node. */ if (j & 1) { @@ -107,6 +109,13 @@ test_spmc(void *c) ck_error("[%p] We dequeued twice.\n", (void *)o); } + if ((i % 4) == 0) { + spin = common_rand_r(&seed) % 16384; + for (k = 0; k < spin; k++) { + ck_pr_stall(); + } + } + free(o); } } @@ -120,6 +129,7 @@ test(void *c) { struct context *context = c; struct entry *entry; + unsigned int s; int i, j; bool r; ck_barrier_centralized_state_t sense = @@ -145,7 +155,18 @@ test(void *c) entries[i].value = i; entries[i].tid = 0; - r = ck_ring_enqueue_spmc(ring, entries + i); + if (i & 1) { + r = ck_ring_enqueue_spmc(ring, entries + i); + } else { + r = ck_ring_enqueue_spmc_size(ring, + entries + i, &s); + + if ((int)s != i) { + ck_error("Size is %u, expected %d.\n", + s, size); + } + } + assert(r != false); } @@ -180,7 +201,19 @@ test(void *c) } entry->tid = context->tid; - r = ck_ring_enqueue_spmc(ring + context->tid, entry); + + if (i & 1) { + r = ck_ring_enqueue_spmc(ring + context->tid, + entry); + } else { + r = ck_ring_enqueue_spmc_size(ring + context->tid, + entry, &s); + + if ((int)s >= size) { + ck_error("Size %u out of range of %d\n", + s, size); + } + } assert(r == true); } } @@ -268,8 +301,21 @@ main(int argc, char *argv[]) entry->ref = 0; /* Wait until queue is not full. */ - while (ck_ring_enqueue_spmc(&ring_spmc, entry) == false) - ck_pr_stall(); + if (l & 1) { + while (ck_ring_enqueue_spmc(&ring_spmc, entry) == false) + ck_pr_stall(); + } else { + unsigned int s; + + while (ck_ring_enqueue_spmc_size(&ring_spmc, + entry, &s) == false) { + ck_pr_stall(); + } + + if ((int)s >= (size * ITERATIONS * (nthr - 1))) { + ck_error("MPMC: Unexpected size of %u\n", s); + } + } } for (i = 0; i < nthr - 1; i++) diff --git a/regressions/ck_ring/validate/ck_ring_spmc_template.c b/regressions/ck_ring/validate/ck_ring_spmc_template.c index f284710..08a7eb1 100644 --- a/regressions/ck_ring/validate/ck_ring_spmc_template.c +++ b/regressions/ck_ring/validate/ck_ring_spmc_template.c @@ -121,6 +121,7 @@ test(void *c) { struct context *context = c; struct entry entry; + unsigned int s; int i, j; bool r; ck_barrier_centralized_state_t sense = @@ -141,7 +142,19 @@ test(void *c) memset(&entry, 0, sizeof(entry)); entry.value = i; - r = CK_RING_ENQUEUE_SPMC(spmc_ring, ring, &entry); + if (i & 1) { + r = CK_RING_ENQUEUE_SPMC(spmc_ring, ring, + &entry); + } else { + r = CK_RING_ENQUEUE_SPMC_SIZE(spmc_ring, ring, + &entry, &s); + + if ((int)s != i) { + ck_error("Size %u, expected %d.\n", + s, i); + } + } + assert(r != false); } diff --git a/regressions/ck_ring/validate/ck_ring_spsc.c b/regressions/ck_ring/validate/ck_ring_spsc.c index c54bf9e..080f9c7 100644 --- a/regressions/ck_ring/validate/ck_ring_spsc.c +++ b/regressions/ck_ring/validate/ck_ring_spsc.c @@ -59,6 +59,7 @@ test(void *c) { struct context *context = c; struct entry *entry; + unsigned int s; int i, j; bool r; ck_barrier_centralized_state_t sense = @@ -84,7 +85,18 @@ test(void *c) entries[i].value = i; entries[i].tid = 0; - r = ck_ring_enqueue_spsc(ring, entries + i); + if (i & 1) { + r = ck_ring_enqueue_spsc(ring, entries + i); + } else { + r = ck_ring_enqueue_spsc_size(ring, + entries + i, &s); + + if ((int)s != i) { + ck_error("Size is %u, expected %d\n", + s, i + 1); + } + } + assert(r != false); } @@ -116,7 +128,18 @@ test(void *c) } entry->tid = context->tid; - r = ck_ring_enqueue_spsc(ring + context->tid, entry); + if (i & 1) { + r = ck_ring_enqueue_spsc(ring + context->tid, + entry); + } else { + r = ck_ring_enqueue_spsc_size(ring + + context->tid, entry, &s); + + if ((int)s >= size) { + ck_error("Size %u is out of range %d\n", + s, size); + } + } assert(r == true); } } diff --git a/regressions/ck_ring/validate/ck_ring_spsc_template.c b/regressions/ck_ring/validate/ck_ring_spsc_template.c index 0cc0f69..6b4b4c5 100644 --- a/regressions/ck_ring/validate/ck_ring_spsc_template.c +++ b/regressions/ck_ring/validate/ck_ring_spsc_template.c @@ -60,6 +60,7 @@ test(void *c) { struct context *context = c; struct entry entry; + unsigned int s; int i, j; bool r; ck_barrier_centralized_state_t sense = @@ -85,7 +86,20 @@ test(void *c) entries[i].value = i; entries[i].tid = 0; - r = CK_RING_ENQUEUE_SPSC(entry_ring, ring, entries + i); + if (i & 1) { + r = CK_RING_ENQUEUE_SPSC(entry_ring, + ring, entries + i); + } else { + r = CK_RING_ENQUEUE_SPSC_SIZE(entry_ring, + ring, entries + i, &s); + + if ((int)s != i) { + ck_error("Size is %u, expected %d\n", + s, i); + } + } + + assert(r != false); } if (CK_RING_SIZE(entry_ring, ring) != @@ -113,7 +127,20 @@ test(void *c) } entry.tid = context->tid; - r = CK_RING_ENQUEUE_SPSC(entry_ring, ring + context->tid, &entry); + + if (i & 1) { + r = CK_RING_ENQUEUE_SPSC(entry_ring, + ring + context->tid, &entry); + } else { + r = CK_RING_ENQUEUE_SPSC_SIZE(entry_ring, + ring + context->tid, &entry, &s); + + if ((int)s >= size) { + ck_error("Size %u is out of range %d\n", + s, size); + } + } + assert(r == true); } } From 34a5bf4266e4c730c42f086b6c425ae2bffd8f3d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 28 Mar 2013 13:50:32 -0400 Subject: [PATCH 16/60] regressions/ck_cohort: Whitespace cleanup. --- regressions/ck_cohort/ck_cohort.h | 39 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/regressions/ck_cohort/ck_cohort.h b/regressions/ck_cohort/ck_cohort.h index 847544c..4194c2e 100644 --- a/regressions/ck_cohort/ck_cohort.h +++ b/regressions/ck_cohort/ck_cohort.h @@ -1,25 +1,24 @@ #define LOCK_NAME "ck_cohort" -#define LOCK_DEFINE\ - static ck_spinlock_fas_t global_fas_lock = CK_SPINLOCK_FAS_INITIALIZER;\ - static ck_spinlock_fas_t local_fas_lock = CK_SPINLOCK_FAS_INITIALIZER;\ - static void\ - ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context)\ - {\ - (void)context;\ - ck_spinlock_fas_lock(lock);\ - }\ -\ - static void\ - ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context)\ - {\ - (void)context;\ - ck_spinlock_fas_unlock(lock);\ - }\ - CK_COHORT_PROTOTYPE(fas_fas,\ - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context,\ - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context)\ +#define LOCK_DEFINE \ + static ck_spinlock_fas_t global_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; \ + static ck_spinlock_fas_t local_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; \ + static void \ + ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) \ + { \ + (void)context; \ + ck_spinlock_fas_lock(lock); \ + } \ + static void \ + ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) \ + { \ + (void)context; \ + ck_spinlock_fas_unlock(lock); \ + } \ + CK_COHORT_PROTOTYPE(fas_fas, \ + ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, \ + ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context) \ static CK_COHORT_INSTANCE(fas_fas) CK_CC_CACHELINE cohort = CK_COHORT_INITIALIZER -#define LOCK_INIT CK_COHORT_INIT(fas_fas, &cohort, &global_fas_lock, &local_fas_lock,\ +#define LOCK_INIT CK_COHORT_INIT(fas_fas, &cohort, &global_fas_lock, &local_fas_lock, \ CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT) #define LOCK CK_COHORT_LOCK(fas_fas, &cohort, NULL, NULL) #define UNLOCK CK_COHORT_UNLOCK(fas_fas, &cohort, NULL, NULL) From 72aa172de01dab93b9cb41d94961503dbb01f198 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 28 Mar 2013 14:37:50 -0400 Subject: [PATCH 17/60] Bump version for next release. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 19b6739..0af1d80 100755 --- a/configure +++ b/configure @@ -33,7 +33,7 @@ EXIT_FAILURE=1 P_PWD=`pwd` MAINTAINER='sbahra@repnop.org' -VERSION=${VERSION:-'0.2.15'} +VERSION=${VERSION:-'0.2.16'} VERSION_MAJOR='0' BUILD="$PWD/build/ck.build" PREFIX=${PREFIX:-"/usr/local"} From 19d1aa501f391e44deee9dcbb5647ab0f299b284 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 28 Mar 2013 14:44:48 -0400 Subject: [PATCH 18/60] build: Prepare version for next release. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0af1d80..c1400bd 100755 --- a/configure +++ b/configure @@ -33,7 +33,7 @@ EXIT_FAILURE=1 P_PWD=`pwd` MAINTAINER='sbahra@repnop.org' -VERSION=${VERSION:-'0.2.16'} +VERSION=${VERSION:-'0.2.17'} VERSION_MAJOR='0' BUILD="$PWD/build/ck.build" PREFIX=${PREFIX:-"/usr/local"} From d6fefccd6e2aaefce8831d6a44ee3483559bc9b3 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 28 Mar 2013 14:56:19 -0400 Subject: [PATCH 19/60] ck_pflock: Update comment, implementation is not so naive now. --- include/ck_pflock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ck_pflock.h b/include/ck_pflock.h index b352339..49a47ac 100644 --- a/include/ck_pflock.h +++ b/include/ck_pflock.h @@ -29,8 +29,8 @@ #define _CK_PFLOCK_H /* - * This is a naive implementation of phase-fair locks derived - * from the work described in: + * This is an implementation of phase-fair locks derived from the work + * described in: * Brandenburg, B. and Anderson, J. 2010. Spin-Based * Reader-Writer Synchronization for Multiprocessor Real-Time Systems */ From e827557ee979150de53dcb05493895c0aa4b2e27 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 29 Mar 2013 21:33:15 -0400 Subject: [PATCH 20/60] ck_hs: Whitespace change. --- include/ck_hs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/ck_hs.h b/include/ck_hs.h index 938266e..07db610 100644 --- a/include/ck_hs.h +++ b/include/ck_hs.h @@ -88,7 +88,8 @@ typedef struct ck_hs_iterator ck_hs_iterator_t; void ck_hs_iterator_init(ck_hs_iterator_t *); bool ck_hs_next(ck_hs_t *, ck_hs_iterator_t *, void **); -bool ck_hs_init(ck_hs_t *, unsigned int, ck_hs_hash_cb_t *, ck_hs_compare_cb_t *, struct ck_malloc *, unsigned long, unsigned long); +bool ck_hs_init(ck_hs_t *, unsigned int, ck_hs_hash_cb_t *, + ck_hs_compare_cb_t *, struct ck_malloc *, unsigned long, unsigned long); void ck_hs_destroy(ck_hs_t *); void *ck_hs_get(ck_hs_t *, unsigned long, const void *); bool ck_hs_put(ck_hs_t *, unsigned long, const void *); @@ -100,3 +101,4 @@ bool ck_hs_reset(ck_hs_t *); void ck_hs_stat(ck_hs_t *, struct ck_hs_stat *); #endif /* _CK_HS_H */ + From 758db2f3ac833afd23a282a97e9e4199c650a3c7 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 12:41:30 -0400 Subject: [PATCH 21/60] doc: Bd mismatch in ck_ht_stat. --- doc/ck_ht_stat | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/ck_ht_stat b/doc/ck_ht_stat index 8b9c00e..1d1f55d 100644 --- a/doc/ck_ht_stat +++ b/doc/ck_ht_stat @@ -47,6 +47,7 @@ struct ck_ht_stat { uint64_t probe_maximum; /* Longest read-side probe sequence. */ uint64_t n_entries; /* Current number of keys in hash set. */ }; +.Ed .Sh RETURN VALUES .Fn ck_ht_stat 3 has no return value. From 5186f1d50c73b6205721ee315b84620280fff608 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 12:52:29 -0400 Subject: [PATCH 22/60] doc: Fix various groff/nroff warnings. --- doc/ck_cohort | 2 +- doc/ck_epoch_barrier | 1 + doc/ck_epoch_call | 3 +-- doc/ck_epoch_synchronize | 1 + doc/ck_hs_destroy | 1 - doc/ck_hs_stat | 1 + 6 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/ck_cohort b/doc/ck_cohort index 91f6c1e..d6f4edf 100644 --- a/doc/ck_cohort +++ b/doc/ck_cohort @@ -188,7 +188,7 @@ main(void) return 0; } - +.Ed .Sh SEE ALSO .Xr CK_COHORT_PROTOTYPE 3 , .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , diff --git a/doc/ck_epoch_barrier b/doc/ck_epoch_barrier index c0087c0..e4b63ac 100644 --- a/doc/ck_epoch_barrier +++ b/doc/ck_epoch_barrier @@ -95,6 +95,7 @@ function(void) free(s); return; } +.Ed .Sh RETURN VALUES This function has no return value. .Sh ERRORS diff --git a/doc/ck_epoch_call b/doc/ck_epoch_call index 132b9d0..2736488 100644 --- a/doc/ck_epoch_call +++ b/doc/ck_epoch_call @@ -33,9 +33,7 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_epoch.h - typedef struct ck_epoch_entry ck_epoch_entry_t; - typedef void ck_epoch_cb_t(ck_epoch_entry_t *); .Ft void .Fn ck_epoch_call "ck_epoch_t *epoch" "ck_epoch_record_t *record" "ck_epoch_entry_t *entry" "ck_epoch_cb_t *function" @@ -114,6 +112,7 @@ function(void) ck_epoch_poll(&epoch, record); return; } +.Ed .Sh RETURN VALUES This function has no return value. .Sh ERRORS diff --git a/doc/ck_epoch_synchronize b/doc/ck_epoch_synchronize index 08bd4f0..e1b8ab3 100644 --- a/doc/ck_epoch_synchronize +++ b/doc/ck_epoch_synchronize @@ -99,6 +99,7 @@ function(void) free(s); return; } +.Ed .Sh RETURN VALUES This function has no return value. .Sh ERRORS diff --git a/doc/ck_hs_destroy b/doc/ck_hs_destroy index 7d05b21..ad73575 100644 --- a/doc/ck_hs_destroy +++ b/doc/ck_hs_destroy @@ -43,7 +43,6 @@ function will request that the underlying allocator, as specified by the function, immediately destroy the object pointed to by the .Fa hs argument. - The user must guarantee that no threads are accessing the object pointed to by .Fa hs diff --git a/doc/ck_hs_stat b/doc/ck_hs_stat index 1f89f9a..b4ad5a9 100644 --- a/doc/ck_hs_stat +++ b/doc/ck_hs_stat @@ -48,6 +48,7 @@ struct ck_hs_stat { unsigned long n_entries; /* Current number of keys in hash set. */ unsigned int probe_maximum; /* Longest read-side probe sequence. */ }; +.Ed .Sh RETURN VALUES .Fn ck_hs_stat 3 has no return value. From bbb375348c19de43c014bbf6cdc4d1d474346905 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 12:58:15 -0400 Subject: [PATCH 23/60] doc: Add man2html target for website. --- doc/Makefile.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/Makefile.in b/doc/Makefile.in index 6e61948..58634a2 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -5,6 +5,7 @@ GZIP=@GZIP@ GZIP_SUFFIX=.3@GZIP_SUFFIX@ BUILD_DIR=@BUILD_DIR@ SRC_DIR=@SRC_DIR@ +HTML_SUFFIX=.html OBJECTS=ck_ht_count \ ck_ht_destroy \ @@ -90,6 +91,12 @@ all: $(GZIP) $(SRC_DIR)/doc/$$target > $(BUILD_DIR)/doc/$$target$(GZIP_SUFFIX); \ done +html: + for target in $(OBJECTS); do \ + echo $$target; \ + groff -man -Tascii $(SRC_DIR)/doc/$$target | man2html -bare -compress -cgiurl='$$title.html' > $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ + done + install: mkdir -p $(DESTDIR)/$(MANDIR)/man3 || exit cp *$(GZIP_SUFFIX) $(DESTDIR)/$(MANDIR)/man3 || exit @@ -100,5 +107,5 @@ uninstall: done clean: - rm -f $(BUILD_DIR)/doc/*~ $(BUILD_DIR)/doc/*.3.gz + rm -f $(BUILD_DIR)/doc/*~ $(BUILD_DIR)/doc/*.3.gz $(BUILD_DIR)/doc/*.html From a5e127bbb835f1ef5836b944f6667c60fece1ac7 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 13:10:05 -0400 Subject: [PATCH 24/60] doc/html: Do not generate section headers. --- doc/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile.in b/doc/Makefile.in index 58634a2..ba81039 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -94,7 +94,7 @@ all: html: for target in $(OBJECTS); do \ echo $$target; \ - groff -man -Tascii $(SRC_DIR)/doc/$$target | man2html -bare -compress -cgiurl='$$title.html' > $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ + groff -man -Tascii $(SRC_DIR)/doc/$$target | man2html -noheads -bare -compress -cgiurl='$$title.html' > $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ done install: From 6d51ae712c5dc0a237acef9facc33d120f50e9b2 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 13:56:39 -0400 Subject: [PATCH 25/60] doc/ck_cohort: Various fixes to manual pages. --- doc/CK_COHORT_INIT | 2 +- doc/CK_COHORT_INSTANCE | 2 +- doc/CK_COHORT_LOCK | 2 +- doc/CK_COHORT_PROTOTYPE | 2 +- doc/CK_COHORT_TRYLOCK | 2 +- doc/CK_COHORT_TRYLOCK_PROTOTYPE | 2 +- doc/CK_COHORT_UNLOCK | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/CK_COHORT_INIT b/doc/CK_COHORT_INIT index 5f367de..8d1bd4d 100644 --- a/doc/CK_COHORT_INIT +++ b/doc/CK_COHORT_INIT @@ -28,7 +28,7 @@ .Dt CK_COHORT_INIT 3 .Sh NAME .Nm CK_COHORT_INIT -.Nd Initialize an instance of a cohort type +.Nd initialize instance of a cohort type .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS diff --git a/doc/CK_COHORT_INSTANCE b/doc/CK_COHORT_INSTANCE index ca622a0..bc5a893 100644 --- a/doc/CK_COHORT_INSTANCE +++ b/doc/CK_COHORT_INSTANCE @@ -28,7 +28,7 @@ .Dt CK_COHORT_INSTANCE 3 .Sh NAME .Nm CK_COHORT_INSTANCE -.Nd Declare an instance of a cohort type +.Nd declare an instance of a cohort type .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS diff --git a/doc/CK_COHORT_LOCK b/doc/CK_COHORT_LOCK index a1e42e5..5e0f594 100644 --- a/doc/CK_COHORT_LOCK +++ b/doc/CK_COHORT_LOCK @@ -28,7 +28,7 @@ .Dt CK_COHORT_LOCK 3 .Sh NAME .Nm CK_COHORT_LOCK -.Nd Acquire a cohort's locks +.Nd acquire cohort lock .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS diff --git a/doc/CK_COHORT_PROTOTYPE b/doc/CK_COHORT_PROTOTYPE index e8766af..eb70b1e 100644 --- a/doc/CK_COHORT_PROTOTYPE +++ b/doc/CK_COHORT_PROTOTYPE @@ -28,7 +28,7 @@ .Dt CK_COHORT_PROTOTYPE 3 .Sh NAME .Nm CK_COHORT_PROTOTYPE -.Nd Define a cohort type with the given lock types +.Nd define cohort type with specified lock types .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS diff --git a/doc/CK_COHORT_TRYLOCK b/doc/CK_COHORT_TRYLOCK index 55959df..936a33b 100644 --- a/doc/CK_COHORT_TRYLOCK +++ b/doc/CK_COHORT_TRYLOCK @@ -28,7 +28,7 @@ .Dt CK_COHORT_TRYLOCK 3 .Sh NAME .Nm CK_COHORT_TRYLOCK -.Nd Try to acquire a cohort's locks +.Nd try to acquire cohort lock .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS diff --git a/doc/CK_COHORT_TRYLOCK_PROTOTYPE b/doc/CK_COHORT_TRYLOCK_PROTOTYPE index 62f3e68..93063ac 100644 --- a/doc/CK_COHORT_TRYLOCK_PROTOTYPE +++ b/doc/CK_COHORT_TRYLOCK_PROTOTYPE @@ -28,7 +28,7 @@ .Dt CK_COHORT_TRYLOCK_PROTOTYPE 3 .Sh NAME .Nm CK_COHORT_TRYLOCK_PROTOTYPE -.Nd Define a cohort type with the given lock types +.Nd define cohort type with specified lock types .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS diff --git a/doc/CK_COHORT_UNLOCK b/doc/CK_COHORT_UNLOCK index 7dca173..23401c8 100644 --- a/doc/CK_COHORT_UNLOCK +++ b/doc/CK_COHORT_UNLOCK @@ -28,7 +28,7 @@ .Dt CK_COHORT_UNLOCK 3 .Sh NAME .Nm CK_COHORT_UNLOCK -.Nd Acquire a cohort's locks +.Nd release cohort lock .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS From ab18c9d3c93ffab9e66c5f674a3c368cee24fcb3 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 14:05:02 -0400 Subject: [PATCH 26/60] doc/ck_hs_destroy: Fix summary typo. --- doc/ck_hs_destroy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ck_hs_destroy b/doc/ck_hs_destroy index ad73575..33d1f70 100644 --- a/doc/ck_hs_destroy +++ b/doc/ck_hs_destroy @@ -28,7 +28,7 @@ .Dt CK_HS_DESTROY 3 .Sh NAME .Nm ck_hs_destroy -.Nd initialize a hash set +.Nd destroy hash set .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS From 19afbfb362211f4a37b621ce6c17ead454ed5fd5 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 14:06:11 -0400 Subject: [PATCH 27/60] doc/ck_cohort: Fix style issue. --- doc/ck_cohort | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ck_cohort b/doc/ck_cohort index d6f4edf..011ca1b 100644 --- a/doc/ck_cohort +++ b/doc/ck_cohort @@ -28,7 +28,7 @@ .Dt ck_cohort 3 .Sh NAME .Nm ck_cohort -.Nd Generalized interface for lock cohorts +.Nd generalized interface for lock cohorts .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS From 679d5e94f76143f1a0aa2a14e7cf0970917472b0 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 14:11:04 -0400 Subject: [PATCH 28/60] doc/ck_bag_set_spmc: Shorten summary, fix style. --- doc/ck_bag_set_spmc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ck_bag_set_spmc b/doc/ck_bag_set_spmc index 4da8992..7bf262e 100644 --- a/doc/ck_bag_set_spmc +++ b/doc/ck_bag_set_spmc @@ -29,7 +29,7 @@ .Dt CK_BAG_SET_SPMC 3 .Sh NAME .Nm ck_bag_set_spmc -.Nd Replace the first occurence of a value in a bag. Insert value into the bag if value didn't previously exist. +.Nd replace the first occurence of a value in a bag .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS From 51eca10f408f36d9bcf784fbc6c35177f0f5d73e Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 7 Apr 2013 21:14:06 -0400 Subject: [PATCH 29/60] doc: Beginnings of ck_pr documentation. --- doc/Makefile.in | 10 +++- doc/ck_pr | 69 ++++++++++++++++++++++ doc/ck_pr_barrier | 66 +++++++++++++++++++++ doc/ck_pr_fas | 90 ++++++++++++++++++++++++++++ doc/ck_pr_fence_load | 108 ++++++++++++++++++++++++++++++++++ doc/ck_pr_fence_load_depends | 70 ++++++++++++++++++++++ doc/ck_pr_fence_memory | 111 +++++++++++++++++++++++++++++++++++ doc/ck_pr_fence_store | 107 +++++++++++++++++++++++++++++++++ doc/ck_pr_stall | 86 +++++++++++++++++++++++++++ 9 files changed, 716 insertions(+), 1 deletion(-) create mode 100644 doc/ck_pr create mode 100644 doc/ck_pr_barrier create mode 100644 doc/ck_pr_fas create mode 100644 doc/ck_pr_fence_load create mode 100644 doc/ck_pr_fence_load_depends create mode 100644 doc/ck_pr_fence_memory create mode 100644 doc/ck_pr_fence_store create mode 100644 doc/ck_pr_stall diff --git a/doc/Makefile.in b/doc/Makefile.in index ba81039..aa08f0a 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -84,7 +84,15 @@ OBJECTS=ck_ht_count \ CK_COHORT_INIT \ CK_COHORT_LOCK \ CK_COHORT_UNLOCK \ - CK_COHORT_TRYLOCK + CK_COHORT_TRYLOCK \ + ck_pr \ + ck_pr_barrier \ + ck_pr_fas \ + ck_pr_fence_load \ + ck_pr_fence_load_depends \ + ck_pr_fence_memory \ + ck_pr_fence_store \ + ck_pr_stall all: for target in $(OBJECTS); do \ diff --git a/doc/ck_pr b/doc/ck_pr new file mode 100644 index 0000000..ad77a47 --- /dev/null +++ b/doc/ck_pr @@ -0,0 +1,69 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr 3 +.Sh NAME +.Nm ck_pr +.Nd concurrency primitives interface +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Sh DESCRIPTION +ck_pr.h provides an interface to volatile atomic instructions, +memory barriers and busy-wait facilities as provided by the +underlying processor. The presence of an atomic operation +is detected by the presence of a corresponding CK_F_PR macro. +For example, the availability of +.Xr ck_pr_add_16 3 +would be determined by the presence of CK_F_PR_ADD_16. +.Sh SEE ALSO +.Xr ck_pr_stall 3 , +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_barrier 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_barrier b/doc/ck_pr_barrier new file mode 100644 index 0000000..128bf38 --- /dev/null +++ b/doc/ck_pr_barrier @@ -0,0 +1,66 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_barrier 3 +.Sh NAME +.Nm ck_pr_barrier +.Nd compiler optimization barrier +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_barrier void +.Sh DESCRIPTION +The +.Fn ck_pr_barrier 3 +function is used to disable code movement optimizations +across the invocation of the function. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fas b/doc/ck_pr_fas new file mode 100644 index 0000000..d51a447 --- /dev/null +++ b/doc/ck_pr_fas @@ -0,0 +1,90 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_fas 3 +.Sh NAME +.Nm ck_pr_fas +.Nd atomic swap operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void * +.Fn ck_pr_fas_ptr "void *target" "void *new_value" +.Ft double +.Fn ck_pr_fas_double "double *target" "double new_value" +.Ft char +.Fn ck_pr_fas_char "char *target" "char new_value" +.Ft unsigned int +.Fn ck_pr_fas_uint "unsigned int *target" "unsigned int new_value" +.Ft int +.Fn ck_pr_fas_int "int *target" "int new_value" +.Ft uint64_t +.Fn ck_pr_fas_64 "uint64_t *target" "uint64_t new_value" +.Ft uint32_t +.Fn ck_pr_fas_32 "uint32_t *target" "uint32_t new_value" +.Ft uint16_t +.Fn ck_pr_fas_16 "uint16_t *target" "uint16_t new_value" +.Ft uint8_t +.Fn ck_pr_fas_8 "uint8_t *target" "uint8_t new_value" +.Sh DESCRIPTION +The +.Fn ck_pr_fas 3 +function will atomically fetch the value pointed to +by +.Fa target +and then replace it with the value specified by +.Fa new_value . +.Sh RETURN VALUES +This function will return the value pointed to by +.Fa target +at the time of operation invocation before it was +atomically replaced with +.Fa new_value . +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_load b/doc/ck_pr_fence_load new file mode 100644 index 0000000..44431a1 --- /dev/null +++ b/doc/ck_pr_fence_load @@ -0,0 +1,108 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_fence_load 3 +.Sh NAME +.Nm ck_pr_fence_load +.Nd enforce partial ordering of load operations +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_fence_load void +.Ft void +.Fn ck_pr_fence_strict_load void +.Sh DESCRIPTION +This function will enforce the ordering of any memory load +and +.Fn ck_pr_load 3 +operations relative to the invocation of the function. Any +store operations that were committed on remote processors +and received by the calling processor before the invocation of +.Fn ck_pr_fence_load +will also be made visible only after a call to +.Fn ck_pr_fence_load . +This function will always serve as an implicit compiler barrier. +On architectures with CK_MD_TSO or CK_MD_PSO specified (total store ordering +and partial store ordering respectively), this operation will only serve +as a compiler barrier and no fence instructions will be emitted. To +force the unconditional emission of a load fence, use +.Fn ck_pr_fence_strict_load . +Architectures implementing CK_MD_RMO will always emit a load fence. +.Sh EXAMPLE +.Bd -literal -offset indent + +#include + +static unsigned int a; +static unsigned int b; + +void +function(void) +{ + unsigned int snapshot_a, snapshot_b; + + snapshot_a = ck_pr_load_uint(&a); + + /* + * Guarantee that the load from "a" completes + * before the load from "b". + */ + ck_pr_fence_load(); + snapshot_b = ck_pr_load_uint(&b); + + return; +} +.Ed +.Sh RETURN VALUES +This function has no return value. +.Sh SEE ALSO +.Xr ck_pr_stall 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_barrier 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_load_depends b/doc/ck_pr_fence_load_depends new file mode 100644 index 0000000..7a98389 --- /dev/null +++ b/doc/ck_pr_fence_load_depends @@ -0,0 +1,70 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_fence_load_depends 3 +.Sh NAME +.Nm ck_pr_fence_load_depends +.Nd data dependency barrier +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_fence_load_depends void +.Sh DESCRIPTION +The +.Fn ck_pr_fence_load_depends 3 +emits necessary fences for pure data-dependent loads. It currently only serves as a compiler +barrier for Concurrency Kit's supported platforms. Unless you're on architecture +which re-orders data-dependent loads (such as the defunct Alpha), this function is unnecessary. +.Sh RETURN VALUES +This function has no return value. +.Sh SEE ALSO +.Xr ck_pr_stall 3 , +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_barrier 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_memory b/doc/ck_pr_fence_memory new file mode 100644 index 0000000..eab10ae --- /dev/null +++ b/doc/ck_pr_fence_memory @@ -0,0 +1,111 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_fence_memory 3 +.Sh NAME +.Nm ck_pr_fence_memory +.Nd enforce partial ordering of all memory operations +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_fence_memory +.Ft void +.Fn ck_pr_fence_strict_memory +.Sh DESCRIPTION +The +.Fn ck_pr_fence_memory 3 +function will enforce the ordering of any memory operations +with respect to the invocation of the function. This function +will always serve as an implicit compiler barrier. +Achitectures implementing CK_MD_TSO will +only have this function serve as a compiler barrier and +no fence instructions will be emitted. Architectures +implementing CK_MD_PSO and CK_MD_RMO will always emit +an instructions which provides the specified ordering +guarantees. To force the unconditional emission of a memory +fence, use +.Fn ck_pr_fence_strict_memory . +.Sh EXAMPLE +.Bd -literal -offset indent + +#include + +static int a = 0; +static int b; +static int c; +static int d; + +void +function(void) +{ + int snapshot_a; + + ck_pr_store_int(&b, 1); + snapshot_a = ck_pr_load_int(&a); + + /* + * Make sure previous memory operations are + * ordered with respect to memory operations + * following the ck_pr_fence_memory. + */ + ck_pr_fence_memory(); + + ck_pr_store_int(&d, 3); + ck_pr_store_int(&c, 2); + + return; +} +.Ed +.Sh RETURN VALUES +This function has no return value. +.Sh SEE ALSO +.Xr ck_pr_stall 3 , +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_barrier 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_store b/doc/ck_pr_fence_store new file mode 100644 index 0000000..5bc0e6c --- /dev/null +++ b/doc/ck_pr_fence_store @@ -0,0 +1,107 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_fence_store 3 +.Sh NAME +.Nm ck_pr_fence_store +.Nd enforce partial ordering of store operations +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_fence_store void +.Ft void +.Fn ck_pr_fence_strict_store void +.Sh DESCRIPTION +The +.Fn ck_pr_fence_store +function will enfore the ordering of any memory store, +.Fn ck_pr_store +and atomic read-modify-write operations relative to +the invocation of the function. This function will +always serve as an implicit compiler barrier. On +architectures implementing CK_MD_TSO, this operation +will only serve as a compiler barrier and no fences +will be emitted. On architectures implementing +CK_MD_PSO and CK_MD_RMO, a store fence will be +emitted. To force the unconditional emission of +a store fence, use +.Fn ck_pr_fence_strict_store . +.Sh EXAMPLE +.Bd -literal -offset indent + +#include + +static int a = 0; +static int b = 0; +static int c = 0; + +void +function(void) +{ + + ck_pr_store_int(&a, 1); + + /* + * Guarantee that the store to a is completed + * with respect to the stores of b and c. + */ + ck_pr_fence_store(); + ck_pr_store_int(&b, 2); + ck_pr_store_int(&c, 2); + + return; +} +.Ed +.Sh RETURN VALUES +This function has no return value. +.Sh SEE ALSO +.Xr ck_pr_stall 3 , +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_barrier 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_stall b/doc/ck_pr_stall new file mode 100644 index 0000000..762a739 --- /dev/null +++ b/doc/ck_pr_stall @@ -0,0 +1,86 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_stall 3 +.Sh NAME +.Nm ck_pr_stall +.Nd busy-wait primitive +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_stall void +.Sh DESCRIPTION +The +.Fn ck_pr_stall 3 +function should be used inside retry paths of busy-wait loops. +It not only serves as a compiler barrier, but on some architectures +it emits cycle-saving instructions. +.Sh EXAMPLE +.Bd -literal -offset indent + +#include + +static int ready = 0; + +void +function(void) +{ + + /* Busy-wait until ready is non-zero. */ + while (ck_pr_load_int(&ready) == 0) + ck_pr_stall(); + + return; +} +.Ed +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_barrier 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ From ef2ad6b9988a9f03aa2a2961b4e0950e7e2e1ec8 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Tue, 9 Apr 2013 13:00:42 -0400 Subject: [PATCH 30/60] regressions: Implement common_gettimeofday. Windows uses GetSystemTimeAsFileTime, which has some differences with Unix' gettimeofday. This commit also reduces the number of iterations for the ck_ticket_pb validation to 1000 - the test was taking too long on MinGW systems. --- .../ck_spinlock/validate/ck_ticket_pb.c | 4 ++ regressions/ck_stack/validate/pair.c | 4 +- regressions/ck_stack/validate/pop.c | 4 +- regressions/ck_stack/validate/push.c | 4 +- regressions/common.h | 45 +++++++++++++++++++ 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/regressions/ck_spinlock/validate/ck_ticket_pb.c b/regressions/ck_spinlock/validate/ck_ticket_pb.c index e62ee0e..28cba32 100644 --- a/regressions/ck_spinlock/validate/ck_ticket_pb.c +++ b/regressions/ck_spinlock/validate/ck_ticket_pb.c @@ -1,2 +1,6 @@ #include "../ck_ticket_pb.h" +#ifdef _WIN32 +#undef ITERATE +#define ITERATE 1000 +#endif #include "validate.h" diff --git a/regressions/ck_stack/validate/pair.c b/regressions/ck_stack/validate/pair.c index c26b11c..f4adae5 100644 --- a/regressions/ck_stack/validate/pair.c +++ b/regressions/ck_stack/validate/pair.c @@ -233,11 +233,11 @@ main(int argc, char *argv[]) for (i = 0; i < nthr; i++) pthread_create(&thread[i], NULL, stack_thread, bucket + i); - gettimeofday(&stv, NULL); + common_gettimeofday(&stv, NULL); barrier = 1; for (i = 0; i < nthr; i++) pthread_join(thread[i], NULL); - gettimeofday(&etv, NULL); + common_gettimeofday(&etv, NULL); stack_assert(); printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); diff --git a/regressions/ck_stack/validate/pop.c b/regressions/ck_stack/validate/pop.c index 3d06aef..5881bfa 100644 --- a/regressions/ck_stack/validate/pop.c +++ b/regressions/ck_stack/validate/pop.c @@ -253,11 +253,11 @@ main(int argc, char *argv[]) for (i = 0; i < nthr; i++) pthread_create(&thread[i], NULL, stack_thread, NULL); - gettimeofday(&stv, NULL); + common_gettimeofday(&stv, NULL); barrier = 1; for (i = 0; i < nthr; i++) pthread_join(thread[i], NULL); - gettimeofday(&etv, NULL); + common_gettimeofday(&etv, NULL); stack_assert(); printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); diff --git a/regressions/ck_stack/validate/push.c b/regressions/ck_stack/validate/push.c index 44d515b..9b5ae7e 100644 --- a/regressions/ck_stack/validate/push.c +++ b/regressions/ck_stack/validate/push.c @@ -232,11 +232,11 @@ main(int argc, char *argv[]) for (i = 0; i < nthr; i++) pthread_create(&thread[i], NULL, stack_thread, bucket + i * n); - gettimeofday(&stv, NULL); + common_gettimeofday(&stv, NULL); barrier = 1; for (i = 0; i < nthr; i++) pthread_join(thread[i], NULL); - gettimeofday(&etv, NULL); + common_gettimeofday(&etv, NULL); stack_assert(); printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); diff --git a/regressions/common.h b/regressions/common.h index 98e0901..1cdc174 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -41,9 +41,12 @@ #if defined(_WIN32) #include +#include #include +#define DELTA_EPOCH 11644473600000000ULL #else #include +#include #include #endif @@ -127,6 +130,48 @@ common_sleep(unsigned int n) #endif } +CK_CC_INLINE static int +common_gettimeofday(struct timeval *tv, void *tz) +{ +#ifdef _WIN32 + FILETIME ft; + uint64_t tmp_time = 0; + static bool tzflag = false; + + if (tv != NULL) { + GetSystemTimeAsFileTime(&ft); + tmp_time |= ft.dwHighDateTime; + tmp_time <<= 32; + tmp_time |= ft.dwLowDateTime; + + /* GetSystemTimeAsFileTime returns 100 nanosecond intervals. */ + tmp_time /= 10; + + /* Windows' epoch starts on 01/01/1601, while Unix' starts on 01/01/1970. */ + tmp_time -= DELTA_EPOCH; + } + + tv->tv_sec = (long)(tmp_time / 1000000UL); + tv->tv_usec = (long)(tmp_time % 1000000UL); + + if (tz != NULL) { + if (tzflag == false) { + _tzset(); + tzflag = true; + } + + struct timezone *tzp = (struct timezone *)tz; + + tzp->tz_minuteswest = _timezone / 60; + tzp->tz_dsttime = _daylight; + } + + return 0; +#else + return gettimeofday(tv, tz); +#endif +} + CK_CC_UNUSED static unsigned int common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) { From 8c881905579ad07d869fdfa95c43559917abd422 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Tue, 9 Apr 2013 15:17:06 -0400 Subject: [PATCH 31/60] regressions: fix printing timevalues in MinGW. --- regressions/ck_stack/validate/pair.c | 4 ++++ regressions/ck_stack/validate/pop.c | 4 ++++ regressions/ck_stack/validate/push.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/regressions/ck_stack/validate/pair.c b/regressions/ck_stack/validate/pair.c index f4adae5..c0f1bb1 100644 --- a/regressions/ck_stack/validate/pair.c +++ b/regressions/ck_stack/validate/pair.c @@ -240,6 +240,10 @@ main(int argc, char *argv[]) common_gettimeofday(&etv, NULL); stack_assert(); +#ifdef _WIN32 + printf("%3llu %.6f\n", nthr, TVTOD(etv) - TVTOD(stv)); +#else printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); +#endif return 0; } diff --git a/regressions/ck_stack/validate/pop.c b/regressions/ck_stack/validate/pop.c index 5881bfa..c1f5809 100644 --- a/regressions/ck_stack/validate/pop.c +++ b/regressions/ck_stack/validate/pop.c @@ -260,6 +260,10 @@ main(int argc, char *argv[]) common_gettimeofday(&etv, NULL); stack_assert(); +#ifdef _WIN32 + printf("%3llu %.6f\n", nthr, TVTOD(etv) - TVTOD(stv)); +#else printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); +#endif return 0; } diff --git a/regressions/ck_stack/validate/push.c b/regressions/ck_stack/validate/push.c index 9b5ae7e..a2aa1db 100644 --- a/regressions/ck_stack/validate/push.c +++ b/regressions/ck_stack/validate/push.c @@ -239,6 +239,10 @@ main(int argc, char *argv[]) common_gettimeofday(&etv, NULL); stack_assert(); +#ifdef _WIN32 + printf("%3llu %.6f\n", nthr, TVTOD(etv) - TVTOD(stv)); +#else printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); +#endif return 0; } From ebc58ede20b4e35f5ea29d2e63d1a3d8049e64d0 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Tue, 9 Apr 2013 15:48:05 -0400 Subject: [PATCH 32/60] regressions: fix common_gettimeofday. Accidentally moved code that sets tv_sec/usec outside of tv NULL check. --- regressions/common.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index 1cdc174..e6f9f5a 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -149,10 +149,11 @@ common_gettimeofday(struct timeval *tv, void *tz) /* Windows' epoch starts on 01/01/1601, while Unix' starts on 01/01/1970. */ tmp_time -= DELTA_EPOCH; + + tv->tv_sec = (long)(tmp_time / 1000000UL); + tv->tv_usec = (long)(tmp_time % 1000000UL); } - tv->tv_sec = (long)(tmp_time / 1000000UL); - tv->tv_usec = (long)(tmp_time % 1000000UL); if (tz != NULL) { if (tzflag == false) { From 25c99e806b6b846a96a438faad6203fe4d2f465f Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 10 Apr 2013 23:56:32 -0400 Subject: [PATCH 33/60] doc/ck_pr: Additional documentation. --- doc/Makefile.in | 5 ++- doc/ck_pr_dec | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_faa | 91 +++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_fas | 6 ++- doc/ck_pr_inc | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 311 insertions(+), 3 deletions(-) create mode 100644 doc/ck_pr_dec create mode 100644 doc/ck_pr_faa create mode 100644 doc/ck_pr_inc diff --git a/doc/Makefile.in b/doc/Makefile.in index aa08f0a..6b941b0 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -92,7 +92,10 @@ OBJECTS=ck_ht_count \ ck_pr_fence_load_depends \ ck_pr_fence_memory \ ck_pr_fence_store \ - ck_pr_stall + ck_pr_stall \ + ck_pr_faa \ + ck_pr_inc \ + ck_pr_dec all: for target in $(OBJECTS); do \ diff --git a/doc/ck_pr_dec b/doc/ck_pr_dec new file mode 100644 index 0000000..afd5dcc --- /dev/null +++ b/doc/ck_pr_dec @@ -0,0 +1,106 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_dec 3 +.Sh NAME +.Nm ck_pr_dec +.Nd atomic decrement operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_dec_ptr "void *target" +.Ft bool +.Fn ck_pr_dec_ptr_zero "void *target" +.Ft void +.Fn ck_pr_dec_double "double *target" +.Ft bool +.Fn ck_pr_dec_double_zero "double *target" +.Ft void +.Fn ck_pr_dec_char "char *target" +.Ft bool +.Fn ck_pr_dec_char_zero "char *target" +.Ft void +.Fn ck_pr_dec_uint "unsigned int *target" +.Ft bool +.Fn ck_pr_dec_uint_zero "unsigned int *target" +.Ft void +.Fn ck_pr_dec_int "int *target" +.Ft bool +.Fn ck_pr_dec_int_zero "int *target" +.Ft void +.Fn ck_pr_dec_64 "uint64_t *target" +.Ft bool +.Fn ck_pr_dec_64_zero "uint64_t *target" +.Ft void +.Fn ck_pr_dec_32 "uint32_t *target" +.Ft bool +.Fn ck_pr_dec_32_zero "uint32_t *target" +.Ft void +.Fn ck_pr_dec_16 "uint16_t *target" +.Ft bool +.Fn ck_pr_dec_16_zero "uint16_t *target" +.Ft void +.Fn ck_pr_dec_8 "uint8_t *target" +.Ft bool +.Fn ck_pr_dec_8_zero "uint8_t *target" +.Sh DESCRIPTION +The +.Fn ck_pr_dec 3 +family of functions will atomically decrement the value pointed to +by +.Fa target . +.Sh RETURN VALUES +The +.Fn ck_pr_dec_*_zero +family of functions will return true if the result +of the decrement operation was 0. They will return +false otherwise. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_faa b/doc/ck_pr_faa new file mode 100644 index 0000000..491eabc --- /dev/null +++ b/doc/ck_pr_faa @@ -0,0 +1,91 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_faa 3 +.Sh NAME +.Nm ck_pr_faa +.Nd atomic fetch-and-add operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft uintptr_t +.Fn ck_pr_faa_ptr "void *target" "uintptr_t delta" +.Ft double +.Fn ck_pr_faa_double "double *target" "double delta" +.Ft char +.Fn ck_pr_faa_char "char *target" "char delta" +.Ft unsigned int +.Fn ck_pr_faa_uint "unsigned int *target" "unsigned int delta" +.Ft int +.Fn ck_pr_faa_int "int *target" "int delta" +.Ft uint64_t +.Fn ck_pr_faa_64 "uint64_t *target" "uint64_t delta" +.Ft uint32_t +.Fn ck_pr_faa_32 "uint32_t *target" "uint32_t delta" +.Ft uint16_t +.Fn ck_pr_faa_16 "uint16_t *target" "uint16_t delta" +.Ft uint8_t +.Fn ck_pr_faa_8 "uint8_t *target" "uint8_t delta" +.Sh DESCRIPTION +The +.Fn ck_pr_faa 3 +family of functions will atomically fetch the value pointed to +by +.Fa target +and add the value specified by +.Fa delta +to the value pointed to by +.Fa target . +.Sh RETURN VALUES +This function will return the value pointed to by +.Fa target +at the time of operation invocation before the +addition operation is applied. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fas b/doc/ck_pr_fas index d51a447..89d7f88 100644 --- a/doc/ck_pr_fas +++ b/doc/ck_pr_fas @@ -54,10 +54,12 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_fas 3 -function will atomically fetch the value pointed to +family of functions will atomically fetch the value pointed to by .Fa target -and then replace it with the value specified by +and replace the value pointed to by +.Fa target +with the value specified by .Fa new_value . .Sh RETURN VALUES This function will return the value pointed to by diff --git a/doc/ck_pr_inc b/doc/ck_pr_inc new file mode 100644 index 0000000..cdc9798 --- /dev/null +++ b/doc/ck_pr_inc @@ -0,0 +1,106 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_inc 3 +.Sh NAME +.Nm ck_pr_inc +.Nd atomic increment operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_inc_ptr "void *target" +.Ft bool +.Fn ck_pr_inc_ptr_zero "void *target" +.Ft void +.Fn ck_pr_inc_double "double *target" +.Ft bool +.Fn ck_pr_inc_double_zero "double *target" +.Ft void +.Fn ck_pr_inc_char "char *target" +.Ft bool +.Fn ck_pr_inc_char_zero "char *target" +.Ft void +.Fn ck_pr_inc_uint "unsigned int *target" +.Ft bool +.Fn ck_pr_inc_uint_zero "unsigned int *target" +.Ft void +.Fn ck_pr_inc_int "int *target" +.Ft bool +.Fn ck_pr_inc_int_zero "int *target" +.Ft void +.Fn ck_pr_inc_64 "uint64_t *target" +.Ft bool +.Fn ck_pr_inc_64_zero "uint64_t *target" +.Ft void +.Fn ck_pr_inc_32 "uint32_t *target" +.Ft bool +.Fn ck_pr_inc_32_zero "uint32_t *target" +.Ft void +.Fn ck_pr_inc_16 "uint16_t *target" +.Ft bool +.Fn ck_pr_inc_16_zero "uint16_t *target" +.Ft void +.Fn ck_pr_inc_8 "uint8_t *target" +.Ft bool +.Fn ck_pr_inc_8_zero "uint8_t *target" +.Sh DESCRIPTION +The +.Fn ck_pr_inc 3 +family of functions will atomically increment the value pointed to +by +.Fa target . +.Sh RETURN VALUES +The +.Fn ck_pr_inc_*_zero +family of functions will return true if the result +of the increment operation was 0. They will return +false otherwise. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ From 6a42ad9bde3c526bfb2ae0e338dc401e88d24e10 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 00:05:37 -0400 Subject: [PATCH 34/60] doc/ck_pr: Additional documentation and targets. --- doc/Makefile.in | 4 +- doc/ck_pr_neg | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_not | 84 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 doc/ck_pr_neg create mode 100644 doc/ck_pr_not diff --git a/doc/Makefile.in b/doc/Makefile.in index 6b941b0..4697345 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -95,7 +95,9 @@ OBJECTS=ck_ht_count \ ck_pr_stall \ ck_pr_faa \ ck_pr_inc \ - ck_pr_dec + ck_pr_dec \ + ck_pr_not \ + ck_pr_neg all: for target in $(OBJECTS); do \ diff --git a/doc/ck_pr_neg b/doc/ck_pr_neg new file mode 100644 index 0000000..78e4a87 --- /dev/null +++ b/doc/ck_pr_neg @@ -0,0 +1,106 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_neg 3 +.Sh NAME +.Nm ck_pr_neg +.Nd atomic negation operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_neg_ptr "void *target" +.Ft bool +.Fn ck_pr_neg_ptr_zero "void *target" +.Ft void +.Fn ck_pr_neg_double "double *target" +.Ft bool +.Fn ck_pr_neg_double_zero "double *target" +.Ft void +.Fn ck_pr_neg_char "char *target" +.Ft bool +.Fn ck_pr_neg_char_zero "char *target" +.Ft void +.Fn ck_pr_neg_uint "unsigned int *target" +.Ft bool +.Fn ck_pr_neg_uint_zero "unsigned int *target" +.Ft void +.Fn ck_pr_neg_int "int *target" +.Ft bool +.Fn ck_pr_neg_int_zero "int *target" +.Ft void +.Fn ck_pr_neg_64 "uint64_t *target" +.Ft bool +.Fn ck_pr_neg_64_zero "uint64_t *target" +.Ft void +.Fn ck_pr_neg_32 "uint32_t *target" +.Ft bool +.Fn ck_pr_neg_32_zero "uint32_t *target" +.Ft void +.Fn ck_pr_neg_16 "uint16_t *target" +.Ft bool +.Fn ck_pr_neg_16_zero "uint16_t *target" +.Ft void +.Fn ck_pr_neg_8 "uint8_t *target" +.Ft bool +.Fn ck_pr_neg_8_zero "uint8_t *target" +.Sh DESCRIPTION +The +.Fn ck_pr_neg 3 +family of functions will atomically negation the value pointed to +by +.Fa target . +.Sh RETURN VALUES +The +.Fn ck_pr_neg_*_zero +family of functions will return true if the result +of the negation operation was 0. They will return +false otherwise. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_not b/doc/ck_pr_not new file mode 100644 index 0000000..ed776ca --- /dev/null +++ b/doc/ck_pr_not @@ -0,0 +1,84 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 7, 2013 +.Dt ck_pr_not 3 +.Sh NAME +.Nm ck_pr_not +.Nd atomic complement operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_not_ptr "void *target" +.Ft void +.Fn ck_pr_not_double "double *target" +.Ft void +.Fn ck_pr_not_char "char *target" +.Ft void +.Fn ck_pr_not_uint "unsigned int *target" +.Ft void +.Fn ck_pr_not_int "int *target" +.Ft void +.Fn ck_pr_not_64 "uint64_t *target" +.Ft void +.Fn ck_pr_not_32 "uint32_t *target" +.Ft void +.Fn ck_pr_not_16 "uint16_t *target" +.Ft void +.Fn ck_pr_not_8 "uint8_t *target" +.Sh DESCRIPTION +The +.Fn ck_pr_not 3 +family of functions will atomically complement the value pointed to +by +.Fa target . +.Sh RETURN VALUES +These functions have no return value. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ From 01075577df485be303768bac94aa32084f5f0ea2 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 00:38:20 -0400 Subject: [PATCH 35/60] doc/ck_bag_init: Correct formatting error. --- doc/ck_bag_init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ck_bag_init b/doc/ck_bag_init index e4eb254..8e5df75 100644 --- a/doc/ck_bag_init +++ b/doc/ck_bag_init @@ -35,7 +35,7 @@ Concurrency Kit (libck, \-lck) .Sh SYNOPSIS .In ck_bag.h .Ft bool -.Fn ck_bag_init "struct ck_bag *bag, size_t n_cachelines, enum ck_bag_allocation_strategy as" +.Fn ck_bag_init "struct ck_bag *bag" "size_t n_cachelines" "enum ck_bag_allocation_strategy as" .Sh DESCRIPTION The .Fn ck_bag_init From 0bb9196f0f4eee20f2f92914a0e4c5ba148f225b Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 00:51:24 -0400 Subject: [PATCH 36/60] doc/ck_pr: Do not cross-reference non-existant functions. --- doc/Makefile.in | 2 +- doc/ck_pr_dec | 4 +--- doc/ck_pr_inc | 6 ++---- doc/ck_pr_neg | 7 ++----- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/doc/Makefile.in b/doc/Makefile.in index 4697345..d98cbc3 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -107,7 +107,7 @@ all: html: for target in $(OBJECTS); do \ echo $$target; \ - groff -man -Tascii $(SRC_DIR)/doc/$$target | man2html -noheads -bare -compress -cgiurl='$$title.html' > $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ + groff -man -Tascii $(SRC_DIR)/doc/$$target | man2html -noheads -bare -cgiurl='$$title.html' > $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ done install: diff --git a/doc/ck_pr_dec b/doc/ck_pr_dec index afd5dcc..f1a0659 100644 --- a/doc/ck_pr_dec +++ b/doc/ck_pr_dec @@ -76,9 +76,7 @@ family of functions will atomically decrement the value pointed to by .Fa target . .Sh RETURN VALUES -The -.Fn ck_pr_dec_*_zero -family of functions will return true if the result +The ck_pr_dec_zero family of functions will return true if the result of the decrement operation was 0. They will return false otherwise. .Sh SEE ALSO diff --git a/doc/ck_pr_inc b/doc/ck_pr_inc index cdc9798..b2d9cbd 100644 --- a/doc/ck_pr_inc +++ b/doc/ck_pr_inc @@ -76,10 +76,8 @@ family of functions will atomically increment the value pointed to by .Fa target . .Sh RETURN VALUES -The -.Fn ck_pr_inc_*_zero -family of functions will return true if the result -of the increment operation was 0. They will return +The ck_pr_inc_zero family of functions will return true +if the result of the increment operation was 0. They will return false otherwise. .Sh SEE ALSO .Xr ck_pr_fence_load 3 , diff --git a/doc/ck_pr_neg b/doc/ck_pr_neg index 78e4a87..d5f196b 100644 --- a/doc/ck_pr_neg +++ b/doc/ck_pr_neg @@ -76,11 +76,8 @@ family of functions will atomically negation the value pointed to by .Fa target . .Sh RETURN VALUES -The -.Fn ck_pr_neg_*_zero -family of functions will return true if the result -of the negation operation was 0. They will return -false otherwise. +The ck_pr_neg_zero family of functions will return true if the result +of the negation operation was 0. They will return false otherwise. .Sh SEE ALSO .Xr ck_pr_fence_load 3 , .Xr ck_pr_fence_load_depends 3 , From ae688d1f091b7ae8d6d8436eab058caee17bd48f Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 00:57:46 -0400 Subject: [PATCH 37/60] doc/ck_pr: Fix typo in ck_pr_neg manual page. --- doc/ck_pr_neg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ck_pr_neg b/doc/ck_pr_neg index d5f196b..9563e1e 100644 --- a/doc/ck_pr_neg +++ b/doc/ck_pr_neg @@ -72,7 +72,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_neg 3 -family of functions will atomically negation the value pointed to +family of functions will atomically negate the value pointed to by .Fa target . .Sh RETURN VALUES From c22dcdb04bad8d2bd517b9c5b8305a8bf0f0f506 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 23:49:09 -0400 Subject: [PATCH 38/60] doc/ck_pr: Additional manual pages. --- doc/Makefile.in | 7 +++- doc/ck_pr_add | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_and | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_or | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_sub | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_xor | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 434 insertions(+), 1 deletion(-) create mode 100644 doc/ck_pr_add create mode 100644 doc/ck_pr_and create mode 100644 doc/ck_pr_or create mode 100644 doc/ck_pr_sub create mode 100644 doc/ck_pr_xor diff --git a/doc/Makefile.in b/doc/Makefile.in index d98cbc3..be84805 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -97,7 +97,12 @@ OBJECTS=ck_ht_count \ ck_pr_inc \ ck_pr_dec \ ck_pr_not \ - ck_pr_neg + ck_pr_neg \ + ck_pr_add \ + ck_pr_sub \ + ck_pr_and \ + ck_pr_xor \ + ck_pr_or all: for target in $(OBJECTS); do \ diff --git a/doc/ck_pr_add b/doc/ck_pr_add new file mode 100644 index 0000000..44f3259 --- /dev/null +++ b/doc/ck_pr_add @@ -0,0 +1,85 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_add 3 +.Sh NAME +.Nm ck_pr_add +.Nd atomic addition operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_add_ptr "void *target" "uintptr_t delta" +.Ft void +.Fn ck_pr_add_double "double *target" "double delta" +.Ft void +.Fn ck_pr_add_char "char *target" "char delta" +.Ft void +.Fn ck_pr_add_uint "unsigned int *target" "unsigned int delta" +.Ft void +.Fn ck_pr_add_int "int *target" "int delta" +.Ft void +.Fn ck_pr_add_64 "uint64_t *target" "uint64_t delta" +.Ft void +.Fn ck_pr_add_32 "uint32_t *target" "uint32_t delta" +.Ft void +.Fn ck_pr_add_16 "uint16_t *target" "uint16_t delta" +.Ft void +.Fn ck_pr_add_8 "uint8_t *target" "uint8_t delta" +.Sh DESCRIPTION +The +.Fn ck_pr_add 3 +family of functions will atomically add the value specified by +.Fa delta +to the value pointed to by +.Fa target . +.Sh RETURN VALUES +This family of functions does not have a return value. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_and b/doc/ck_pr_and new file mode 100644 index 0000000..44d6395 --- /dev/null +++ b/doc/ck_pr_and @@ -0,0 +1,86 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_and 3 +.Sh NAME +.Nm ck_pr_and +.Nd atomic bitwise-and operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_and_ptr "void *target" "uintptr_t delta" +.Ft void +.Fn ck_pr_and_char "char *target" "char delta" +.Ft void +.Fn ck_pr_and_uint "unsigned int *target" "unsigned int delta" +.Ft void +.Fn ck_pr_and_int "int *target" "int delta" +.Ft void +.Fn ck_pr_and_64 "uint64_t *target" "uint64_t delta" +.Ft void +.Fn ck_pr_and_32 "uint32_t *target" "uint32_t delta" +.Ft void +.Fn ck_pr_and_16 "uint16_t *target" "uint16_t delta" +.Ft void +.Fn ck_pr_and_8 "uint8_t *target" "uint8_t delta" +.Sh DESCRIPTION +The +.Fn ck_pr_and 3 +family of functions will atomically compute and store the +result of a bitwise-and of the value pointed to by +.Fa target +and +.Fa delta +into the value pointed to by +.Fa target . +.Sh RETURN VALUES +This family of functions does not have a return value. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_or b/doc/ck_pr_or new file mode 100644 index 0000000..c5ff055 --- /dev/null +++ b/doc/ck_pr_or @@ -0,0 +1,86 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_or 3 +.Sh NAME +.Nm ck_pr_or +.Nd atomic bitwise-or operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_or_ptr "void *target" "uintptr_t delta" +.Ft void +.Fn ck_pr_or_char "char *target" "char delta" +.Ft void +.Fn ck_pr_or_uint "unsigned int *target" "unsigned int delta" +.Ft void +.Fn ck_pr_or_int "int *target" "int delta" +.Ft void +.Fn ck_pr_or_64 "uint64_t *target" "uint64_t delta" +.Ft void +.Fn ck_pr_or_32 "uint32_t *target" "uint32_t delta" +.Ft void +.Fn ck_pr_or_16 "uint16_t *target" "uint16_t delta" +.Ft void +.Fn ck_pr_or_8 "uint8_t *target" "uint8_t delta" +.Sh DESCRIPTION +The +.Fn ck_pr_or 3 +family of functions will atomically compute and store the +result of a bitwise-or of the value pointed to by +.Fa target +and +.Fa delta +into the value pointed to by +.Fa target . +.Sh RETURN VALUES +This family of functions does not have a return value. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_sub b/doc/ck_pr_sub new file mode 100644 index 0000000..c33f65d --- /dev/null +++ b/doc/ck_pr_sub @@ -0,0 +1,85 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_sub 3 +.Sh NAME +.Nm ck_pr_sub +.Nd atomic subtraction operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_sub_ptr "void *target" "uintptr_t delta" +.Ft void +.Fn ck_pr_sub_double "double *target" "double delta" +.Ft void +.Fn ck_pr_sub_char "char *target" "char delta" +.Ft void +.Fn ck_pr_sub_uint "unsigned int *target" "unsigned int delta" +.Ft void +.Fn ck_pr_sub_int "int *target" "int delta" +.Ft void +.Fn ck_pr_sub_64 "uint64_t *target" "uint64_t delta" +.Ft void +.Fn ck_pr_sub_32 "uint32_t *target" "uint32_t delta" +.Ft void +.Fn ck_pr_sub_16 "uint16_t *target" "uint16_t delta" +.Ft void +.Fn ck_pr_sub_8 "uint8_t *target" "uint8_t delta" +.Sh DESCRIPTION +The +.Fn ck_pr_sub 3 +family of functions will atomically subtract the value specified by +.Fa delta +from the value pointed to by +.Fa target . +.Sh RETURN VALUES +This family of functions does not have a return value. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_xor b/doc/ck_pr_xor new file mode 100644 index 0000000..9b0dcb5 --- /dev/null +++ b/doc/ck_pr_xor @@ -0,0 +1,86 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_xor 3 +.Sh NAME +.Nm ck_pr_xor +.Nd atomic bitwise-xor operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_xor_ptr "void *target" "uintptr_t delta" +.Ft void +.Fn ck_pr_xor_char "char *target" "char delta" +.Ft void +.Fn ck_pr_xor_uint "unsigned int *target" "unsigned int delta" +.Ft void +.Fn ck_pr_xor_int "int *target" "int delta" +.Ft void +.Fn ck_pr_xor_64 "uint64_t *target" "uint64_t delta" +.Ft void +.Fn ck_pr_xor_32 "uint32_t *target" "uint32_t delta" +.Ft void +.Fn ck_pr_xor_16 "uint16_t *target" "uint16_t delta" +.Ft void +.Fn ck_pr_xor_8 "uint8_t *target" "uint8_t delta" +.Sh DESCRIPTION +The +.Fn ck_pr_xor 3 +family of functions will atomically compute and store the +result of a bitwise-xor of the value pointed to by +.Fa target +and +.Fa delta +into the value pointed to by +.Fa target . +.Sh RETURN VALUES +This family of functions does not have a return value. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ From 5c483e3b1c951c1509e7a061f88a15ad12787e5d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 23:54:16 -0400 Subject: [PATCH 39/60] ck_hp: hp_acquire patterns require strict fences under TSO. Several counter-examples were found which break in the presence of store-to-load re-ordering. Strict fence semantics are necessary. Thanks to Paul McKenney for helpful discussions. --- include/ck_hp_fifo.h | 12 ++++++------ include/ck_hp_stack.h | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/ck_hp_fifo.h b/include/ck_hp_fifo.h index e40e90e..12fa790 100644 --- a/include/ck_hp_fifo.h +++ b/include/ck_hp_fifo.h @@ -81,7 +81,7 @@ ck_hp_fifo_enqueue_mpmc(ck_hp_record_t *record, for (;;) { tail = ck_pr_load_ptr(&fifo->tail); ck_hp_set(record, 0, tail); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); if (tail != ck_pr_load_ptr(&fifo->tail)) continue; @@ -112,7 +112,7 @@ ck_hp_fifo_tryenqueue_mpmc(ck_hp_record_t *record, tail = ck_pr_load_ptr(&fifo->tail); ck_hp_set(record, 0, tail); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); if (tail != ck_pr_load_ptr(&fifo->tail)) return false; @@ -140,13 +140,13 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, ck_pr_fence_load(); tail = ck_pr_load_ptr(&fifo->tail); ck_hp_set(record, 0, head); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); if (head != ck_pr_load_ptr(&fifo->head)) continue; next = ck_pr_load_ptr(&head->next); ck_hp_set(record, 1, next); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); if (head != ck_pr_load_ptr(&fifo->head)) continue; @@ -175,13 +175,13 @@ ck_hp_fifo_trydequeue_mpmc(ck_hp_record_t *record, ck_pr_fence_load(); tail = ck_pr_load_ptr(&fifo->tail); ck_hp_set(record, 0, head); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); if (head != ck_pr_load_ptr(&fifo->head)) return NULL; next = ck_pr_load_ptr(&head->next); ck_hp_set(record, 1, next); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); if (head != ck_pr_load_ptr(&fifo->head)) return NULL; diff --git a/include/ck_hp_stack.h b/include/ck_hp_stack.h index 412d8d5..6699d63 100644 --- a/include/ck_hp_stack.h +++ b/include/ck_hp_stack.h @@ -62,7 +62,7 @@ ck_hp_stack_pop_mpmc(ck_hp_record_t *record, struct ck_stack *target) return (NULL); ck_hp_set(record, 0, entry); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); } while (entry != ck_pr_load_ptr(&target->head)); while (ck_pr_cas_ptr_value(&target->head, entry, entry->next, &entry) == false) { @@ -70,11 +70,11 @@ ck_hp_stack_pop_mpmc(ck_hp_record_t *record, struct ck_stack *target) return (NULL); ck_hp_set(record, 0, entry); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); update = ck_pr_load_ptr(&target->head); while (entry != update) { ck_hp_set(record, 0, update); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); entry = update; update = ck_pr_load_ptr(&target->head); if (update == NULL) @@ -95,7 +95,7 @@ ck_hp_stack_trypop_mpmc(ck_hp_record_t *record, struct ck_stack *target, struct return false; ck_hp_set(record, 0, entry); - ck_pr_fence_memory(); + ck_pr_fence_strict_memory(); if (entry != ck_pr_load_ptr(&target->head)) goto leave; From 7980489eaf11efe40ffd253452ddef323318167b Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 23:57:07 -0400 Subject: [PATCH 40/60] ck_hp_stack: Style fixes. --- include/ck_hp_stack.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ck_hp_stack.h b/include/ck_hp_stack.h index 6699d63..2a7856c 100644 --- a/include/ck_hp_stack.h +++ b/include/ck_hp_stack.h @@ -59,7 +59,7 @@ ck_hp_stack_pop_mpmc(ck_hp_record_t *record, struct ck_stack *target) do { entry = ck_pr_load_ptr(&target->head); if (entry == NULL) - return (NULL); + return NULL; ck_hp_set(record, 0, entry); ck_pr_fence_strict_memory(); @@ -67,7 +67,7 @@ ck_hp_stack_pop_mpmc(ck_hp_record_t *record, struct ck_stack *target) while (ck_pr_cas_ptr_value(&target->head, entry, entry->next, &entry) == false) { if (entry == NULL) - return (NULL); + return NULL; ck_hp_set(record, 0, entry); ck_pr_fence_strict_memory(); @@ -78,11 +78,11 @@ ck_hp_stack_pop_mpmc(ck_hp_record_t *record, struct ck_stack *target) entry = update; update = ck_pr_load_ptr(&target->head); if (update == NULL) - return (NULL); + return NULL; } } - return (entry); + return entry; } CK_CC_INLINE static bool From 5a13fddf7010d976a30c49b3f452fc04fbfd7986 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 11 Apr 2013 23:57:26 -0400 Subject: [PATCH 41/60] ck_hp_fifo: Style fixes. --- include/ck_hp_fifo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ck_hp_fifo.h b/include/ck_hp_fifo.h index 12fa790..41064f3 100644 --- a/include/ck_hp_fifo.h +++ b/include/ck_hp_fifo.h @@ -152,7 +152,7 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, if (head == tail) { if (next == NULL) - return (NULL); + return NULL; ck_pr_cas_ptr(&fifo->tail, tail, next); continue; @@ -161,7 +161,7 @@ ck_hp_fifo_dequeue_mpmc(ck_hp_record_t *record, } ck_pr_store_ptr(value, next->value); - return (head); + return head; } CK_CC_INLINE static struct ck_hp_fifo_entry * From 9cf089b157ed0ad8619c7c108da2fba946bd4f27 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 12 Apr 2013 15:57:25 -0400 Subject: [PATCH 42/60] regressions/ck_list: Coverage for INSERT_AFTER/INSERT_BELOW. --- regressions/ck_queue/validate/ck_list.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/regressions/ck_queue/validate/ck_list.c b/regressions/ck_queue/validate/ck_list.c index 0c6c504..58aa291 100644 --- a/regressions/ck_queue/validate/ck_list.c +++ b/regressions/ck_queue/validate/ck_list.c @@ -167,6 +167,21 @@ main(int argc, char *argv[]) ck_error("List is not empty after bulk removal.\n"); } + CK_LIST_INSERT_HEAD(&head, &a, list_entry); + CK_LIST_INSERT_AFTER(&a, &b, list_entry); + + if (CK_LIST_NEXT(&b, list_entry) != NULL) + ck_error("Inserted item after last, it should not have no next.\n"); + + CK_LIST_INIT(&head); + + CK_LIST_INSERT_HEAD(&head, &a, list_entry); + CK_LIST_INSERT_BEFORE(&a, &b, list_entry); + + if (CK_LIST_NEXT(&b, list_entry) != &a) + ck_error("Inserted item before last, it should point to last.\n"); + + CK_LIST_INIT(&head); fprintf(stderr, "done (success)\n"); fprintf(stderr, "Beginning parallel traversal..."); From 011a9751a668310432cde86567c10a878c262706 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 12 Apr 2013 18:20:43 -0400 Subject: [PATCH 43/60] ck_queue: Add traversal-safe SPMC STAILQ. --- include/ck_queue.h | 161 ++++++++++++-- regressions/ck_queue/validate/Makefile | 14 +- regressions/ck_queue/validate/ck_stailq.c | 257 ++++++++++++++++++++++ 3 files changed, 409 insertions(+), 23 deletions(-) create mode 100644 regressions/ck_queue/validate/ck_stailq.c diff --git a/include/ck_queue.h b/include/ck_queue.h index a9a502d..0393eef 100644 --- a/include/ck_queue.h +++ b/include/ck_queue.h @@ -88,24 +88,25 @@ * This facility is currently unsupported on architectures such as the Alpha * which require load-depend memory fences. * - * CK_SLIST CK_LIST - * _HEAD + + - * _HEAD_INITIALIZER + + - * _ENTRY + + - * _INIT + + - * _EMPTY + + - * _FIRST + + - * _NEXT + + - * _FOREACH + + - * _FOREACH_SAFE + + - * _INSERT_HEAD + + - * _INSERT_BEFORE - + - * _INSERT_AFTER + + - * _REMOVE_AFTER + - - * _REMOVE_HEAD + - - * _REMOVE + + - * _SWAP + + - * _MOVE + + + * CK_SLIST CK_LIST CK_STAILQ + * _HEAD + + + + * _HEAD_INITIALIZER + + + + * _ENTRY + + + + * _INIT + + + + * _EMPTY + + + + * _FIRST + + + + * _NEXT + + + + * _FOREACH + + + + * _FOREACH_SAFE + + + + * _INSERT_HEAD + + + + * _INSERT_BEFORE - + - + * _INSERT_AFTER + + + + * _INSERT_TAIL - - + + * _REMOVE_AFTER + - + + * _REMOVE_HEAD + - + + * _REMOVE + + + + * _SWAP + + + + * _MOVE + + + */ /* @@ -202,6 +203,130 @@ struct { \ (b)->slh_first = swap_first; \ } while (0) +/* + * Singly-linked Tail queue declarations. + */ +#define CK_STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first;/* first element */ \ + struct type **stqh_last;/* addr of last next element */ \ +} + +#define CK_STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define CK_STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue functions. + */ +#define CK_STAILQ_CONCAT(head1, head2) do { \ + if ((head2)->stqh_first == NULL) { \ + ck_pr_store_ptr((head1)->stqh_last, (head2)->stqh_first); \ + ck_pr_fence_store(); \ + (head1)->stqh_last = (head2)->stqh_last; \ + CK_STAILQ_INIT((head2)); \ + } \ +} while (0) + +#define CK_STAILQ_EMPTY(head) (ck_pr_load_ptr(&(head)->stqh_first) == NULL) + +#define CK_STAILQ_FIRST(head) (ck_pr_load_ptr(&(head)->stqh_first)) + +#define CK_STAILQ_FOREACH(var, head, field) \ + for((var) = CK_STAILQ_FIRST((head)); \ + (var) && (ck_pr_fence_load(), 1); \ + (var) = CK_STAILQ_NEXT((var), field)) + +#define CK_STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = CK_STAILQ_FIRST((head)); \ + (var) && (ck_pr_fence_load(), (tvar) = \ + CK_STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define CK_STAILQ_INIT(head) do { \ + ck_pr_store_ptr(&(head)->stqh_first, NULL); \ + ck_pr_fence_store(); \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (0) + +#define CK_STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ + (elm)->field.stqe_next = (tqelm)->field.stqe_next; \ + ck_pr_fence_store(); \ + ck_pr_store_ptr(&(tqelm)->field.stqe_next, elm); \ + if ((elm)->field.stqe_next == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (0) + +#define CK_STAILQ_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.stqe_next = (head)->stqh_first; \ + ck_pr_fence_store(); \ + ck_pr_store_ptr(&(head)->stqh_first, elm); \ + if ((elm)->field.stqe_next == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (0) + +#define CK_STAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.stqe_next = NULL; \ + ck_pr_fence_store(); \ + ck_pr_store_ptr((head)->stqh_last, (elm)); \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (0) + +#define CK_STAILQ_NEXT(elm, field) \ + (ck_pr_load_ptr(&(elm)->field.stqe_next)) + +#define CK_STAILQ_REMOVE(head, elm, type, field) do { \ + if ((head)->stqh_first == (elm)) { \ + CK_STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->stqh_first; \ + while (curelm->field.stqe_next != (elm)) \ + curelm = curelm->field.stqe_next; \ + CK_STAILQ_REMOVE_AFTER(head, curelm, field); \ + } \ +} while (0) + +#define CK_STAILQ_REMOVE_AFTER(head, elm, field) do { \ + ck_pr_store_ptr(&(elm)->field.stqe_next, \ + (elm)->field.stqe_next->field.stqe_next); \ + if ((elm)->field.stqe_next == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (0) + +#define CK_STAILQ_REMOVE_HEAD(head, field) do { \ + ck_pr_store_ptr(&(head)->stqh_first, \ + (head)->stqh_first->field.stqe_next); \ + if ((head)->stqh_first == NULL) \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (0) + +#define CK_STAILQ_MOVE(head1, head2, field) do { \ + ck_pr_store_ptr(&(head1)->stqh_first, (head2)->stqh_first); \ + (head1)->stqh_last = (head2)->stqh_last; \ + if ((head2)->stqh_last == &(head2)->stqh_first) \ + (head1)->stqh_last = &(head1)->stqh_first; \ +} while (0) + +/* + * This operation is not applied atomically. + */ +#define CK_STAILQ_SWAP(head1, head2, type) do { \ + struct type *swap_first = CK_STAILQ_FIRST(head1); \ + struct type **swap_last = (head1)->stqh_last; \ + CK_STAILQ_FIRST(head1) = CK_STAILQ_FIRST(head2); \ + (head1)->stqh_last = (head2)->stqh_last; \ + CK_STAILQ_FIRST(head2) = swap_first; \ + (head2)->stqh_last = swap_last; \ + if (CK_STAILQ_EMPTY(head1)) \ + (head1)->stqh_last = &(head1)->stqh_first; \ + if (CK_STAILQ_EMPTY(head2)) \ + (head2)->stqh_last = &(head2)->stqh_first; \ +} while (0) + /* * List declarations. */ diff --git a/regressions/ck_queue/validate/Makefile b/regressions/ck_queue/validate/Makefile index 07ce22b..7a690d3 100644 --- a/regressions/ck_queue/validate/Makefile +++ b/regressions/ck_queue/validate/Makefile @@ -1,19 +1,23 @@ .PHONY: check clean distribution HEADER=../../../include/ck_queue.h -OBJECTS=ck_slist ck_list +OBJECTS=ck_list ck_slist ck_stailq all: $(OBJECTS) check: all - ./ck_slist $(CORES) 100000 - ./ck_list $(CORES) 100000 + ./ck_list $(CORES) 5 + ./ck_slist $(CORES) 5 + ./ck_stailq $(CORES) 1000000 + +ck_list: $(HEADER) ck_list.c + $(CC) $(CFLAGS) -o ck_list ck_list.c ck_slist: $(HEADER) ck_slist.c $(CC) $(CFLAGS) -o ck_slist ck_slist.c -ck_list: $(HEADER) ck_list.c - $(CC) $(CFLAGS) -o ck_list ck_list.c +ck_stailq: $(HEADER) ck_stailq.c + $(CC) $(CFLAGS) -o ck_stailq ck_stailq.c clean: rm -rf *~ *.o $(OBJECTS) *.dSYM diff --git a/regressions/ck_queue/validate/ck_stailq.c b/regressions/ck_queue/validate/ck_stailq.c new file mode 100644 index 0000000..a129068 --- /dev/null +++ b/regressions/ck_queue/validate/ck_stailq.c @@ -0,0 +1,257 @@ +/* + * Copyright 2012-2013 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include "../../common.h" + +struct test { + int value; + CK_STAILQ_ENTRY(test) list_entry; +}; +static CK_STAILQ_HEAD(test_list, test) head = CK_STAILQ_HEAD_INITIALIZER(head); + +static int goal; + +static void +test_foreach(void) +{ + struct test *n, *next, *safe; + int i, s = 0, j = 0, k = 0; + + for (i = goal; i != 0; i = goal) { + s = 0; + + CK_STAILQ_FOREACH(n, &head, list_entry) { + j++; + if (s == 0) + s = n->value; + else + s = s - 1; + + if (n->value != s) { + ck_error("\nExpected %d, but got %d.\n", + s, n->value); + } + + next = CK_STAILQ_NEXT(n, list_entry); + if (next != NULL && next->value != s - 1) { + ck_error("\nExpected %d, but got %d.\n", + s, next->value); + } + + i--; + } + + if (i == 0) + break; + + s = 0; + CK_STAILQ_FOREACH_SAFE(n, &head, list_entry, safe) { + k++; + + if (s == 0) + s = n->value; + else + s = s - 1; + + if (n->value != s) { + ck_error("\nExpected %d, but got %d.\n", + s, n->value); + } + + next = CK_STAILQ_NEXT(n, list_entry); + if (next != NULL && next->value != s - 1) { + ck_error("\nExpected %d, but got %d.\n", + s, next->value); + } + + i--; + } + + if (i == 0 || CK_STAILQ_EMPTY(&head) == true) + break; + } + + fprintf(stderr, "(%d, %d) ", j, k); + return; +} + +static void * +execute(void *c) +{ + + (void)c; + test_foreach(); + return NULL; +} + +int +main(int argc, char *argv[]) +{ + pthread_t *thread; + struct test *n, a, b; + struct test_list target; + int n_threads, i; + + if (argc != 3) { + ck_error("Usage: %s \n", argv[0]); + } + + n_threads = atoi(argv[1]); + if (n_threads < 1) { + ck_error("ERROR: Number of threads must be >= 1.\n"); + } + + thread = malloc(sizeof(pthread_t) * n_threads); + assert(thread != NULL); + + goal = atoi(argv[2]); + if (goal < 4) { + ck_error("ERROR: Number of entries must be >= 4.\n"); + } + + fprintf(stderr, "Beginning serial test..."); + CK_STAILQ_INIT(&head); + + for (i = 1; i <= goal; i++) { + n = malloc(sizeof *n); + assert(n != NULL); + n->value = i; + CK_STAILQ_INSERT_HEAD(&head, n, list_entry); + } + + test_foreach(); + + for (i = 1; i <= goal; i++) { + n = CK_STAILQ_FIRST(&head); + CK_STAILQ_REMOVE(&head, n, test, list_entry); + free(n); + } + + if (CK_STAILQ_EMPTY(&head) == false) { + ck_error("List is not empty after bulk removal.\n"); + } + + for (i = 1; i <= goal; i++) { + n = malloc(sizeof *n); + assert(n != NULL); + n->value = goal - i; + CK_STAILQ_INSERT_TAIL(&head, n, list_entry); + } + + test_foreach(); + + for (i = 1; i <= goal; i++) { + n = CK_STAILQ_FIRST(&head); + CK_STAILQ_REMOVE(&head, n, test, list_entry); + free(n); + } + + if (CK_STAILQ_EMPTY(&head) == false) { + ck_error("List is not empty after bulk removal.\n"); + } + + CK_STAILQ_INSERT_HEAD(&head, &a, list_entry); + CK_STAILQ_INSERT_HEAD(&head, &b, list_entry); + CK_STAILQ_REMOVE(&head, &a, test, list_entry); + if (CK_STAILQ_FIRST(&head) != &b) + ck_error("List is in invalid state.\n"); + CK_STAILQ_REMOVE(&head, &b, test, list_entry); + + if (CK_STAILQ_EMPTY(&head) == false) { + ck_error("List is not empty after bulk removal.\n"); + } + + CK_STAILQ_INSERT_HEAD(&head, &a, list_entry); + CK_STAILQ_INSERT_AFTER(&head, &a, &b, list_entry); + + if (CK_STAILQ_NEXT(&b, list_entry) != NULL) + ck_error("Inserted item after last, it should not have no next.\n"); + + CK_STAILQ_INIT(&head); + + CK_STAILQ_INSERT_HEAD(&head, &a, list_entry); + if (CK_STAILQ_NEXT(&a, list_entry) != NULL) + ck_error("Inserted item as last, but it contains next pointer.\n"); + + CK_STAILQ_INIT(&head); + fprintf(stderr, "done (success)\n"); + + fprintf(stderr, "Beginning parallel traversal..."); + + n = malloc(sizeof *n); + assert(n != NULL); + n->value = 1; + CK_STAILQ_INSERT_HEAD(&head, n, list_entry); + + for (i = 0; i < n_threads; i++) { + int r = pthread_create(&thread[i], NULL, execute, NULL); + assert(r == 0); + } + + for (i = 2; i <= goal; i++) { + volatile int j; + + n = malloc(sizeof *n); + assert(n != NULL); + n->value = i; + CK_STAILQ_INSERT_HEAD(&head, n, list_entry); + for (j = 0; j <= 1000; j++); + } + + for (i = 0; i < n_threads; i++) + pthread_join(thread[i], NULL); + + for (i = 0; i < n_threads; i++) { + int r = pthread_create(&thread[i], NULL, execute, NULL); + assert(r == 0); + } + + CK_STAILQ_MOVE(&target, &head, list_entry); + + for (i = 1; i <= goal; i++) { + volatile int j; + + if (CK_STAILQ_EMPTY(&target) == false) { + struct test *r = CK_STAILQ_FIRST(&target); + CK_STAILQ_REMOVE(&target, r, test, list_entry); + } + + for (j = 0; j <= 1000; j++); + } + + for (i = 0; i < n_threads; i++) + pthread_join(thread[i], NULL); + + fprintf(stderr, "done (success)\n"); + return (0); +} + From 187d67f4c97aa3ebdbf44e7873ca9fbf480d2ebb Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 12 Apr 2013 18:41:17 -0400 Subject: [PATCH 44/60] doc/ck_pr: Add ck_pr_cas manual page. --- doc/Makefile.in | 3 +- doc/ck_pr_cas | 130 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 doc/ck_pr_cas diff --git a/doc/Makefile.in b/doc/Makefile.in index be84805..2deaad0 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -102,7 +102,8 @@ OBJECTS=ck_ht_count \ ck_pr_sub \ ck_pr_and \ ck_pr_xor \ - ck_pr_or + ck_pr_or \ + ck_pr_cas all: for target in $(OBJECTS); do \ diff --git a/doc/ck_pr_cas b/doc/ck_pr_cas new file mode 100644 index 0000000..660d2d3 --- /dev/null +++ b/doc/ck_pr_cas @@ -0,0 +1,130 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_cas 3 +.Sh NAME +.Nm ck_pr_cas +.Nd atomic compare-and-swap operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft bool +.Fn ck_pr_cas_ptr "void *target" "void *old_value" "void *new_value" +.Ft bool +.Fn ck_pr_cas_ptr_value "void *target" "void *old_value" "void *new_value" "void *original_value" +.Ft bool +.Fn ck_pr_cas_ptr_2 "void *target" "void *old_value" "void *new_value" +.Ft bool +.Fn ck_pr_cas_ptr_2_value "void *target" "void *old_value" "void *new_value" "void *original_value" +.Ft bool +.Fn ck_pr_cas_double "double *target" "double old_value" "double new_value" +.Ft bool +.Fn ck_pr_cas_double_value "double *target" "double old_value" "double new_value" "double *original_value" +.Ft bool +.Fn ck_pr_cas_char "char *target" "char old_value" "char new_value" +.Ft bool +.Fn ck_pr_cas_char_value "char *target" "char old_value" "char new_value" "char *original_value" +.Ft bool +.Fn ck_pr_cas_uint "unsigned int *target" "unsigned int old_value" "unsigned int new_value" +.Ft bool +.Fn ck_pr_cas_uint_value "unsigned int *target" "unsigned int old_value" "unsigned int new_value" "unsigned int *original_value" +.Ft bool +.Fn ck_pr_cas_int "int *target" "int old_value" "int new_value" +.Ft bool +.Fn ck_pr_cas_int_value "int *target" "int old_value" "int new_value" "int *original_value" +.Ft bool +.Fn ck_pr_cas_64_2 "uint64_t target[static 2]" "uint64_t old_value[static 2]" "uint64_t new_value[static 2]" +.Ft bool +.Fn ck_pr_cas_64_2_value "uint64_t target[static 2]" "uint64_t old_value[static 2]" "uint64_t new_value[static 2]" "uint64_t original_value[static 2]" +.Ft bool +.Fn ck_pr_cas_64 "uint64_t *target" "uint64_t old_value" "uint64_t new_value" +.Ft bool +.Fn ck_pr_cas_64_value "uint64_t *target" "uint64_t old_value" "uint64_t new_value" "uint64_t *original_value" +.Ft bool +.Fn ck_pr_cas_64_2 "uint64_t target[static 2]" "uint64_t old_value[static 2]" "uint64_t new_value[static 2]" +.Ft bool +.Fn ck_pr_cas_64_2_value "uint64_t target[static 2]" "uint64_t old_value[static 2]" "uint64_t new_value[static 2]" "uint64_t original_value[static 2]" +.Ft bool +.Fn ck_pr_cas_32 "uint32_t *target" "uint32_t old_value" "uint32_t new_value" +.Ft bool +.Fn ck_pr_cas_32_value "uint32_t *target" "uint32_t old_value" "uint32_t new_value" "uint32_t *original_value" +.Ft bool +.Fn ck_pr_cas_16 "uint16_t *target" "uint16_t old_value" "uint16_t new_value" +.Ft bool +.Fn ck_pr_cas_16_value "uint16_t *target" "uint16_t old_value" "uint16_t new_value" "uint16_t *original_value" +.Ft bool +.Fn ck_pr_cas_8 "uint8_t *target" "uint8_t old_value" "uint8_t new_value" +.Ft bool +.Fn ck_pr_cas_8_value "uint8_t *target" "uint8_t old_value" "uint8_t new_value" "uint8_t *original_value" +.Sh DESCRIPTION +The +.Fn ck_pr_cas 3 +family of functions will atomically compare the value in +.Fa target +for equality with +.Fa old_value +and if so, replace the value pointed to by +.Fa target +with the value specified by +.Fa original_value . +If the value in +.Fa target +was not equal to the value specified by +.Fa old_value +then no modifications occur to the value in +.Fa target . +The *_value form of these functions will unconditionally update +.Fa original_value . +.Sh RETURN VALUES +This family of functions will return true if the value in +.Fa target +was modified as a result of the operation. Otherwise, they +will return false. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ From 235a57ebef9a38ec0dda4aa54b7c12c61bc3c83d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 12 Apr 2013 18:52:01 -0400 Subject: [PATCH 45/60] doc/ck_pr: Add ck_pr_bt{c,r,s} manual pages. --- doc/Makefile.in | 5 ++- doc/ck_pr_btc | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_btr | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/ck_pr_bts | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 doc/ck_pr_btc create mode 100644 doc/ck_pr_btr create mode 100644 doc/ck_pr_bts diff --git a/doc/Makefile.in b/doc/Makefile.in index 2deaad0..64242f3 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -103,7 +103,10 @@ OBJECTS=ck_ht_count \ ck_pr_and \ ck_pr_xor \ ck_pr_or \ - ck_pr_cas + ck_pr_cas \ + ck_pr_bts \ + ck_pr_btc \ + ck_pr_btr all: for target in $(OBJECTS); do \ diff --git a/doc/ck_pr_btc b/doc/ck_pr_btc new file mode 100644 index 0000000..49bf35d --- /dev/null +++ b/doc/ck_pr_btc @@ -0,0 +1,85 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_btc 3 +.Sh NAME +.Nm ck_pr_btc +.Nd atomic bit test-and-complement operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft bool +.Fn ck_pr_btc_ptr "void *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btc_uint "uint *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btc_int "int *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btc_64 "uint64_t *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btc_32 "uint32_t *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btc_16 "uint16_t *target" "unsigned int bit_index" +.Sh DESCRIPTION +The +.Fn ck_pr_btc 3 +family of functions will atomically fetch the value +of the bit in +.Fa target +at index +.Fa bit_index +and set that bit to its complement. +.Sh RETURN VALUES +These family of functions will return the original value of +the bit at offset +.Fa bit_index +that is in the value pointed to by +.Fa target . +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_btr 3 , +.Xr ck_pr_cas 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_btr b/doc/ck_pr_btr new file mode 100644 index 0000000..2bc44c0 --- /dev/null +++ b/doc/ck_pr_btr @@ -0,0 +1,85 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_btr 3 +.Sh NAME +.Nm ck_pr_btr +.Nd atomic bit test-and-reset operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft bool +.Fn ck_pr_btr_ptr "void *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btr_uint "uint *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btr_int "int *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btr_64 "uint64_t *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btr_32 "uint32_t *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_btr_16 "uint16_t *target" "unsigned int bit_index" +.Sh DESCRIPTION +The +.Fn ck_pr_btr 3 +family of functions will atomically fetch the value +of the bit in +.Fa target +at index +.Fa bit_index +and set that bit to 0. +.Sh RETURN VALUES +These family of functions will return the original value of +the bit at offset +.Fa bit_index +that is in the value pointed to by +.Fa target . +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_cas 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_bts b/doc/ck_pr_bts new file mode 100644 index 0000000..dc50c32 --- /dev/null +++ b/doc/ck_pr_bts @@ -0,0 +1,85 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 11, 2013 +.Dt ck_pr_bts 3 +.Sh NAME +.Nm ck_pr_bts +.Nd atomic bit test-and-set operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft bool +.Fn ck_pr_bts_ptr "void *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_bts_uint "uint *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_bts_int "int *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_bts_64 "uint64_t *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_bts_32 "uint32_t *target" "unsigned int bit_index" +.Ft bool +.Fn ck_pr_bts_16 "uint16_t *target" "unsigned int bit_index" +.Sh DESCRIPTION +The +.Fn ck_pr_bts 3 +family of functions will atomically fetch the value +of the bit in +.Fa target +at index +.Fa bit_index +and set that bit to 1. +.Sh RETURN VALUES +These family of functions will return the original value of +the bit at offset +.Fa bit_index +that is in the value pointed to by +.Fa target . +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_btr 3 , +.Xr ck_pr_cas 3 +.Pp +Additional information available at http://concurrencykit.org/ From 667285e493020a30669010504eef70539586b41a Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 12 Apr 2013 20:00:18 -0400 Subject: [PATCH 46/60] doc/ck_hs: Fix title for ck_hs_iterator_init. --- doc/ck_hs_iterator_init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ck_hs_iterator_init b/doc/ck_hs_iterator_init index b6ffe54..5fe2d42 100644 --- a/doc/ck_hs_iterator_init +++ b/doc/ck_hs_iterator_init @@ -28,7 +28,7 @@ .Dt CK_HS_ITERATOR_INIT 3 .Sh NAME .Nm ck_hs_iterator_init -.Nd initialize a hash set +.Nd initialize hash set iterator .Sh LIBRARY Concurrency Kit (libck, \-lck) .Sh SYNOPSIS From 72a3b844b2122c7e899d06ccbf200bede13febea Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 14 Apr 2013 20:07:02 -0400 Subject: [PATCH 47/60] doc/ck_cohort: Minor fixes. --- doc/ck_cohort | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/ck_cohort b/doc/ck_cohort index 011ca1b..5548896 100644 --- a/doc/ck_cohort +++ b/doc/ck_cohort @@ -85,7 +85,6 @@ man pages for more details. .Pp .Sh EXAMPLE .Bd -literal -offset indent - #include #include @@ -124,7 +123,7 @@ CK_COHORT_PROTOTYPE(test_cohort, static ck_spinlock_t global_lock = CK_SPINLOCK_INITIALIZER; static unsigned int ready; -static void* +static void * function(void *context) { CK_COHORT_INSTANCE(test_cohort) *cohort = context; From 537391bb72d4e89803cc826b9945748b3f1ab451 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 15 Apr 2013 22:11:12 -0400 Subject: [PATCH 48/60] doc/ck_pr: Add ck_pr_load manual page. --- doc/Makefile.in | 3 +- doc/ck_pr_load | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 doc/ck_pr_load diff --git a/doc/Makefile.in b/doc/Makefile.in index 64242f3..465e6b7 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -106,7 +106,8 @@ OBJECTS=ck_ht_count \ ck_pr_cas \ ck_pr_bts \ ck_pr_btc \ - ck_pr_btr + ck_pr_btr \ + ck_pr_load all: for target in $(OBJECTS); do \ diff --git a/doc/ck_pr_load b/doc/ck_pr_load new file mode 100644 index 0000000..c7f23e0 --- /dev/null +++ b/doc/ck_pr_load @@ -0,0 +1,88 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 15, 2013 +.Dt ck_pr_load 3 +.Sh NAME +.Nm ck_pr_load +.Nd atomic volatile load operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void * +.Fn ck_pr_load_ptr "const void *target" +.Ft double +.Fn ck_pr_load_double "const double *target" +.Ft unsigned int +.Fn ck_pr_load_uint "const unsigned int *target" +.Ft int +.Fn ck_pr_load_int "const int *target" +.Ft char +.Fn ck_pr_load_char "const char *target" +.Ft uint64_t +.Fn ck_pr_load_64 "const uint64_t *target" +.Ft uint32_t +.Fn ck_pr_load_32 "const uint32_t *target" +.Ft uint16_t +.Fn ck_pr_load_16 "const uint16_t *target" +.Ft uint8_t +.Fn ck_pr_load_8 "const uint8_t *target" +.Sh DESCRIPTION +The +.Fn ck_pr_load 3 +family of functions will atomically load the value +pointed to by +.Fa target +and return it. This family of functions will always +serve as implicit compiler barriers and will under-go +re-ordering by the compiler. +.Sh RETURN VALUES +This family of functions returns the value contained +in the location pointed to by the first argument. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ From 5a26d1a41d54bc9dc1439b53d2040e8260f0780c Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 15 Apr 2013 22:17:41 -0400 Subject: [PATCH 49/60] doc/ck_pr: Add ck_pr_store manual page. --- doc/Makefile.in | 1 + doc/ck_pr_store | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 doc/ck_pr_store diff --git a/doc/Makefile.in b/doc/Makefile.in index 465e6b7..a8604e8 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -107,6 +107,7 @@ OBJECTS=ck_ht_count \ ck_pr_bts \ ck_pr_btc \ ck_pr_btr \ + ck_pr_store \ ck_pr_load all: diff --git a/doc/ck_pr_store b/doc/ck_pr_store new file mode 100644 index 0000000..d4b527f --- /dev/null +++ b/doc/ck_pr_store @@ -0,0 +1,88 @@ +.\" +.\" Copyright 2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 15, 2013 +.Dt ck_pr_store 3 +.Sh NAME +.Nm ck_pr_store +.Nd atomic volatile store operation +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_store_ptr "void *target" "void *value" +.Ft void +.Fn ck_pr_store_double "double *target" "double value" +.Ft void +.Fn ck_pr_store_uint "unsigned int *target" "unsigned int value" +.Ft void +.Fn ck_pr_store_int "int *target" "int value" +.Ft void +.Fn ck_pr_store_char "char *target" "char value" +.Ft void +.Fn ck_pr_store_64 "uint64_t *target" "uint64_t value" +.Ft void +.Fn ck_pr_store_32 "uint32_t *target" "uint32_t value" +.Ft void +.Fn ck_pr_store_16 "uint16_t *target" "uint16_t value" +.Ft void +.Fn ck_pr_store_8 "uint8_t *target" "uint8_t value" +.Sh DESCRIPTION +The +.Fn ck_pr_store 3 +family of functions atomically stores the value specified +by +.Fa value +into the location pointed to by +.Fa target . +This family of functions always serves as an implicit compiler +barrier and is not susceptible to compiler re-ordering. +.Sh RETURN VALUES +This family of functions has no return value. +.Sh SEE ALSO +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ From 57e96b00ede3965572b772820c7a24d3610769d5 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 15 Apr 2013 22:17:48 -0400 Subject: [PATCH 50/60] doc/ck_pr: Additional improvements to ck_pr_load manual page. --- doc/ck_pr_load | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/ck_pr_load b/doc/ck_pr_load index c7f23e0..3a0406b 100644 --- a/doc/ck_pr_load +++ b/doc/ck_pr_load @@ -54,12 +54,12 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_load 3 -family of functions will atomically load the value +family of functions atomically loads the value pointed to by .Fa target -and return it. This family of functions will always -serve as implicit compiler barriers and will under-go -re-ordering by the compiler. +and returns it. This family of functions always +serves as an implicit compiler barrier and is not +susceptible to re-ordering by the compiler. .Sh RETURN VALUES This family of functions returns the value contained in the location pointed to by the first argument. From b8d0ec526f68fd28da79e8ec6324f8df55b60122 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 15 Apr 2013 22:25:34 -0400 Subject: [PATCH 51/60] doc/ck_pr: Passive voice fixes. --- doc/ck_pr_add | 2 +- doc/ck_pr_and | 2 +- doc/ck_pr_btc | 4 ++-- doc/ck_pr_btr | 4 ++-- doc/ck_pr_bts | 4 ++-- doc/ck_pr_cas | 8 ++++---- doc/ck_pr_dec | 6 +++--- doc/ck_pr_faa | 4 ++-- doc/ck_pr_fas | 4 ++-- doc/ck_pr_fence_load | 10 +++++----- doc/ck_pr_fence_memory | 11 +++++------ doc/ck_pr_fence_store | 10 +++++----- doc/ck_pr_inc | 6 +++--- doc/ck_pr_neg | 6 +++--- doc/ck_pr_not | 2 +- doc/ck_pr_or | 2 +- doc/ck_pr_sub | 2 +- doc/ck_pr_xor | 2 +- 18 files changed, 44 insertions(+), 45 deletions(-) diff --git a/doc/ck_pr_add b/doc/ck_pr_add index 44f3259..3fe2c19 100644 --- a/doc/ck_pr_add +++ b/doc/ck_pr_add @@ -54,7 +54,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_add 3 -family of functions will atomically add the value specified by +family of functions atomically add the value specified by .Fa delta to the value pointed to by .Fa target . diff --git a/doc/ck_pr_and b/doc/ck_pr_and index 44d6395..4496149 100644 --- a/doc/ck_pr_and +++ b/doc/ck_pr_and @@ -52,7 +52,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_and 3 -family of functions will atomically compute and store the +family of functions atomically compute and store the result of a bitwise-and of the value pointed to by .Fa target and diff --git a/doc/ck_pr_btc b/doc/ck_pr_btc index 49bf35d..55ced4a 100644 --- a/doc/ck_pr_btc +++ b/doc/ck_pr_btc @@ -48,14 +48,14 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_btc 3 -family of functions will atomically fetch the value +family of functions atomically fetch the value of the bit in .Fa target at index .Fa bit_index and set that bit to its complement. .Sh RETURN VALUES -These family of functions will return the original value of +These family of functions return the original value of the bit at offset .Fa bit_index that is in the value pointed to by diff --git a/doc/ck_pr_btr b/doc/ck_pr_btr index 2bc44c0..fefa32a 100644 --- a/doc/ck_pr_btr +++ b/doc/ck_pr_btr @@ -48,14 +48,14 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_btr 3 -family of functions will atomically fetch the value +family of functions atomically fetch the value of the bit in .Fa target at index .Fa bit_index and set that bit to 0. .Sh RETURN VALUES -These family of functions will return the original value of +This family of functions returns the original value of the bit at offset .Fa bit_index that is in the value pointed to by diff --git a/doc/ck_pr_bts b/doc/ck_pr_bts index dc50c32..7cf1a0a 100644 --- a/doc/ck_pr_bts +++ b/doc/ck_pr_bts @@ -48,14 +48,14 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_bts 3 -family of functions will atomically fetch the value +family of functions atomically fetch the value of the bit in .Fa target at index .Fa bit_index and set that bit to 1. .Sh RETURN VALUES -These family of functions will return the original value of +This family of functions returns the original value of the bit at offset .Fa bit_index that is in the value pointed to by diff --git a/doc/ck_pr_cas b/doc/ck_pr_cas index 660d2d3..fe6fc3f 100644 --- a/doc/ck_pr_cas +++ b/doc/ck_pr_cas @@ -84,7 +84,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_cas 3 -family of functions will atomically compare the value in +family of functions atomically compare the value in .Fa target for equality with .Fa old_value @@ -98,13 +98,13 @@ was not equal to the value specified by .Fa old_value then no modifications occur to the value in .Fa target . -The *_value form of these functions will unconditionally update +The *_value form of these functions unconditionally update .Fa original_value . .Sh RETURN VALUES -This family of functions will return true if the value in +This family of functions return true if the value in .Fa target was modified as a result of the operation. Otherwise, they -will return false. +return false. .Sh SEE ALSO .Xr ck_pr_fence_load 3 , .Xr ck_pr_fence_load_depends 3 , diff --git a/doc/ck_pr_dec b/doc/ck_pr_dec index f1a0659..2aa4375 100644 --- a/doc/ck_pr_dec +++ b/doc/ck_pr_dec @@ -72,12 +72,12 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_dec 3 -family of functions will atomically decrement the value pointed to +family of functions atomically decrement the value pointed to by .Fa target . .Sh RETURN VALUES -The ck_pr_dec_zero family of functions will return true if the result -of the decrement operation was 0. They will return +The ck_pr_dec_zero family of functions returns true if the result +of the decrement operation was 0. They return false otherwise. .Sh SEE ALSO .Xr ck_pr_fence_load 3 , diff --git a/doc/ck_pr_faa b/doc/ck_pr_faa index 491eabc..9622a36 100644 --- a/doc/ck_pr_faa +++ b/doc/ck_pr_faa @@ -54,7 +54,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_faa 3 -family of functions will atomically fetch the value pointed to +family of functions atomically fetch the value pointed to by .Fa target and add the value specified by @@ -62,7 +62,7 @@ and add the value specified by to the value pointed to by .Fa target . .Sh RETURN VALUES -This function will return the value pointed to by +This function returns the value pointed to by .Fa target at the time of operation invocation before the addition operation is applied. diff --git a/doc/ck_pr_fas b/doc/ck_pr_fas index 89d7f88..ce5e6f3 100644 --- a/doc/ck_pr_fas +++ b/doc/ck_pr_fas @@ -54,7 +54,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_fas 3 -family of functions will atomically fetch the value pointed to +family of functions atomically fetch the value pointed to by .Fa target and replace the value pointed to by @@ -62,7 +62,7 @@ and replace the value pointed to by with the value specified by .Fa new_value . .Sh RETURN VALUES -This function will return the value pointed to by +This function returns the value pointed to by .Fa target at the time of operation invocation before it was atomically replaced with diff --git a/doc/ck_pr_fence_load b/doc/ck_pr_fence_load index 44431a1..97cb848 100644 --- a/doc/ck_pr_fence_load +++ b/doc/ck_pr_fence_load @@ -38,22 +38,22 @@ Concurrency Kit (libck, \-lck) .Ft void .Fn ck_pr_fence_strict_load void .Sh DESCRIPTION -This function will enforce the ordering of any memory load +This function enforces the ordering of any memory load and .Fn ck_pr_load 3 operations relative to the invocation of the function. Any store operations that were committed on remote processors and received by the calling processor before the invocation of .Fn ck_pr_fence_load -will also be made visible only after a call to +is also be made visible only after a call to .Fn ck_pr_fence_load . -This function will always serve as an implicit compiler barrier. +This function always serves as an implicit compiler barrier. On architectures with CK_MD_TSO or CK_MD_PSO specified (total store ordering -and partial store ordering respectively), this operation will only serve +and partial store ordering respectively), this operation only serves as a compiler barrier and no fence instructions will be emitted. To force the unconditional emission of a load fence, use .Fn ck_pr_fence_strict_load . -Architectures implementing CK_MD_RMO will always emit a load fence. +Architectures implementing CK_MD_RMO always emit a load fence. .Sh EXAMPLE .Bd -literal -offset indent diff --git a/doc/ck_pr_fence_memory b/doc/ck_pr_fence_memory index eab10ae..31eed57 100644 --- a/doc/ck_pr_fence_memory +++ b/doc/ck_pr_fence_memory @@ -40,13 +40,12 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_fence_memory 3 -function will enforce the ordering of any memory operations +function enforces the ordering of any memory operations with respect to the invocation of the function. This function -will always serve as an implicit compiler barrier. -Achitectures implementing CK_MD_TSO will -only have this function serve as a compiler barrier and -no fence instructions will be emitted. Architectures -implementing CK_MD_PSO and CK_MD_RMO will always emit +always serves as an implicit compiler barrier. +Achitectures implementing CK_MD_TSO do not emit +a barrier, but compiler barrier semantics remain. +Architectures implementing CK_MD_PSO and CK_MD_RMO always emit an instructions which provides the specified ordering guarantees. To force the unconditional emission of a memory fence, use diff --git a/doc/ck_pr_fence_store b/doc/ck_pr_fence_store index 5bc0e6c..0fa573d 100644 --- a/doc/ck_pr_fence_store +++ b/doc/ck_pr_fence_store @@ -40,15 +40,15 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_fence_store -function will enfore the ordering of any memory store, +function enfores the ordering of any memory store, .Fn ck_pr_store and atomic read-modify-write operations relative to -the invocation of the function. This function will +the invocation of the function. This function always serve as an implicit compiler barrier. On architectures implementing CK_MD_TSO, this operation -will only serve as a compiler barrier and no fences -will be emitted. On architectures implementing -CK_MD_PSO and CK_MD_RMO, a store fence will be +only serves as a compiler barrier and no fences +are emitted. On architectures implementing +CK_MD_PSO and CK_MD_RMO, a store fence is emitted. To force the unconditional emission of a store fence, use .Fn ck_pr_fence_strict_store . diff --git a/doc/ck_pr_inc b/doc/ck_pr_inc index b2d9cbd..fe2cb9e 100644 --- a/doc/ck_pr_inc +++ b/doc/ck_pr_inc @@ -72,12 +72,12 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_inc 3 -family of functions will atomically increment the value pointed to +family of functions atomically increment the value pointed to by .Fa target . .Sh RETURN VALUES -The ck_pr_inc_zero family of functions will return true -if the result of the increment operation was 0. They will return +The ck_pr_inc_zero family of functions return true +if the result of the increment operation was 0. The functions return false otherwise. .Sh SEE ALSO .Xr ck_pr_fence_load 3 , diff --git a/doc/ck_pr_neg b/doc/ck_pr_neg index 9563e1e..fb441e8 100644 --- a/doc/ck_pr_neg +++ b/doc/ck_pr_neg @@ -72,12 +72,12 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_neg 3 -family of functions will atomically negate the value pointed to +family of functions atomically negate the value pointed to by .Fa target . .Sh RETURN VALUES -The ck_pr_neg_zero family of functions will return true if the result -of the negation operation was 0. They will return false otherwise. +The ck_pr_neg_zero functions return true if the result +of the negation operation was 0. They return false otherwise. .Sh SEE ALSO .Xr ck_pr_fence_load 3 , .Xr ck_pr_fence_load_depends 3 , diff --git a/doc/ck_pr_not b/doc/ck_pr_not index ed776ca..0847bf6 100644 --- a/doc/ck_pr_not +++ b/doc/ck_pr_not @@ -54,7 +54,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_not 3 -family of functions will atomically complement the value pointed to +family of functions atomically complement the value pointed to by .Fa target . .Sh RETURN VALUES diff --git a/doc/ck_pr_or b/doc/ck_pr_or index c5ff055..dfb4a1e 100644 --- a/doc/ck_pr_or +++ b/doc/ck_pr_or @@ -52,7 +52,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_or 3 -family of functions will atomically compute and store the +family of functions atomically compute and store the result of a bitwise-or of the value pointed to by .Fa target and diff --git a/doc/ck_pr_sub b/doc/ck_pr_sub index c33f65d..df03031 100644 --- a/doc/ck_pr_sub +++ b/doc/ck_pr_sub @@ -54,7 +54,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_sub 3 -family of functions will atomically subtract the value specified by +family of functions atomically subtract the value specified by .Fa delta from the value pointed to by .Fa target . diff --git a/doc/ck_pr_xor b/doc/ck_pr_xor index 9b0dcb5..e3c1db8 100644 --- a/doc/ck_pr_xor +++ b/doc/ck_pr_xor @@ -52,7 +52,7 @@ Concurrency Kit (libck, \-lck) .Sh DESCRIPTION The .Fn ck_pr_xor 3 -family of functions will atomically compute and store the +family of functions atomically compute and store the result of a bitwise-xor of the value pointed to by .Fa target and From d05fb25cfd80adf9730c9c885d73438e57c7bc35 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 17 Apr 2013 12:13:55 -0400 Subject: [PATCH 52/60] regressions: Remove ITERATION specialization silliness. --- regressions/ck_spinlock/validate/ck_ticket_pb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/regressions/ck_spinlock/validate/ck_ticket_pb.c b/regressions/ck_spinlock/validate/ck_ticket_pb.c index 28cba32..e62ee0e 100644 --- a/regressions/ck_spinlock/validate/ck_ticket_pb.c +++ b/regressions/ck_spinlock/validate/ck_ticket_pb.c @@ -1,6 +1,2 @@ #include "../ck_ticket_pb.h" -#ifdef _WIN32 -#undef ITERATE -#define ITERATE 1000 -#endif #include "validate.h" From 9d37e38580e9d2c5a9224c7fd669a37cb96c1534 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Wed, 17 Apr 2013 12:47:46 -0400 Subject: [PATCH 53/60] regressions: Remove exes with make clean. --- regressions/ck_bag/validate/Makefile | 2 +- regressions/ck_barrier/benchmark/Makefile | 2 +- regressions/ck_barrier/validate/Makefile | 2 +- regressions/ck_bitmap/validate/Makefile | 2 +- regressions/ck_brlock/benchmark/Makefile | 2 +- regressions/ck_brlock/validate/Makefile | 2 +- regressions/ck_bytelock/benchmark/Makefile | 2 +- regressions/ck_bytelock/validate/Makefile | 2 +- regressions/ck_cohort/validate/Makefile | 2 +- regressions/ck_epoch/validate/Makefile | 2 +- regressions/ck_fifo/benchmark/Makefile | 2 +- regressions/ck_fifo/validate/Makefile | 2 +- regressions/ck_hp/benchmark/Makefile | 2 +- regressions/ck_hp/validate/Makefile | 2 +- regressions/ck_hs/benchmark/Makefile | 2 +- regressions/ck_hs/validate/Makefile | 2 +- regressions/ck_ht/benchmark/Makefile | 2 +- regressions/ck_ht/validate/Makefile | 2 +- regressions/ck_pflock/benchmark/Makefile | 2 +- regressions/ck_pflock/validate/Makefile | 2 +- regressions/ck_pr/validate/Makefile | 2 +- regressions/ck_queue/validate/Makefile | 2 +- regressions/ck_ring/benchmark/Makefile | 2 +- regressions/ck_ring/validate/Makefile | 2 +- regressions/ck_rwlock/benchmark/Makefile | 2 +- regressions/ck_rwlock/validate/Makefile | 2 +- regressions/ck_sequence/validate/Makefile | 2 +- regressions/ck_stack/benchmark/Makefile | 2 +- regressions/ck_stack/validate/Makefile | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/regressions/ck_bag/validate/Makefile b/regressions/ck_bag/validate/Makefile index 3df6823..534bac1 100644 --- a/regressions/ck_bag/validate/Makefile +++ b/regressions/ck_bag/validate/Makefile @@ -11,7 +11,7 @@ check: all ./order clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/benchmark/Makefile b/regressions/ck_barrier/benchmark/Makefile index 864c6fc..2b94460 100644 --- a/regressions/ck_barrier/benchmark/Makefile +++ b/regressions/ck_barrier/benchmark/Makefile @@ -8,7 +8,7 @@ throughput: throughput.c ../../../include/ck_barrier.h ../../../src/ck_barrier_c $(CC) $(CFLAGS) -o throughput throughput.c ../../../src/ck_barrier_centralized.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/validate/Makefile b/regressions/ck_barrier/validate/Makefile index f11b70a..266bdaf 100644 --- a/regressions/ck_barrier/validate/Makefile +++ b/regressions/ck_barrier/validate/Makefile @@ -28,7 +28,7 @@ check: all exit $$rc clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bitmap/validate/Makefile b/regressions/ck_bitmap/validate/Makefile index c96f924..6faa33d 100644 --- a/regressions/ck_bitmap/validate/Makefile +++ b/regressions/ck_bitmap/validate/Makefile @@ -8,7 +8,7 @@ serial: serial.c ../../../include/ck_bitmap.h $(CC) $(CFLAGS) -o serial serial.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM check: all ./serial diff --git a/regressions/ck_brlock/benchmark/Makefile b/regressions/ck_brlock/benchmark/Makefile index 1c6c0d6..fc5486f 100644 --- a/regressions/ck_brlock/benchmark/Makefile +++ b/regressions/ck_brlock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_brlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_brlock/validate/Makefile b/regressions/ck_brlock/validate/Makefile index e233d69..a5d21ab 100644 --- a/regressions/ck_brlock/validate/Makefile +++ b/regressions/ck_brlock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/benchmark/Makefile b/regressions/ck_bytelock/benchmark/Makefile index 0fe3712..d6700e9 100644 --- a/regressions/ck_bytelock/benchmark/Makefile +++ b/regressions/ck_bytelock/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/validate/Makefile b/regressions/ck_bytelock/validate/Makefile index dce3a0a..fd6def6 100644 --- a/regressions/ck_bytelock/validate/Makefile +++ b/regressions/ck_bytelock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_cohort/validate/Makefile b/regressions/ck_cohort/validate/Makefile index 794e3e6..f894659 100644 --- a/regressions/ck_cohort/validate/Makefile +++ b/regressions/ck_cohort/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate `expr $(CORES) / 2` 2 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_epoch/validate/Makefile b/regressions/ck_epoch/validate/Makefile index 59b2252..f89f094 100644 --- a/regressions/ck_epoch/validate/Makefile +++ b/regressions/ck_epoch/validate/Makefile @@ -20,7 +20,7 @@ ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../ $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/benchmark/Makefile b/regressions/ck_fifo/benchmark/Makefile index 50e5a09..1ef3baf 100644 --- a/regressions/ck_fifo/benchmark/Makefile +++ b/regressions/ck_fifo/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/validate/Makefile b/regressions/ck_fifo/validate/Makefile index d12d703..e6511ad 100644 --- a/regressions/ck_fifo/validate/Makefile +++ b/regressions/ck_fifo/validate/Makefile @@ -23,7 +23,7 @@ ck_fifo_mpmc_iterator: ck_fifo_mpmc_iterator.c ../../../include/ck_fifo.h $(CC) $(CFLAGS) -o ck_fifo_mpmc_iterator ck_fifo_mpmc_iterator.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/benchmark/Makefile b/regressions/ck_hp/benchmark/Makefile index 8ab5273..7b81edd 100644 --- a/regressions/ck_hp/benchmark/Makefile +++ b/regressions/ck_hp/benchmark/Makefile @@ -11,7 +11,7 @@ stack_latency: stack_latency.c $(CC) $(CFLAGS) -o stack_latency ../../../src/ck_hp.c stack_latency.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/validate/Makefile b/regressions/ck_hp/validate/Makefile index f1e091c..3d6d2a8 100644 --- a/regressions/ck_hp/validate/Makefile +++ b/regressions/ck_hp/validate/Makefile @@ -27,7 +27,7 @@ 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 clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hs/benchmark/Makefile b/regressions/ck_hs/benchmark/Makefile index 6ffdb43..58370a0 100644 --- a/regressions/ck_hs/benchmark/Makefile +++ b/regressions/ck_hs/benchmark/Makefile @@ -11,7 +11,7 @@ parallel_bytestring: parallel_bytestring.c ../../../include/ck_hs.h ../../../src $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_hs/validate/Makefile b/regressions/ck_hs/validate/Makefile index a01a08a..eebe842 100644 --- a/regressions/ck_hs/validate/Makefile +++ b/regressions/ck_hs/validate/Makefile @@ -11,7 +11,7 @@ check: all ./serial clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ht/benchmark/Makefile b/regressions/ck_ht/benchmark/Makefile index df5e16c..7667547 100644 --- a/regressions/ck_ht/benchmark/Makefile +++ b/regressions/ck_ht/benchmark/Makefile @@ -14,7 +14,7 @@ parallel_direct: parallel_direct.c ../../../include/ck_ht.h ../../../src/ck_ht.c $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_direct parallel_direct.c ../../../src/ck_ht.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ht/validate/Makefile b/regressions/ck_ht/validate/Makefile index f89e117..9e31b58 100644 --- a/regressions/ck_ht/validate/Makefile +++ b/regressions/ck_ht/validate/Makefile @@ -11,7 +11,7 @@ check: all ./serial clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_pflock/benchmark/Makefile b/regressions/ck_pflock/benchmark/Makefile index 59c0b53..e0f1519 100644 --- a/regressions/ck_pflock/benchmark/Makefile +++ b/regressions/ck_pflock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_rwlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pflock/validate/Makefile b/regressions/ck_pflock/validate/Makefile index fd25fea..8e61064 100644 --- a/regressions/ck_pflock/validate/Makefile +++ b/regressions/ck_pflock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pr/validate/Makefile b/regressions/ck_pr/validate/Makefile index c255b03..7eaa2db 100644 --- a/regressions/ck_pr/validate/Makefile +++ b/regressions/ck_pr/validate/Makefile @@ -78,7 +78,7 @@ ck_pr_unary: ck_pr_unary.c $(CC) $(CFLAGS) -o ck_pr_unary ck_pr_unary.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_queue/validate/Makefile b/regressions/ck_queue/validate/Makefile index 7a690d3..f13339b 100644 --- a/regressions/ck_queue/validate/Makefile +++ b/regressions/ck_queue/validate/Makefile @@ -20,7 +20,7 @@ ck_stailq: $(HEADER) ck_stailq.c $(CC) $(CFLAGS) -o ck_stailq ck_stailq.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_ring/benchmark/Makefile b/regressions/ck_ring/benchmark/Makefile index 7457654..5b0190e 100644 --- a/regressions/ck_ring/benchmark/Makefile +++ b/regressions/ck_ring/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c ../../../include/ck_ring.h $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile index cd63556..f713f40 100644 --- a/regressions/ck_ring/validate/Makefile +++ b/regressions/ck_ring/validate/Makefile @@ -28,7 +28,7 @@ ck_ring_spmc: ck_ring_spmc.c ../../../include/ck_ring.h ../../../src/ck_barrier_centralized.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/benchmark/Makefile b/regressions/ck_rwlock/benchmark/Makefile index 59c0b53..e0f1519 100644 --- a/regressions/ck_rwlock/benchmark/Makefile +++ b/regressions/ck_rwlock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_rwlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/validate/Makefile b/regressions/ck_rwlock/validate/Makefile index 2dbaa37..2ed443a 100644 --- a/regressions/ck_rwlock/validate/Makefile +++ b/regressions/ck_rwlock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_sequence/validate/Makefile b/regressions/ck_sequence/validate/Makefile index 28e7db0..ace69a7 100644 --- a/regressions/ck_sequence/validate/Makefile +++ b/regressions/ck_sequence/validate/Makefile @@ -11,7 +11,7 @@ check: all ./ck_sequence $(CORES) 1 clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_stack/benchmark/Makefile b/regressions/ck_stack/benchmark/Makefile index 50e5a09..1ef3baf 100644 --- a/regressions/ck_stack/benchmark/Makefile +++ b/regressions/ck_stack/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_stack/validate/Makefile b/regressions/ck_stack/validate/Makefile index b81c166..ef74c3b 100644 --- a/regressions/ck_stack/validate/Makefile +++ b/regressions/ck_stack/validate/Makefile @@ -50,7 +50,7 @@ mpmc_trypair mpmc_pair spinlock_pair spinlock_eb_pair pthreads_pair: pair.c $(CC) -DPTHREADS $(CFLAGS) -o pthreads_pair pair.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE From 099ec934b2ba7294616808638d63f67d2aa0082d Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Wed, 17 Apr 2013 14:57:41 -0400 Subject: [PATCH 54/60] regressions/ck_queue: Remove stale include file. This was added during testing to verify parity with sys/queue.h. --- regressions/ck_queue/validate/ck_stailq.c | 1 - 1 file changed, 1 deletion(-) diff --git a/regressions/ck_queue/validate/ck_stailq.c b/regressions/ck_queue/validate/ck_stailq.c index a129068..0268afc 100644 --- a/regressions/ck_queue/validate/ck_stailq.c +++ b/regressions/ck_queue/validate/ck_stailq.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "../../common.h" struct test { From a4cd7f2ef2a5f55677a880ac4f7ff1a28a7f6fe8 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Thu, 18 Apr 2013 16:10:31 -0400 Subject: [PATCH 55/60] Revert "regressions: Remove exes with make clean." This reverts commit 9d37e38580e9d2c5a9224c7fd669a37cb96c1534. --- regressions/ck_bag/validate/Makefile | 2 +- regressions/ck_barrier/benchmark/Makefile | 2 +- regressions/ck_barrier/validate/Makefile | 2 +- regressions/ck_bitmap/validate/Makefile | 2 +- regressions/ck_brlock/benchmark/Makefile | 2 +- regressions/ck_brlock/validate/Makefile | 2 +- regressions/ck_bytelock/benchmark/Makefile | 2 +- regressions/ck_bytelock/validate/Makefile | 2 +- regressions/ck_cohort/validate/Makefile | 2 +- regressions/ck_epoch/validate/Makefile | 2 +- regressions/ck_fifo/benchmark/Makefile | 2 +- regressions/ck_fifo/validate/Makefile | 2 +- regressions/ck_hp/benchmark/Makefile | 2 +- regressions/ck_hp/validate/Makefile | 2 +- regressions/ck_hs/benchmark/Makefile | 2 +- regressions/ck_hs/validate/Makefile | 2 +- regressions/ck_ht/benchmark/Makefile | 2 +- regressions/ck_ht/validate/Makefile | 2 +- regressions/ck_pflock/benchmark/Makefile | 2 +- regressions/ck_pflock/validate/Makefile | 2 +- regressions/ck_pr/validate/Makefile | 2 +- regressions/ck_queue/validate/Makefile | 2 +- regressions/ck_ring/benchmark/Makefile | 2 +- regressions/ck_ring/validate/Makefile | 2 +- regressions/ck_rwlock/benchmark/Makefile | 2 +- regressions/ck_rwlock/validate/Makefile | 2 +- regressions/ck_sequence/validate/Makefile | 2 +- regressions/ck_stack/benchmark/Makefile | 2 +- regressions/ck_stack/validate/Makefile | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/regressions/ck_bag/validate/Makefile b/regressions/ck_bag/validate/Makefile index 534bac1..3df6823 100644 --- a/regressions/ck_bag/validate/Makefile +++ b/regressions/ck_bag/validate/Makefile @@ -11,7 +11,7 @@ check: all ./order clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/benchmark/Makefile b/regressions/ck_barrier/benchmark/Makefile index 2b94460..864c6fc 100644 --- a/regressions/ck_barrier/benchmark/Makefile +++ b/regressions/ck_barrier/benchmark/Makefile @@ -8,7 +8,7 @@ throughput: throughput.c ../../../include/ck_barrier.h ../../../src/ck_barrier_c $(CC) $(CFLAGS) -o throughput throughput.c ../../../src/ck_barrier_centralized.c clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/validate/Makefile b/regressions/ck_barrier/validate/Makefile index 266bdaf..f11b70a 100644 --- a/regressions/ck_barrier/validate/Makefile +++ b/regressions/ck_barrier/validate/Makefile @@ -28,7 +28,7 @@ check: all exit $$rc clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bitmap/validate/Makefile b/regressions/ck_bitmap/validate/Makefile index 6faa33d..c96f924 100644 --- a/regressions/ck_bitmap/validate/Makefile +++ b/regressions/ck_bitmap/validate/Makefile @@ -8,7 +8,7 @@ serial: serial.c ../../../include/ck_bitmap.h $(CC) $(CFLAGS) -o serial serial.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM check: all ./serial diff --git a/regressions/ck_brlock/benchmark/Makefile b/regressions/ck_brlock/benchmark/Makefile index fc5486f..1c6c0d6 100644 --- a/regressions/ck_brlock/benchmark/Makefile +++ b/regressions/ck_brlock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_brlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_brlock/validate/Makefile b/regressions/ck_brlock/validate/Makefile index a5d21ab..e233d69 100644 --- a/regressions/ck_brlock/validate/Makefile +++ b/regressions/ck_brlock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/benchmark/Makefile b/regressions/ck_bytelock/benchmark/Makefile index d6700e9..0fe3712 100644 --- a/regressions/ck_bytelock/benchmark/Makefile +++ b/regressions/ck_bytelock/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/validate/Makefile b/regressions/ck_bytelock/validate/Makefile index fd6def6..dce3a0a 100644 --- a/regressions/ck_bytelock/validate/Makefile +++ b/regressions/ck_bytelock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_cohort/validate/Makefile b/regressions/ck_cohort/validate/Makefile index f894659..794e3e6 100644 --- a/regressions/ck_cohort/validate/Makefile +++ b/regressions/ck_cohort/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate `expr $(CORES) / 2` 2 1 clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_epoch/validate/Makefile b/regressions/ck_epoch/validate/Makefile index f89f094..59b2252 100644 --- a/regressions/ck_epoch/validate/Makefile +++ b/regressions/ck_epoch/validate/Makefile @@ -20,7 +20,7 @@ ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../ $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/benchmark/Makefile b/regressions/ck_fifo/benchmark/Makefile index 1ef3baf..50e5a09 100644 --- a/regressions/ck_fifo/benchmark/Makefile +++ b/regressions/ck_fifo/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/validate/Makefile b/regressions/ck_fifo/validate/Makefile index e6511ad..d12d703 100644 --- a/regressions/ck_fifo/validate/Makefile +++ b/regressions/ck_fifo/validate/Makefile @@ -23,7 +23,7 @@ ck_fifo_mpmc_iterator: ck_fifo_mpmc_iterator.c ../../../include/ck_fifo.h $(CC) $(CFLAGS) -o ck_fifo_mpmc_iterator ck_fifo_mpmc_iterator.c clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/benchmark/Makefile b/regressions/ck_hp/benchmark/Makefile index 7b81edd..8ab5273 100644 --- a/regressions/ck_hp/benchmark/Makefile +++ b/regressions/ck_hp/benchmark/Makefile @@ -11,7 +11,7 @@ stack_latency: stack_latency.c $(CC) $(CFLAGS) -o stack_latency ../../../src/ck_hp.c stack_latency.c clean: - rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/validate/Makefile b/regressions/ck_hp/validate/Makefile index 3d6d2a8..f1e091c 100644 --- a/regressions/ck_hp/validate/Makefile +++ b/regressions/ck_hp/validate/Makefile @@ -27,7 +27,7 @@ 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 clean: - rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hs/benchmark/Makefile b/regressions/ck_hs/benchmark/Makefile index 58370a0..6ffdb43 100644 --- a/regressions/ck_hs/benchmark/Makefile +++ b/regressions/ck_hs/benchmark/Makefile @@ -11,7 +11,7 @@ parallel_bytestring: parallel_bytestring.c ../../../include/ck_hs.h ../../../src $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_hs/validate/Makefile b/regressions/ck_hs/validate/Makefile index eebe842..a01a08a 100644 --- a/regressions/ck_hs/validate/Makefile +++ b/regressions/ck_hs/validate/Makefile @@ -11,7 +11,7 @@ check: all ./serial clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ht/benchmark/Makefile b/regressions/ck_ht/benchmark/Makefile index 7667547..df5e16c 100644 --- a/regressions/ck_ht/benchmark/Makefile +++ b/regressions/ck_ht/benchmark/Makefile @@ -14,7 +14,7 @@ parallel_direct: parallel_direct.c ../../../include/ck_ht.h ../../../src/ck_ht.c $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_direct parallel_direct.c ../../../src/ck_ht.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ht/validate/Makefile b/regressions/ck_ht/validate/Makefile index 9e31b58..f89e117 100644 --- a/regressions/ck_ht/validate/Makefile +++ b/regressions/ck_ht/validate/Makefile @@ -11,7 +11,7 @@ check: all ./serial clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_pflock/benchmark/Makefile b/regressions/ck_pflock/benchmark/Makefile index e0f1519..59c0b53 100644 --- a/regressions/ck_pflock/benchmark/Makefile +++ b/regressions/ck_pflock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_rwlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pflock/validate/Makefile b/regressions/ck_pflock/validate/Makefile index 8e61064..fd25fea 100644 --- a/regressions/ck_pflock/validate/Makefile +++ b/regressions/ck_pflock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pr/validate/Makefile b/regressions/ck_pr/validate/Makefile index 7eaa2db..c255b03 100644 --- a/regressions/ck_pr/validate/Makefile +++ b/regressions/ck_pr/validate/Makefile @@ -78,7 +78,7 @@ ck_pr_unary: ck_pr_unary.c $(CC) $(CFLAGS) -o ck_pr_unary ck_pr_unary.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_queue/validate/Makefile b/regressions/ck_queue/validate/Makefile index f13339b..7a690d3 100644 --- a/regressions/ck_queue/validate/Makefile +++ b/regressions/ck_queue/validate/Makefile @@ -20,7 +20,7 @@ ck_stailq: $(HEADER) ck_stailq.c $(CC) $(CFLAGS) -o ck_stailq ck_stailq.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_ring/benchmark/Makefile b/regressions/ck_ring/benchmark/Makefile index 5b0190e..7457654 100644 --- a/regressions/ck_ring/benchmark/Makefile +++ b/regressions/ck_ring/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c ../../../include/ck_ring.h $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile index f713f40..cd63556 100644 --- a/regressions/ck_ring/validate/Makefile +++ b/regressions/ck_ring/validate/Makefile @@ -28,7 +28,7 @@ ck_ring_spmc: ck_ring_spmc.c ../../../include/ck_ring.h ../../../src/ck_barrier_centralized.c clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/benchmark/Makefile b/regressions/ck_rwlock/benchmark/Makefile index e0f1519..59c0b53 100644 --- a/regressions/ck_rwlock/benchmark/Makefile +++ b/regressions/ck_rwlock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_rwlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/validate/Makefile b/regressions/ck_rwlock/validate/Makefile index 2ed443a..2dbaa37 100644 --- a/regressions/ck_rwlock/validate/Makefile +++ b/regressions/ck_rwlock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o *.exe $(OBJECTS) + rm -rf *.dSYM *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_sequence/validate/Makefile b/regressions/ck_sequence/validate/Makefile index ace69a7..28e7db0 100644 --- a/regressions/ck_sequence/validate/Makefile +++ b/regressions/ck_sequence/validate/Makefile @@ -11,7 +11,7 @@ check: all ./ck_sequence $(CORES) 1 clean: - rm -rf *~ *.o *.exe $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_stack/benchmark/Makefile b/regressions/ck_stack/benchmark/Makefile index 1ef3baf..50e5a09 100644 --- a/regressions/ck_stack/benchmark/Makefile +++ b/regressions/ck_stack/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_stack/validate/Makefile b/regressions/ck_stack/validate/Makefile index ef74c3b..b81c166 100644 --- a/regressions/ck_stack/validate/Makefile +++ b/regressions/ck_stack/validate/Makefile @@ -50,7 +50,7 @@ mpmc_trypair mpmc_pair spinlock_pair spinlock_eb_pair pthreads_pair: pair.c $(CC) -DPTHREADS $(CFLAGS) -o pthreads_pair pair.c clean: - rm -rf *~ *.o *.exe *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE From 7b94d7c13d45e92c2ce0fc6db058382fac978356 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Thu, 18 Apr 2013 16:14:11 -0400 Subject: [PATCH 56/60] regressions: Make clean and gettimeofday fixes. --- regressions/ck_backoff/validate/Makefile | 2 +- regressions/ck_bag/validate/Makefile | 2 +- regressions/ck_barrier/benchmark/Makefile | 2 +- regressions/ck_barrier/validate/Makefile | 2 +- regressions/ck_bitmap/validate/Makefile | 2 +- regressions/ck_brlock/benchmark/Makefile | 2 +- regressions/ck_brlock/validate/Makefile | 2 +- regressions/ck_bytelock/benchmark/Makefile | 2 +- regressions/ck_bytelock/validate/Makefile | 2 +- regressions/ck_cohort/benchmark/Makefile | 2 +- regressions/ck_cohort/validate/Makefile | 2 +- regressions/ck_epoch/validate/Makefile | 2 +- regressions/ck_fifo/benchmark/Makefile | 2 +- regressions/ck_fifo/validate/Makefile | 2 +- regressions/ck_hp/benchmark/Makefile | 2 +- regressions/ck_hp/validate/Makefile | 2 +- regressions/ck_hs/benchmark/Makefile | 2 +- regressions/ck_hs/validate/Makefile | 2 +- regressions/ck_ht/benchmark/Makefile | 2 +- regressions/ck_ht/validate/Makefile | 2 +- regressions/ck_pflock/benchmark/Makefile | 2 +- regressions/ck_pflock/validate/Makefile | 2 +- regressions/ck_pr/benchmark/Makefile | 2 +- regressions/ck_pr/validate/Makefile | 2 +- regressions/ck_queue/validate/Makefile | 2 +- regressions/ck_ring/benchmark/Makefile | 2 +- regressions/ck_ring/validate/Makefile | 2 +- regressions/ck_rwlock/benchmark/Makefile | 2 +- regressions/ck_rwlock/validate/Makefile | 2 +- regressions/ck_sequence/validate/Makefile | 2 +- regressions/ck_spinlock/benchmark/Makefile | 2 +- regressions/ck_spinlock/validate/Makefile | 2 +- regressions/ck_stack/benchmark/Makefile | 2 +- regressions/ck_stack/validate/Makefile | 2 +- regressions/common.h | 6 +++--- 35 files changed, 37 insertions(+), 37 deletions(-) diff --git a/regressions/ck_backoff/validate/Makefile b/regressions/ck_backoff/validate/Makefile index 60cd40b..39e6d4f 100644 --- a/regressions/ck_backoff/validate/Makefile +++ b/regressions/ck_backoff/validate/Makefile @@ -9,7 +9,7 @@ check: all ./validate clean: - rm -rf validate *.dSYM + rm -rf validate *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_bag/validate/Makefile b/regressions/ck_bag/validate/Makefile index 3df6823..b06f8b7 100644 --- a/regressions/ck_bag/validate/Makefile +++ b/regressions/ck_bag/validate/Makefile @@ -11,7 +11,7 @@ check: all ./order clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/benchmark/Makefile b/regressions/ck_barrier/benchmark/Makefile index 864c6fc..ea973d2 100644 --- a/regressions/ck_barrier/benchmark/Makefile +++ b/regressions/ck_barrier/benchmark/Makefile @@ -8,7 +8,7 @@ throughput: throughput.c ../../../include/ck_barrier.h ../../../src/ck_barrier_c $(CC) $(CFLAGS) -o throughput throughput.c ../../../src/ck_barrier_centralized.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/validate/Makefile b/regressions/ck_barrier/validate/Makefile index f11b70a..f31a1a6 100644 --- a/regressions/ck_barrier/validate/Makefile +++ b/regressions/ck_barrier/validate/Makefile @@ -28,7 +28,7 @@ check: all exit $$rc clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bitmap/validate/Makefile b/regressions/ck_bitmap/validate/Makefile index c96f924..85e13c8 100644 --- a/regressions/ck_bitmap/validate/Makefile +++ b/regressions/ck_bitmap/validate/Makefile @@ -8,7 +8,7 @@ serial: serial.c ../../../include/ck_bitmap.h $(CC) $(CFLAGS) -o serial serial.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe check: all ./serial diff --git a/regressions/ck_brlock/benchmark/Makefile b/regressions/ck_brlock/benchmark/Makefile index 1c6c0d6..cd12e7c 100644 --- a/regressions/ck_brlock/benchmark/Makefile +++ b/regressions/ck_brlock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_brlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_brlock/validate/Makefile b/regressions/ck_brlock/validate/Makefile index e233d69..3a49c43 100644 --- a/regressions/ck_brlock/validate/Makefile +++ b/regressions/ck_brlock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/benchmark/Makefile b/regressions/ck_bytelock/benchmark/Makefile index 0fe3712..c819099 100644 --- a/regressions/ck_bytelock/benchmark/Makefile +++ b/regressions/ck_bytelock/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/validate/Makefile b/regressions/ck_bytelock/validate/Makefile index dce3a0a..2a890e0 100644 --- a/regressions/ck_bytelock/validate/Makefile +++ b/regressions/ck_bytelock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_cohort/benchmark/Makefile b/regressions/ck_cohort/benchmark/Makefile index 7cf62da..6af18b9 100644 --- a/regressions/ck_cohort/benchmark/Makefile +++ b/regressions/ck_cohort/benchmark/Makefile @@ -11,7 +11,7 @@ ck_cohort.LATENCY: ck_cohort.c $(CC) -DLATENCY $(CFLAGS) -o ck_cohort.LATENCY ck_cohort.c clean: - rm -rf *.dSYM $(OBJECTS) + rm -rf *.dSYM *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm diff --git a/regressions/ck_cohort/validate/Makefile b/regressions/ck_cohort/validate/Makefile index 794e3e6..145af3a 100644 --- a/regressions/ck_cohort/validate/Makefile +++ b/regressions/ck_cohort/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate `expr $(CORES) / 2` 2 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_epoch/validate/Makefile b/regressions/ck_epoch/validate/Makefile index 59b2252..73f8e5d 100644 --- a/regressions/ck_epoch/validate/Makefile +++ b/regressions/ck_epoch/validate/Makefile @@ -20,7 +20,7 @@ ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../ $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/benchmark/Makefile b/regressions/ck_fifo/benchmark/Makefile index 50e5a09..6e2df2a 100644 --- a/regressions/ck_fifo/benchmark/Makefile +++ b/regressions/ck_fifo/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/validate/Makefile b/regressions/ck_fifo/validate/Makefile index d12d703..a669896 100644 --- a/regressions/ck_fifo/validate/Makefile +++ b/regressions/ck_fifo/validate/Makefile @@ -23,7 +23,7 @@ ck_fifo_mpmc_iterator: ck_fifo_mpmc_iterator.c ../../../include/ck_fifo.h $(CC) $(CFLAGS) -o ck_fifo_mpmc_iterator ck_fifo_mpmc_iterator.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/benchmark/Makefile b/regressions/ck_hp/benchmark/Makefile index 8ab5273..2025ea9 100644 --- a/regressions/ck_hp/benchmark/Makefile +++ b/regressions/ck_hp/benchmark/Makefile @@ -11,7 +11,7 @@ stack_latency: stack_latency.c $(CC) $(CFLAGS) -o stack_latency ../../../src/ck_hp.c stack_latency.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/validate/Makefile b/regressions/ck_hp/validate/Makefile index f1e091c..476b34f 100644 --- a/regressions/ck_hp/validate/Makefile +++ b/regressions/ck_hp/validate/Makefile @@ -27,7 +27,7 @@ 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 clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hs/benchmark/Makefile b/regressions/ck_hs/benchmark/Makefile index 6ffdb43..18ccdba 100644 --- a/regressions/ck_hs/benchmark/Makefile +++ b/regressions/ck_hs/benchmark/Makefile @@ -11,7 +11,7 @@ parallel_bytestring: parallel_bytestring.c ../../../include/ck_hs.h ../../../src $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_hs/validate/Makefile b/regressions/ck_hs/validate/Makefile index a01a08a..a96e652 100644 --- a/regressions/ck_hs/validate/Makefile +++ b/regressions/ck_hs/validate/Makefile @@ -11,7 +11,7 @@ check: all ./serial clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ht/benchmark/Makefile b/regressions/ck_ht/benchmark/Makefile index df5e16c..8e21d5b 100644 --- a/regressions/ck_ht/benchmark/Makefile +++ b/regressions/ck_ht/benchmark/Makefile @@ -14,7 +14,7 @@ parallel_direct: parallel_direct.c ../../../include/ck_ht.h ../../../src/ck_ht.c $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_direct parallel_direct.c ../../../src/ck_ht.c ../../../src/ck_epoch.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ht/validate/Makefile b/regressions/ck_ht/validate/Makefile index f89e117..5942975 100644 --- a/regressions/ck_ht/validate/Makefile +++ b/regressions/ck_ht/validate/Makefile @@ -11,7 +11,7 @@ check: all ./serial clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_pflock/benchmark/Makefile b/regressions/ck_pflock/benchmark/Makefile index 59c0b53..6f739d9 100644 --- a/regressions/ck_pflock/benchmark/Makefile +++ b/regressions/ck_pflock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_rwlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pflock/validate/Makefile b/regressions/ck_pflock/validate/Makefile index fd25fea..eea9d02 100644 --- a/regressions/ck_pflock/validate/Makefile +++ b/regressions/ck_pflock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pr/benchmark/Makefile b/regressions/ck_pr/benchmark/Makefile index 669b2a2..f43e792 100644 --- a/regressions/ck_pr/benchmark/Makefile +++ b/regressions/ck_pr/benchmark/Makefile @@ -12,7 +12,7 @@ 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 + rm -rf ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm diff --git a/regressions/ck_pr/validate/Makefile b/regressions/ck_pr/validate/Makefile index c255b03..9e4a82d 100644 --- a/regressions/ck_pr/validate/Makefile +++ b/regressions/ck_pr/validate/Makefile @@ -78,7 +78,7 @@ ck_pr_unary: ck_pr_unary.c $(CC) $(CFLAGS) -o ck_pr_unary ck_pr_unary.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_queue/validate/Makefile b/regressions/ck_queue/validate/Makefile index 7a690d3..d6be3dc 100644 --- a/regressions/ck_queue/validate/Makefile +++ b/regressions/ck_queue/validate/Makefile @@ -20,7 +20,7 @@ ck_stailq: $(HEADER) ck_stailq.c $(CC) $(CFLAGS) -o ck_stailq ck_stailq.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_ring/benchmark/Makefile b/regressions/ck_ring/benchmark/Makefile index 7457654..4087ed1 100644 --- a/regressions/ck_ring/benchmark/Makefile +++ b/regressions/ck_ring/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c ../../../include/ck_ring.h $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile index cd63556..83d4273 100644 --- a/regressions/ck_ring/validate/Makefile +++ b/regressions/ck_ring/validate/Makefile @@ -28,7 +28,7 @@ ck_ring_spmc: ck_ring_spmc.c ../../../include/ck_ring.h ../../../src/ck_barrier_centralized.c clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/benchmark/Makefile b/regressions/ck_rwlock/benchmark/Makefile index 59c0b53..6f739d9 100644 --- a/regressions/ck_rwlock/benchmark/Makefile +++ b/regressions/ck_rwlock/benchmark/Makefile @@ -11,7 +11,7 @@ throughput: throughput.c ../../../include/ck_rwlock.h $(CC) $(CFLAGS) -o throughput throughput.c clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/validate/Makefile b/regressions/ck_rwlock/validate/Makefile index 2dbaa37..eeab170 100644 --- a/regressions/ck_rwlock/validate/Makefile +++ b/regressions/ck_rwlock/validate/Makefile @@ -11,7 +11,7 @@ check: all ./validate $(CORES) 1 clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) + rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_sequence/validate/Makefile b/regressions/ck_sequence/validate/Makefile index 28e7db0..bc2e5be 100644 --- a/regressions/ck_sequence/validate/Makefile +++ b/regressions/ck_sequence/validate/Makefile @@ -11,7 +11,7 @@ check: all ./ck_sequence $(CORES) 1 clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_spinlock/benchmark/Makefile b/regressions/ck_spinlock/benchmark/Makefile index 61e70db..14bd901 100644 --- a/regressions/ck_spinlock/benchmark/Makefile +++ b/regressions/ck_spinlock/benchmark/Makefile @@ -74,7 +74,7 @@ ck_anderson.LATENCY: ck_anderson.c $(CC) -DLATENCY $(CFLAGS) -o ck_anderson.LATENCY ck_anderson.c clean: - rm -rf *.dSYM $(OBJECTS) + rm -rf *.dSYM *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm diff --git a/regressions/ck_spinlock/validate/Makefile b/regressions/ck_spinlock/validate/Makefile index 964085b..da37bae 100644 --- a/regressions/ck_spinlock/validate/Makefile +++ b/regressions/ck_spinlock/validate/Makefile @@ -47,7 +47,7 @@ ck_dec: ck_dec.c clean: rm -rf ck_ticket ck_mcs ck_dec ck_cas ck_fas ck_clh linux_spinlock ck_ticket_pb \ - ck_anderson ck_spinlock *.dSYM + ck_anderson ck_spinlock *.dSYM *.exe include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm diff --git a/regressions/ck_stack/benchmark/Makefile b/regressions/ck_stack/benchmark/Makefile index 50e5a09..6e2df2a 100644 --- a/regressions/ck_stack/benchmark/Makefile +++ b/regressions/ck_stack/benchmark/Makefile @@ -8,7 +8,7 @@ latency: latency.c $(CC) $(CFLAGS) -o latency latency.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_stack/validate/Makefile b/regressions/ck_stack/validate/Makefile index b81c166..519dca1 100644 --- a/regressions/ck_stack/validate/Makefile +++ b/regressions/ck_stack/validate/Makefile @@ -50,7 +50,7 @@ mpmc_trypair mpmc_pair spinlock_pair spinlock_eb_pair pthreads_pair: pair.c $(CC) -DPTHREADS $(CFLAGS) -o pthreads_pair pair.c clean: - rm -rf *~ *.o *.dSYM $(OBJECTS) + rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) include ../../../build/regressions.build CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/common.h b/regressions/common.h index e6f9f5a..eec39cf 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef __linux__ #include @@ -46,7 +47,6 @@ #define DELTA_EPOCH 11644473600000000ULL #else #include -#include #include #endif @@ -137,6 +137,7 @@ common_gettimeofday(struct timeval *tv, void *tz) FILETIME ft; uint64_t tmp_time = 0; static bool tzflag = false; + struct timezone *tzp = NULL; if (tv != NULL) { GetSystemTimeAsFileTime(&ft); @@ -161,8 +162,7 @@ common_gettimeofday(struct timeval *tv, void *tz) tzflag = true; } - struct timezone *tzp = (struct timezone *)tz; - + tzp = (struct timezone *)tz; tzp->tz_minuteswest = _timezone / 60; tzp->tz_dsttime = _daylight; } From d17d8e87bb13494d8eda032f379fcd0191d317a5 Mon Sep 17 00:00:00 2001 From: David Joseph Date: Thu, 18 Apr 2013 16:56:04 -0400 Subject: [PATCH 57/60] regressions: Remove void * casting. --- regressions/common.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index eec39cf..ce5aa92 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -137,7 +137,7 @@ common_gettimeofday(struct timeval *tv, void *tz) FILETIME ft; uint64_t tmp_time = 0; static bool tzflag = false; - struct timezone *tzp = NULL; + struct timezone *tzp = tz; if (tv != NULL) { GetSystemTimeAsFileTime(&ft); @@ -162,7 +162,6 @@ common_gettimeofday(struct timeval *tv, void *tz) tzflag = true; } - tzp = (struct timezone *)tz; tzp->tz_minuteswest = _timezone / 60; tzp->tz_dsttime = _daylight; } @@ -180,7 +179,7 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) (void)sig_handler; (void)duration; bool success; - HANDLE *alarm_handle = (HANDLE *)alarm_event; + HANDLE *alarm_handle = alarm_event; success = SetEvent(*alarm_handle); assert(success != false); return 0; From 1201e095775feb520b4d26bab060105356395d02 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sat, 20 Apr 2013 19:12:08 -0400 Subject: [PATCH 58/60] ck_ring: Remove stale comment. --- include/ck_ring.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/ck_ring.h b/include/ck_ring.h index e97e00b..a089bd3 100644 --- a/include/ck_ring.h +++ b/include/ck_ring.h @@ -229,9 +229,6 @@ struct ck_ring { }; typedef struct ck_ring ck_ring_t; -/* - * Single consumer and single producer ring buffer enqueue (producer). - */ CK_CC_INLINE static unsigned int ck_ring_size(struct ck_ring *ring) { From 16e8b1c672294f35ac4bc0cc3f215f7667b81f15 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 21 Apr 2013 06:54:38 -0400 Subject: [PATCH 59/60] regressions/ck_ring: Allow for buffers of size 4 or more. --- regressions/ck_ring/validate/ck_ring_spmc.c | 2 +- regressions/ck_ring/validate/ck_ring_spmc_template.c | 2 +- regressions/ck_ring/validate/ck_ring_spsc.c | 2 +- regressions/ck_ring/validate/ck_ring_spsc_template.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/regressions/ck_ring/validate/ck_ring_spmc.c b/regressions/ck_ring/validate/ck_ring_spmc.c index 259a8a1..75b8d18 100644 --- a/regressions/ck_ring/validate/ck_ring_spmc.c +++ b/regressions/ck_ring/validate/ck_ring_spmc.c @@ -241,7 +241,7 @@ main(int argc, char *argv[]) assert(nthr >= 1); size = atoi(argv[3]); - assert(size > 4 && (size & size - 1) == 0); + assert(size >= 4 && (size & size - 1) == 0); size -= 1; ring = malloc(sizeof(ck_ring_t) * nthr); diff --git a/regressions/ck_ring/validate/ck_ring_spmc_template.c b/regressions/ck_ring/validate/ck_ring_spmc_template.c index 08a7eb1..379329b 100644 --- a/regressions/ck_ring/validate/ck_ring_spmc_template.c +++ b/regressions/ck_ring/validate/ck_ring_spmc_template.c @@ -214,7 +214,7 @@ main(int argc, char *argv[]) assert(nthr >= 1); size = atoi(argv[3]); - assert(size > 4 && (size & size - 1) == 0); + assert(size >= 4 && (size & size - 1) == 0); size -= 1; ring = malloc(sizeof(ck_ring_t) * nthr); diff --git a/regressions/ck_ring/validate/ck_ring_spsc.c b/regressions/ck_ring/validate/ck_ring_spsc.c index 080f9c7..9dbb079 100644 --- a/regressions/ck_ring/validate/ck_ring_spsc.c +++ b/regressions/ck_ring/validate/ck_ring_spsc.c @@ -166,7 +166,7 @@ main(int argc, char *argv[]) assert(nthr >= 1); size = atoi(argv[3]); - assert(size > 4 && (size & size - 1) == 0); + assert(size >= 4 && (size & size - 1) == 0); size -= 1; ring = malloc(sizeof(ck_ring_t) * nthr); diff --git a/regressions/ck_ring/validate/ck_ring_spsc_template.c b/regressions/ck_ring/validate/ck_ring_spsc_template.c index 6b4b4c5..d176986 100644 --- a/regressions/ck_ring/validate/ck_ring_spsc_template.c +++ b/regressions/ck_ring/validate/ck_ring_spsc_template.c @@ -167,7 +167,7 @@ main(int argc, char *argv[]) assert(nthr >= 1); size = atoi(argv[3]); - assert(size > 4 && (size & size - 1) == 0); + assert(size >= 4 && (size & size - 1) == 0); size -= 1; ring = malloc(sizeof(CK_RING_INSTANCE(entry_ring)) * nthr); From ced5ade8931e7f890e955e56f32b1e333d2b0819 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 21 Apr 2013 07:40:18 -0400 Subject: [PATCH 60/60] doc: Add ck_ring manual pages. --- doc/Makefile.in | 18 ++++-- doc/ck_ring_dequeue_spmc | 107 +++++++++++++++++++++++++++++++ doc/ck_ring_dequeue_spsc | 103 ++++++++++++++++++++++++++++++ doc/ck_ring_enqueue_spmc | 103 ++++++++++++++++++++++++++++++ doc/ck_ring_enqueue_spmc_size | 115 +++++++++++++++++++++++++++++++++ doc/ck_ring_enqueue_spsc | 101 +++++++++++++++++++++++++++++ doc/ck_ring_enqueue_spsc_size | 116 ++++++++++++++++++++++++++++++++++ doc/ck_ring_init | 66 +++++++++++++++++++ doc/ck_ring_trydequeue_spmc | 114 +++++++++++++++++++++++++++++++++ 9 files changed, 839 insertions(+), 4 deletions(-) create mode 100644 doc/ck_ring_dequeue_spmc create mode 100644 doc/ck_ring_dequeue_spsc create mode 100644 doc/ck_ring_enqueue_spmc create mode 100644 doc/ck_ring_enqueue_spmc_size create mode 100644 doc/ck_ring_enqueue_spsc create mode 100644 doc/ck_ring_enqueue_spsc_size create mode 100644 doc/ck_ring_init create mode 100644 doc/ck_ring_trydequeue_spmc diff --git a/doc/Makefile.in b/doc/Makefile.in index a8604e8..b67dfc8 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -108,7 +108,15 @@ OBJECTS=ck_ht_count \ ck_pr_btc \ ck_pr_btr \ ck_pr_store \ - ck_pr_load + ck_pr_load \ + ck_ring_init \ + ck_ring_dequeue_spmc \ + ck_ring_enqueue_spmc \ + ck_ring_enqueue_spmc_size \ + ck_ring_trydequeue_spmc \ + ck_ring_dequeue_spsc \ + ck_ring_enqueue_spsc \ + ck_ring_enqueue_spsc_size all: for target in $(OBJECTS); do \ @@ -116,9 +124,11 @@ all: done html: - for target in $(OBJECTS); do \ - echo $$target; \ - groff -man -Tascii $(SRC_DIR)/doc/$$target | man2html -noheads -bare -cgiurl='$$title.html' > $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ + for target in $(OBJECTS); do \ + echo $$target; \ + groff -man -Tascii $(SRC_DIR)/doc/$$target | \ + man2html -noheads -bare -cgiurl='$$title.html' > \ + $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ done install: diff --git a/doc/ck_ring_dequeue_spmc b/doc/ck_ring_dequeue_spmc new file mode 100644 index 0000000..076ceec --- /dev/null +++ b/doc/ck_ring_dequeue_spmc @@ -0,0 +1,107 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_DEQUEUE_SPMC 3 +.Sh NAME +.Nm ck_ring_dequeue_spmc +.Nd dequeue pointer from bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_dequeue_spmc "ck_ring_t *ring" "void *result" +.Sh DESCRIPTION +The +.Fn ck_ring_dequeue_spmc 3 +function dequeues a pointer from the bounded buffer +pointed to by +.Fa ring +in FIFO fashion. The pointer is stored in the pointer +pointed to by +.Fa result . +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa result . +This function is safe to call without locking for UINT_MAX +concurrent invocations of +.Fn ck_ring_dequeue_spmc 3 +or +.Fn ck_ring_trydequeue_spmc 3 +and up to one concurrent +.Fn ck_ring_enqueue_spmc 3 +or +.Fn ck_ring_tryenqueue_spmc 3 +invocation. This function provides lock-free progress +guarantees. +.Sh EXAMPLE +.Bd -literal -offset indent +#include + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +void +dequeue(void) +{ + void *result; + + /* Dequeue from ring until it is empty. */ + while (ck_ring_dequeue_spmc(&ring, &result) == true) { + /* + * Results contains the oldest pointer in ring + * since the dequeue operation returned true. + */ + operation(result); + } + + /* An empty ring was encountered, leave. */ + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the buffer was non-empty. +The result of the dequeue operation is stored in the +value pointed to by +.Fa result . +The function will return false if the buffer was empty +and the value in +.Fa result +will be undefined. +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_dequeue_spsc b/doc/ck_ring_dequeue_spsc new file mode 100644 index 0000000..ed362f1 --- /dev/null +++ b/doc/ck_ring_dequeue_spsc @@ -0,0 +1,103 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_DEQUEUE_SPSC 3 +.Sh NAME +.Nm ck_ring_dequeue_spsc +.Nd dequeue pointer from bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_dequeue_spsc "ck_ring_t *ring" "void *result" +.Sh DESCRIPTION +The +.Fn ck_ring_dequeue_spsc 3 +function dequeues a pointer from the bounded buffer +pointed to by +.Fa ring +in FIFO fashion. The pointer is stored in the pointer +pointed to by +.Fa result . +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa result . +This function is safe to call without locking for one +concurrent invocation of +.Fn ck_ring_dequeue_spsc 3 +and up to one concurrent +.Fn ck_ring_enqueue_spsc 3 +invocation. This function provides wait-free progress +guarantees. +.Sh EXAMPLE +.Bd -literal -offset indent +#include + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +void +dequeue(void) +{ + void *result; + + /* Dequeue from ring until it is empty. */ + while (ck_ring_dequeue_spsc(&ring, &result) == true) { + /* + * Results contains the oldest pointer in ring + * since the dequeue operation returned true. + */ + operation(result); + } + + /* An empty ring was encountered, leave. */ + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the buffer was non-empty. +The result of the dequeue operation is stored in the +value pointed to by +.Fa result . +The function will return false if the buffer was empty +and the value in +.Fa result +will be undefined. +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spmc b/doc/ck_ring_enqueue_spmc new file mode 100644 index 0000000..12732aa --- /dev/null +++ b/doc/ck_ring_enqueue_spmc @@ -0,0 +1,103 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_ENQUEUE_SPMC 3 +.Sh NAME +.Nm ck_ring_enqueue_spmc +.Nd enqueue pointer into bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_enqueue_spmc "ck_ring_t *ring" "void *entry" +.Sh DESCRIPTION +The +.Fn ck_ring_enqueue_spmc 3 +function enqueues the pointer +.Fa entry +into the bounded buffer pointed to by +.Fa ring +in FIFO fashion. +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa entry . +This function is safe to call without locking for UINT_MAX +concurrent invocations of +.Fn ck_ring_dequeue_spmc 3 +or +.Fn ck_ring_trydequeue_spmc 3 . +This function provides wait-free progress +guarantees for one active invocation. +.Sh EXAMPLE +.Bd -literal -offset indent +#include + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +void +enqueue(void) +{ + void *entry = some_object; + + /* Attempt to enqueue pointer to some_object into buffer. */ + if (ck_ring_enqueue_spmc(&ring, &entry) == false) { + /* + * The buffer was full and the enqueue operation + * has failed. + */ + return; + } + + /* Enqueue operation completed successfully. */ + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the value of +.Fa entry +was successfully enqueued into +.Fa ring . +The function will return false if the value of +.Fa entry +could not be enqueued which only occurs if +.Fa ring +was full. +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spmc_size b/doc/ck_ring_enqueue_spmc_size new file mode 100644 index 0000000..a137789 --- /dev/null +++ b/doc/ck_ring_enqueue_spmc_size @@ -0,0 +1,115 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_ENQUEUE_SPMC_SIZE 3 +.Sh NAME +.Nm ck_ring_enqueue_spmc_size +.Nd enqueue pointer into bounded FIFO and return size of buffer +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_enqueue_spmc_size "ck_ring_t *ring" "void *entry" "unsigned int *length" +.Sh DESCRIPTION +The +.Fn ck_ring_enqueue_spmc 3 +function enqueues the pointer +.Fa entry +into the bounded buffer pointed to by +.Fa ring +in FIFO fashion. +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa entry . +This function is safe to call without locking for UINT_MAX +concurrent invocations of +.Fn ck_ring_dequeue_spmc 3 +or +.Fn ck_ring_trydequeue_spmc 3 . +This function provides wait-free progress +guarantees for one active invocation. +.Sh EXAMPLE +.Bd -literal -offset indent +#include + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +void +enqueue(void) +{ + void *entry = some_object; + unsigned int length; + + /* Attempt to enqueue pointer to some_object into buffer. */ + if (ck_ring_enqueue_spmc_size(&ring, &entry, &length) == false) { + /* + * The buffer was full and the enqueue operation + * has failed. + */ + return; + } + + /* + * If entry was the 101st or greater pointer in the buffer, + * do something. + */ + if (length > 100) { + do_something; + } + + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the value of +.Fa entry +was successfully enqueued into +.Fa ring . +The function will return false if the value of +.Fa entry +could not be enqueued which only occurs if +.Fa ring +was full. The number of entries in the buffer +with respect to the point in time that +.Fa entry +is enqueued is stored in the integer pointed to by +.Fa length . +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spsc b/doc/ck_ring_enqueue_spsc new file mode 100644 index 0000000..b1384d5 --- /dev/null +++ b/doc/ck_ring_enqueue_spsc @@ -0,0 +1,101 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_ENQUEUE_SPSC 3 +.Sh NAME +.Nm ck_ring_enqueue_spsc +.Nd enqueue pointer into bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_enqueue_spsc "ck_ring_t *ring" "void *entry" +.Sh DESCRIPTION +The +.Fn ck_ring_enqueue_spsc 3 +function enqueues the pointer +.Fa entry +into the bounded buffer pointed to by +.Fa ring +in FIFO fashion. +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa entry . +This function is safe to call without locking for up to +one concurrent invocation of +.Fn ck_ring_dequeue_spsc 3 . +This function provides wait-free progress +guarantees. +.Sh EXAMPLE +.Bd -literal -offset indent +#include + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +void +enqueue(void) +{ + void *entry = some_object; + + /* Attempt to enqueue pointer to some_object into buffer. */ + if (ck_ring_enqueue_spsc(&ring, &entry) == false) { + /* + * The buffer was full and the enqueue operation + * has failed. + */ + return; + } + + /* Enqueue operation completed successfully. */ + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the value of +.Fa entry +was successfully enqueued into +.Fa ring . +The function will return false if the value of +.Fa entry +could not be enqueued which only occurs if +.Fa ring +was full. +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spsc_size b/doc/ck_ring_enqueue_spsc_size new file mode 100644 index 0000000..3cfb507 --- /dev/null +++ b/doc/ck_ring_enqueue_spsc_size @@ -0,0 +1,116 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_ENQUEUE_SPSC_SIZE 3 +.Sh NAME +.Nm ck_ring_enqueue_spsc_size +.Nd enqueue pointer into bounded FIFO and return size of buffer +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_enqueue_spsc_size "ck_ring_t *ring" "void *entry" "unsigned int *size" +.Sh DESCRIPTION +The +.Fn ck_ring_enqueue_spsc_size 3 +function enqueues the pointer +.Fa entry +into the bounded buffer pointed to by +.Fa ring +in FIFO fashion. +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa entry . +This function is safe to call without locking for up to +one concurrent invocation of +.Fn ck_ring_dequeue_spsc 3 . +This function provides wait-free progress +guarantees. +.Sh EXAMPLE +.Bd -literal -offset indent +#include + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +void +enqueue(void) +{ + void *entry = some_object; + unsigned int length; + + /* Attempt to enqueue pointer to some_object into buffer. */ + if (ck_ring_enqueue_spsc(&ring, &entry, &length) == false) { + /* + * The buffer was full and the enqueue operation + * has failed. + */ + return; + } + + /* + * If buffer length was 100 items or more at the time entry was + * enqueued, do something. + */ + if (length > 100) { + do_something; + } + + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the value of +.Fa entry +was successfully enqueued into +.Fa ring . +This function will return the number of items +in +.Fa ring +with respect to the linearization point (the +point in item that +.Fa entry +is enqueued). +The function will return false if the value of +.Fa entry +could not be enqueued which only occurs if +.Fa ring +was full. +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_init b/doc/ck_ring_init new file mode 100644 index 0000000..11c4074 --- /dev/null +++ b/doc/ck_ring_init @@ -0,0 +1,66 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_INIT 3 +.Sh NAME +.Nm ck_ring_init +.Nd initialize bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft void +.Fn ck_ring_init "ck_ring_t *ring" "void *buffer" "unsigned int size" +.Sh DESCRIPTION +The +.Fn ck_ring_init +function initializes a bounded FIFO buffer pointed to by +.Fa ring +for the storage of up to +.Fa size +number of pointers. The +.Fa buffer +argument must be a pointer to an array of void * of +length +.Fa size . +The +.Fa size +argument must be a power-of-two greater than or equal to 4. +.Sh RETURN VALUES +This function has no return value. +.Sh SEE ALSO +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_trydequeue_spmc b/doc/ck_ring_trydequeue_spmc new file mode 100644 index 0000000..4551724 --- /dev/null +++ b/doc/ck_ring_trydequeue_spmc @@ -0,0 +1,114 @@ +.\" +.\" Copyright 2012-2013 Samy Al Bahra. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd April 20, 2013 +.Dt CK_RING_TRYDEQUEUE_SPMC 3 +.Sh NAME +.Nm ck_ring_trydequeue_spmc +.Nd dequeue from bounded FIFO and allow for spurious failure +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_trydequeue_spmc "ck_ring_t *ring" "void *result" +.Sh DESCRIPTION +The +.Fn ck_ring_trydequeue_spmc 3 +function attempts to dequeue a pointer from the bounded buffer +pointed to by +.Fa ring +in FIFO fashion. The pointer is stored in the pointer +pointed to by +.Fa result . +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa result . +This function is safe to call without locking for UINT_MAX +concurrent +.Fn ck_ring_dequeue_spmc 3 +or +.Fn ck_ring_trydequeue_spmc 3 +invocations and up to one concurrent +.Fn ck_ring_enqueue_spmc 3 +or +.Fn ck_ring_tryenqueue_spmc 3 +invocation. This operation will always complete +in a bounded number of steps. It is +possible for the function to return false even +if +.Fa ring +is non-empty. This +.Sh EXAMPLE +.Bd -literal -offset indent +#include + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +void +dequeue(void) +{ + void *result; + + /* Dequeue from ring until contention is actively observed. */ + while (ck_ring_trydequeue_spmc(&ring, &result) == true) { + /* + * Results contains the oldest pointer in ring + * since the dequeue operation returned true. + */ + operation(result); + } + + /* An empty ring was encountered, leave. */ + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the dequeue operation +completely successfully in a bounded number of steps. +The result of the dequeue operation is stored in the +value pointed to by +.Fa result . +Otherwise, the function will return false if the buffer was empty +or if the operation could not be completed in a bounded +number of steps. If the function returns false, then the contents +of +.Fa result +are undefined. +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/