fix: timers on Linux #6

Open
wiesendsi102436 wants to merge 1 commits from wiesendsi102436/info2Praktikum-DobleSpiel:bugfix/timer into main

11
timer.c
View File

@ -1,6 +1,12 @@
#include "timer.h"
#if __APPLE__
#ifdef __linux__
// Defines strict posix compliance for CLOCK_MONOTONIC
#define _POSIX_C_SOURCE 199309L
#include <time.h>
#endif
#if __APPLE__ || __linux__
#include <sys/time.h>
static struct timespec start = {0, 0};
@ -21,7 +27,8 @@ double stopTimer()
double measuredSeconds = (double)delta_us / 1000000.;
if(start.tv_nsec > 0) {
if (start.tv_nsec > 0)
{
start.tv_nsec = 0;
start.tv_sec = 0;
}