diff --git a/Makefile b/Makefile index b207257..16e01d0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ CFLAGS=-fPIC +CFLAGS+=-std=c11 -pedantic -Werror -Wformat # Debug flags #CFLAGS+=-fsanitize=address diff --git a/dump.c b/dump.c index f8caf2a..2341fec 100644 --- a/dump.c +++ b/dump.c @@ -43,7 +43,7 @@ void emit(struct ovni_stream *stream, struct ovni_ev *ev) delta = clock - stream->lastclock; - printf("%d.%d.%d %c %c %c % 20lu % 15ld ", + printf("%d.%d.%d %c %c %c % 20ld % 15ld ", stream->loom, stream->proc, stream->tid, ev->header.model, ev->header.class, ev->header.value, clock, delta); diff --git a/emu.c b/emu.c index e50ad64..280712e 100644 --- a/emu.c +++ b/emu.c @@ -1,3 +1,5 @@ +#define _POSIX_C_SOURCE 200112L + #include #include #include @@ -483,7 +485,11 @@ load_clock_offsets(struct ovni_emu *emu) } /* Ignore header line */ - fgets(buf, 1024, f); + if(fgets(buf, 1024, f) == NULL) + { + perror("fgets failed"); + exit(EXIT_FAILURE); + } while(1) { diff --git a/ovni.c b/ovni.c index f009b58..ce84bfc 100644 --- a/ovni.c +++ b/ovni.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,11 @@ #include "ovni_trace.h" #include "parson.h" +#ifndef gettid +# include +# define gettid() ((pid_t)syscall(SYS_gettid)) +#endif + //#define ENABLE_SLOW_CHECKS //#define USE_RDTSC @@ -69,7 +73,7 @@ create_trace_stream() char path[PATH_MAX]; fprintf(stderr, "create thread stream tid=%d gettid=%d rproc.proc=%d rproc.ready=%d\n", - rthread.tid, syscall(SYS_gettid), rproc.proc, rproc.ready); + rthread.tid, gettid(), rproc.proc, rproc.ready); snprintf(path, PATH_MAX, "%s/thread.%d", rproc.dir, rthread.tid); @@ -294,7 +298,7 @@ uint64_t rdtsc(void) uint32_t lo, hi; // RDTSC copies contents of 64-bit TSC into EDX:EAX - asm volatile("rdtsc" : "=a" (lo), "=d" (hi)); + __asm__ volatile("rdtsc" : "=a" (lo), "=d" (hi)); return (uint64_t) hi << 32 | lo; } @@ -782,7 +786,7 @@ load_stream_buf(struct ovni_stream *stream, struct ovni_ethread *thread) if(st.st_size == 0) { - err("warning: stream %s is empty\n", stream->tid); + err("warning: stream %d is empty\n", stream->tid); stream->size = 0; stream->buf = NULL; stream->active = 0; diff --git a/ovni.h b/ovni.h index 8bf666b..9f7cc1f 100644 --- a/ovni.h +++ b/ovni.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "parson.h" diff --git a/ovnisync.c b/ovnisync.c index 2ff3379..e8d2d14 100644 --- a/ovnisync.c +++ b/ovnisync.c @@ -1,3 +1,5 @@ +#define _POSIX_C_SOURCE 200112L + #include #include #include @@ -6,6 +8,7 @@ #include #include #include +#include #include "ovni.h" @@ -400,7 +403,7 @@ do_work(struct options *options, int rank) } if(drift_mode) - usleep(options->drift_wait * 1000 * 1000); + sleep(options->drift_wait); } } diff --git a/test_speed.c b/test_speed.c index cae40b9..53ff3b7 100644 --- a/test_speed.c +++ b/test_speed.c @@ -1,9 +1,13 @@ +#define _POSIX_C_SOURCE 200112L +#define _GNU_SOURCE + #include #include #include #include #include #include +#include #include "ovni.h"