From: Brian Norris Date: Thu, 8 Nov 2012 17:53:11 +0000 (-0800) Subject: mpmc-queue: unify source file again X-Git-Tag: pldi2013~11 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker-benchmarks.git;a=commitdiff_plain;h=ca8555d0e02fb0b6e37bfbff4adee760c2248efb;ds=sidebyside mpmc-queue: unify source file again I really didn't want 3 copies of the same source file just to get around some model-checker snapshotting limitations in argument parsing... So now, it's a compile-time option to configure the number of reader/writer threads. --- diff --git a/mpmc-queue/Makefile b/mpmc-queue/Makefile index 52847dd..05272db 100644 --- a/mpmc-queue/Makefile +++ b/mpmc-queue/Makefile @@ -5,7 +5,11 @@ TESTS = mpmc-queue mpmc-1r2w mpmc-2r1w all: $(TESTS) -%: %.cc $(TESTNAME).h +mpmc-queue: CPPFLAGS += -DCONFIG_MPMC_READERS=2 -DCONFIG_MPMC_WRITERS=2 +mpmc-1r2w: CPPFLAGS += -DCONFIG_MPMC_READERS=1 -DCONFIG_MPMC_WRITERS=2 +mpmc-2r1w: CPPFLAGS += -DCONFIG_MPMC_READERS=2 -DCONFIG_MPMC_WRITERS=1 + +%: $(TESTNAME).cc $(TESTNAME).h $(CXX) -o $@ $< $(CPPFLAGS) $(LDFLAGS) clean: diff --git a/mpmc-queue/mpmc-queue.cc b/mpmc-queue/mpmc-queue.cc index d6271be..53bc613 100644 --- a/mpmc-queue/mpmc-queue.cc +++ b/mpmc-queue/mpmc-queue.cc @@ -27,7 +27,19 @@ void threadB(struct mpmc_boundq_1_alt *queue) #define MAXREADERS 3 #define MAXWRITERS 3 -int readers = 2, writers = 2; +#ifdef CONFIG_MPMC_READERS +#define DEFAULT_READERS (CONFIG_MPMC_READERS) +#else +#define DEFAULT_READERS 2 +#endif + +#ifdef CONFIG_MPMC_WRITERS +#define DEFAULT_WRITERS (CONFIG_MPMC_WRITERS) +#else +#define DEFAULT_WRITERS 2 +#endif + +int readers = DEFAULT_READERS, writers = DEFAULT_WRITERS; void print_usage() {