mpmc-queue: unify source file again
authorBrian Norris <banorris@uci.edu>
Thu, 8 Nov 2012 17:53:11 +0000 (09:53 -0800)
committerBrian Norris <banorris@uci.edu>
Thu, 8 Nov 2012 17:53:11 +0000 (09:53 -0800)
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.

mpmc-queue/Makefile
mpmc-queue/mpmc-queue.cc

index 52847ddb76ca1b1eb070551d043e5dddb3514be2..05272db4721e3446d36f05f122ea1f8fee9359ce 100644 (file)
@@ -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:
index d6271be9c03031f1615db33cefb9bd83f69b233d..53bc6134ea028c4e9e6d3addcd1d8685922eb3d1 100644 (file)
@@ -27,7 +27,19 @@ void threadB(struct mpmc_boundq_1_alt<int32_t, sizeof(int32_t)> *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()
 {