├── CNAME ├── _config.yml ├── regressions ├── ck_rwcohort │ ├── validate │ │ ├── ck_rp.c │ │ ├── ck_wp.c │ │ ├── ck_neutral.c │ │ └── Makefile │ ├── benchmark │ │ ├── ck_rp.c │ │ ├── ck_wp.c │ │ ├── ck_neutral.c │ │ └── Makefile │ ├── ck_rp.h │ ├── ck_wp.h │ └── ck_neutral.h ├── ck_spinlock │ ├── validate │ │ ├── ck_cas.c │ │ ├── ck_clh.c │ │ ├── ck_dec.c │ │ ├── ck_fas.c │ │ ├── ck_hclh.c │ │ ├── ck_mcs.c │ │ ├── ck_ticket.c │ │ ├── ck_anderson.c │ │ ├── ck_spinlock.c │ │ ├── ck_ticket_pb.c │ │ ├── linux_spinlock.c │ │ └── Makefile │ ├── benchmark │ │ ├── ck_clh.c │ │ ├── ck_dec.c │ │ ├── ck_fas.c │ │ ├── ck_mcs.c │ │ ├── ck_cas.c │ │ ├── ck_hclh.c │ │ ├── pthread.c │ │ ├── ck_spinlock.c │ │ ├── ck_ticket.c │ │ ├── ck_anderson.c │ │ ├── ck_ticket_pb.c │ │ ├── linux_spinlock.c │ │ └── latency.h │ ├── ck_spinlock.h │ ├── ck_cas.h │ ├── ck_dec.h │ ├── ck_fas.h │ ├── ck_ticket_pb.h │ ├── ck_mcs.h │ ├── ck_ticket.h │ ├── ck_clh.h │ ├── ck_anderson.h │ ├── ck_hclh.h │ ├── linux_spinlock.h │ └── pthread.h ├── Makefile.unsupported ├── ck_cohort │ ├── benchmark │ │ ├── ck_cohort.c │ │ └── Makefile │ ├── validate │ │ └── Makefile │ └── ck_cohort.h ├── ck_fifo │ ├── benchmark │ │ └── Makefile │ └── validate │ │ └── Makefile ├── ck_stack │ ├── benchmark │ │ └── Makefile │ └── validate │ │ ├── Makefile │ │ └── serial.c ├── ck_bytelock │ ├── benchmark │ │ └── Makefile │ └── validate │ │ └── Makefile ├── ck_ring │ ├── benchmark │ │ └── Makefile │ └── validate │ │ └── Makefile ├── ck_backoff │ └── validate │ │ ├── Makefile │ │ └── validate.c ├── ck_pr │ ├── benchmark │ │ ├── ck_pr_add_64.c │ │ ├── ck_pr_faa_64.c │ │ ├── ck_pr_fas_64.c │ │ ├── ck_pr_neg_64.c │ │ ├── ck_pr_cas_64.c │ │ ├── ck_pr_cas_64_2.c │ │ ├── Makefile │ │ └── fp.c │ └── validate │ │ └── Makefile ├── ck_bitmap │ └── validate │ │ └── Makefile ├── ck_cc │ └── validate │ │ ├── Makefile │ │ └── ck_cc.c ├── ck_ec │ ├── benchmark │ │ └── Makefile │ └── validate │ │ ├── prop_test_timeutil_scale.c │ │ ├── prop_test_timeutil_add_ns.c │ │ ├── prop_test_timeutil_cmp.c │ │ ├── prop_test_timeutil_add.c │ │ ├── prop_test_slow_wakeup.c │ │ └── fuzz_harness.h ├── ck_brlock │ ├── validate │ │ └── Makefile │ └── benchmark │ │ └── Makefile ├── ck_pflock │ ├── validate │ │ └── Makefile │ └── benchmark │ │ ├── Makefile │ │ └── latency.c ├── ck_rhs │ ├── validate │ │ └── Makefile │ └── benchmark │ │ └── Makefile ├── ck_swlock │ ├── validate │ │ └── Makefile │ └── benchmark │ │ └── Makefile ├── ck_sequence │ ├── benchmark │ │ └── Makefile │ └── validate │ │ └── Makefile ├── ck_array │ └── validate │ │ └── Makefile ├── ck_rwlock │ ├── validate │ │ └── Makefile │ └── benchmark │ │ └── Makefile ├── ck_tflock │ ├── validate │ │ └── Makefile │ └── benchmark │ │ ├── Makefile │ │ └── latency.c ├── ck_barrier │ ├── benchmark │ │ └── Makefile │ └── validate │ │ └── Makefile ├── ck_hp │ ├── benchmark │ │ └── Makefile │ └── validate │ │ └── Makefile ├── ck_hs │ ├── validate │ │ └── Makefile │ └── benchmark │ │ └── Makefile ├── ck_ht │ ├── validate │ │ └── Makefile │ └── benchmark │ │ └── Makefile ├── ck_queue │ └── validate │ │ └── Makefile └── ck_epoch │ └── validate │ ├── Makefile │ └── ck_epoch_call.c ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── tools ├── feature.sh └── ci-build.sh ├── doc ├── refcheck.pl ├── ck_bitmap_clear ├── ck_bitmap_set ├── ck_bitmap_reset ├── ck_bitmap_bits ├── ck_ring_size ├── ck_bitmap_union ├── ck_array_length ├── ck_bitmap_base ├── ck_bitmap_bts ├── ck_ring_capacity ├── ck_bitmap_test ├── ck_pr_barrier ├── ck_ring_init ├── ck_array_deinit ├── ck_epoch_init ├── ck_array_buffer ├── ck_array_commit ├── ck_hs_count ├── ck_array_initialized ├── ck_bitmap_size ├── ck_bitmap_buffer ├── ck_epoch_end ├── ck_rhs_count ├── CK_COHORT_UNLOCK ├── CK_HS_HASH ├── CK_RHS_HASH ├── CK_COHORT_LOCK ├── ck_bitmap_iterator_init ├── ck_epoch_unregister ├── CK_COHORT_INSTANCE ├── ck_pr_fence_release ├── ck_array_put ├── ck_pr_fence_acquire ├── ck_array_remove ├── ck_rhs_gc ├── ck_pr ├── ck_hs_destroy ├── ck_rhs_destroy └── ck_hs_reset ├── include ├── gcc │ ├── sparcv9 │ │ └── ck_f_pr.h │ └── ppc │ │ └── ck_f_pr.h ├── ck_stdbool.h ├── ck_stddef.h ├── ck_stdlib.h ├── ck_string.h ├── ck_stdint.h ├── ck_malloc.h ├── ck_limits.h ├── ck_backoff.h ├── ck_md.h.in └── ck_spinlock.h ├── src └── ck_barrier_centralized.c └── LICENSE /CNAME: -------------------------------------------------------------------------------- 1 | concurrencykit.org -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal 2 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/validate/ck_rp.c: -------------------------------------------------------------------------------- 1 | #include "../ck_rp.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/validate/ck_wp.c: -------------------------------------------------------------------------------- 1 | #include "../ck_wp.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_cas.c: -------------------------------------------------------------------------------- 1 | #include "../ck_cas.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_clh.c: -------------------------------------------------------------------------------- 1 | #include "../ck_clh.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_dec.c: -------------------------------------------------------------------------------- 1 | #include "../ck_dec.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_fas.c: -------------------------------------------------------------------------------- 1 | #include "../ck_fas.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_hclh.c: -------------------------------------------------------------------------------- 1 | #include "../ck_hclh.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_mcs.c: -------------------------------------------------------------------------------- 1 | #include "../ck_mcs.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/validate/ck_neutral.c: -------------------------------------------------------------------------------- 1 | #include "../ck_neutral.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_ticket.c: -------------------------------------------------------------------------------- 1 | #include "../ck_ticket.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_anderson.c: -------------------------------------------------------------------------------- 1 | #include "../ck_anderson.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_spinlock.c: -------------------------------------------------------------------------------- 1 | #include "../ck_spinlock.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/ck_ticket_pb.c: -------------------------------------------------------------------------------- 1 | #include "../ck_ticket_pb.h" 2 | #include "validate.h" 3 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/benchmark/ck_rp.c: -------------------------------------------------------------------------------- 1 | #include "../ck_rp.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/benchmark/ck_wp.c: -------------------------------------------------------------------------------- 1 | #include "../ck_wp.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_clh.c: -------------------------------------------------------------------------------- 1 | #include "../ck_clh.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_dec.c: -------------------------------------------------------------------------------- 1 | #include "../ck_dec.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_fas.c: -------------------------------------------------------------------------------- 1 | #include "../ck_fas.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_mcs.c: -------------------------------------------------------------------------------- 1 | #include "../ck_mcs.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_cas.c: -------------------------------------------------------------------------------- 1 | #include "../ck_cas.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_hclh.c: -------------------------------------------------------------------------------- 1 | #include "../ck_hclh.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/pthread.c: -------------------------------------------------------------------------------- 1 | #include "../pthread.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" # Location of package manifests 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/benchmark/ck_neutral.c: -------------------------------------------------------------------------------- 1 | #include "../ck_neutral.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_spinlock.c: -------------------------------------------------------------------------------- 1 | #include "../ck_spinlock.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_ticket.c: -------------------------------------------------------------------------------- 1 | #include "../ck_ticket.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /regressions/Makefile.unsupported: -------------------------------------------------------------------------------- 1 | .PHONY: all clean check 2 | 3 | all: 4 | @echo Regressions are currently unsupported for out-of-source builds 5 | 6 | clean: all 7 | 8 | check: all 9 | 10 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_anderson.c: -------------------------------------------------------------------------------- 1 | #include "../ck_anderson.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/ck_ticket_pb.c: -------------------------------------------------------------------------------- 1 | #include "../ck_ticket_pb.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/linux_spinlock.c: -------------------------------------------------------------------------------- 1 | #include "../linux_spinlock.h" 2 | 3 | #ifdef THROUGHPUT 4 | #include "throughput.h" 5 | #elif defined(LATENCY) 6 | #include "latency.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /regressions/ck_cohort/benchmark/ck_cohort.c: -------------------------------------------------------------------------------- 1 | #include "../ck_cohort.h" 2 | 3 | #include 4 | #ifdef THROUGHPUT 5 | #include "../../ck_spinlock/benchmark/throughput.h" 6 | #elif defined(LATENCY) 7 | #include "../../ck_spinlock/benchmark/latency.h" 8 | #endif 9 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/linux_spinlock.c: -------------------------------------------------------------------------------- 1 | #ifdef __x86_64__ 2 | #include "../linux_spinlock.h" 3 | #include "validate.h" 4 | #else 5 | #include 6 | 7 | int 8 | main(void) 9 | { 10 | 11 | fprintf(stderr, "Unsupported.\n"); 12 | return 0; 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_spinlock.h: -------------------------------------------------------------------------------- 1 | #define LOCK_NAME "ck_spinlock" 2 | #define LOCK_DEFINE static ck_spinlock_t CK_CC_CACHELINE lock = CK_SPINLOCK_INITIALIZER 3 | #define LOCK ck_spinlock_lock_eb(&lock) 4 | #define UNLOCK ck_spinlock_unlock(&lock) 5 | #define LOCKED ck_spinlock_locked(&lock) 6 | 7 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_cas.h: -------------------------------------------------------------------------------- 1 | #define LOCK_NAME "ck_cas" 2 | #define LOCK_DEFINE static ck_spinlock_cas_t CK_CC_CACHELINE lock = CK_SPINLOCK_CAS_INITIALIZER 3 | #define LOCK ck_spinlock_cas_lock_eb(&lock) 4 | #define UNLOCK ck_spinlock_cas_unlock(&lock) 5 | #define LOCKED ck_spinlock_cas_locked(&lock) 6 | 7 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_dec.h: -------------------------------------------------------------------------------- 1 | #define LOCK_NAME "ck_dec" 2 | #define LOCK_DEFINE static ck_spinlock_dec_t CK_CC_CACHELINE lock = CK_SPINLOCK_DEC_INITIALIZER 3 | #define LOCK ck_spinlock_dec_lock_eb(&lock) 4 | #define UNLOCK ck_spinlock_dec_unlock(&lock) 5 | #define LOCKED ck_spinlock_dec_locked(&lock) 6 | 7 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_fas.h: -------------------------------------------------------------------------------- 1 | #define LOCK_NAME "ck_fas" 2 | #define LOCK_DEFINE static ck_spinlock_fas_t CK_CC_CACHELINE lock = CK_SPINLOCK_FAS_INITIALIZER 3 | #define LOCK ck_spinlock_fas_lock_eb(&lock) 4 | #define UNLOCK ck_spinlock_fas_unlock(&lock) 5 | #define LOCKED ck_spinlock_fas_locked(&lock) 6 | 7 | -------------------------------------------------------------------------------- /tools/feature.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This will generate the list of feature flags for implemented symbols. 3 | 4 | echo '/* DO NOT EDIT. This is auto-generated from feature.sh */' 5 | nm ../regressions/ck_pr/validate/ck_pr_cas|cut -d ' ' -f 3|sed s/ck_pr/ck_f_pr/|awk '/^ck_f_pr/ {print "#define " toupper($1);}'|sort 6 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_ticket_pb.h: -------------------------------------------------------------------------------- 1 | #define LOCK_NAME "ck_ticket_pb" 2 | #define LOCK_DEFINE static ck_spinlock_ticket_t CK_CC_CACHELINE lock = CK_SPINLOCK_TICKET_INITIALIZER 3 | #define LOCK ck_spinlock_ticket_lock_pb(&lock, 0) 4 | #define UNLOCK ck_spinlock_ticket_unlock(&lock) 5 | #define LOCKED ck_spinlock_ticket_locked(&lock) 6 | 7 | -------------------------------------------------------------------------------- /regressions/ck_fifo/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | clean: 11 | rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) 12 | 13 | include ../../../build/regressions.build 14 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 15 | -------------------------------------------------------------------------------- /regressions/ck_stack/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | clean: 11 | rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) 12 | 13 | include ../../../build/regressions.build 14 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 15 | -------------------------------------------------------------------------------- /regressions/ck_bytelock/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | clean: 11 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 12 | 13 | include ../../../build/regressions.build 14 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 15 | -------------------------------------------------------------------------------- /regressions/ck_ring/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c ../../../include/ck_ring.h 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | clean: 11 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 12 | 13 | include ../../../build/regressions.build 14 | CFLAGS+=-D_GNU_SOURCE 15 | -------------------------------------------------------------------------------- /regressions/ck_backoff/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | all: validate 4 | 5 | validate: validate.c ../../../include/ck_backoff.h 6 | $(CC) $(CFLAGS) -o validate validate.c 7 | 8 | check: all 9 | ./validate 10 | 11 | clean: 12 | rm -rf validate *.dSYM *.exe 13 | 14 | include ../../../build/regressions.build 15 | CFLAGS+=-D_GNU_SOURCE 16 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_mcs.h: -------------------------------------------------------------------------------- 1 | #define LOCK_NAME "ck_mcs" 2 | #define LOCK_DEFINE static ck_spinlock_mcs_t CK_CC_CACHELINE lock = NULL 3 | #define LOCK_STATE ck_spinlock_mcs_context_t node CK_CC_CACHELINE; 4 | #define LOCK ck_spinlock_mcs_lock(&lock, &node) 5 | #define UNLOCK ck_spinlock_mcs_unlock(&lock, &node) 6 | #define LOCKED ck_spinlock_mcs_locked(&lock) 7 | 8 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/ck_pr_add_64.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CK_F_PR_ADD_64 4 | #define ATOMIC ck_pr_add_64(object, 1) 5 | #define ATOMIC_STRING "ck_pr_add_64" 6 | #include "benchmark.h" 7 | #else 8 | #warning Did not find ADD_64 implementation. 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | exit(EXIT_FAILURE); 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/ck_pr_faa_64.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CK_F_PR_FAA_64 4 | #define ATOMIC ck_pr_faa_64(object, 1) 5 | #define ATOMIC_STRING "ck_pr_faa_64" 6 | #include "benchmark.h" 7 | #else 8 | #warning Did not find FAA_64 implementation. 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | exit(EXIT_FAILURE); 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/ck_pr_fas_64.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CK_F_PR_FAS_64 4 | #define ATOMIC ck_pr_fas_64(object, 1) 5 | #define ATOMIC_STRING "ck_pr_fas_64" 6 | #include "benchmark.h" 7 | #else 8 | #warning Did not find FAS_64 implementation. 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | 15 | return 0; 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/ck_pr_neg_64.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CK_F_PR_NEG_64 4 | #define ATOMIC ck_pr_neg_64(object) 5 | #define ATOMIC_STRING "ck_pr_neg_64" 6 | #include "benchmark.h" 7 | #else 8 | #warning Did not find NEG_64 implementation. 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | exit(EXIT_FAILURE); 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/ck_pr_cas_64.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CK_F_PR_CAS_64 4 | #define ATOMIC ck_pr_cas_64(object, 1, 1) 5 | #define ATOMIC_STRING "ck_pr_cas_64" 6 | #include "benchmark.h" 7 | #else 8 | #warning Did not find CAS_64 implementation. 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | exit(EXIT_FAILURE); 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /regressions/ck_bitmap/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | OBJECTS=serial 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_bitmap.h 8 | $(CC) $(CFLAGS) -o serial serial.c 9 | 10 | clean: 11 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 12 | 13 | check: all 14 | ./serial 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=-D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_cc/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_cc 4 | 5 | all: $(OBJECTS) 6 | 7 | ck_cc: ck_cc.c ../../../include/ck_cc.h 8 | $(CC) $(CFLAGS) -g2 -o ck_cc ck_cc.c 9 | 10 | check: all 11 | ./ck_cc 12 | 13 | clean: 14 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=-D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/ck_pr_cas_64_2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef CK_F_PR_CAS_64_2 4 | #define ATOMIC { uint64_t z[2] = {1, 2}; ck_pr_cas_64_2(object, z, z); } 5 | #define ATOMIC_STRING "ck_pr_cas_64_2" 6 | #include "benchmark.h" 7 | #else 8 | #include 9 | #include 10 | 11 | int 12 | main(void) 13 | { 14 | fprintf(stderr, "Unsupported.\n"); 15 | return 0; 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /regressions/ck_ec/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_ec 4 | 5 | all: $(OBJECTS) 6 | 7 | ck_ec: ck_ec.c ../../../include/ck_ec.h 8 | $(CC) $(CFLAGS) ../../../src/ck_ec.c -o ck_ec ck_ec.c 9 | 10 | check: all 11 | ./ck_ec $(CORES) 1 12 | 13 | clean: 14 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=-D_GNU_SOURCE 18 | 19 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/ck_rp.h: -------------------------------------------------------------------------------- 1 | #define LOCK_PROTOTYPE CK_RWCOHORT_RP_PROTOTYPE 2 | #define LOCK_INSTANCE CK_RWCOHORT_RP_INSTANCE 3 | #define LOCK_INITIALIZER CK_RWCOHORT_RP_INITIALIZER 4 | #define LOCK_INIT CK_RWCOHORT_RP_INIT 5 | #define READ_LOCK CK_RWCOHORT_RP_READ_LOCK 6 | #define READ_UNLOCK CK_RWCOHORT_RP_READ_UNLOCK 7 | #define WRITE_LOCK CK_RWCOHORT_RP_WRITE_LOCK 8 | #define WRITE_UNLOCK CK_RWCOHORT_RP_WRITE_UNLOCK 9 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/ck_wp.h: -------------------------------------------------------------------------------- 1 | #define LOCK_PROTOTYPE CK_RWCOHORT_WP_PROTOTYPE 2 | #define LOCK_INSTANCE CK_RWCOHORT_WP_INSTANCE 3 | #define LOCK_INITIALIZER CK_RWCOHORT_WP_INITIALIZER 4 | #define LOCK_INIT CK_RWCOHORT_WP_INIT 5 | #define READ_LOCK CK_RWCOHORT_WP_READ_LOCK 6 | #define WRITE_LOCK CK_RWCOHORT_WP_WRITE_LOCK 7 | #define READ_UNLOCK CK_RWCOHORT_WP_READ_UNLOCK 8 | #define WRITE_UNLOCK CK_RWCOHORT_WP_WRITE_UNLOCK 9 | -------------------------------------------------------------------------------- /regressions/ck_brlock/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=validate 4 | 5 | all: $(OBJECTS) 6 | 7 | validate: validate.c ../../../include/ck_brlock.h 8 | $(CC) $(CFLAGS) -o validate validate.c 9 | 10 | check: all 11 | ./validate $(CORES) 1 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_pflock/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=validate 4 | 5 | all: $(OBJECTS) 6 | 7 | validate: validate.c ../../../include/ck_pflock.h 8 | $(CC) $(CFLAGS) -o validate validate.c 9 | 10 | check: all 11 | ./validate $(CORES) 1 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_rhs/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=serial 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_rhs.h ../../../src/ck_rhs.c 8 | $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_rhs.c 9 | 10 | check: all 11 | ./serial 12 | 13 | clean: 14 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=-D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_swlock/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=validate 4 | 5 | all: $(OBJECTS) 6 | 7 | validate: validate.c ../../../include/ck_swlock.h 8 | $(CC) $(CFLAGS) -o validate validate.c 9 | 10 | check: all 11 | ./validate $(CORES) 1 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_bytelock/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=validate 4 | 5 | all: $(OBJECTS) 6 | 7 | validate: validate.c ../../../include/ck_bytelock.h 8 | $(CC) $(CFLAGS) -o validate validate.c 9 | 10 | check: all 11 | ./validate $(CORES) 1 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_sequence/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=ck_sequence 4 | 5 | all: $(OBJECTS) 6 | 7 | ck_sequence: ck_sequence.c ../../../include/ck_sequence.h 8 | $(CC) $(CFLAGS) -o ck_sequence ck_sequence.c 9 | 10 | check: all 11 | ./ck_sequence $(CORES) 1 12 | 13 | clean: 14 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=-D_GNU_SOURCE 18 | 19 | -------------------------------------------------------------------------------- /regressions/ck_array/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=serial 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_array.h ../../../src/ck_array.c 8 | $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_array.c 9 | 10 | check: all 11 | ./serial 12 | 13 | clean: 14 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=-D_GNU_SOURCE -ggdb 18 | -------------------------------------------------------------------------------- /regressions/ck_cohort/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=validate 4 | 5 | all: $(OBJECTS) 6 | 7 | validate: validate.c ../../../include/ck_cohort.h 8 | $(CC) $(CFLAGS) -o validate validate.c 9 | 10 | check: all 11 | ./validate `expr $(CORES) / 2` 2 1 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_sequence/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_sequence 4 | 5 | all: $(OBJECTS) 6 | 7 | ck_sequence: ck_sequence.c ../../../include/ck_sequence.h 8 | $(CC) $(CFLAGS) -o ck_sequence ck_sequence.c 9 | 10 | check: all 11 | ./ck_sequence $(CORES) 1 12 | 13 | clean: 14 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_rwlock/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=validate 4 | 5 | all: $(OBJECTS) 6 | 7 | validate: validate.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h 8 | $(CC) $(CFLAGS) -o validate validate.c 9 | 10 | check: all 11 | ./validate $(CORES) 1 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_tflock/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=validate 4 | 5 | all: $(OBJECTS) 6 | 7 | validate: validate.c ../../../include/ck_tflock.h ../../../include/ck_elide.h 8 | $(CC) $(CFLAGS) -o validate validate.c 9 | 10 | check: all 11 | ./validate $(CORES) 1 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_barrier/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=throughput 4 | 5 | all: $(OBJECTS) 6 | 7 | throughput: throughput.c ../../../include/ck_barrier.h ../../../src/ck_barrier_centralized.c 8 | $(CC) $(CFLAGS) -o throughput throughput.c ../../../src/ck_barrier_centralized.c 9 | 10 | clean: 11 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 12 | 13 | include ../../../build/regressions.build 14 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 15 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_ticket.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LOCK_NAME "ck_ticket" 4 | #define LOCK_DEFINE static ck_spinlock_ticket_t CK_CC_CACHELINE lock = CK_SPINLOCK_TICKET_INITIALIZER 5 | #define LOCK ck_spinlock_ticket_lock(&lock) 6 | #define UNLOCK ck_spinlock_ticket_unlock(&lock) 7 | #ifdef CK_F_SPINLOCK_TICKET_TRYLOCK 8 | #define TRYLOCK ck_spinlock_ticket_trylock(&lock) 9 | #endif 10 | #define LOCKED ck_spinlock_ticket_locked(&lock) 11 | 12 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/ck_neutral.h: -------------------------------------------------------------------------------- 1 | #define LOCK_PROTOTYPE CK_RWCOHORT_NEUTRAL_PROTOTYPE 2 | #define LOCK_INSTANCE CK_RWCOHORT_NEUTRAL_INSTANCE 3 | #define LOCK_INITIALIZER CK_RWCOHORT_NEUTRAL_INITIALIZER 4 | #define LOCK_INIT(N, C, W) CK_RWCOHORT_NEUTRAL_INIT(N, C) 5 | #define READ_LOCK CK_RWCOHORT_NEUTRAL_READ_LOCK 6 | #define WRITE_LOCK CK_RWCOHORT_NEUTRAL_WRITE_LOCK 7 | #define READ_UNLOCK CK_RWCOHORT_NEUTRAL_READ_UNLOCK 8 | #define WRITE_UNLOCK CK_RWCOHORT_NEUTRAL_WRITE_UNLOCK 9 | -------------------------------------------------------------------------------- /regressions/ck_brlock/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency throughput 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c ../../../include/ck_brlock.h 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | throughput: throughput.c ../../../include/ck_brlock.h 11 | $(CC) $(CFLAGS) -o throughput throughput.c 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_pflock/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency throughput 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c ../../../include/ck_rwlock.h 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | throughput: throughput.c ../../../include/ck_rwlock.h 11 | $(CC) $(CFLAGS) -o throughput throughput.c 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_swlock/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency throughput 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c ../../../include/ck_swlock.h 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | throughput: throughput.c ../../../include/ck_swlock.h 11 | $(CC) $(CFLAGS) -o throughput throughput.c 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_cohort/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean 2 | 3 | OBJECTS=ck_cohort.THROUGHPUT ck_cohort.LATENCY 4 | 5 | all: $(OBJECTS) 6 | 7 | ck_cohort.THROUGHPUT: ck_cohort.c 8 | $(CC) $(CFLAGS) -o ck_cohort.THROUGHPUT throughput.c -lm 9 | 10 | ck_cohort.LATENCY: ck_cohort.c 11 | $(CC) -DLATENCY $(CFLAGS) -o ck_cohort.LATENCY ck_cohort.c 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm 18 | -------------------------------------------------------------------------------- /regressions/ck_hp/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=fifo_latency stack_latency 4 | 5 | all: $(OBJECTS) 6 | 7 | fifo_latency: fifo_latency.c 8 | $(CC) $(CFLAGS) -o fifo_latency ../../../src/ck_hp.c fifo_latency.c 9 | 10 | stack_latency: stack_latency.c 11 | $(CC) $(CFLAGS) -o stack_latency ../../../src/ck_hp.c stack_latency.c 12 | 13 | clean: 14 | rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_clh.h: -------------------------------------------------------------------------------- 1 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) 2 | #define LOCK_NAME "ck_clh" 3 | #define LOCK_DEFINE static ck_spinlock_clh_t CK_CC_CACHELINE *lock = NULL 4 | #define LOCK_STATE ck_spinlock_clh_t *na = malloc(MAX(sizeof(ck_spinlock_clh_t), 64)) 5 | #define LOCK ck_spinlock_clh_lock(&lock, na) 6 | #define UNLOCK ck_spinlock_clh_unlock(&na) 7 | #define LOCK_INIT ck_spinlock_clh_init(&lock, malloc(MAX(sizeof(ck_spinlock_clh_t), 64))) 8 | #define LOCKED ck_spinlock_clh_locked(&lock) 9 | 10 | -------------------------------------------------------------------------------- /regressions/ck_rwlock/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency throughput 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | throughput: throughput.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h 11 | $(CC) $(CFLAGS) -o throughput throughput.c 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_tflock/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency throughput 4 | 5 | all: $(OBJECTS) 6 | 7 | latency: latency.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h 8 | $(CC) $(CFLAGS) -o latency latency.c 9 | 10 | throughput: throughput.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h 11 | $(CC) $(CFLAGS) -o throughput throughput.c 12 | 13 | clean: 14 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_anderson.h: -------------------------------------------------------------------------------- 1 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) 2 | #define LOCK_NAME "ck_anderson" 3 | #define LOCK_DEFINE static ck_spinlock_anderson_t lock CK_CC_CACHELINE 4 | #define LOCK_STATE ck_spinlock_anderson_thread_t *nad = NULL 5 | #define LOCK ck_spinlock_anderson_lock(&lock, &nad) 6 | #define UNLOCK ck_spinlock_anderson_unlock(&lock, nad) 7 | #define LOCK_INIT ck_spinlock_anderson_init(&lock, malloc(MAX(64,sizeof(ck_spinlock_anderson_thread_t)) * nthr), nthr) 8 | #define LOCKED ck_spinlock_anderson_locked(&lock) 9 | 10 | #define NO_LOCAL 11 | 12 | -------------------------------------------------------------------------------- /regressions/ck_hs/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=serial hs_init_opts 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_hs.h ../../../src/ck_hs.c 8 | $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_hs.c 9 | 10 | hs_init_opts: hs_init_opts.c ../../../include/ck_hs.h ../../../src/ck_hs.c 11 | $(CC) $(CFLAGS) -o hs_init_opts hs_init_opts.c ../../../src/ck_hs.c 12 | 13 | check: all 14 | ./serial 15 | 16 | clean: 17 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 18 | 19 | include ../../../build/regressions.build 20 | CFLAGS+=-D_GNU_SOURCE 21 | -------------------------------------------------------------------------------- /regressions/ck_ht/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=serial serial.delete 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c 8 | $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_ht.c 9 | 10 | serial.delete: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c 11 | $(CC) $(CFLAGS) -DHT_DELETE -o serial.delete serial.c ../../../src/ck_ht.c 12 | 13 | check: all 14 | ./serial 15 | ./serial.delete 16 | 17 | clean: 18 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 19 | 20 | include ../../../build/regressions.build 21 | CFLAGS+=-D_GNU_SOURCE 22 | -------------------------------------------------------------------------------- /doc/refcheck.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use warnings; 4 | use strict; 5 | 6 | my @files = @ARGV; 7 | 8 | my $h; 9 | 10 | foreach my $file (@files) { 11 | $h->{$file} = 1; 12 | } 13 | 14 | foreach my $file (@files) { 15 | open(my $fh, "<", $file) or die "cannot open < $file: $!"; 16 | while (<$fh>) { 17 | chomp; 18 | if ($_ =~ /\.Xr ((ck|CK)_[a-zA-Z_]+) ([0-9])/) { 19 | my $name = $1; 20 | my $section = $3; 21 | if (!$h->{$name}) { 22 | print STDERR "$file: ref to missing ${name}($section)\n"; 23 | } 24 | } 25 | } 26 | close($fh) or die("cannot close $file: $!"); 27 | } 28 | -------------------------------------------------------------------------------- /regressions/ck_rhs/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=serial parallel_bytestring 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_rhs.h ../../../src/ck_rhs.c 8 | $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_rhs.c 9 | 10 | parallel_bytestring: parallel_bytestring.c ../../../include/ck_rhs.h ../../../src/ck_rhs.c ../../../src/ck_epoch.c 11 | $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_rhs.c ../../../src/ck_epoch.c 12 | 13 | clean: 14 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 15 | 16 | include ../../../build/regressions.build 17 | CFLAGS+=-D_GNU_SOURCE 18 | -------------------------------------------------------------------------------- /regressions/ck_queue/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | HEADER=../../../include/ck_queue.h 4 | OBJECTS=ck_list ck_slist ck_stailq 5 | 6 | all: $(OBJECTS) 7 | 8 | check: all 9 | ./ck_list $(CORES) 5 10 | ./ck_slist $(CORES) 5 11 | ./ck_stailq $(CORES) 1000000 12 | 13 | ck_list: $(HEADER) ck_list.c 14 | $(CC) $(CFLAGS) -o ck_list ck_list.c 15 | 16 | ck_slist: $(HEADER) ck_slist.c 17 | $(CC) $(CFLAGS) -o ck_slist ck_slist.c 18 | 19 | ck_stailq: $(HEADER) ck_stailq.c 20 | $(CC) $(CFLAGS) -o ck_stailq ck_stailq.c 21 | 22 | clean: 23 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 24 | 25 | include ../../../build/regressions.build 26 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 27 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_neutral ck_rp ck_wp 4 | 5 | all: $(OBJECTS) 6 | 7 | ck_neutral: ck_neutral.c ../../../include/ck_rwcohort.h 8 | $(CC) $(CFLAGS) -o ck_neutral ck_neutral.c 9 | 10 | ck_rp: ck_rp.c ../../../include/ck_rwcohort.h 11 | $(CC) $(CFLAGS) -o ck_rp ck_rp.c 12 | 13 | ck_wp: ck_wp.c ../../../include/ck_rwcohort.h 14 | $(CC) $(CFLAGS) -o ck_wp ck_wp.c 15 | 16 | check: all 17 | ./ck_neutral `expr $(CORES) / 2` 2 1 18 | ./ck_rp `expr $(CORES) / 2` 2 1 19 | ./ck_wp `expr $(CORES) / 2` 2 1 20 | 21 | clean: 22 | rm -rf *.dSYM *~ *.o $(OBJECTS) 23 | 24 | include ../../../build/regressions.build 25 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 26 | -------------------------------------------------------------------------------- /include/gcc/sparcv9/ck_f_pr.h: -------------------------------------------------------------------------------- 1 | #define CK_F_PR_CAS_64 2 | #define CK_F_PR_CAS_64_VALUE 3 | #define CK_F_PR_CAS_PTR 4 | #define CK_F_PR_CAS_PTR_VALUE 5 | #define CK_F_PR_FAS_32 6 | #define CK_F_PR_FAS_UINT 7 | #define CK_F_PR_FAS_INT 8 | #define CK_F_PR_CAS_32 9 | #define CK_F_PR_CAS_32_VALUE 10 | #define CK_F_PR_CAS_UINT 11 | #define CK_F_PR_CAS_INT 12 | #define CK_F_PR_CAS_UINT_VALUE 13 | #define CK_F_PR_CAS_INT_VALUE 14 | #define CK_F_PR_STORE_64 15 | #define CK_F_PR_STORE_32 16 | #define CK_F_PR_STORE_DOUBLE 17 | #define CK_F_PR_STORE_UINT 18 | #define CK_F_PR_STORE_INT 19 | #define CK_F_PR_STORE_PTR 20 | #define CK_F_PR_LOAD_64 21 | #define CK_F_PR_LOAD_32 22 | #define CK_F_PR_LOAD_DOUBLE 23 | #define CK_F_PR_LOAD_UINT 24 | #define CK_F_PR_LOAD_INT 25 | #define CK_F_PR_LOAD_PTR 26 | 27 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/ck_hclh.h: -------------------------------------------------------------------------------- 1 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) 2 | 3 | #if CORES < 2 4 | #undef CORES 5 | #define CORES 2 6 | #endif 7 | 8 | #define LOCK_NAME "ck_clh" 9 | #define LOCK_DEFINE static ck_spinlock_hclh_t CK_CC_CACHELINE *glob_lock; \ 10 | static ck_spinlock_hclh_t CK_CC_CACHELINE *local_lock[CORES / 2] 11 | 12 | #define LOCK_STATE ck_spinlock_hclh_t *na = malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)) 13 | #define LOCK ck_spinlock_hclh_lock(&glob_lock, &local_lock[core % (CORES / 2)], na) 14 | #define UNLOCK ck_spinlock_hclh_unlock(&na) 15 | #define LOCK_INIT do { \ 16 | int _i; \ 17 | ck_spinlock_hclh_init(&glob_lock, malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)), -1); \ 18 | for (_i = 0; _i < CORES / 2; _i++) { \ 19 | ck_spinlock_hclh_init(&local_lock[_i], malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)), _i); } \ 20 | } while (0) 21 | 22 | #define LOCKED ck_spinlock_hclh_locked(&glob_lock) 23 | 24 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean 2 | 3 | OBJECTS=ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 ck_pr_add_64 ck_pr_faa_64 ck_pr_neg_64 fp 4 | 5 | all: $(OBJECTS) 6 | 7 | fp: fp.c 8 | $(CC) $(CFLAGS) -o fp fp.c 9 | 10 | ck_pr_cas_64_2: ck_pr_cas_64_2.c 11 | $(CC) $(CFLAGS) -o ck_pr_cas_64_2 ck_pr_cas_64_2.c -lm 12 | 13 | ck_pr_cas_64: ck_pr_cas_64.c 14 | $(CC) $(CFLAGS) -o ck_pr_cas_64 ck_pr_cas_64.c -lm 15 | 16 | ck_pr_fas_64: ck_pr_fas_64.c 17 | $(CC) $(CFLAGS) -o ck_pr_fas_64 ck_pr_fas_64.c -lm 18 | 19 | ck_pr_add_64: ck_pr_add_64.c 20 | $(CC) $(CFLAGS) -o ck_pr_add_64 ck_pr_add_64.c -lm 21 | 22 | ck_pr_faa_64: ck_pr_faa_64.c 23 | $(CC) $(CFLAGS) -o ck_pr_faa_64 ck_pr_faa_64.c -lm 24 | 25 | ck_pr_neg_64: ck_pr_neg_64.c 26 | $(CC) $(CFLAGS) -o ck_pr_neg_64 ck_pr_neg_64.c -lm 27 | 28 | clean: 29 | rm -rf *.dSYM *.exe *.o $(OBJECTS) 30 | 31 | include ../../../build/regressions.build 32 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 33 | -------------------------------------------------------------------------------- /regressions/ck_ec/validate/prop_test_timeutil_scale.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../../../src/ck_ec_timeutil.h" 4 | #include "fuzz_harness.h" 5 | 6 | struct example { 7 | uint32_t nsec; 8 | uint32_t multiplier; 9 | unsigned int shift; 10 | }; 11 | 12 | static const struct example examples[] = { 13 | { 14 | UINT32_MAX, 15 | UINT32_MAX, 16 | 1 17 | }, 18 | { 19 | 10, 20 | 20, 21 | 0 22 | } 23 | }; 24 | 25 | static inline int test_wait_time_scale(const struct example *example) 26 | { 27 | const uint32_t nsec = example->nsec; 28 | const uint32_t multiplier = example->multiplier; 29 | const unsigned int shift = example->shift % 32; 30 | uint32_t actual = wait_time_scale(nsec, multiplier, shift); 31 | uint64_t expected = ((uint64_t)nsec * multiplier) >> shift; 32 | 33 | if (expected > UINT32_MAX) { 34 | expected = UINT32_MAX; 35 | } 36 | 37 | assert(actual == expected); 38 | return 0; 39 | } 40 | 41 | TEST(test_wait_time_scale, examples) 42 | -------------------------------------------------------------------------------- /regressions/ck_rwcohort/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=latency throughput 4 | OBJECTS=ck_neutral.THROUGHPUT ck_neutral.LATENCY \ 5 | ck_rp.THROUGHPUT ck_rp.LATENCY \ 6 | ck_wp.THROUGHPUT ck_wp.LATENCY 7 | 8 | all: $(OBJECTS) 9 | 10 | ck_neutral.THROUGHPUT: ck_neutral.c 11 | $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_neutral.THROUGHPUT ck_neutral.c 12 | 13 | ck_neutral.LATENCY: ck_neutral.c 14 | $(CC) -DLATENCY $(CFLAGS) -o ck_neutral.LATENCY ck_neutral.c 15 | 16 | ck_rp.THROUGHPUT: ck_rp.c 17 | $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_rp.THROUGHPUT ck_rp.c 18 | 19 | ck_rp.LATENCY: ck_rp.c 20 | $(CC) -DLATENCY $(CFLAGS) -o ck_rp.LATENCY ck_rp.c 21 | 22 | ck_wp.THROUGHPUT: ck_wp.c 23 | $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_wp.THROUGHPUT ck_wp.c 24 | 25 | ck_wp.LATENCY: ck_wp.c 26 | $(CC) -DLATENCY $(CFLAGS) -o ck_wp.LATENCY ck_wp.c 27 | 28 | clean: 29 | rm -rf *.dSYM *~ *.o $(OBJECTS) 30 | 31 | include ../../../build/regressions.build 32 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 33 | -------------------------------------------------------------------------------- /regressions/ck_cc/validate/ck_cc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../../common.h" 6 | 7 | int 8 | main(void) 9 | { 10 | unsigned int x; 11 | 12 | ck_pr_store_uint(&x, 0x10110); 13 | 14 | if (ck_cc_ffs(0) != 0) 15 | ck_error("ffs(0) = %d\n", ck_cc_ffs(0)); 16 | if (ck_cc_ffs(4) != 3) 17 | ck_error("ffs(4) = %d\n", ck_cc_ffs(4)); 18 | if (ck_cc_ffs(UINT_MAX) != 1) 19 | ck_error("ffs(UINT_MAX) = %d\n", ck_cc_ffs(UINT_MAX)); 20 | if (ck_cc_ffs(x) != 5) 21 | ck_error("ffs(%u) = %d\n", x, ck_cc_ffs(x)); 22 | 23 | if (ck_cc_ffs(x) != ck_cc_ffsl(x) || 24 | ck_cc_ffsl(x) != ck_cc_ffsll(x) || 25 | ck_cc_ffs(x) != ck_cc_ffsll(x)) { 26 | ck_error(" ffs = %d, ffsl = %d, ffsll = %d\n", 27 | ck_cc_ffs(x), ck_cc_ffsl(x), ck_cc_ffsll(x)); 28 | } 29 | 30 | if (ck_cc_ctz(x) != 4) 31 | ck_error("ctz = %d\n", ck_cc_ctz(x)); 32 | 33 | if (ck_cc_popcount(x) != 3) 34 | ck_error("popcount = %d\n", ck_cc_popcount(x)); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /regressions/ck_fifo/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_fifo_spsc ck_fifo_mpmc ck_fifo_spsc_iterator ck_fifo_mpmc_iterator 4 | 5 | all: $(OBJECTS) 6 | 7 | check: all 8 | ./ck_fifo_spsc $(CORES) 1 64000 9 | ./ck_fifo_mpmc $(CORES) 1 16000 10 | ./ck_fifo_spsc_iterator 11 | ./ck_fifo_mpmc_iterator 12 | 13 | ck_fifo_spsc: ck_fifo_spsc.c ../../../include/ck_fifo.h 14 | $(CC) $(CFLAGS) -o ck_fifo_spsc ck_fifo_spsc.c 15 | 16 | ck_fifo_mpmc: ck_fifo_mpmc.c ../../../include/ck_fifo.h 17 | $(CC) $(CFLAGS) -o ck_fifo_mpmc ck_fifo_mpmc.c 18 | 19 | ck_fifo_spsc_iterator: ck_fifo_spsc_iterator.c ../../../include/ck_fifo.h 20 | $(CC) $(CFLAGS) -o ck_fifo_spsc_iterator ck_fifo_spsc_iterator.c 21 | 22 | ck_fifo_mpmc_iterator: ck_fifo_mpmc_iterator.c ../../../include/ck_fifo.h 23 | $(CC) $(CFLAGS) -o ck_fifo_mpmc_iterator ck_fifo_mpmc_iterator.c 24 | 25 | clean: 26 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 27 | 28 | include ../../../build/regressions.build 29 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 30 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/linux_spinlock.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | CK_CC_INLINE static void 4 | spin_lock(volatile unsigned int *lock) 5 | { 6 | #ifdef __x86_64__ 7 | __asm__ __volatile__( 8 | "\n1:\t" 9 | "lock ; decl %0\n\t" 10 | "jns 2f\n" 11 | "3:\n" 12 | "rep;nop\n\t" 13 | "cmpl $0,%0\n\t" 14 | "jle 3b\n\t" 15 | "jmp 1b\n" 16 | "2:\t" : "=m" (*lock) : : "memory"); 17 | #else 18 | *lock = 1; 19 | #endif 20 | 21 | return; 22 | } 23 | 24 | CK_CC_INLINE static void 25 | spin_unlock(volatile unsigned int *lock) 26 | { 27 | #ifdef __x86_64__ 28 | __asm__ __volatile__("movl $1,%0" :"=m" (*lock) :: "memory"); 29 | #else 30 | *lock = 0; 31 | return; 32 | #endif 33 | } 34 | 35 | #define LOCK_NAME "linux_spinlock" 36 | #define LOCK_DEFINE volatile unsigned int lock = 1 37 | #define LOCK spin_lock(&lock) 38 | #define UNLOCK spin_unlock(&lock) 39 | 40 | -------------------------------------------------------------------------------- /regressions/ck_hs/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=serial parallel_bytestring parallel_bytestring.delete apply 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_hs.h ../../../src/ck_hs.c 8 | $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_hs.c 9 | 10 | apply: apply.c ../../../include/ck_hs.h ../../../src/ck_hs.c 11 | $(CC) $(CFLAGS) -o apply apply.c ../../../src/ck_hs.c 12 | 13 | parallel_bytestring: parallel_bytestring.c ../../../include/ck_hs.h ../../../src/ck_hs.c ../../../src/ck_epoch.c 14 | $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c 15 | 16 | parallel_bytestring.delete: parallel_bytestring.c ../../../include/ck_hs.h ../../../src/ck_hs.c ../../../src/ck_epoch.c 17 | $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -DHS_DELETE -o parallel_bytestring.delete parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c 18 | 19 | clean: 20 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 21 | 22 | include ../../../build/regressions.build 23 | CFLAGS+=-D_GNU_SOURCE 24 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/pthread.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | CK_CC_INLINE static void 5 | spin_lock(volatile unsigned int *lock) 6 | { 7 | #ifdef __x86_64__ 8 | __asm__ __volatile__( 9 | "\n1:\t" 10 | "lock ; decl %0\n\t" 11 | "jns 2f\n" 12 | "3:\n" 13 | "rep;nop\n\t" 14 | "cmpl $0,%0\n\t" 15 | "jle 3b\n\t" 16 | "jmp 1b\n" 17 | "2:\t" : "=m" (*lock) : : "memory"); 18 | #else 19 | *lock = 1; 20 | #endif 21 | 22 | return; 23 | } 24 | 25 | CK_CC_INLINE static void 26 | spin_unlock(volatile unsigned int *lock) 27 | { 28 | #ifdef __x86_64__ 29 | __asm__ __volatile__("movl $1,%0" :"=m" (*lock) :: "memory"); 30 | #else 31 | *lock = 0; 32 | return; 33 | #endif 34 | } 35 | 36 | #define LOCK_NAME "pthread_mutex" 37 | #define LOCK_DEFINE pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER 38 | #define LOCK pthread_mutex_lock(&lock) 39 | #define UNLOCK pthread_mutex_unlock(&lock) 40 | 41 | -------------------------------------------------------------------------------- /tools/ci-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Skeleton for continuous integration testing. 4 | ############################################################################## 5 | 6 | set -x 7 | 8 | # Determine the number of processor cores available but favor a value specified 9 | # as a command line argument to the script, if provided 10 | CORES= 11 | for arg do 12 | # Look for `--cores=n` and set `CORES=n` if found 13 | if [ `echo "${arg}" | cut -d'=' -f1` = "--cores" ]; then 14 | CORES=`echo "${arg}" | cut -d'=' -f2` 15 | fi 16 | done 17 | ARGS="${@}" 18 | if [ -z "${CORES}" ]; then 19 | # `--cores` not provided, attempt to determine it using appropriate utilities 20 | if command -v nproc; then 21 | # Linux and FreeBSD 13.2+ 22 | CORES=`nproc` 23 | elif command -v sysctl; then 24 | # macOS and BSDs 25 | CORES=`sysctl -n hw.ncpu` 26 | fi 27 | if [ ! -z "${CORES}" ]; then 28 | ARGS="${ARGS} --cores=${CORES}" 29 | fi 30 | fi 31 | 32 | export CFLAGS="-DITERATE=400 -DPAIRS_S=100 -DITERATIONS=24 -DSTEPS=10000" 33 | ./configure ${ARGS} 34 | 35 | make -j${CORES} 36 | -------------------------------------------------------------------------------- /regressions/ck_hp/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_hp_stack nbds_haz_test serial ck_hp_fifo ck_hp_fifo_donner 4 | 5 | all: $(OBJECTS) 6 | 7 | check: all 8 | ./serial 9 | ./ck_hp_stack `expr $(CORES) / 2` 64 1 10 | ./ck_hp_fifo `expr $(CORES) / 2` 1 1024 100 11 | ./nbds_haz_test `expr $(CORES) / 2` 15 1 12 | ./ck_hp_fifo_donner `expr $(CORES) / 2` 16384 13 | 14 | ck_hp_stack: ../../../src/ck_hp.c ck_hp_stack.c ../../../include/ck_hp_stack.h 15 | $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_stack ck_hp_stack.c 16 | 17 | ck_hp_fifo: ../../../src/ck_hp.c ck_hp_fifo.c ../../../include/ck_hp_fifo.h 18 | $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_fifo ck_hp_fifo.c 19 | 20 | ck_hp_fifo_donner: ../../../src/ck_hp.c ck_hp_fifo_donner.c ../../../include/ck_hp_fifo.h 21 | $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_fifo_donner ck_hp_fifo_donner.c 22 | 23 | serial: ../../../src/ck_hp.c serial.c ../../../include/ck_hp_stack.h 24 | $(CC) $(CFLAGS) ../../../src/ck_hp.c -o serial serial.c 25 | 26 | nbds_haz_test: ../../../src/ck_hp.c nbds_haz_test.c 27 | $(CC) $(CFLAGS) ../../../src/ck_hp.c -o nbds_haz_test nbds_haz_test.c 28 | 29 | clean: 30 | rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) 31 | 32 | include ../../../build/regressions.build 33 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 34 | -------------------------------------------------------------------------------- /regressions/ck_ht/benchmark/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean distribution 2 | 3 | OBJECTS=serial serial.delete parallel_bytestring parallel_bytestring.delete parallel_direct 4 | 5 | all: $(OBJECTS) 6 | 7 | serial: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c 8 | $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_ht.c 9 | 10 | serial.delete: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c 11 | $(CC) $(CFLAGS) -DHT_DELETE -o serial.delete serial.c ../../../src/ck_ht.c 12 | 13 | parallel_bytestring.delete: parallel_bytestring.c ../../../include/ck_ht.h ../../../src/ck_ht.c ../../../src/ck_epoch.c 14 | $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -DHT_DELETE -o parallel_bytestring.delete parallel_bytestring.c ../../../src/ck_ht.c ../../../src/ck_epoch.c 15 | 16 | parallel_bytestring: parallel_bytestring.c ../../../include/ck_ht.h ../../../src/ck_ht.c ../../../src/ck_epoch.c 17 | $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_ht.c ../../../src/ck_epoch.c 18 | 19 | parallel_direct: parallel_direct.c ../../../include/ck_ht.h ../../../src/ck_ht.c ../../../src/ck_epoch.c 20 | $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_direct parallel_direct.c ../../../src/ck_ht.c ../../../src/ck_epoch.c 21 | 22 | clean: 23 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 24 | 25 | include ../../../build/regressions.build 26 | CFLAGS+=-D_GNU_SOURCE 27 | 28 | -------------------------------------------------------------------------------- /regressions/ck_ring/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_ring_spsc ck_ring_spmc ck_ring_spmc_template ck_ring_mpmc \ 4 | ck_ring_mpmc_template 5 | SIZE=2048 6 | 7 | all: $(OBJECTS) 8 | 9 | check: all 10 | ./ck_ring_spsc $(CORES) 1 $(SIZE) 11 | ./ck_ring_spmc $(CORES) 1 $(SIZE) 12 | ./ck_ring_spmc_template $(CORES) 1 $(SIZE) 13 | ./ck_ring_mpmc $(CORES) 1 $(SIZE) 14 | ./ck_ring_mpmc_template $(CORES) 1 $(SIZE) 15 | 16 | ck_ring_spsc: ck_ring_spsc.c ../../../include/ck_ring.h 17 | $(CC) $(CFLAGS) -o ck_ring_spsc ck_ring_spsc.c \ 18 | ../../../src/ck_barrier_centralized.c 19 | 20 | ck_ring_spmc: ck_ring_spmc.c ../../../include/ck_ring.h 21 | $(CC) $(CFLAGS) -o ck_ring_spmc ck_ring_spmc.c \ 22 | ../../../src/ck_barrier_centralized.c 23 | 24 | ck_ring_mpmc: ck_ring_mpmc.c ../../../include/ck_ring.h 25 | $(CC) $(CFLAGS) -o ck_ring_mpmc ck_ring_mpmc.c \ 26 | ../../../src/ck_barrier_centralized.c 27 | 28 | ck_ring_mpmc_template: ck_ring_mpmc_template.c ../../../include/ck_ring.h 29 | $(CC) $(CFLAGS) -o ck_ring_mpmc_template ck_ring_mpmc_template.c \ 30 | ../../../src/ck_barrier_centralized.c 31 | 32 | ck_ring_spmc_template: ck_ring_spmc_template.c ../../../include/ck_ring.h 33 | $(CC) $(CFLAGS) -o ck_ring_spmc_template ck_ring_spmc_template.c \ 34 | ../../../src/ck_barrier_centralized.c 35 | 36 | clean: 37 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 38 | 39 | include ../../../build/regressions.build 40 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 41 | -------------------------------------------------------------------------------- /regressions/ck_pr/benchmark/fp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../../common.h" 6 | 7 | #ifndef IR 8 | #define IR 3000000 9 | #endif /* IR */ 10 | 11 | static int a CK_CC_CACHELINE; 12 | static int b CK_CC_CACHELINE; 13 | 14 | int 15 | main(void) 16 | { 17 | uint64_t s, e; 18 | unsigned int i; 19 | 20 | s = rdtsc(); 21 | for (i = 0; i < IR; i++) { 22 | ck_pr_load_int(&a); 23 | ck_pr_fence_strict_load(); 24 | ck_pr_load_int(&b); 25 | } 26 | e = rdtsc(); 27 | printf("[A] fence_load: %" PRIu64 "\n", (e - s) / IR); 28 | 29 | s = rdtsc(); 30 | for (i = 0; i < IR; i++) { 31 | if (ck_pr_load_int(&a) == 0) 32 | ck_pr_barrier(); 33 | ck_pr_fence_strict_lock(); 34 | ck_pr_load_int(&b); 35 | } 36 | e = rdtsc(); 37 | printf("[A] fence_lock: %" PRIu64 "\n", (e - s) / IR); 38 | 39 | s = rdtsc(); 40 | for (i = 0; i < IR; i++) { 41 | ck_pr_store_int(&a, 0); 42 | ck_pr_fence_strict_store(); 43 | ck_pr_store_int(&b, 0); 44 | } 45 | e = rdtsc(); 46 | printf("[B] fence_store: %" PRIu64 "\n", (e - s) / IR); 47 | 48 | s = rdtsc(); 49 | for (i = 0; i < IR; i++) { 50 | ck_pr_store_int(&a, 0); 51 | ck_pr_fence_strict_memory(); 52 | ck_pr_load_int(&b); 53 | } 54 | e = rdtsc(); 55 | printf("[C] fence_memory: %" PRIu64 "\n", (e - s) / IR); 56 | 57 | s = rdtsc(); 58 | for (i = 0; i < IR; i++) { 59 | ck_pr_store_int(&a, 0); 60 | ck_pr_faa_int(&a, 0); 61 | ck_pr_load_int(&b); 62 | } 63 | e = rdtsc(); 64 | printf("[C] atomic: %" PRIu64 "\n", (e - s) / IR); 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /include/ck_stdbool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Olivier Houchard. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #if defined(__FreeBSD__) && defined(_KERNEL) 28 | #include 29 | #else 30 | #include 31 | #endif 32 | -------------------------------------------------------------------------------- /include/ck_stddef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Olivier Houchard. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #if defined(__FreeBSD__) && defined(_KERNEL) 28 | #include 29 | #else 30 | #include 31 | #endif 32 | -------------------------------------------------------------------------------- /include/ck_stdlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Olivier Houchard. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #if defined(__FreeBSD__) && defined(_KERNEL) 28 | #include 29 | #else 30 | #include 31 | #endif 32 | -------------------------------------------------------------------------------- /include/ck_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Olivier Houchard. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #if defined(__FreeBSD__) && defined(_KERNEL) 28 | #include 29 | #else 30 | #include 31 | #endif 32 | -------------------------------------------------------------------------------- /regressions/ck_cohort/ck_cohort.h: -------------------------------------------------------------------------------- 1 | #define LOCK_NAME "ck_cohort" 2 | #define LOCK_DEFINE \ 3 | static ck_spinlock_fas_t global_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; \ 4 | static ck_spinlock_fas_t local_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; \ 5 | static void \ 6 | ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) \ 7 | { \ 8 | (void)context; \ 9 | ck_spinlock_fas_lock(lock); \ 10 | } \ 11 | \ 12 | static void \ 13 | ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) \ 14 | { \ 15 | (void)context; \ 16 | ck_spinlock_fas_unlock(lock); \ 17 | } \ 18 | \ 19 | static bool \ 20 | ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) \ 21 | { \ 22 | (void)context; \ 23 | return ck_spinlock_fas_locked(lock); \ 24 | } \ 25 | CK_COHORT_PROTOTYPE(fas_fas, \ 26 | ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, \ 27 | ck_spinlock_fas_locked_with_context, ck_spinlock_fas_lock_with_context, \ 28 | ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) \ 29 | static CK_COHORT_INSTANCE(fas_fas) CK_CC_CACHELINE cohort = CK_COHORT_INITIALIZER 30 | 31 | 32 | #define LOCK_INIT CK_COHORT_INIT(fas_fas, &cohort, &global_fas_lock, &local_fas_lock, \ 33 | CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT) 34 | #define LOCK CK_COHORT_LOCK(fas_fas, &cohort, NULL, NULL) 35 | #define UNLOCK CK_COHORT_UNLOCK(fas_fas, &cohort, NULL, NULL) 36 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | all: ck_ticket ck_mcs ck_dec ck_cas ck_fas ck_clh linux_spinlock \ 4 | ck_ticket_pb ck_anderson ck_spinlock ck_hclh 5 | 6 | check: all 7 | ./ck_ticket $(CORES) 1 8 | ./ck_mcs $(CORES) 1 9 | ./ck_dec $(CORES) 1 10 | ./ck_cas $(CORES) 1 11 | ./ck_fas $(CORES) 1 12 | ./ck_clh $(CORES) 1 13 | ./ck_hclh $(CORES) 1 14 | ./linux_spinlock $(CORES) 1 15 | ./ck_ticket_pb $(CORES) 1 16 | ./ck_anderson $(CORES) 1 17 | ./ck_spinlock $(CORES) 1 18 | 19 | linux_spinlock: linux_spinlock.c 20 | $(CC) $(CFLAGS) -o linux_spinlock linux_spinlock.c 21 | 22 | ck_spinlock: ck_spinlock.c 23 | $(CC) $(CFLAGS) -o ck_spinlock ck_spinlock.c 24 | 25 | ck_ticket_pb: ck_ticket_pb.c 26 | $(CC) $(CFLAGS) -o ck_ticket_pb ck_ticket_pb.c 27 | 28 | ck_clh: ck_clh.c 29 | $(CC) $(CFLAGS) -o ck_clh ck_clh.c 30 | 31 | ck_hclh: ck_hclh.c 32 | $(CC) $(CFLAGS) -o ck_hclh ck_hclh.c 33 | 34 | ck_anderson: ck_anderson.c 35 | $(CC) $(CFLAGS) -o ck_anderson ck_anderson.c 36 | 37 | ck_fas: ck_fas.c 38 | $(CC) $(CFLAGS) -o ck_fas ck_fas.c 39 | 40 | ck_ticket: ck_ticket.c 41 | $(CC) $(CFLAGS) -o ck_ticket ck_ticket.c 42 | 43 | ck_cas: ck_cas.c 44 | $(CC) $(CFLAGS) -o ck_cas ck_cas.c 45 | 46 | ck_mcs: ck_mcs.c 47 | $(CC) $(CFLAGS) -o ck_mcs ck_mcs.c 48 | 49 | ck_dec: ck_dec.c 50 | $(CC) $(CFLAGS) -o ck_dec ck_dec.c 51 | 52 | clean: 53 | rm -rf ck_ticket ck_mcs ck_dec ck_cas ck_fas ck_clh linux_spinlock ck_ticket_pb \ 54 | ck_anderson ck_spinlock ck_hclh *.dSYM *.exe 55 | 56 | include ../../../build/regressions.build 57 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm 58 | -------------------------------------------------------------------------------- /regressions/ck_barrier/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=barrier_centralized barrier_combining barrier_dissemination barrier_tournament barrier_mcs 4 | 5 | all: $(OBJECTS) 6 | 7 | barrier_centralized: barrier_centralized.c ../../../include/ck_barrier.h ../../../src/ck_barrier_centralized.c 8 | $(CC) $(CFLAGS) -o barrier_centralized barrier_centralized.c ../../../src/ck_barrier_centralized.c 9 | 10 | barrier_combining: barrier_combining.c ../../../include/ck_barrier.h ../../../src/ck_barrier_combining.c 11 | $(CC) $(CFLAGS) -o barrier_combining barrier_combining.c ../../../src/ck_barrier_combining.c 12 | 13 | barrier_dissemination: barrier_dissemination.c ../../../include/ck_barrier.h ../../../src/ck_barrier_dissemination.c 14 | $(CC) $(CFLAGS) -o barrier_dissemination barrier_dissemination.c ../../../src/ck_barrier_dissemination.c 15 | 16 | barrier_tournament: barrier_tournament.c ../../../include/ck_barrier.h ../../../src/ck_barrier_tournament.c 17 | $(CC) $(CFLAGS) -o barrier_tournament barrier_tournament.c ../../../src/ck_barrier_tournament.c 18 | 19 | barrier_mcs: barrier_mcs.c ../../../include/ck_barrier.h ../../../src/ck_barrier_mcs.c 20 | $(CC) $(CFLAGS) -o barrier_mcs barrier_mcs.c ../../../src/ck_barrier_mcs.c 21 | 22 | check: all 23 | rc=0; \ 24 | for d in $(OBJECTS) ; do \ 25 | echo $$d; \ 26 | ./$$d $(CORES) 1 1 || rc=1; \ 27 | done; \ 28 | exit $$rc 29 | 30 | clean: 31 | rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) 32 | 33 | include ../../../build/regressions.build 34 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 35 | -------------------------------------------------------------------------------- /include/ck_stdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #if defined(__linux__) && defined(__KERNEL__) 28 | #include 29 | #include 30 | #elif defined(__FreeBSD__) && defined(_KERNEL) 31 | #include 32 | #else 33 | #include 34 | #endif /* __linux__ && __KERNEL__ */ 35 | -------------------------------------------------------------------------------- /regressions/ck_ec/validate/prop_test_timeutil_add_ns.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../../../src/ck_ec_timeutil.h" 4 | #include "fuzz_harness.h" 5 | 6 | #if ULONG_MAX > 4294967295 7 | typedef unsigned __int128 dword_t; 8 | #else 9 | typedef uint64_t dword_t; 10 | #endif 11 | 12 | struct example { 13 | struct timespec ts; 14 | uint32_t ns; 15 | }; 16 | 17 | static const struct example examples[] = { 18 | { 19 | { 20 | 42, 21 | 100 22 | }, 23 | 1 24 | }, 25 | { 26 | { 27 | 42, 28 | 100 29 | }, 30 | 2 * NSEC_MAX 31 | }, 32 | { 33 | { 34 | 42, 35 | NSEC_MAX 36 | }, 37 | NSEC_MAX 38 | }, 39 | { 40 | { 41 | TIME_MAX - 1, 42 | 1000 43 | }, 44 | 2 * NSEC_MAX 45 | } 46 | }; 47 | 48 | static inline int test_timespec_add_ns(const struct example *example) 49 | { 50 | struct timespec ts = { 51 | .tv_sec = example->ts.tv_sec, 52 | .tv_nsec = example->ts.tv_nsec 53 | }; 54 | const uint32_t ns = example->ns; 55 | 56 | if (ts.tv_sec < 0) { 57 | ts.tv_sec = ~ts.tv_sec; 58 | } 59 | 60 | if (ts.tv_nsec < 0) { 61 | ts.tv_nsec = ~ts.tv_nsec; 62 | } 63 | 64 | ts.tv_nsec %= NSEC_MAX + 1; 65 | 66 | const struct timespec actual = timespec_add_ns(ts, ns); 67 | 68 | dword_t nanos = 69 | (dword_t)ts.tv_sec * (NSEC_MAX + 1) + ts.tv_nsec; 70 | 71 | if (ns > NSEC_MAX) { 72 | nanos += NSEC_MAX + 1; 73 | } else { 74 | nanos += ns; 75 | } 76 | 77 | if (nanos / (NSEC_MAX + 1) > TIME_MAX) { 78 | assert(actual.tv_sec == TIME_MAX); 79 | assert(actual.tv_nsec == NSEC_MAX); 80 | } else { 81 | assert(actual.tv_sec == (time_t)(nanos / (NSEC_MAX + 1))); 82 | assert(actual.tv_nsec == (long)(nanos % (NSEC_MAX + 1))); 83 | } 84 | 85 | return 0; 86 | } 87 | 88 | TEST(test_timespec_add_ns, examples) 89 | -------------------------------------------------------------------------------- /include/ck_malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef CK_MALLOC_H 28 | #define CK_MALLOC_H 29 | 30 | #include 31 | #include 32 | 33 | struct ck_malloc { 34 | void *(*malloc)(size_t); 35 | void *(*realloc)(void *, size_t, size_t, bool); 36 | void (*free)(void *, size_t, bool); 37 | }; 38 | 39 | #endif /* CK_MALLOC_H */ 40 | -------------------------------------------------------------------------------- /regressions/ck_epoch/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_stack ck_epoch_synchronize ck_epoch_poll ck_epoch_call \ 4 | ck_epoch_section ck_epoch_section_2 torture 5 | HALF=`expr $(CORES) / 2` 6 | 7 | all: $(OBJECTS) 8 | 9 | check: all 10 | ./ck_stack $(CORES) 1 11 | ./ck_epoch_synchronize $(HALF) $(HALF) 1 12 | ./ck_epoch_poll $(CORES) 1 1 13 | ./ck_epoch_section 14 | ./ck_epoch_section_2 $(HALF) $(HALF) 1 15 | ./torture $(HALF) $(HALF) 1 16 | 17 | ck_epoch_synchronize: ck_epoch_synchronize.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c 18 | $(CC) $(CFLAGS) -o ck_epoch_synchronize ck_epoch_synchronize.c ../../../src/ck_epoch.c 19 | 20 | ck_epoch_poll: ck_epoch_poll.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c 21 | $(CC) $(CFLAGS) -o ck_epoch_poll ck_epoch_poll.c ../../../src/ck_epoch.c 22 | 23 | torture: torture.c ../../../include/ck_epoch.h ../../../src/ck_epoch.c 24 | $(CC) $(CFLAGS) -o torture torture.c ../../../src/ck_epoch.c 25 | 26 | ck_epoch_section: ck_epoch_section.c ../../../include/ck_epoch.h ../../../src/ck_epoch.c 27 | $(CC) $(CFLAGS) -o ck_epoch_section ck_epoch_section.c ../../../src/ck_epoch.c 28 | 29 | ck_epoch_section_2: ck_epoch_section_2.c ../../../include/ck_epoch.h ../../../src/ck_epoch.c 30 | $(CC) $(CFLAGS) -o ck_epoch_section_2 ck_epoch_section_2.c ../../../src/ck_epoch.c 31 | 32 | ck_epoch_call: ck_epoch_call.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c 33 | $(CC) $(CFLAGS) -o ck_epoch_call ck_epoch_call.c ../../../src/ck_epoch.c 34 | 35 | ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c 36 | $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c 37 | 38 | clean: 39 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 40 | 41 | include ../../../build/regressions.build 42 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 43 | -------------------------------------------------------------------------------- /include/ck_limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #if defined(__linux__) && defined(__KERNEL__) 28 | #include 29 | 30 | #ifndef UINT8_MAX 31 | #define UINT8_MAX ((u8)(~0U)) 32 | #endif 33 | #ifndef UINT16_MAX 34 | #define UINT16_MAX USHRT_MAX 35 | #endif 36 | #ifndef UINT32_MAX 37 | #define UINT32_MAX UINT_MAX 38 | #endif 39 | #ifndef UINT64_MAX 40 | #define UINT64_MAX ULLONG_MAX 41 | #endif 42 | 43 | #elif defined(__FreeBSD__) && defined(_KERNEL) 44 | #include 45 | #include 46 | #else 47 | #include 48 | #endif /* __linux__ && __KERNEL__ */ 49 | -------------------------------------------------------------------------------- /regressions/ck_ec/validate/prop_test_timeutil_cmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../../../src/ck_ec_timeutil.h" 4 | #include "fuzz_harness.h" 5 | 6 | #if ULONG_MAX > 4294967295 7 | typedef __int128 dsword_t; 8 | #else 9 | typedef int64_t dsword_t; 10 | #endif 11 | 12 | struct example { 13 | struct timespec x; 14 | struct timespec y; 15 | }; 16 | 17 | static const struct example examples[] = { 18 | { 19 | { 20 | 42, 21 | 100 22 | }, 23 | { 24 | 1, 25 | 2 26 | } 27 | }, 28 | { 29 | { 30 | 42, 31 | 100 32 | }, 33 | { 34 | 1, 35 | NSEC_MAX 36 | } 37 | }, 38 | { 39 | { 40 | 42, 41 | NSEC_MAX 42 | }, 43 | { 44 | 0, 45 | NSEC_MAX 46 | } 47 | }, 48 | { 49 | { 50 | TIME_MAX - 1, 51 | 1000 52 | }, 53 | { 54 | 2, 55 | NSEC_MAX 56 | } 57 | } 58 | }; 59 | 60 | static struct timespec normalize_ts(const struct timespec ts) 61 | { 62 | struct timespec ret = ts; 63 | 64 | if (ret.tv_nsec < 0) { 65 | ret.tv_nsec = ~ret.tv_nsec; 66 | } 67 | 68 | ret.tv_nsec %= NSEC_MAX + 1; 69 | return ret; 70 | } 71 | 72 | static dsword_t ts_to_nanos(const struct timespec ts) 73 | { 74 | return (dsword_t)ts.tv_sec * (NSEC_MAX + 1) + ts.tv_nsec; 75 | } 76 | 77 | static inline int test_timespec_cmp(const struct example *example) 78 | { 79 | const struct timespec x = normalize_ts(example->y); 80 | const struct timespec y = normalize_ts(example->x); 81 | const dsword_t x_nanos = ts_to_nanos(x); 82 | const dsword_t y_nanos = ts_to_nanos(y); 83 | 84 | assert(timespec_cmp(x, x) == 0); 85 | assert(timespec_cmp(y, y) == 0); 86 | assert(timespec_cmp(x, y) == -timespec_cmp(y, x)); 87 | 88 | if (x_nanos == y_nanos) { 89 | assert(timespec_cmp(x, y) == 0); 90 | } else if (x_nanos < y_nanos) { 91 | assert(timespec_cmp(x, y) == -1); 92 | } else { 93 | assert(timespec_cmp(x, y) == 1); 94 | } 95 | 96 | return 0; 97 | } 98 | 99 | TEST(test_timespec_cmp, examples) 100 | -------------------------------------------------------------------------------- /include/ck_backoff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef CK_BACKOFF_H 28 | #define CK_BACKOFF_H 29 | 30 | #include 31 | #include 32 | 33 | #ifndef CK_BACKOFF_CEILING 34 | #define CK_BACKOFF_CEILING ((1 << 20) - 1) 35 | #endif 36 | 37 | #define CK_BACKOFF_INITIALIZER (1 << 9) 38 | 39 | typedef unsigned int ck_backoff_t; 40 | 41 | /* 42 | * This is a exponential back-off implementation. 43 | */ 44 | CK_CC_INLINE static void 45 | ck_backoff_eb(unsigned int *c) 46 | { 47 | unsigned int i, ceiling; 48 | 49 | ceiling = *c; 50 | for (i = 0; i < ceiling; i++) 51 | ck_pr_barrier(); 52 | 53 | *c = ceiling << (ceiling < CK_BACKOFF_CEILING); 54 | return; 55 | } 56 | 57 | #endif /* CK_BACKOFF_H */ 58 | -------------------------------------------------------------------------------- /regressions/ck_ec/validate/prop_test_timeutil_add.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../../../src/ck_ec_timeutil.h" 6 | #include "fuzz_harness.h" 7 | 8 | #if ULONG_MAX > 4294967295 9 | typedef unsigned __int128 dword_t; 10 | #else 11 | typedef uint64_t dword_t; 12 | #endif 13 | 14 | struct example { 15 | struct timespec ts; 16 | struct timespec inc; 17 | }; 18 | 19 | static const struct example examples[] = { 20 | { 21 | { 22 | 42, 23 | 100 24 | }, 25 | { 26 | 1, 27 | 2 28 | } 29 | }, 30 | { 31 | { 32 | 42, 33 | 100 34 | }, 35 | { 36 | 1, 37 | NSEC_MAX 38 | } 39 | }, 40 | { 41 | { 42 | 42, 43 | NSEC_MAX 44 | }, 45 | { 46 | 0, 47 | NSEC_MAX 48 | } 49 | }, 50 | { 51 | { 52 | TIME_MAX - 1, 53 | 1000 54 | }, 55 | { 56 | 2, 57 | NSEC_MAX 58 | } 59 | } 60 | }; 61 | 62 | static struct timespec normalize_ts(const struct timespec ts) 63 | { 64 | struct timespec ret = ts; 65 | 66 | if (ret.tv_sec < 0) { 67 | ret.tv_sec = ~ret.tv_sec; 68 | } 69 | 70 | if (ret.tv_nsec < 0) { 71 | ret.tv_nsec = ~ret.tv_nsec; 72 | } 73 | 74 | ret.tv_nsec %= NSEC_MAX + 1; 75 | return ret; 76 | } 77 | 78 | static dword_t ts_to_nanos(const struct timespec ts) 79 | { 80 | return (dword_t)ts.tv_sec * (NSEC_MAX + 1) + ts.tv_nsec; 81 | } 82 | 83 | static inline int test_timespec_add(const struct example *example) 84 | { 85 | const struct timespec ts = normalize_ts(example->ts); 86 | const struct timespec inc = normalize_ts(example->inc); 87 | const struct timespec actual = timespec_add(ts, inc); 88 | const dword_t nanos = ts_to_nanos(ts) + ts_to_nanos(inc); 89 | 90 | if (nanos / (NSEC_MAX + 1) > TIME_MAX) { 91 | assert(actual.tv_sec == TIME_MAX); 92 | assert(actual.tv_nsec == NSEC_MAX); 93 | } else { 94 | assert(actual.tv_sec == (time_t)(nanos / (NSEC_MAX + 1))); 95 | assert(actual.tv_nsec == (long)(nanos % (NSEC_MAX + 1))); 96 | } 97 | 98 | return 0; 99 | } 100 | 101 | TEST(test_timespec_add, examples) 102 | -------------------------------------------------------------------------------- /regressions/ck_stack/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=serial mpnc_push mpmc_push upmc_push spinlock_push spinlock_eb_push \ 4 | mpmc_pop upmc_pop spinlock_pop spinlock_eb_pop \ 5 | upmc_trypop mpmc_trypop mpmc_trypair \ 6 | mpmc_pair spinlock_pair spinlock_eb_pair pthreads_pair \ 7 | mpmc_trypush upmc_trypush 8 | 9 | all: $(OBJECTS) 10 | 11 | check: all 12 | ./serial 13 | ./mpmc_pair $(CORES) 1 0 14 | ./upmc_trypop $(CORES) 1 0 15 | ./mpmc_trypop $(CORES) 1 0 16 | ./mpmc_trypair $(CORES) 1 0 17 | ./mpmc_pop $(CORES) 1 0 18 | ./upmc_pop $(CORES) 1 0 19 | ./mpnc_push $(CORES) 1 0 20 | ./mpmc_push $(CORES) 1 0 21 | ./upmc_push $(CORES) 1 0 22 | ./mpmc_trypush $(CORES) 1 0 23 | ./upmc_trypush $(CORES) 1 0 24 | 25 | serial: serial.c 26 | $(CC) $(CFLAGS) -o serial serial.c 27 | 28 | mpmc_trypush upmc_trypush mpnc_push mpmc_push upmc_push spinlock_push spinlock_eb_push: push.c 29 | $(CC) -DTRYUPMC $(CFLAGS) -o upmc_trypush push.c 30 | $(CC) -DTRYMPMC $(CFLAGS) -o mpmc_trypush push.c 31 | $(CC) -DMPNC $(CFLAGS) -o mpnc_push push.c 32 | $(CC) -DMPMC $(CFLAGS) -o mpmc_push push.c 33 | $(CC) -DUPMC $(CFLAGS) -o upmc_push push.c 34 | $(CC) -DSPINLOCK $(CFLAGS) -o spinlock_push push.c 35 | $(CC) -DSPINLOCK -DEB $(CFLAGS) -o spinlock_eb_push push.c 36 | 37 | upmc_trypop mpmc_trypop mpmc_pop tryupmc_pop upmc_pop spinlock_pop spinlock_eb_pop: pop.c 38 | $(CC) -DTRYMPMC $(CFLAGS) -o mpmc_trypop pop.c 39 | $(CC) -DTRYUPMC $(CFLAGS) -o upmc_trypop pop.c 40 | $(CC) -DMPMC $(CFLAGS) -o mpmc_pop pop.c 41 | $(CC) -DUPMC $(CFLAGS) -o upmc_pop pop.c 42 | $(CC) -DSPINLOCK $(CFLAGS) -o spinlock_pop pop.c 43 | $(CC) -DEB -DSPINLOCK $(CFLAGS) -o spinlock_eb_pop pop.c 44 | 45 | mpmc_trypair mpmc_pair spinlock_pair spinlock_eb_pair pthreads_pair: pair.c 46 | $(CC) -DTRYMPMC $(CFLAGS) -o mpmc_trypair pair.c 47 | $(CC) -DMPMC $(CFLAGS) -o mpmc_pair pair.c 48 | $(CC) -DSPINLOCK $(CFLAGS) -o spinlock_pair pair.c 49 | $(CC) -DEB -DSPINLOCK $(CFLAGS) -o spinlock_eb_pair pair.c 50 | $(CC) -DPTHREADS $(CFLAGS) -o pthreads_pair pair.c 51 | 52 | clean: 53 | rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) 54 | 55 | include ../../../build/regressions.build 56 | CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE 57 | -------------------------------------------------------------------------------- /doc/ck_bitmap_clear: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_CLEAR 3 29 | .Sh NAME 30 | .Nm ck_bitmap_clear 31 | .Nd reset all bits 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft void 37 | .Fn ck_bitmap_clear "ck_bitmap_t *bitmap" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_clear 41 | function sets all bits in the bitmap pointed to by 42 | .Fa bitmap 43 | to 0. 44 | .Sh RETURN VALUES 45 | This function has no return value. 46 | .Sh SEE ALSO 47 | .Xr ck_bitmap_base 3 , 48 | .Xr ck_bitmap_size 3 , 49 | .Xr ck_bitmap_init 3 , 50 | .Xr ck_bitmap_set 3 , 51 | .Xr ck_bitmap_reset 3 , 52 | .Xr ck_bitmap_test 3 , 53 | .Xr ck_bitmap_bits 3 , 54 | .Xr ck_bitmap_buffer 3 55 | .Pp 56 | Additional information available at http://concurrencykit.org/ 57 | -------------------------------------------------------------------------------- /doc/ck_bitmap_set: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_SET 3 29 | .Sh NAME 30 | .Nm ck_bitmap_set 31 | .Nd set the bit at the specified index 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft void 37 | .Fn ck_bitmap_set "ck_bitmap_t *bitmap" "unsigned int n" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_set 41 | sets the bit at offset specified by the argument 42 | .Fa n 43 | to 44 | .Dv 1 . 45 | .Sh RETURN VALUES 46 | This function has no return value. 47 | .Sh SEE ALSO 48 | .Xr ck_bitmap_base 3 , 49 | .Xr ck_bitmap_size 3 , 50 | .Xr ck_bitmap_init 3 , 51 | .Xr ck_bitmap_reset 3 , 52 | .Xr ck_bitmap_clear 3 , 53 | .Xr ck_bitmap_test 3 , 54 | .Xr ck_bitmap_bits 3 , 55 | .Xr ck_bitmap_buffer 3 56 | .Pp 57 | Additional information available at http://concurrencykit.org/ 58 | -------------------------------------------------------------------------------- /doc/ck_bitmap_reset: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_RESET 3 29 | .Sh NAME 30 | .Nm ck_bitmap_reset 31 | .Nd resets the bit at the specified index 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft void 37 | .Fn ck_bitmap_reset "ck_bitmap_t *bitmap" "unsigned int n" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_reset 41 | resets the bit at offset specified by the argument 42 | .Fa n 43 | to 44 | .Dv 0 . 45 | .Sh RETURN VALUES 46 | This function has no return value. 47 | .Sh SEE ALSO 48 | .Xr ck_bitmap_base 3 , 49 | .Xr ck_bitmap_size 3 , 50 | .Xr ck_bitmap_init 3 , 51 | .Xr ck_bitmap_set 3 , 52 | .Xr ck_bitmap_clear 3 , 53 | .Xr ck_bitmap_test 3 , 54 | .Xr ck_bitmap_bits 3 , 55 | .Xr ck_bitmap_buffer 3 56 | .Pp 57 | Additional information available at http://concurrencykit.org/ 58 | -------------------------------------------------------------------------------- /doc/ck_bitmap_bits: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_BITS 3 29 | .Sh NAME 30 | .Nm ck_bitmap_bits 31 | .Nd return number of addressable bits in bitmap 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft unsigned int 37 | .Fn ck_bitmap_bits "ck_bitmap_t *bitmap" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_bits 41 | function returns the maximum number of addressable bits in 42 | the object pointed to by 43 | .Fa bitmap . 44 | .Sh RETURN VALUES 45 | This function returns a non-zero value. 46 | .Sh SEE ALSO 47 | .Xr ck_bitmap_base 3 , 48 | .Xr ck_bitmap_size 3 , 49 | .Xr ck_bitmap_init 3 , 50 | .Xr ck_bitmap_set 3 , 51 | .Xr ck_bitmap_reset 3 , 52 | .Xr ck_bitmap_test 3 , 53 | .Xr ck_bitmap_clear 3 , 54 | .Xr ck_bitmap_buffer 3 55 | .Pp 56 | Additional information available at http://concurrencykit.org/ 57 | -------------------------------------------------------------------------------- /doc/ck_ring_size: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 20, 2013 28 | .Dt CK_RING_SIZE 3 29 | .Sh NAME 30 | .Nm ck_ring_size 31 | .Nd return number of pointers enqueued in bounded FIFO 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_ring.h 36 | .Ft unsigned int 37 | .Fn ck_ring_size "ck_ring_t *ring" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_ring_size 3 41 | function returns the number of pointers currently 42 | enqueued in the buffer pointed to by 43 | .Fa ring . 44 | .Sh SEE ALSO 45 | .Xr ck_ring_init 3 , 46 | .Xr ck_ring_enqueue_spmc 3 , 47 | .Xr ck_ring_dequeue_spmc 3 , 48 | .Xr ck_ring_trydequeue_spmc 3 , 49 | .Xr ck_ring_enqueue_spmc_size 3 , 50 | .Xr ck_ring_dequeue_spsc 3 , 51 | .Xr ck_ring_enqueue_spsc 3 , 52 | .Xr ck_ring_enqueue_spsc_size 3 , 53 | .Xr ck_ring_capacity 3 54 | .Pp 55 | Additional information available at http://concurrencykit.org/ 56 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: ["*"] 5 | tags: ["*"] 6 | pull_request: 7 | workflow_dispatch: 8 | 9 | jobs: 10 | linux: 11 | name: Linux ${{ matrix.arch }} / ${{ matrix.cc }} 12 | runs-on: ${{ matrix.runner }} 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | arch: [x86_64, arm64] 17 | cc: [gcc, clang] 18 | include: 19 | - arch: x86_64 20 | runner: ubuntu-latest 21 | - arch: arm64 22 | runner: ubuntu-22.04-arm 23 | steps: 24 | - uses: actions/checkout@v6 25 | 26 | - name: Install compilers 27 | run: sudo apt-get update && sudo apt-get install -y gcc clang 28 | 29 | - name: Compiler version 30 | run: ${{ matrix.cc }} --version 31 | 32 | - name: Build 33 | run: ./tools/ci-build.sh CC=${{ matrix.cc }} --cores=2 34 | 35 | - name: Test 36 | run: make check 37 | 38 | macos: 39 | name: macOS ${{ matrix.variant }} 40 | runs-on: ${{ matrix.runner }} 41 | strategy: 42 | fail-fast: false 43 | matrix: 44 | include: 45 | - variant: arm64 46 | runner: macos-latest # Arm64 47 | - variant: x86_64 48 | runner: macos-15-intel # x86-64 49 | steps: 50 | - uses: actions/checkout@v6 51 | - run: ./tools/ci-build.sh --cores=2 52 | - run: make check 53 | 54 | freebsd: 55 | name: "FreeBSD ${{ matrix.version }} / ${{ matrix.arch }} / ${{ matrix.cc }}" 56 | runs-on: ubuntu-latest 57 | strategy: 58 | fail-fast: false 59 | matrix: 60 | version: ['13.3', '14.2', '15.0'] 61 | arch: ['x86_64', 'aarch64'] 62 | cc: ['clang', 'gcc'] 63 | steps: 64 | - uses: actions/checkout@v6 65 | 66 | - name: Build & Test inside FreeBSD 67 | uses: vmactions/freebsd-vm@v1.3.0 68 | with: 69 | release: ${{ matrix.version }} 70 | arch: ${{ matrix.arch }} 71 | mem: 6144 72 | cpu: 2 73 | usesh: true 74 | sync: rsync 75 | prepare: | 76 | pkg install -y gcc gmake 77 | run: | 78 | ${{ matrix.cc }} --version 79 | ./tools/ci-build.sh CC=${{ matrix.cc }} --cores=2 80 | make check 81 | -------------------------------------------------------------------------------- /doc/ck_bitmap_union: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2014 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd February 23, 2013 28 | .Dt CK_BITMAP_UNION 3 29 | .Sh NAME 30 | .Nm ck_bitmap_union 31 | .Nd generates union of two bitmaps 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft void 37 | .Fn ck_bitmap_union "ck_bitmap_t *dst" "ck_bitmap_t *src" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_union 41 | function sets all bits in the bitmap pointed to by 42 | .Fa src 43 | in the bitmap pointed to by 44 | .Fa dst . 45 | .Sh RETURN VALUES 46 | This function has no return value. 47 | .Sh SEE ALSO 48 | .Xr ck_bitmap_base 3 , 49 | .Xr ck_bitmap_size 3 , 50 | .Xr ck_bitmap_init 3 , 51 | .Xr ck_bitmap_reset 3 , 52 | .Xr ck_bitmap_set 3 , 53 | .Xr ck_bitmap_clear 3 , 54 | .Xr ck_bitmap_test 3 , 55 | .Xr ck_bitmap_bits 3 , 56 | .Xr ck_bitmap_buffer 3 57 | .Pp 58 | Additional information available at http://concurrencykit.org/ 59 | -------------------------------------------------------------------------------- /regressions/ck_backoff/validate/validate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include "../../common.h" 32 | 33 | int 34 | main(void) 35 | { 36 | ck_backoff_t backoff = CK_BACKOFF_INITIALIZER; 37 | const ck_backoff_t ceiling = CK_BACKOFF_CEILING + 1; 38 | unsigned int i = 0; 39 | 40 | fprintf(stderr, "Ceiling is: %u (%#x)\n", CK_BACKOFF_CEILING, CK_BACKOFF_CEILING); 41 | 42 | for (;;) { 43 | ck_backoff_t previous = backoff; 44 | ck_backoff_eb(&backoff); 45 | 46 | printf("EB %u\n", backoff); 47 | if (previous == ceiling) { 48 | if (backoff != ceiling) 49 | ck_error("[C] GB: expected %u, got %u\n", ceiling, backoff); 50 | 51 | if (i++ >= 1) 52 | break; 53 | } else if (previous != backoff >> 1) { 54 | ck_error("[N] GB: expected %u (%u), got %u\n", previous << 1, previous, backoff); 55 | } 56 | } 57 | 58 | return 0; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /regressions/ck_spinlock/benchmark/latency.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2015 Samy Al Bahra. 3 | * Copyright 2011 David Joseph. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "../../common.h" 35 | 36 | #ifndef STEPS 37 | #define STEPS 30000000 38 | #endif 39 | 40 | LOCK_DEFINE; 41 | 42 | int 43 | main(void) 44 | { 45 | CK_CC_UNUSED unsigned int nthr = 1; 46 | 47 | #ifdef LOCK_INIT 48 | LOCK_INIT; 49 | #endif 50 | 51 | #ifdef LOCK_STATE 52 | LOCK_STATE; 53 | #endif 54 | 55 | uint64_t s_b, e_b, i; 56 | CK_CC_UNUSED int core = 0; 57 | 58 | s_b = rdtsc(); 59 | for (i = 0; i < STEPS; ++i) { 60 | #ifdef LOCK 61 | LOCK; 62 | UNLOCK; 63 | LOCK; 64 | UNLOCK; 65 | LOCK; 66 | UNLOCK; 67 | LOCK; 68 | UNLOCK; 69 | #endif 70 | } 71 | e_b = rdtsc(); 72 | printf("%15" PRIu64 "\n", (e_b - s_b) / 4 / STEPS); 73 | 74 | return (0); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /include/gcc/ppc/ck_f_pr.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT. This is auto-generated from feature.sh */ 2 | #define CK_F_PR_ADD_32 3 | #define CK_F_PR_ADD_INT 4 | #define CK_F_PR_ADD_PTR 5 | #define CK_F_PR_ADD_UINT 6 | #define CK_F_PR_AND_32 7 | #define CK_F_PR_AND_INT 8 | #define CK_F_PR_AND_PTR 9 | #define CK_F_PR_AND_UINT 10 | #define CK_F_PR_CAS_32 11 | #define CK_F_PR_CAS_32_VALUE 12 | #define CK_F_PR_CAS_INT 13 | #define CK_F_PR_CAS_INT_VALUE 14 | #define CK_F_PR_CAS_PTR 15 | #define CK_F_PR_CAS_PTR_VALUE 16 | #define CK_F_PR_CAS_UINT 17 | #define CK_F_PR_CAS_UINT_VALUE 18 | #define CK_F_PR_DEC_32 19 | #define CK_F_PR_DEC_INT 20 | #define CK_F_PR_DEC_PTR 21 | #define CK_F_PR_DEC_UINT 22 | #define CK_F_PR_FAA_32 23 | #define CK_F_PR_FAA_INT 24 | #define CK_F_PR_FAA_PTR 25 | #define CK_F_PR_FAA_UINT 26 | #define CK_F_PR_FAS_32 27 | #define CK_F_PR_FAS_INT 28 | #define CK_F_PR_FAS_PTR 29 | #define CK_F_PR_FAS_UINT 30 | #define CK_F_PR_FENCE_LOAD 31 | #define CK_F_PR_FENCE_LOAD_DEPENDS 32 | #define CK_F_PR_FENCE_MEMORY 33 | #define CK_F_PR_FENCE_STORE 34 | #define CK_F_PR_FENCE_STRICT_LOAD 35 | #define CK_F_PR_FENCE_STRICT_LOAD_DEPENDS 36 | #define CK_F_PR_FENCE_STRICT_MEMORY 37 | #define CK_F_PR_FENCE_STRICT_STORE 38 | #define CK_F_PR_INC_32 39 | #define CK_F_PR_INC_INT 40 | #define CK_F_PR_INC_PTR 41 | #define CK_F_PR_INC_UINT 42 | #define CK_F_PR_LOAD_16 43 | #define CK_F_PR_LOAD_32 44 | #define CK_F_PR_LOAD_8 45 | #define CK_F_PR_LOAD_CHAR 46 | #define CK_F_PR_LOAD_INT 47 | #define CK_F_PR_LOAD_PTR 48 | #define CK_F_PR_LOAD_SHORT 49 | #define CK_F_PR_LOAD_UINT 50 | #define CK_F_PR_NEG_32 51 | #define CK_F_PR_NEG_INT 52 | #define CK_F_PR_NEG_PTR 53 | #define CK_F_PR_NEG_UINT 54 | #define CK_F_PR_NOT_32 55 | #define CK_F_PR_NOT_INT 56 | #define CK_F_PR_NOT_PTR 57 | #define CK_F_PR_NOT_UINT 58 | #define CK_F_PR_OR_32 59 | #define CK_F_PR_OR_INT 60 | #define CK_F_PR_OR_PTR 61 | #define CK_F_PR_OR_UINT 62 | #define CK_F_PR_STALL 63 | #define CK_F_PR_STORE_16 64 | #define CK_F_PR_STORE_32 65 | #define CK_F_PR_STORE_8 66 | #define CK_F_PR_STORE_CHAR 67 | #define CK_F_PR_STORE_INT 68 | #define CK_F_PR_STORE_PTR 69 | #define CK_F_PR_STORE_SHORT 70 | #define CK_F_PR_STORE_UINT 71 | #define CK_F_PR_SUB_32 72 | #define CK_F_PR_SUB_INT 73 | #define CK_F_PR_SUB_PTR 74 | #define CK_F_PR_SUB_UINT 75 | #define CK_F_PR_XOR_32 76 | #define CK_F_PR_XOR_INT 77 | #define CK_F_PR_XOR_PTR 78 | #define CK_F_PR_XOR_UINT 79 | 80 | -------------------------------------------------------------------------------- /doc/ck_array_length: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd October 18, 2013 28 | .Dt CK_ARRAY_LENGTH 3 29 | .Sh NAME 30 | .Nm ck_array_length 31 | .Nd returns the number of pointers committed to an array 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_array.h 36 | .Ft unsigned int 37 | .Fn ck_array_length "ck_array_t *array" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_array_length 3 41 | function returns the number of items a concurrent 42 | traversal operation would encounter at completion 43 | time. 44 | .Sh RETURN VALUES 45 | The number of traversal-visible pointers is returned. 46 | .Sh SEE ALSO 47 | .Xr ck_array_commit 3 , 48 | .Xr ck_array_put 3 , 49 | .Xr ck_array_put_unique 3 , 50 | .Xr ck_array_remove 3 , 51 | .Xr ck_array_init 3 52 | .Xr ck_array_deinit 3 , 53 | .Xr ck_array_buffer 3 , 54 | .Xr ck_array_initialized 3 , 55 | .Xr CK_ARRAY_FOREACH 3 56 | .Pp 57 | Additional information available at http://concurrencykit.org/ 58 | -------------------------------------------------------------------------------- /doc/ck_bitmap_base: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_BASE 3 29 | .Sh NAME 30 | .Nm ck_bitmap_base 31 | .Nd determine the size of a bit array in bytes 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft unsigned int 37 | .Fn ck_bitmap_base "unsigned int n_bits" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_base 41 | function returns the number of bytes that would be used 42 | to store the number of bits specified by 43 | .Fa n_bits . 44 | .Sh RETURN VALUES 45 | This function returns a non-zero value that is guaranteed to 46 | be a multiple of 47 | .Dv sizeof(CK_BITMAP_WORD) . 48 | .Sh SEE ALSO 49 | .Xr ck_bitmap_size 3 , 50 | .Xr ck_bitmap_init 3 , 51 | .Xr ck_bitmap_set 3 , 52 | .Xr ck_bitmap_reset 3 , 53 | .Xr ck_bitmap_test 3 , 54 | .Xr ck_bitmap_clear 3 , 55 | .Xr ck_bitmap_bits 3 , 56 | .Xr ck_bitmap_buffer 3 57 | .Pp 58 | Additional information available at http://concurrencykit.org/ 59 | -------------------------------------------------------------------------------- /doc/ck_bitmap_bts: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2014 David Joseph. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd August 22, 2014 28 | .Dt CK_BITMAP_BTS 3 29 | .Sh NAME 30 | .Nm ck_bitmap_bts 31 | .Nd set the bit at the specified index and fetch its original value 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft bool 37 | .Fn ck_bitmap_bts "ck_bitmap_t *bitmap" "unsigned int n" 38 | .Sh DESCRIPTION 39 | .Fn ck_bitmap_bts 40 | sets the bit at the offset specified by the argument 41 | .Fa n 42 | to 43 | .Dv 1 44 | and fetches its original value. 45 | .Sh RETURN VALUES 46 | This function returns the original value of the bit at offset 47 | .Fa n 48 | in 49 | .Fa bitmap . 50 | .Sh SEE ALSO 51 | .Xr ck_bitmap_base 3 , 52 | .Xr ck_bitmap_size 3 , 53 | .Xr ck_bitmap_init 3 , 54 | .Xr ck_bitmap_reset 3 , 55 | .Xr ck_bitmap_clear 3 , 56 | .Xr ck_bitmap_set 3 , 57 | .Xr ck_bitmap_test 3 , 58 | .Xr ck_bitmap_bits 3 , 59 | .Xr ck_bitmap_buffer 3 60 | .Pp 61 | Additional information available at http://concurrencykit.org/ 62 | -------------------------------------------------------------------------------- /doc/ck_ring_capacity: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 20, 2013 28 | .Dt CK_RING_CAPACITY 3 29 | .Sh NAME 30 | .Nm ck_ring_capacity 31 | .Nd returns number of pointer slots in bounded FIFO 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_ring.h 36 | .Ft unsigned int 37 | .Fn ck_ring_capacity "ck_ring_t *ring" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_ring_capacity 3 41 | function returns the number of pointers that can be 42 | held in the buffer pointed to by 43 | .Fa ring . 44 | Note that a ring can only hold 45 | .Fn ck_ring_capacity 3 46 | minus one entries at a time. 47 | .Sh SEE ALSO 48 | .Xr ck_ring_init 3 , 49 | .Xr ck_ring_enqueue_spmc 3 , 50 | .Xr ck_ring_dequeue_spmc 3 , 51 | .Xr ck_ring_trydequeue_spmc 3 , 52 | .Xr ck_ring_enqueue_spmc_size 3 , 53 | .Xr ck_ring_dequeue_spsc 3 , 54 | .Xr ck_ring_enqueue_spsc 3 , 55 | .Xr ck_ring_enqueue_spsc_size 3 , 56 | .Xr ck_ring_size 3 57 | .Pp 58 | Additional information available at http://concurrencykit.org/ 59 | -------------------------------------------------------------------------------- /doc/ck_bitmap_test: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_TEST 3 29 | .Sh NAME 30 | .Nm ck_bitmap_test 31 | .Nd determine if the bit at the specified index is set 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft bool 37 | .Fn ck_bitmap_test "ck_bitmap_t *bitmap" "unsigned int n" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_test 41 | determines if the bit at the offset specified by the argument 42 | .Fa n 43 | is set to 44 | .Dv 1 . 45 | .Sh RETURN VALUES 46 | This function returns 47 | .Dv true 48 | if the bit at the specified offset is set to 49 | .Dv 1 50 | and otherwise returns 51 | .Dv false . 52 | .Sh SEE ALSO 53 | .Xr ck_bitmap_base 3 , 54 | .Xr ck_bitmap_size 3 , 55 | .Xr ck_bitmap_init 3 , 56 | .Xr ck_bitmap_set_mpmc 3 , 57 | .Xr ck_bitmap_reset_mpmc 3 , 58 | .Xr ck_bitmap_clear 3 , 59 | .Xr ck_bitmap_bits 3 , 60 | .Xr ck_bitmap_buffer 3 61 | .Pp 62 | Additional information available at http://concurrencykit.org/ 63 | -------------------------------------------------------------------------------- /src/ck_barrier_centralized.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2015 Samy Al Bahra. 3 | * Copyright 2011 David Joseph. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | void 32 | ck_barrier_centralized(struct ck_barrier_centralized *barrier, 33 | struct ck_barrier_centralized_state *state, 34 | unsigned int n_threads) 35 | { 36 | unsigned int sense, value; 37 | 38 | /* 39 | * Every execution context has a sense associated with it. 40 | * This sense is reversed when the barrier is entered. Every 41 | * thread will spin on the global sense until the last thread 42 | * reverses it. 43 | */ 44 | sense = state->sense = ~state->sense; 45 | value = ck_pr_faa_uint(&barrier->value, 1); 46 | if (value == n_threads - 1) { 47 | ck_pr_store_uint(&barrier->value, 0); 48 | ck_pr_fence_memory(); 49 | ck_pr_store_uint(&barrier->sense, sense); 50 | return; 51 | } 52 | 53 | ck_pr_fence_atomic_load(); 54 | while (sense != ck_pr_load_uint(&barrier->sense)) 55 | ck_pr_stall(); 56 | 57 | ck_pr_fence_acquire(); 58 | return; 59 | } 60 | -------------------------------------------------------------------------------- /doc/ck_pr_barrier: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 7, 2013 28 | .Dt ck_pr_barrier 3 29 | .Sh NAME 30 | .Nm ck_pr_barrier 31 | .Nd compiler optimization barrier 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_pr.h 36 | .Ft void 37 | .Fn ck_pr_barrier void 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_pr_barrier 3 41 | function is used to disable code movement optimizations 42 | across the invocation of the function. 43 | .Sh SEE ALSO 44 | .Xr ck_pr_fence_load 3 , 45 | .Xr ck_pr_fence_load_depends 3 , 46 | .Xr ck_pr_fence_store 3 , 47 | .Xr ck_pr_fence_memory 3 , 48 | .Xr ck_pr_fas 3 , 49 | .Xr ck_pr_load 3 , 50 | .Xr ck_pr_store 3 , 51 | .Xr ck_pr_faa 3 , 52 | .Xr ck_pr_inc 3 , 53 | .Xr ck_pr_dec 3 , 54 | .Xr ck_pr_neg 3 , 55 | .Xr ck_pr_not 3 , 56 | .Xr ck_pr_add 3 , 57 | .Xr ck_pr_sub 3 , 58 | .Xr ck_pr_and 3 , 59 | .Xr ck_pr_or 3 , 60 | .Xr ck_pr_xor 3 , 61 | .Xr ck_pr_cas 3 , 62 | .Xr ck_pr_btc 3 , 63 | .Xr ck_pr_bts 3 , 64 | .Xr ck_pr_btr 3 65 | .Pp 66 | Additional information available at http://concurrencykit.org/ 67 | -------------------------------------------------------------------------------- /doc/ck_ring_init: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 20, 2013 28 | .Dt CK_RING_INIT 3 29 | .Sh NAME 30 | .Nm ck_ring_init 31 | .Nd initialize bounded FIFO 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_ring.h 36 | .Ft void 37 | .Fn ck_ring_init "ck_ring_t *ring" "unsigned int size" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_ring_init 41 | function initializes a bounded FIFO buffer pointed to by 42 | .Fa ring 43 | for the storage of up to 44 | .Fa size 45 | number of pointers. 46 | The 47 | .Fa size 48 | argument must be a power-of-two greater than or equal to 4. 49 | .Sh RETURN VALUES 50 | This function has no return value. 51 | .Sh SEE ALSO 52 | .Xr ck_ring_dequeue_spmc 3 , 53 | .Xr ck_ring_trydequeue_spmc 3 , 54 | .Xr ck_ring_enqueue_spmc 3 , 55 | .Xr ck_ring_enqueue_spmc_size 3 , 56 | .Xr ck_ring_dequeue_spsc 3 , 57 | .Xr ck_ring_enqueue_spsc 3 , 58 | .Xr ck_ring_enqueue_spsc_size 3 , 59 | .Xr ck_ring_capacity 3 , 60 | .Xr ck_ring_size 3 61 | .Pp 62 | Additional information available at http://concurrencykit.org/ 63 | -------------------------------------------------------------------------------- /include/ck_md.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef CK_MD_H 28 | #define CK_MD_H 29 | 30 | #ifndef CK_MD_CACHELINE 31 | #define CK_MD_CACHELINE (64) 32 | #endif 33 | 34 | #ifndef CK_MD_PAGESIZE 35 | #define CK_MD_PAGESIZE (4096) 36 | #endif 37 | 38 | #ifndef @RTM_ENABLE@ 39 | #define @RTM_ENABLE@ 40 | #endif /* @RTM_ENABLE@ */ 41 | 42 | #ifndef @LSE_ENABLE@ 43 | #define @LSE_ENABLE@ 44 | #endif /* @LSE_ENABLE@ */ 45 | 46 | #ifndef @POINTER_PACK_ENABLE@ 47 | #define @POINTER_PACK_ENABLE@ 48 | #endif /* @POINTER_PACK_ENABLE@ */ 49 | 50 | #ifndef @SSE_DISABLE@ 51 | #define @SSE_DISABLE@ 52 | #endif /* @SSE_DISABLE@ */ 53 | 54 | #ifndef @PPC32_LWSYNC_ENABLE@ 55 | #define @PPC32_LWSYNC_ENABLE@ 56 | #endif /* @PPC32_LWSYNC_ENABLE@ */ 57 | 58 | #ifndef @VMA_BITS@ 59 | #define @VMA_BITS@ @VMA_BITS_VALUE@ 60 | #endif /* @VMA_BITS@ */ 61 | 62 | #ifndef @MM@ 63 | #define @MM@ 64 | #endif /* @MM@ */ 65 | 66 | #ifndef @DISABLE_DOUBLE@ 67 | #define @DISABLE_DOUBLE@ 68 | #endif /* @DISABLE_DOUBLE@ */ 69 | 70 | #define CK_VERSION "@VERSION@" 71 | #define CK_GIT_SHA "@GIT_SHA@" 72 | 73 | #endif /* CK_MD_H */ 74 | -------------------------------------------------------------------------------- /doc/ck_array_deinit: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd October 18, 2013 28 | .Dt CK_ARRAY_DEINIT 3 29 | .Sh NAME 30 | .Nm ck_array_deinit 31 | .Nd destroy and deinitialize a pointer array 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_array.h 36 | .Ft void 37 | .Fn ck_array_deinit "ck_array_t *array" "bool defer" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_array_deinit 3 41 | destroys the memory associated with the array pointed 42 | to by 43 | .Fa array . 44 | The 45 | .Fa defer 46 | argument is true if the allocator must destroy 47 | the memory using safe memory reclamation or false 48 | if the allocator can destroy this memory immediately. 49 | .Sh RETURN VALUES 50 | This function has no return value. 51 | .Sh SEE ALSO 52 | .Xr ck_array_commit 3 , 53 | .Xr ck_array_put 3 , 54 | .Xr ck_array_put_unique 3 , 55 | .Xr ck_array_remove 3 , 56 | .Xr ck_array_init 3 57 | .Xr ck_array_length 3 , 58 | .Xr ck_array_buffer 3 , 59 | .Xr ck_array_initialized 3 , 60 | .Xr CK_ARRAY_FOREACH 3 61 | .Pp 62 | Additional information available at http://concurrencykit.org/ 63 | -------------------------------------------------------------------------------- /doc/ck_epoch_init: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 2, 2012 28 | .Dt CK_EPOCH_INIT 3 29 | .Sh NAME 30 | .Nm ck_epoch_init 31 | .Nd initialize epoch reclamation object 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_epoch.h 36 | .Ft void 37 | .Fn ck_epoch_init "ck_epoch_t *epoch" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_epoch_init 41 | function initializes the epoch object pointed to by the 42 | .Fa epoch 43 | pointer. 44 | .Sh RETURN VALUES 45 | This function has no return value. 46 | .Sh ERRORS 47 | .Bl -tag -width Er 48 | .Pp 49 | The behavior of 50 | .Fn ck_epoch_init 51 | is undefined if 52 | .Fa epoch 53 | is not a pointer to a 54 | .Vt ck_epoch_t 55 | object. 56 | .El 57 | .Sh SEE ALSO 58 | .Xr ck_epoch_register 3 , 59 | .Xr ck_epoch_unregister 3 , 60 | .Xr ck_epoch_recycle 3 , 61 | .Xr ck_epoch_poll 3 , 62 | .Xr ck_epoch_synchronize 3 , 63 | .Xr ck_epoch_reclaim 3 , 64 | .Xr ck_epoch_barrier 3 , 65 | .Xr ck_epoch_call 3 , 66 | .Xr ck_epoch_begin 3 , 67 | .Xr ck_epoch_end 3 68 | .Pp 69 | Additional information available at http://concurrencykit.org/ 70 | -------------------------------------------------------------------------------- /doc/ck_array_buffer: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd October 18, 2013 28 | .Dt CK_ARRAY_BUFFER 3 29 | .Sh NAME 30 | .Nm ck_array_buffer 31 | .Nd return length and pointer to array of reader-visible pointers 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_array.h 36 | .Ft void * 37 | .Fn ck_array_buffer "ck_array_t *array" "unsigned int *length" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_array_buffer 3 41 | returns a pointer to the array of pointers currently visible 42 | to readers after the last commit operation in 43 | .Fa array . 44 | The unsigned integer pointed to by 45 | .Fa length 46 | is updated to reflect the length of the array. 47 | .Sh RETURN VALUES 48 | This function returns a pointer to an array of pointers. 49 | .Sh SEE ALSO 50 | .Xr ck_array_commit 3 , 51 | .Xr ck_array_put 3 , 52 | .Xr ck_array_put_unique 3 , 53 | .Xr ck_array_remove 3 , 54 | .Xr ck_array_init 3 55 | .Xr ck_array_deinit 3 , 56 | .Xr ck_array_length 3 , 57 | .Xr ck_array_initialized 3 , 58 | .Xr CK_ARRAY_FOREACH 3 59 | .Pp 60 | Additional information available at http://concurrencykit.org/ 61 | -------------------------------------------------------------------------------- /doc/ck_array_commit: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd October 18, 2013 28 | .Dt CK_ARRAY_COMMIT 3 29 | .Sh NAME 30 | .Nm ck_array_commit 31 | .Nd linearization point for mutations before commit call 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_array.h 36 | .Ft bool 37 | .Fn ck_array_commit "ck_array_t *array" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_array_commit 3 41 | function will commit any pending put or remove operations associated 42 | with the array. The function may end up requesting the safe reclamation 43 | of memory actively being iterated upon by other threads. 44 | .Sh RETURN VALUES 45 | This function returns true if the commit operation succeeded. It will 46 | return false otherwise, and pending operations will not be applied. 47 | .Sh SEE ALSO 48 | .Xr ck_array_init 3 , 49 | .Xr ck_array_put 3 , 50 | .Xr ck_array_put_unique 3 , 51 | .Xr ck_array_remove 3 , 52 | .Xr ck_array_deinit 3 53 | .Xr ck_array_length 3 , 54 | .Xr ck_array_buffer 3 , 55 | .Xr ck_array_initialized 3 , 56 | .Xr CK_ARRAY_FOREACH 3 57 | .Pp 58 | Additional information available at http://concurrencykit.org/ 59 | -------------------------------------------------------------------------------- /regressions/ck_pflock/benchmark/latency.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2015 Samy Al Bahra. 3 | * Copyright 2013 John Wittrock. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHEPFISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "../../common.h" 33 | 34 | #ifndef STEPS 35 | #define STEPS 1000000 36 | #endif 37 | 38 | int 39 | main(void) 40 | { 41 | uint64_t s_b, e_b, i; 42 | ck_pflock_t pflock = CK_PFLOCK_INITIALIZER; 43 | 44 | for (i = 0; i < STEPS; i++) { 45 | ck_pflock_write_lock(&pflock); 46 | ck_pflock_write_unlock(&pflock); 47 | } 48 | 49 | s_b = rdtsc(); 50 | for (i = 0; i < STEPS; i++) { 51 | ck_pflock_write_lock(&pflock); 52 | ck_pflock_write_unlock(&pflock); 53 | } 54 | e_b = rdtsc(); 55 | printf("WRITE: pflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); 56 | 57 | for (i = 0; i < STEPS; i++) { 58 | ck_pflock_read_lock(&pflock); 59 | ck_pflock_read_unlock(&pflock); 60 | } 61 | 62 | s_b = rdtsc(); 63 | for (i = 0; i < STEPS; i++) { 64 | ck_pflock_read_lock(&pflock); 65 | ck_pflock_read_unlock(&pflock); 66 | } 67 | e_b = rdtsc(); 68 | printf("READ: pflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); 69 | 70 | return 0; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /regressions/ck_pr/validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean distribution 2 | 3 | OBJECTS=ck_pr_cas ck_pr_faa ck_pr_inc ck_pr_dec ck_pr_bts \ 4 | ck_pr_btr ck_pr_btc ck_pr_load ck_pr_store \ 5 | ck_pr_and ck_pr_or ck_pr_xor ck_pr_add ck_pr_sub \ 6 | ck_pr_fas ck_pr_bin ck_pr_btx ck_pr_fax ck_pr_n \ 7 | ck_pr_unary ck_pr_fence ck_pr_dec_zero ck_pr_inc_zero 8 | 9 | all: $(OBJECTS) 10 | 11 | check: all 12 | for d in $(OBJECTS) ; do \ 13 | echo $$d; \ 14 | ./$$d || exit 1; \ 15 | done; 16 | 17 | ck_pr_cas: ck_pr_cas.c 18 | $(CC) $(CFLAGS) -o ck_pr_cas ck_pr_cas.c 19 | 20 | ck_pr_inc: ck_pr_inc.c 21 | $(CC) $(CFLAGS) -o ck_pr_inc ck_pr_inc.c 22 | 23 | ck_pr_inc_zero: ck_pr_inc_zero.c 24 | $(CC) $(CFLAGS) -o ck_pr_inc_zero ck_pr_inc_zero.c 25 | 26 | ck_pr_dec: ck_pr_dec.c 27 | $(CC) $(CFLAGS) -o ck_pr_dec ck_pr_dec.c 28 | 29 | ck_pr_dec_zero: ck_pr_dec_zero.c 30 | $(CC) $(CFLAGS) -o ck_pr_dec_zero ck_pr_dec_zero.c 31 | 32 | ck_pr_faa: ck_pr_faa.c 33 | $(CC) $(CFLAGS) -o ck_pr_faa ck_pr_faa.c 34 | 35 | ck_pr_fence: ck_pr_fence.c 36 | $(CC) $(CFLAGS) -o ck_pr_fence ck_pr_fence.c 37 | 38 | ck_pr_btc: ck_pr_btc.c 39 | $(CC) $(CFLAGS) -o ck_pr_btc ck_pr_btc.c 40 | 41 | ck_pr_btr: ck_pr_btr.c 42 | $(CC) $(CFLAGS) -o ck_pr_btr ck_pr_btr.c 43 | 44 | ck_pr_bts: ck_pr_bts.c 45 | $(CC) $(CFLAGS) -o ck_pr_bts ck_pr_bts.c 46 | 47 | ck_pr_load: ck_pr_load.c 48 | $(CC) $(CFLAGS) -o ck_pr_load ck_pr_load.c 49 | 50 | ck_pr_store: ck_pr_store.c 51 | $(CC) $(CFLAGS) -o ck_pr_store ck_pr_store.c 52 | 53 | ck_pr_and: ck_pr_and.c 54 | $(CC) $(CFLAGS) -o ck_pr_and ck_pr_and.c 55 | 56 | ck_pr_or: ck_pr_or.c 57 | $(CC) $(CFLAGS) -o ck_pr_or ck_pr_or.c 58 | 59 | ck_pr_xor: ck_pr_xor.c 60 | $(CC) $(CFLAGS) -o ck_pr_xor ck_pr_xor.c 61 | 62 | ck_pr_add: ck_pr_add.c 63 | $(CC) $(CFLAGS) -o ck_pr_add ck_pr_add.c 64 | 65 | ck_pr_sub: ck_pr_sub.c 66 | $(CC) $(CFLAGS) -o ck_pr_sub ck_pr_sub.c 67 | 68 | ck_pr_fas: ck_pr_fas.c 69 | $(CC) $(CFLAGS) -o ck_pr_fas ck_pr_fas.c 70 | 71 | ck_tp: ck_tp.c 72 | $(CC) $(CFLAGS) -o ck_tp ck_tp.c 73 | 74 | ck_pr_bin: ck_pr_bin.c 75 | $(CC) $(CFLAGS) -o ck_pr_bin ck_pr_bin.c 76 | 77 | ck_pr_btx: ck_pr_btx.c 78 | $(CC) $(CFLAGS) -o ck_pr_btx ck_pr_btx.c 79 | 80 | ck_pr_fax: ck_pr_fax.c 81 | $(CC) $(CFLAGS) -o ck_pr_fax ck_pr_fax.c 82 | 83 | ck_pr_n: ck_pr_n.c 84 | $(CC) $(CFLAGS) -o ck_pr_n ck_pr_n.c 85 | 86 | ck_pr_unary: ck_pr_unary.c 87 | $(CC) $(CFLAGS) -o ck_pr_unary ck_pr_unary.c 88 | 89 | clean: 90 | rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe 91 | 92 | include ../../../build/regressions.build 93 | CFLAGS+=-D_GNU_SOURCE 94 | -------------------------------------------------------------------------------- /doc/ck_hs_count: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 17, 2012 28 | .Dt CK_HS_COUNT 3 29 | .Sh NAME 30 | .Nm ck_hs_count 31 | .Nd returns number of entries in hash set 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_hs.h 36 | .Ft unsigned long 37 | .Fn ck_hs_count "ck_hs_t *hs" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_hs_count 3 41 | function returns the number of keys currently 42 | stored in 43 | .Fa hs . 44 | .Sh ERRORS 45 | Behavior is undefined if 46 | .Fa hs 47 | is uninitialized. Behavior is 48 | undefined if this function is called by a non-writer 49 | thread. 50 | .Sh SEE ALSO 51 | .Xr ck_hs_init 3 , 52 | .Xr ck_hs_move 3 , 53 | .Xr ck_hs_destroy 3 , 54 | .Xr CK_HS_HASH 3 , 55 | .Xr ck_hs_iterator_init 3 , 56 | .Xr ck_hs_next 3 , 57 | .Xr ck_hs_get 3 , 58 | .Xr ck_hs_put 3 , 59 | .Xr ck_hs_put_unique 3 , 60 | .Xr ck_hs_set 3 , 61 | .Xr ck_hs_fas 3 , 62 | .Xr ck_hs_remove 3 , 63 | .Xr ck_hs_grow 3 , 64 | .Xr ck_hs_rebuild 3 , 65 | .Xr ck_hs_gc 3 , 66 | .Xr ck_hs_reset 3 , 67 | .Xr ck_hs_reset_size 3 , 68 | .Xr ck_hs_stat 3 69 | .Pp 70 | Additional information available at http://concurrencykit.org/ 71 | -------------------------------------------------------------------------------- /doc/ck_array_initialized: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd October 18, 2013 28 | .Dt CK_ARRAY_INITIALIZED 3 29 | .Sh NAME 30 | .Nm ck_array_initialized 31 | .Nd indicates whether an array was recently initialized or deinitialized 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_array.h 36 | .Ft bool 37 | .Fn ck_array_initialized "ck_array_t *array" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_array_initialized 3 41 | can be used to determine whether an array was recently initialized 42 | with 43 | .Fn ck_array_init 3 44 | or deinitialized with 45 | .Fn ck_array_deinit 3 . 46 | Behavior is undefined if a user allocates internal allocator data 47 | in through other means. 48 | .Sh RETURN VALUES 49 | This function returns true if the array is initialized, and false 50 | otherwise. 51 | .Sh SEE ALSO 52 | .Xr ck_array_commit 3 , 53 | .Xr ck_array_put 3 , 54 | .Xr ck_array_put_unique 3 , 55 | .Xr ck_array_remove 3 , 56 | .Xr ck_array_init 3 57 | .Xr ck_array_deinit 3 , 58 | .Xr ck_array_length 3 , 59 | .Xr ck_array_buffer 3 , 60 | .Xr CK_ARRAY_FOREACH 3 61 | .Pp 62 | Additional information available at http://concurrencykit.org/ 63 | -------------------------------------------------------------------------------- /doc/ck_bitmap_size: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_SIZE 3 29 | .Sh NAME 30 | .Nm ck_bitmap_size 31 | .Nd returns necessary number of bytes for bitmap 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft unsigned int 37 | .Fn ck_bitmap_size "unsigned int n_bits" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_size 41 | function returns the number of bytes that are necessary 42 | to allocate for a bitmap that will contain the number 43 | of bits specified by 44 | .Fa n_bits . 45 | .Pp 46 | This function is used to determine how many bytes to 47 | allocate for dynamically created bitmap objects. The 48 | allocated object must still be initialized using 49 | .Xr ck_bitmap_init 3 . 50 | .Sh RETURN VALUES 51 | This function returns a non-zero value. 52 | .Sh SEE ALSO 53 | .Xr ck_bitmap_base 3 , 54 | .Xr ck_bitmap_init 3 , 55 | .Xr ck_bitmap_set_mpmc 3 , 56 | .Xr ck_bitmap_reset_mpmc 3 , 57 | .Xr ck_bitmap_test 3 , 58 | .Xr ck_bitmap_clear 3 , 59 | .Xr ck_bitmap_bits 3 , 60 | .Xr ck_bitmap_buffer 3 61 | .Pp 62 | Additional information available at http://concurrencykit.org/ 63 | -------------------------------------------------------------------------------- /doc/ck_bitmap_buffer: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 22, 2012 28 | .Dt CK_BITMAP_BUFFER 3 29 | .Sh NAME 30 | .Nm ck_bitmap_buffer 31 | .Nd returns pointer to bit array 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_bitmap.h 36 | .Ft void * 37 | .Fn ck_bitmap_buffer "ck_bitmap_t *bitmap" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_bitmap_buffer 41 | functions returns a pointer to the actual bit array. 42 | For ck_bitmap pointers, the bit array is of type 43 | CK_BITMAP_WORD[] and consists of 44 | ck_bitmap_base(bitmap) / sizeof(CK_BITMAP_WORD) elements. 45 | On currently supported 64-bit platforms 46 | .Dv CK_BITMAP_WORD 47 | is 48 | .Dv uint64_t . 49 | On currently supported 32-bit platforms 50 | .Dv CK_BITMAP_WORD 51 | is 52 | .Dv uint32_t . 53 | .Sh RETURN VALUES 54 | This function returns a non-NULL value. 55 | .Sh SEE ALSO 56 | .Xr ck_bitmap_base 3 , 57 | .Xr ck_bitmap_size 3 , 58 | .Xr ck_bitmap_init 3 , 59 | .Xr ck_bitmap_set 3 , 60 | .Xr ck_bitmap_reset 3 , 61 | .Xr ck_bitmap_test 3 , 62 | .Xr ck_bitmap_clear 3 , 63 | .Xr ck_bitmap_bits 3 64 | .Pp 65 | Additional information available at http://concurrencykit.org/ 66 | -------------------------------------------------------------------------------- /doc/ck_epoch_end: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 2, 2012 28 | .Dt CK_EPOCH_END 3 29 | .Sh NAME 30 | .Nm ck_epoch_end 31 | .Nd end epoch-protected segment of execution 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_epoch.h 36 | .Ft void 37 | .Fn ck_epoch_end "ck_epoch_record_t *record" "ck_epoch_section_t *section" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_epoch_end 3 41 | function will mark the end of an epoch-protected code section. 42 | .Fa section 43 | must point to a section object initialized previously with 44 | .Fn ck_epoch_begin 3 . 45 | .Sh RETURN VALUES 46 | This function has no return value. 47 | .Sh ERRORS 48 | The object pointed to by 49 | .Fa record 50 | must have been previously registered via 51 | .Fn ck_epoch_register 3 . 52 | .Sh SEE ALSO 53 | .Xr ck_epoch_init 3 , 54 | .Xr ck_epoch_register 3 , 55 | .Xr ck_epoch_unregister 3 , 56 | .Xr ck_epoch_recycle 3 , 57 | .Xr ck_epoch_poll 3 , 58 | .Xr ck_epoch_synchronize 3 , 59 | .Xr ck_epoch_reclaim 3 , 60 | .Xr ck_epoch_barrier 3 , 61 | .Xr ck_epoch_call 3 , 62 | .Xr ck_epoch_begin 3 63 | .Pp 64 | Additional information available at http://concurrencykit.org/ 65 | -------------------------------------------------------------------------------- /regressions/ck_epoch/validate/ck_epoch_call.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "../../common.h" 31 | 32 | static ck_epoch_t epoch; 33 | static unsigned int counter; 34 | static ck_epoch_record_t record[2]; 35 | 36 | static void 37 | cb(ck_epoch_entry_t *p) 38 | { 39 | 40 | /* Test that we can reregister the callback. */ 41 | if (counter == 0) 42 | ck_epoch_call(&record[1], p, cb); 43 | 44 | printf("Counter value: %u -> %u\n", 45 | counter, counter + 1); 46 | counter++; 47 | return; 48 | } 49 | 50 | int 51 | main(void) 52 | { 53 | ck_epoch_entry_t entry; 54 | ck_epoch_entry_t another; 55 | 56 | ck_epoch_register(&epoch, &record[0], NULL); 57 | ck_epoch_register(&epoch, &record[1], NULL); 58 | 59 | ck_epoch_call(&record[1], &entry, cb); 60 | ck_epoch_barrier(&record[1]); 61 | ck_epoch_barrier(&record[1]); 62 | 63 | /* Make sure that strict works. */ 64 | ck_epoch_call_strict(&record[1], &entry, cb); 65 | ck_epoch_call_strict(&record[1], &another, cb); 66 | ck_epoch_barrier(&record[1]); 67 | 68 | if (counter != 4) 69 | ck_error("Expected counter value 4, read %u.\n", counter); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /doc/ck_rhs_count: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 17, 2012 28 | .Dt CK_RHS_COUNT 3 29 | .Sh NAME 30 | .Nm ck_rhs_count 31 | .Nd returns number of entries in hash set 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_rhs.h 36 | .Ft unsigned long 37 | .Fn ck_rhs_count "ck_rhs_t *hs" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_rhs_count 3 41 | function returns the number of keys currently 42 | stored in 43 | .Fa hs . 44 | .Sh ERRORS 45 | Behavior is undefined if 46 | .Fa hs 47 | is uninitialized. Behavior is 48 | undefined if this function is called by a non-writer 49 | thread. 50 | .Sh SEE ALSO 51 | .Xr ck_rhs_init 3 , 52 | .Xr ck_rhs_move 3 , 53 | .Xr ck_rhs_destroy 3 , 54 | .Xr CK_RHS_HASH 3 , 55 | .Xr ck_rhs_iterator_init 3 , 56 | .Xr ck_rhs_next 3 , 57 | .Xr ck_rhs_get 3 , 58 | .Xr ck_rhs_put 3 , 59 | .Xr ck_rhs_put_unique 3 , 60 | .Xr ck_rhs_set 3 , 61 | .Xr ck_rhs_fas 3 , 62 | .Xr ck_rhs_remove 3 , 63 | .Xr ck_rhs_grow 3 , 64 | .Xr ck_rhs_rebuild 3 , 65 | .Xr ck_rhs_gc 3 , 66 | .Xr ck_rhs_reset 3 , 67 | .Xr ck_rhs_reset_size 3 , 68 | .Xr ck_rhs_stat 3 69 | .Pp 70 | Additional information available at http://concurrencykit.org/ 71 | -------------------------------------------------------------------------------- /doc/CK_COHORT_UNLOCK: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Brendon Scheinman. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd February 24, 2013. 28 | .Dt CK_COHORT_UNLOCK 3 29 | .Sh NAME 30 | .Nm CK_COHORT_UNLOCK 31 | .Nd release cohort lock 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_cohort.h 36 | .Fn CK_COHORT_UNLOCK "COHORT_NAME cohort_name" "COHORT *cohort" "void *global_context" \ 37 | "void *local_context" 38 | .Sh DESCRIPTION 39 | This call instructs 40 | .Fa cohort 41 | to relinquish its local lock and potentially its global lock as well. 42 | .Fa global_context 43 | will be passed as the second argument to the function that was provided as the 44 | .Fa global_lock_method 45 | argument to CK_COHORT_PROTOTYPE if that method is called, and 46 | .Fa local_context 47 | will be passed to the function specified by 48 | .Fa local_lock_method 49 | . 50 | .Sh SEE ALSO 51 | .Xr ck_cohort 3 , 52 | .Xr CK_COHORT_PROTOTYPE 3 , 53 | .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , 54 | .Xr CK_COHORT_INSTANCE 3 , 55 | .Xr CK_COHORT_INITIALIZER 3 , 56 | .Xr CK_COHORT_INIT 3 , 57 | .Xr CK_COHORT_LOCK 3 , 58 | .Xr CK_COHORT_LOCKED 3 , 59 | .Xr CK_COHORT_TRYLOCK 3 , 60 | .Pp 61 | Additional information available at http://concurrencykit.org/ 62 | -------------------------------------------------------------------------------- /doc/CK_HS_HASH: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd March 28, 2012 28 | .Dt CK_HS_HASH 3 29 | .Sh NAME 30 | .Nm CK_HS_HASH 31 | .Nd invoke hash function with hash set seed 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_hs.h 36 | .Ft unsigned long 37 | .Fn CK_HS_HASH "ck_hs_t *hs" "ck_hs_hash_cb_t *hf" "const void *key" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn CK_HS_HASH 3 41 | macro will invoke the hash function pointed to by the 42 | .Fa hf 43 | argument with the seed value associated with 44 | .Fa hs 45 | and the key pointer specified by the 46 | .Fa key 47 | argument. 48 | .Sh RETURN VALUES 49 | This function will return the value returned by the 50 | .Fa hf 51 | function. 52 | .Sh ERRORS 53 | It is expected 54 | .Fa hs 55 | was previously initialized via 56 | .Fn ck_hs_init 3 . 57 | .Sh SEE ALSO 58 | .Xr ck_hs_init 3 , 59 | .Xr ck_hs_destroy 3 , 60 | .Xr ck_hs_iterator_init 3 , 61 | .Xr ck_hs_next 3 , 62 | .Xr ck_hs_get 3 , 63 | .Xr ck_hs_put 3 , 64 | .Xr ck_hs_set 3 , 65 | .Xr ck_hs_remove 3 , 66 | .Xr ck_hs_grow 3 , 67 | .Xr ck_hs_count 3 , 68 | .Xr ck_hs_reset 3 , 69 | .Xr ck_hs_stat 3 70 | .Pp 71 | Additional information available at http://concurrencykit.org/ 72 | -------------------------------------------------------------------------------- /regressions/ck_tflock/benchmark/latency.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "../../common.h" 32 | 33 | #define CK_F_PR_RTM 34 | 35 | #ifndef STEPS 36 | #define STEPS 2000000 37 | #endif 38 | 39 | int 40 | main(void) 41 | { 42 | uint64_t s_b, e_b, i; 43 | ck_tflock_ticket_t tflock = CK_TFLOCK_TICKET_INITIALIZER; 44 | 45 | for (i = 0; i < STEPS; i++) { 46 | ck_tflock_ticket_write_lock(&tflock); 47 | ck_tflock_ticket_write_unlock(&tflock); 48 | } 49 | 50 | s_b = rdtsc(); 51 | for (i = 0; i < STEPS; i++) { 52 | ck_tflock_ticket_write_lock(&tflock); 53 | ck_tflock_ticket_write_unlock(&tflock); 54 | } 55 | e_b = rdtsc(); 56 | printf(" WRITE: tflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); 57 | 58 | for (i = 0; i < STEPS; i++) { 59 | ck_tflock_ticket_read_lock(&tflock); 60 | ck_tflock_ticket_read_unlock(&tflock); 61 | } 62 | 63 | s_b = rdtsc(); 64 | for (i = 0; i < STEPS; i++) { 65 | ck_tflock_ticket_read_lock(&tflock); 66 | ck_tflock_ticket_read_unlock(&tflock); 67 | } 68 | e_b = rdtsc(); 69 | printf(" READ: tflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); 70 | 71 | return 0; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /doc/CK_RHS_HASH: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd March 28, 2012 28 | .Dt CK_RHS_HASH 3 29 | .Sh NAME 30 | .Nm CK_RHS_HASH 31 | .Nd invoke hash function with hash set seed 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_rhs.h 36 | .Ft unsigned long 37 | .Fn CK_RHS_HASH "ck_rhs_t *hs" "ck_rhs_hash_cb_t *hf" "const void *key" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn CK_RHS_HASH 3 41 | macro will invoke the hash function pointed to by the 42 | .Fa hf 43 | argument with the seed value associated with 44 | .Fa hs 45 | and the key pointer specified by the 46 | .Fa key 47 | argument. 48 | .Sh RETURN VALUES 49 | This function will return the value returned by the 50 | .Fa hf 51 | function. 52 | .Sh ERRORS 53 | It is expected 54 | .Fa hs 55 | was previously initialized via 56 | .Fn ck_rhs_init 3 . 57 | .Sh SEE ALSO 58 | .Xr ck_rhs_init 3 , 59 | .Xr ck_rhs_destroy 3 , 60 | .Xr ck_rhs_iterator_init 3 , 61 | .Xr ck_rhs_next 3 , 62 | .Xr ck_rhs_get 3 , 63 | .Xr ck_rhs_put 3 , 64 | .Xr ck_rhs_set 3 , 65 | .Xr ck_rhs_remove 3 , 66 | .Xr ck_rhs_grow 3 , 67 | .Xr ck_rhs_count 3 , 68 | .Xr ck_rhs_reset 3 , 69 | .Xr ck_rhs_stat 3 70 | .Pp 71 | Additional information available at http://concurrencykit.org/ 72 | -------------------------------------------------------------------------------- /doc/CK_COHORT_LOCK: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Brendon Scheinman. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd February 24, 2013. 28 | .Dt CK_COHORT_LOCK 3 29 | .Sh NAME 30 | .Nm CK_COHORT_LOCK 31 | .Nd acquire cohort lock 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_cohort.h 36 | .Fn CK_COHORT_LOCK "COHORT_NAME cohort_name" "COHORT *cohort" "void *global_context" \ 37 | "void *local_context" 38 | .Sh DESCRIPTION 39 | This call attempts to acquire both the local and global (if necessary) locks from 40 | .Fa cohort . 41 | The call will block until both locks have been acquired. 42 | .Fa global_context 43 | will be passed as the second argument to the function that was provided as the 44 | .Fa global_lock_method 45 | argument to CK_COHORT_PROTOTYPE if that method is called, and 46 | .Fa local_context 47 | will be passed to the function specified by 48 | .Fa local_lock_method 49 | . 50 | .Sh SEE ALSO 51 | .Xr ck_cohort 3 , 52 | .Xr CK_COHORT_PROTOTYPE 3 , 53 | .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , 54 | .Xr CK_COHORT_INSTANCE 3 , 55 | .Xr CK_COHORT_INITIALIZER 3 , 56 | .Xr CK_COHORT_INIT 3 , 57 | .Xr CK_COHORT_UNLOCK 3 , 58 | .Xr CK_COHORT_LOCKED 3 , 59 | .Xr CK_COHORT_TRYLOCK 3 , 60 | .Pp 61 | Additional information available at http://concurrencykit.org/ 62 | -------------------------------------------------------------------------------- /doc/ck_bitmap_iterator_init: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" Copyright 2012-2013 Shreyas Prasad. 4 | .\" All rights reserved. 5 | .\" 6 | .\" Redistribution and use in source and binary forms, with or without 7 | .\" modification, are permitted provided that the following conditions 8 | .\" are met: 9 | .\" 1. Redistributions of source code must retain the above copyright 10 | .\" notice, this list of conditions and the following disclaimer. 11 | .\" 2. Redistributions in binary form must reproduce the above copyright 12 | .\" notice, this list of conditions and the following disclaimer in the 13 | .\" documentation and/or other materials provided with the distribution. 14 | .\" 15 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 16 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 19 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | .\" SUCH DAMAGE. 26 | .\" 27 | .\" 28 | .Dd April 27, 2012 29 | .Dt CK_BITMAP_ITERATOR_INIT 3 30 | .Sh NAME 31 | .Nm ck_bitmap_iterator_init 32 | .Nd initialize bitmap iterator 33 | .Sh LIBRARY 34 | Concurrency Kit (libck, \-lck) 35 | .Sh SYNOPSIS 36 | .In ck_ht.h 37 | .Pp 38 | .Ft void 39 | .Fn ck_bitmap_iterator_init "ck_bitmap_iterator_t *iterator" "ck_bitmap_t *bitmap" 40 | .Sh DESCRIPTION 41 | The 42 | .Fn ck_bitmap_iterator_init 43 | function will initialize the object pointed to by 44 | the 45 | .Fa iterator 46 | argument for use with 47 | .Fa bitmap . 48 | .Pp 49 | An iterator is used to iterate through set bitmap bits 50 | with the 51 | .Xr ck_bitmap_next 3 52 | function. 53 | .Sh RETURN VALUES 54 | The 55 | .Fn ck_bitmap_iterator_init 56 | function does not return a value. 57 | .Sh ERRORS 58 | This function will not fail. 59 | .Sh SEE ALSO 60 | .Xr ck_bitmap_base 3 , 61 | .Xr ck_bitmap_size 3 , 62 | .Xr ck_bitmap_init 3 , 63 | .Xr ck_bitmap_set 3 , 64 | .Xr ck_bitmap_reset 3 , 65 | .Xr ck_bitmap_clear 3 , 66 | .Xr ck_bitmap_bits 3 , 67 | .Xr ck_bitmap_buffer 3 , 68 | .Xr ck_bitmap_next 3 69 | .Pp 70 | Additional information available at http://concurrencykit.org/ 71 | -------------------------------------------------------------------------------- /doc/ck_epoch_unregister: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 2, 2012 28 | .Dt CK_EPOCH_UNREGISTER 3 29 | .Sh NAME 30 | .Nm ck_epoch_unregister 31 | .Nd unregister a thread for epoch reclamation 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_epoch.h 36 | .Ft void 37 | .Fn ck_epoch_unregister "ck_epoch_record_t *record" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_epoch_unregister 3 41 | function allows for the record pointed by the 42 | .Fa record 43 | pointer to be used as a return value by the 44 | .Fn ck_epoch_recycle 3 45 | function. This record can now be used by another thread 46 | of execution. Behavior is undefined if the object pointed by 47 | .Fa record 48 | is modified in any way, even after a call is made to the 49 | .Fn ck_epoch_unregister 3 50 | function. 51 | .Sh RETURN VALUES 52 | This function has no return value. 53 | .Sh SEE ALSO 54 | .Xr ck_epoch_init 3 , 55 | .Xr ck_epoch_register 3 , 56 | .Xr ck_epoch_recycle 3 , 57 | .Xr ck_epoch_poll 3 , 58 | .Xr ck_epoch_synchronize 3 , 59 | .Xr ck_epoch_reclaim 3 , 60 | .Xr ck_epoch_barrier 3 , 61 | .Xr ck_epoch_call 3 , 62 | .Xr ck_epoch_begin 3 , 63 | .Xr ck_epoch_end 3 64 | .Pp 65 | Additional information available at http://concurrencykit.org/ 66 | -------------------------------------------------------------------------------- /doc/CK_COHORT_INSTANCE: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Brendon Scheinman. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd February 24, 2013. 28 | .Dt CK_COHORT_INSTANCE 3 29 | .Sh NAME 30 | .Nm CK_COHORT_INSTANCE 31 | .Nd declare an instance of a cohort type 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_cohort.h 36 | .Fn CK_COHORT_INSTANCE "COHORT_NAME cohort_name" 37 | .Sh DESCRIPTION 38 | The user must use this macro to declare instances of cohort types that they have 39 | defined. For instance, if they have used the CK_COHORT_PROTOTYPE macro to define 40 | a cohort type with name foo, they would create an instance of this type as follows: 41 | .br 42 | CK_COHORT_INSTANCE(foo) cohort; 43 | .Pp 44 | This macro should also be used when allocating memory for cohorts. For instance, 45 | to allocate a block of 4 cohorts: 46 | .br 47 | CK_COHORT_INSTANCE(foo) *cohorts = malloc(4 * sizeof(CK_COHORT_INSTANCE(foo))); 48 | .Sh SEE ALSO 49 | .Xr ck_cohort 3 , 50 | .Xr CK_COHORT_PROTOTYPE 3 , 51 | .Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , 52 | .Xr CK_COHORT_INSTANCE 3 , 53 | .Xr CK_COHORT_INITIALIZER 3 , 54 | .Xr CK_COHORT_LOCK 3 , 55 | .Xr CK_COHORT_UNLOCK 3 , 56 | .Xr CK_COHORT_LOCKED 3 , 57 | .Xr CK_COHORT_TRYLOCK 3 , 58 | .Pp 59 | Additional information available at http://concurrencykit.org/ 60 | -------------------------------------------------------------------------------- /doc/ck_pr_fence_release: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2014 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd January 2, 2014 28 | .Dt CK_PR_FENCE_RELEASE 3 29 | .Sh NAME 30 | .Nm ck_pr_fence_release 31 | .Nd enforce release semantics 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_pr.h 36 | .Ft void 37 | .Fn ck_pr_fence_release void 38 | .Sh DESCRIPTION 39 | This function enforces the partial ordering of any loads prior 40 | to invocation with respect to any following stores and any stores 41 | prior to invocation with respect to any following stores. 42 | .Sh RETURN VALUES 43 | This function has no return value. 44 | .Sh SEE ALSO 45 | .Xr ck_pr_stall 3 , 46 | .Xr ck_pr_fence_atomic 3 , 47 | .Xr ck_pr_fence_atomic_store 3 , 48 | .Xr ck_pr_fence_atomic_load 3 , 49 | .Xr ck_pr_fence_acquire 3 , 50 | .Xr ck_pr_fence_store 3 , 51 | .Xr ck_pr_fence_memory 3 , 52 | .Xr ck_pr_barrier 3 , 53 | .Xr ck_pr_fas 3 , 54 | .Xr ck_pr_load 3 , 55 | .Xr ck_pr_store 3 , 56 | .Xr ck_pr_faa 3 , 57 | .Xr ck_pr_inc 3 , 58 | .Xr ck_pr_dec 3 , 59 | .Xr ck_pr_neg 3 , 60 | .Xr ck_pr_not 3 , 61 | .Xr ck_pr_add 3 , 62 | .Xr ck_pr_sub 3 , 63 | .Xr ck_pr_and 3 , 64 | .Xr ck_pr_or 3 , 65 | .Xr ck_pr_xor 3 , 66 | .Xr ck_pr_cas 3 , 67 | .Xr ck_pr_btc 3 , 68 | .Xr ck_pr_bts 3 , 69 | .Xr ck_pr_btr 3 70 | .Pp 71 | Additional information available at http://concurrencykit.org/ 72 | -------------------------------------------------------------------------------- /doc/ck_array_put: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd October 18, 2013 28 | .Dt CK_ARRAY_PUT 3 29 | .Sh NAME 30 | .Nm ck_array_put 31 | .Nd attempt immediate or deferred insertion of a pointer into array 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_array.h 36 | .Ft bool 37 | .Fn ck_array_put "ck_array_t *array" "void *pointer" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_array_put 3 41 | function will attempt to insert the value of 42 | .Fa pointer 43 | into the array pointed to by 44 | .Fa array . 45 | This function may incur additional memory allocations 46 | if not enough memory has been allocated in the array 47 | for a new entry. The operation is also free to apply 48 | the operation immediately if there is an opportunity 49 | for elimination with a pending (uncommitted) remove 50 | operation. 51 | .Sh RETURN VALUES 52 | This function returns true if the put operation succeeded. It will 53 | return false otherwise due to internal allocation failures. 54 | .Sh SEE ALSO 55 | .Xr ck_array_init 3 , 56 | .Xr ck_array_commit 3 , 57 | .Xr ck_array_put_unique 3 , 58 | .Xr ck_array_remove 3 , 59 | .Xr ck_array_deinit 3 60 | .Xr ck_array_length 3 , 61 | .Xr ck_array_buffer 3 , 62 | .Xr ck_array_initialized 3 , 63 | .Xr CK_ARRAY_FOREACH 3 64 | .Pp 65 | Additional information available at http://concurrencykit.org/ 66 | -------------------------------------------------------------------------------- /doc/ck_pr_fence_acquire: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2014 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd January 2, 2014 28 | .Dt CK_PR_FENCE_ACQUIRE 3 29 | .Sh NAME 30 | .Nm ck_pr_fence_acquire 31 | .Nd enforce acquire semantics 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_pr.h 36 | .Ft void 37 | .Fn ck_pr_fence_acquire void 38 | .Sh DESCRIPTION 39 | This function enforces the partial ordering of any loads prior 40 | to invocation with respect to any following stores, loads and 41 | atomic operations. It is typically used to implement critical 42 | sections. 43 | .Sh RETURN VALUES 44 | This function has no return value. 45 | .Sh SEE ALSO 46 | .Xr ck_pr_stall 3 , 47 | .Xr ck_pr_fence_atomic 3 , 48 | .Xr ck_pr_fence_atomic_store 3 , 49 | .Xr ck_pr_fence_atomic_load 3 , 50 | .Xr ck_pr_fence_release 3 , 51 | .Xr ck_pr_fence_store 3 , 52 | .Xr ck_pr_fence_memory 3 , 53 | .Xr ck_pr_barrier 3 , 54 | .Xr ck_pr_fas 3 , 55 | .Xr ck_pr_load 3 , 56 | .Xr ck_pr_store 3 , 57 | .Xr ck_pr_faa 3 , 58 | .Xr ck_pr_inc 3 , 59 | .Xr ck_pr_dec 3 , 60 | .Xr ck_pr_neg 3 , 61 | .Xr ck_pr_not 3 , 62 | .Xr ck_pr_add 3 , 63 | .Xr ck_pr_sub 3 , 64 | .Xr ck_pr_and 3 , 65 | .Xr ck_pr_or 3 , 66 | .Xr ck_pr_xor 3 , 67 | .Xr ck_pr_cas 3 , 68 | .Xr ck_pr_btc 3 , 69 | .Xr ck_pr_bts 3 , 70 | .Xr ck_pr_btr 3 71 | .Pp 72 | Additional information available at http://concurrencykit.org/ 73 | -------------------------------------------------------------------------------- /doc/ck_array_remove: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd October 18, 2013 28 | .Dt CK_ARRAY_REMOVE 3 29 | .Sh NAME 30 | .Nm ck_array_remove 31 | .Nd attempt immediate or deferred removal of a pointer from an array 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_array.h 36 | .Ft bool 37 | .Fn ck_array_remove "ck_array_t *array" "void *pointer" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_array_remove 3 41 | function will attempt to remove the value of 42 | .Fa pointer 43 | into the array pointed to by 44 | .Fa array . The operation is also free to apply 45 | the operation immediately if there is an opportunity 46 | for elimination with a pending (uncommitted) put 47 | operation. If no elimination was possible, the function 48 | may require to allocate more memory. 49 | .Sh RETURN VALUES 50 | This function returns true if the remove operation succeeded. It will 51 | return false otherwise due to internal allocation failures or because 52 | the value did not exist. 53 | .Sh SEE ALSO 54 | .Xr ck_array_init 3 , 55 | .Xr ck_array_commit 3 , 56 | .Xr ck_array_remove 3 , 57 | .Xr ck_array_put_unique 3 , 58 | .Xr ck_array_deinit 3 59 | .Xr ck_array_length 3 , 60 | .Xr ck_array_buffer 3 , 61 | .Xr ck_array_initialized 3 , 62 | .Xr CK_ARRAY_FOREACH 3 63 | .Pp 64 | Additional information available at http://concurrencykit.org/ 65 | -------------------------------------------------------------------------------- /include/ck_spinlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef CK_SPINLOCK_H 28 | #define CK_SPINLOCK_H 29 | 30 | #include "spinlock/anderson.h" 31 | #include "spinlock/cas.h" 32 | #include "spinlock/clh.h" 33 | #include "spinlock/dec.h" 34 | #include "spinlock/fas.h" 35 | #include "spinlock/hclh.h" 36 | #include "spinlock/mcs.h" 37 | #include "spinlock/ticket.h" 38 | 39 | /* 40 | * On tested x86, x86_64, PPC64 and SPARC64 targets, 41 | * ck_spinlock_fas proved to have lowest latency 42 | * in fast path testing or negligible degradation 43 | * from faster but less robust implementations. 44 | */ 45 | #define CK_SPINLOCK_INITIALIZER CK_SPINLOCK_FAS_INITIALIZER 46 | #define ck_spinlock_t ck_spinlock_fas_t 47 | #define ck_spinlock_init(x) ck_spinlock_fas_init(x) 48 | #define ck_spinlock_lock(x) ck_spinlock_fas_lock(x) 49 | #define ck_spinlock_lock_eb(x) ck_spinlock_fas_lock_eb(x) 50 | #define ck_spinlock_unlock(x) ck_spinlock_fas_unlock(x) 51 | #define ck_spinlock_locked(x) ck_spinlock_fas_locked(x) 52 | #define ck_spinlock_trylock(x) ck_spinlock_fas_trylock(x) 53 | 54 | CK_ELIDE_PROTOTYPE(ck_spinlock, ck_spinlock_t, 55 | ck_spinlock_locked, ck_spinlock_lock, 56 | ck_spinlock_locked, ck_spinlock_unlock) 57 | 58 | CK_ELIDE_TRYLOCK_PROTOTYPE(ck_spinlock, ck_spinlock_t, 59 | ck_spinlock_locked, ck_spinlock_trylock) 60 | 61 | #endif /* CK_SPINLOCK_H */ 62 | -------------------------------------------------------------------------------- /doc/ck_rhs_gc: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd December 17, 2013 28 | .Dt CK_RHS_GC 3 29 | .Sh NAME 30 | .Nm ck_rhs_gc 31 | .Nd perform maintenance on a hash set 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_rhs.h 36 | .Ft bool 37 | .Fn ck_rhs_gc "ck_rhs_t *hs" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_rhs_gc 3 41 | function will perform various maintenance routines on the hash set 42 | pointed to by 43 | .Fa hs , 44 | including recalculating the maximum number of probes. 45 | .Sh RETURN VALUES 46 | Upon successful completion, 47 | .Fn ck_rhs_gc 3 48 | returns true and otherwise returns false on failure due to memory allocation 49 | failure. 50 | .Sh ERRORS 51 | This function will only return false if there are internal memory allocation 52 | failures. 53 | .Sh SEE ALSO 54 | .Xr ck_rhs_init 3 , 55 | .Xr ck_rhs_move 3 , 56 | .Xr ck_rhs_destroy 3 , 57 | .Xr CK_RHS_HASH 3 , 58 | .Xr ck_rhs_iterator_init 3 , 59 | .Xr ck_rhs_next 3 , 60 | .Xr ck_rhs_get 3 , 61 | .Xr ck_rhs_put 3 , 62 | .Xr ck_rhs_put_unique 3 , 63 | .Xr ck_rhs_grow 3 , 64 | .Xr ck_rhs_rebuild 3 , 65 | .Xr ck_rhs_set 3 , 66 | .Xr ck_rhs_fas 3 , 67 | .Xr ck_rhs_remove 3 , 68 | .Xr ck_rhs_count 3 , 69 | .Xr ck_rhs_reset 3 , 70 | .Xr ck_rhs_reset_size 3 , 71 | .Xr ck_rhs_stat 3 72 | .Pp 73 | Additional information available at http://concurrencykit.org/ 74 | -------------------------------------------------------------------------------- /regressions/ck_stack/validate/serial.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2015 Samy Al Bahra. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #ifndef SIZE 34 | #define SIZE 1024000 35 | #endif 36 | 37 | struct entry { 38 | int value; 39 | ck_stack_entry_t next; 40 | }; 41 | 42 | CK_STACK_CONTAINER(struct entry, next, get_entry) 43 | 44 | #define LOOP(PUSH, POP) \ 45 | for (i = 0; i < SIZE; i++) { \ 46 | entries[i].value = i; \ 47 | PUSH(stack, &entries[i].next); \ 48 | } \ 49 | for (i = SIZE - 1; i >= 0; i--) { \ 50 | entry = POP(stack); \ 51 | assert(entry); \ 52 | assert(get_entry(entry)->value == i); \ 53 | } 54 | 55 | static void 56 | serial(ck_stack_t *stack) 57 | { 58 | struct entry *entries; 59 | ck_stack_entry_t *entry; 60 | int i; 61 | 62 | ck_stack_init(stack); 63 | 64 | entries = malloc(sizeof(struct entry) * SIZE); 65 | assert(entries != NULL); 66 | 67 | LOOP(ck_stack_push_upmc, ck_stack_pop_upmc); 68 | #ifdef CK_F_STACK_POP_MPMC 69 | LOOP(ck_stack_push_mpmc, ck_stack_pop_mpmc); 70 | #endif 71 | LOOP(ck_stack_push_mpnc, ck_stack_pop_upmc); 72 | LOOP(ck_stack_push_spnc, ck_stack_pop_npsc); 73 | 74 | return; 75 | } 76 | 77 | int 78 | main(void) 79 | { 80 | ck_stack_t stack CK_CC_CACHELINE; 81 | 82 | serial(&stack); 83 | return (0); 84 | } 85 | -------------------------------------------------------------------------------- /doc/ck_pr: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd April 7, 2013 28 | .Dt ck_pr 3 29 | .Sh NAME 30 | .Nm ck_pr 31 | .Nd concurrency primitives interface 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_pr.h 36 | .Sh DESCRIPTION 37 | ck_pr.h provides an interface to volatile atomic instructions, 38 | memory barriers and busy-wait facilities as provided by the 39 | underlying processor. The presence of an atomic operation 40 | is detected by the presence of a corresponding CK_F_PR macro. 41 | For example, the availability of 42 | .Xr ck_pr_add_16 3 43 | would be determined by the presence of CK_F_PR_ADD_16. 44 | .Sh SEE ALSO 45 | .Xr ck_pr_stall 3 , 46 | .Xr ck_pr_fence_acquire 3 , 47 | .Xr ck_pr_fence_release 3 , 48 | .Xr ck_pr_fence_load 3 , 49 | .Xr ck_pr_fence_load_depends 3 , 50 | .Xr ck_pr_fence_store 3 , 51 | .Xr ck_pr_fence_memory 3 , 52 | .Xr ck_pr_barrier 3 , 53 | .Xr ck_pr_fas 3 , 54 | .Xr ck_pr_load 3 , 55 | .Xr ck_pr_store 3 , 56 | .Xr ck_pr_faa 3 , 57 | .Xr ck_pr_inc 3 , 58 | .Xr ck_pr_dec 3 , 59 | .Xr ck_pr_neg 3 , 60 | .Xr ck_pr_not 3 , 61 | .Xr ck_pr_add 3 , 62 | .Xr ck_pr_sub 3 , 63 | .Xr ck_pr_and 3 , 64 | .Xr ck_pr_or 3 , 65 | .Xr ck_pr_xor 3 , 66 | .Xr ck_pr_cas 3 , 67 | .Xr ck_pr_btc 3 , 68 | .Xr ck_pr_bts 3 , 69 | .Xr ck_pr_btr 3 70 | .Pp 71 | Additional information available at http://concurrencykit.org/ 72 | -------------------------------------------------------------------------------- /doc/ck_hs_destroy: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 17, 2012 28 | .Dt CK_HS_DESTROY 3 29 | .Sh NAME 30 | .Nm ck_hs_destroy 31 | .Nd destroy hash set 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_hs.h 36 | .Ft void 37 | .Fn ck_hs_destroy "ck_hs_t *hs" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_hs_destroy 3 41 | function will request that the underlying allocator, as specified by the 42 | .Xr ck_hs_init 3 43 | function, immediately destroy the object pointed to by the 44 | .Fa hs 45 | argument. 46 | The user must guarantee that no threads are accessing the object pointed to 47 | by 48 | .Fa hs 49 | when 50 | .Fn ck_hs_destroy 3 51 | is called. 52 | .Sh RETURN VALUES 53 | .Fn ck_hs_destroy 3 54 | has no return value. 55 | .Sh ERRORS 56 | This function is guaranteed not to fail. 57 | .Sh SEE ALSO 58 | .Xr ck_hs_init 3 , 59 | .Xr ck_hs_move 3 , 60 | .Xr CK_HS_HASH 3 , 61 | .Xr ck_hs_iterator_init 3 , 62 | .Xr ck_hs_next 3 , 63 | .Xr ck_hs_get 3 , 64 | .Xr ck_hs_put 3 , 65 | .Xr ck_hs_put_unique 3 , 66 | .Xr ck_hs_set 3 , 67 | .Xr ck_hs_fas 3 , 68 | .Xr ck_hs_remove 3 , 69 | .Xr ck_hs_grow 3 , 70 | .Xr ck_hs_rebuild 3 , 71 | .Xr ck_hs_gc 3 , 72 | .Xr ck_hs_count 3 , 73 | .Xr ck_hs_reset 3 , 74 | .Xr ck_hs_reset_size 3 , 75 | .Xr ck_hs_stat 3 76 | .Pp 77 | Additional information available at http://concurrencykit.org/ 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010-2014 Samy Al Bahra. 2 | Copyright 2011-2013 AppNexus, Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | SUCH DAMAGE. 25 | 26 | Hazard Pointers (src/ck_hp.c) also includes this license: 27 | 28 | (c) Copyright 2008, IBM Corporation. 29 | Licensed under the Apache License, Version 2.0 (the "License"); 30 | you may not use this file except in compliance with the License. 31 | You may obtain a copy of the License at 32 | 33 | http://www.apache.org/licenses/LICENSE-2.0 34 | 35 | Unless required by applicable law or agreed to in writing, software 36 | distributed under the License is distributed on an "AS IS" BASIS, 37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 38 | See the License for the specific language governing permissions and 39 | limitations under the License. 40 | 41 | ck_pr_rtm leverages work from Andi Kleen: 42 | Copyright (c) 2012,2013 Intel Corporation 43 | 44 | Redistribution and use in source and binary forms, with or without 45 | modification, are permitted provided that: (1) source code distributions 46 | retain the above copyright notice and this paragraph in its entirety, (2) 47 | distributions including binary code include the above copyright notice and 48 | this paragraph in its entirety in the documentation or other materials 49 | provided with the distribution 50 | 51 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 52 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 53 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 54 | 55 | -------------------------------------------------------------------------------- /doc/ck_rhs_destroy: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 17, 2012 28 | .Dt CK_RHS_DESTROY 3 29 | .Sh NAME 30 | .Nm ck_rhs_destroy 31 | .Nd destroy hash set 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_rhs.h 36 | .Ft void 37 | .Fn ck_rhs_destroy "ck_rhs_t *hs" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_rhs_destroy 3 41 | function will request that the underlying allocator, as specified by the 42 | .Xr ck_rhs_init 3 43 | function, immediately destroy the object pointed to by the 44 | .Fa hs 45 | argument. 46 | The user must guarantee that no threads are accessing the object pointed to 47 | by 48 | .Fa hs 49 | when 50 | .Fn ck_rhs_destroy 3 51 | is called. 52 | .Sh RETURN VALUES 53 | .Fn ck_rhs_destroy 3 54 | has no return value. 55 | .Sh ERRORS 56 | This function is guaranteed not to fail. 57 | .Sh SEE ALSO 58 | .Xr ck_rhs_init 3 , 59 | .Xr ck_rhs_move 3 , 60 | .Xr CK_RHS_HASH 3 , 61 | .Xr ck_rhs_iterator_init 3 , 62 | .Xr ck_rhs_next 3 , 63 | .Xr ck_rhs_get 3 , 64 | .Xr ck_rhs_put 3 , 65 | .Xr ck_rhs_put_unique 3 , 66 | .Xr ck_rhs_set 3 , 67 | .Xr ck_rhs_fas 3 , 68 | .Xr ck_rhs_remove 3 , 69 | .Xr ck_rhs_grow 3 , 70 | .Xr ck_rhs_rebuild 3 , 71 | .Xr ck_rhs_gc 3 , 72 | .Xr ck_rhs_count 3 , 73 | .Xr ck_rhs_reset 3 , 74 | .Xr ck_rhs_reset_size 3 , 75 | .Xr ck_rhs_stat 3 76 | .Pp 77 | Additional information available at http://concurrencykit.org/ 78 | -------------------------------------------------------------------------------- /regressions/ck_ec/validate/prop_test_slow_wakeup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "fuzz_harness.h" 5 | 6 | static int gettime(const struct ck_ec_ops *, struct timespec *out); 7 | static void wake32(const struct ck_ec_ops *, const uint32_t *); 8 | static void wait32(const struct ck_ec_wait_state *, const uint32_t *, 9 | uint32_t, const struct timespec *); 10 | static void wake64(const struct ck_ec_ops *, const uint64_t *); 11 | static void wait64(const struct ck_ec_wait_state *, const uint64_t *, 12 | uint64_t, const struct timespec *); 13 | 14 | static const struct ck_ec_ops test_ops = { 15 | .gettime = gettime, 16 | .wait32 = wait32, 17 | .wait64 = wait64, 18 | .wake32 = wake32, 19 | .wake64 = wake64 20 | }; 21 | 22 | static int gettime(const struct ck_ec_ops *ops, struct timespec *out) 23 | { 24 | (void)out; 25 | 26 | assert(ops == &test_ops); 27 | return -1; 28 | } 29 | 30 | static void wait32(const struct ck_ec_wait_state *wait_state, 31 | const uint32_t *addr, uint32_t expected, 32 | const struct timespec *deadline) 33 | { 34 | (void)addr; 35 | (void)expected; 36 | (void)deadline; 37 | 38 | assert(wait_state->ops == &test_ops); 39 | return; 40 | } 41 | 42 | static void wait64(const struct ck_ec_wait_state *wait_state, 43 | const uint64_t *addr, uint64_t expected, 44 | const struct timespec *deadline) 45 | { 46 | (void)addr; 47 | (void)expected; 48 | (void)deadline; 49 | 50 | assert(wait_state->ops == &test_ops); 51 | return; 52 | } 53 | 54 | static void wake32(const struct ck_ec_ops *ops, const uint32_t *addr) 55 | { 56 | (void)addr; 57 | 58 | assert(ops == &test_ops); 59 | return; 60 | } 61 | 62 | static void wake64(const struct ck_ec_ops *ops, const uint64_t *addr) 63 | { 64 | (void)addr; 65 | 66 | assert(ops == &test_ops); 67 | return; 68 | } 69 | 70 | /* 71 | * Check that calling ck_ec{32,64}_wake always clears the waiting bit. 72 | */ 73 | 74 | struct example { 75 | uint64_t value; 76 | }; 77 | 78 | const struct example examples[] = { 79 | { 0 }, 80 | { 1 }, 81 | { 1UL << 30 }, 82 | { 1UL << 31 }, 83 | { INT32_MAX }, 84 | { INT64_MAX }, 85 | { 1ULL << 62 }, 86 | { 1ULL << 63 }, 87 | }; 88 | 89 | static inline int test_slow_wakeup(const struct example *example) 90 | { 91 | { 92 | struct ck_ec32 ec = { .counter = example->value }; 93 | 94 | ck_ec32_wake(&ec, &test_ops); 95 | assert(!ck_ec32_has_waiters(&ec)); 96 | } 97 | 98 | #ifdef CK_F_EC64 99 | { 100 | struct ck_ec64 ec = { .counter = example->value }; 101 | 102 | ck_ec64_wake(&ec, &test_ops); 103 | assert(!ck_ec64_has_waiters(&ec)); 104 | } 105 | #endif /* CK_F_EC64 */ 106 | 107 | return 0; 108 | } 109 | 110 | TEST(test_slow_wakeup, examples) 111 | -------------------------------------------------------------------------------- /doc/ck_hs_reset: -------------------------------------------------------------------------------- 1 | .\" 2 | .\" Copyright 2012-2013 Samy Al Bahra. 3 | .\" All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 14 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | .\" SUCH DAMAGE. 25 | .\" 26 | .\" 27 | .Dd September 17, 2012 28 | .Dt CK_HS_RESET 3 29 | .Sh NAME 30 | .Nm ck_hs_reset 31 | .Nd remove all keys from a hash set 32 | .Sh LIBRARY 33 | Concurrency Kit (libck, \-lck) 34 | .Sh SYNOPSIS 35 | .In ck_hs.h 36 | .Ft bool 37 | .Fn ck_hs_reset "ck_hs_t *hs" 38 | .Sh DESCRIPTION 39 | The 40 | .Fn ck_hs_reset 3 41 | function will remove all keys stored in the hash 42 | set pointed to by the 43 | .Fa hs 44 | argument. 45 | .Sh RETURN VALUES 46 | If successful, 47 | .Fn ck_hs_reset 3 48 | will return true and will otherwise return false on failure. This 49 | function will only fail if a replacement hash set could not be 50 | allocated internally. 51 | .Sh ERRORS 52 | Behavior is undefined if 53 | .Fa hs 54 | is uninitialized. Behavior is 55 | undefined if this function is called by a non-writer 56 | thread. 57 | .Sh SEE ALSO 58 | .Xr ck_hs_init 3 , 59 | .Xr ck_hs_move 3 , 60 | .Xr ck_hs_destroy 3 , 61 | .Xr CK_HS_HASH 3 , 62 | .Xr ck_hs_iterator_init 3 , 63 | .Xr ck_hs_next 3 , 64 | .Xr ck_hs_get 3 , 65 | .Xr ck_hs_put 3 , 66 | .Xr ck_hs_put_unique 3 , 67 | .Xr ck_hs_set 3 , 68 | .Xr ck_hs_fas 3 , 69 | .Xr ck_hs_remove 3 , 70 | .Xr ck_hs_reset_size 3 , 71 | .Xr ck_hs_grow 3 , 72 | .Xr ck_hs_gc 3 , 73 | .Xr ck_hs_rebuild 3 , 74 | .Xr ck_hs_count 3 , 75 | .Xr ck_hs_stat 3 76 | .Pp 77 | Additional information available at http://concurrencykit.org/ 78 | -------------------------------------------------------------------------------- /regressions/ck_ec/validate/fuzz_harness.h: -------------------------------------------------------------------------------- 1 | #ifndef FUZZ_HARNESS_H 2 | #define FUZZ_HARNESS_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #if defined(USE_LIBFUZZER) 10 | #define TEST(function, examples) \ 11 | void LLVMFuzzerInitialize(int *argcp, char ***argvp); \ 12 | int LLVMFuzzerTestOneInput(const void *data, size_t n); \ 13 | \ 14 | void LLVMFuzzerInitialize(int *argcp, char ***argvp) \ 15 | { \ 16 | static char size[128]; \ 17 | static char *argv[1024]; \ 18 | int argc = *argcp; \ 19 | \ 20 | assert(argc < 1023); \ 21 | \ 22 | int r = snprintf(size, sizeof(size), \ 23 | "-max_len=%zu", sizeof(examples[0])); \ 24 | assert((size_t)r < sizeof(size)); \ 25 | \ 26 | memcpy(argv, *argvp, argc * sizeof(argv[0])); \ 27 | argv[argc++] = size; \ 28 | \ 29 | *argcp = argc; \ 30 | *argvp = argv; \ 31 | \ 32 | for (size_t i = 0; \ 33 | i < sizeof(examples) / sizeof(examples[0]); \ 34 | i++) { \ 35 | assert(function(&examples[i]) == 0); \ 36 | } \ 37 | \ 38 | return; \ 39 | } \ 40 | \ 41 | int LLVMFuzzerTestOneInput(const void *data, size_t n) \ 42 | { \ 43 | char buf[sizeof(examples[0])]; \ 44 | \ 45 | memset(buf, 0, sizeof(buf)); \ 46 | if (n < sizeof(buf)) { \ 47 | memcpy(buf, data, n); \ 48 | } else { \ 49 | memcpy(buf, data, sizeof(buf)); \ 50 | } \ 51 | \ 52 | assert(function((const void *)buf) == 0); \ 53 | return 0; \ 54 | } 55 | #elif defined(USE_AFL) 56 | #define TEST(function, examples) \ 57 | int main(int argc, char **argv) \ 58 | { \ 59 | char buf[sizeof(examples[0])]; \ 60 | \ 61 | (void)argc; \ 62 | (void)argv; \ 63 | for (size_t i = 0; \ 64 | i < sizeof(examples) / sizeof(examples[0]); \ 65 | i++) { \ 66 | assert(function(&examples[i]) == 0); \ 67 | } \ 68 | \ 69 | \ 70 | while (__AFL_LOOP(10000)) { \ 71 | memset(buf, 0, sizeof(buf)); \ 72 | read(0, buf, sizeof(buf)); \ 73 | \ 74 | assert(function((const void *)buf) == 0); \ 75 | } \ 76 | \ 77 | return 0; \ 78 | } 79 | #else 80 | #define TEST(function, examples) \ 81 | int main(int argc, char **argv) \ 82 | { \ 83 | (void)argc; \ 84 | (void)argv; \ 85 | \ 86 | for (size_t i = 0; \ 87 | i < sizeof(examples) / sizeof(examples[0]); \ 88 | i++) { \ 89 | assert(function(&examples[i]) == 0); \ 90 | } \ 91 | \ 92 | return 0; \ 93 | } 94 | #endif 95 | #endif /* !FUZZ_HARNESS_H */ 96 | --------------------------------------------------------------------------------