FreeBSD: no CLOCK_MONOTONIC_RAW #196

This commit is contained in:
nick black 2019-12-27 01:50:44 -05:00 committed by Nick Black
parent caf7e41737
commit 09aa606281
2 changed files with 8 additions and 2 deletions

View File

@ -17,7 +17,7 @@ int box_demo(struct notcurses* nc){
return -1;
}
struct timespec start, now;
clock_gettime(CLOCK_MONOTONIC_RAW, &start);
clock_gettime(CLOCK_MONOTONIC, &start);
int zbonus = 40;
int zbonusdelta = 20;
int ylen, xlen;
@ -86,7 +86,7 @@ int box_demo(struct notcurses* nc){
return -1;
}
nanosleep(&iterdelay, NULL);
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
clock_gettime(CLOCK_MONOTONIC, &now);
if((zbonus += zbonusdelta > 255) || zbonus < 0){
zbonusdelta = -zbonusdelta;
zbonus += zbonusdelta;

View File

@ -2,6 +2,7 @@
#define NOTCURSES_INTERNAL
#include <term.h>
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
@ -263,6 +264,11 @@ cell* ncplane_cell_ref_yx(ncplane* n, int y, int x);
#define NANOSECS_IN_SEC 1000000000
// no CLOCK_MONOTONIC_RAW on FreeBSD as of 12.0 :/
#ifndef CLOCK_MONOTONIC_RAW
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
#endif
#ifdef __cplusplus
}
#endif