ref: 5b4e05db11ca7a7c4f910fef6d6243d623eb8694
parent: 32dfa1f1f37e2128629703bd9371186d616478d2
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Aug 2 10:24:28 EDT 2021
add and use Nmsec
--- a/include/npe/npe.h
+++ b/include/npe/npe.h
@@ -12,6 +12,7 @@
#ifndef Nsec
#define Nsec 1000000000ULL
+#define Nmsec 1000000ULL
uvlong npe_nanosec(void);
void npe_nsleep(uvlong ns);
int npe_mkdirp(char *s, int perm);
--- a/libnpe/_npe.c
+++ b/libnpe/_npe.c
@@ -56,11 +56,11 @@
end = start + ns;
ns = start;
do{
- if(end - ns > 750000000ULL)
- sleep(70);
- else if (end - ns > 25000000ULL)
+ if(end - ns > 85*Nmsec)
+ sleep(80);
+ else if (end - ns > 25*Nmsec)
sleep(20);
- else if (end - ns > 1000000ULL)
+ else if (end - ns > 1*Nmsec)
sleep(1);
else
break;
--- a/libnpe/gettimeofday.c
+++ b/libnpe/gettimeofday.c
@@ -8,8 +8,8 @@
USED(tzp);
t = npe_nanosec();
- tp->tv_sec = t / 1000000000ULL;
- tp->tv_usec = (t / 1000ULL)%1000000ULL;
+ tp->tv_sec = t / Nsec;
+ tp->tv_usec = (t / 1000ULL) % Nmsec;
return 0;
}
--- a/libnpe_sdl2/sdl2.c
+++ b/libnpe_sdl2/sdl2.c
@@ -551,7 +551,7 @@
void
SDL_Delay(Uint32 ms)
{
- npe_nsleep((uvlong)ms*1000000ULL);
+ npe_nsleep((uvlong)ms * Nmsec);
}
static int
@@ -891,7 +891,7 @@
Uint32
SDL_GetTicks(void)
{
- return npe_nanosec()/1000000ULL;
+ return npe_nanosec() / Nmsec;
}
int