use _POSIX_C_SOURCE in cflags, use CLOCK_REALTIME in b and add -v flag to t
authornsz <nsz@port70.net>
Mon, 8 Aug 2011 10:44:19 +0000 (12:44 +0200)
committernsz <nsz@port70.net>
Mon, 8 Aug 2011 10:44:19 +0000 (12:44 +0200)
12 files changed:
Makefile.inc
common/b.c
common/t.c
src/misc/basename.c
src/misc/dirname.c
src/regex/bench.c
src/stdio/bench.c
src/stdio/fscanf.c
src/stdio/popen.c
src/stdio/ungetc.c
src/thread/pthread.c
src/thread/sem.c

index 9b97adb..f163fda 100644 (file)
@@ -19,7 +19,7 @@ libdir = $(prefix)/lib
 AR=ar
 RANLIB=ranlib
 
-CFLAGS += -g -std=c99 -pipe -Wall
+CFLAGS += -g -D_POSIX_C_SOURCE=200809L -std=c99 -pipe -Wall
 LDFLAGS += -g -lpthread -lrt -lm
 INC += -I$(ROOTDIR)/common
 
index 6df833a..ee0650d 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -31,7 +30,7 @@ static unsigned long long dt;
 static unsigned long long tic() {
        struct timespec ts;
 
-       if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
+       if (clock_gettime(CLOCK_REALTIME, &ts) < 0) {
                fprintf(stderr, "bench: clock_gettime failed: %s\n", strerror(errno));
                return 0;
        }
index daf06fd..083e308 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -17,6 +16,7 @@
 static int failed;
 static const char *name;
 
+static int slow;
 static int verbose;
 static int count;
 static int nfailed;
@@ -76,7 +76,28 @@ static int summary() {
        return !!nfailed;
 }
 
-int main() {
+static void usage() {
+       fprintf(stderr, "usage: ./t [-vs]\n");
+       exit(1);
+}
+
+int main(int argc, char *argv[]) {
+       int c;
+
+       while((c = getopt(argc, argv, "vs")) != -1)
+               switch(c) {
+               case 'v':
+                       verbose = 1;
+                       break;
+               case 's':
+                       slow = 1; /* TODO */
+                       break;
+               default:
+                       usage();
+               }
+       if (optind != argc)
+               usage();
+
 #define T(t) run(#t, t);
 #include "tests.h"
        return summary();
index 33159fc..95e0d36 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdlib.h>
 #include <string.h>
 #include <libgen.h>
index 50538b6..b4a1c48 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdlib.h>
 #include <string.h>
 #include <libgen.h>
index 3f911ca..526662b 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index ade4095..95f9b90 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index d0c47c7..1de09c3 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
index a373df6..f647bf4 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
index 855ffaa..230b327 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
index 642f772..ce39a0b 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <pthread.h>
 #include <stdlib.h>
 #include <unistd.h>
index 5bfcdfe..8bc23e8 100644 (file)
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
 #include <pthread.h>
 #include <stdlib.h>
 #include <unistd.h>