diff --git a/Makefile.inc b/Makefile.inc index 9b97adb..f163fda 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -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 diff --git a/common/b.c b/common/b.c index 6df833a..ee0650d 100644 --- a/common/b.c +++ b/common/b.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include @@ -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; } diff --git a/common/t.c b/common/t.c index daf06fd..083e308 100644 --- a/common/t.c +++ b/common/t.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include @@ -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(); diff --git a/src/misc/basename.c b/src/misc/basename.c index 33159fc..95e0d36 100644 --- a/src/misc/basename.c +++ b/src/misc/basename.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/misc/dirname.c b/src/misc/dirname.c index 50538b6..b4a1c48 100644 --- a/src/misc/dirname.c +++ b/src/misc/dirname.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/regex/bench.c b/src/regex/bench.c index 3f911ca..526662b 100644 --- a/src/regex/bench.c +++ b/src/regex/bench.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/stdio/bench.c b/src/stdio/bench.c index ade4095..95f9b90 100644 --- a/src/stdio/bench.c +++ b/src/stdio/bench.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c index d0c47c7..1de09c3 100644 --- a/src/stdio/fscanf.c +++ b/src/stdio/fscanf.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/stdio/popen.c b/src/stdio/popen.c index a373df6..f647bf4 100644 --- a/src/stdio/popen.c +++ b/src/stdio/popen.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/stdio/ungetc.c b/src/stdio/ungetc.c index 855ffaa..230b327 100644 --- a/src/stdio/ungetc.c +++ b/src/stdio/ungetc.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/thread/pthread.c b/src/thread/pthread.c index 642f772..ce39a0b 100644 --- a/src/thread/pthread.c +++ b/src/thread/pthread.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/src/thread/sem.c b/src/thread/sem.c index 5bfcdfe..8bc23e8 100644 --- a/src/thread/sem.c +++ b/src/thread/sem.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include