diff --git a/cutils.c b/cutils.c index 7d36ddfdb..487fb2b09 100644 --- a/cutils.c +++ b/cutils.c @@ -937,12 +937,19 @@ uint64_t js__hrtime_ns(void) { } #else uint64_t js__hrtime_ns(void) { +#ifdef __DJGPP + struct timeval tv; + if (gettimeofday(&tv, NULL)) + abort(); + return tv.tv_sec * NANOSEC + tv.tv_usec * 1000; +#else struct timespec t; if (clock_gettime(CLOCK_MONOTONIC, &t)) abort(); return t.tv_sec * NANOSEC + t.tv_nsec; +#endif } #endif diff --git a/cutils.h b/cutils.h index eaf339842..aa561ce1c 100644 --- a/cutils.h +++ b/cutils.h @@ -50,7 +50,7 @@ extern "C" { #elif defined(_WIN32) #include #endif -#if !defined(_WIN32) && !defined(EMSCRIPTEN) && !defined(__wasi__) +#if !defined(_WIN32) && !defined(EMSCRIPTEN) && !defined(__wasi__) && !defined(__DJGPP) #include #include #endif @@ -578,7 +578,7 @@ int js_exepath(char* buffer, size_t* size); /* Cross-platform threading APIs. */ -#if defined(EMSCRIPTEN) || defined(__wasi__) +#if defined(EMSCRIPTEN) || defined(__wasi__) || defined(__DJGPP) #define JS_HAVE_THREADS 0 diff --git a/quickjs.c b/quickjs.c index 740f07f52..34480196e 100644 --- a/quickjs.c +++ b/quickjs.c @@ -40,7 +40,6 @@ #include #endif #include -#include #include #include "cutils.h" @@ -68,7 +67,7 @@ // atomic_store etc. are completely busted in recent versions of tcc; // somehow the compiler forgets to load |ptr| into %rdi when calling // the __atomic_*() helpers in its lib/stdatomic.c and lib/atomic.S -#if !defined(__TINYC__) && !defined(EMSCRIPTEN) && !defined(__wasi__) && !__STDC_NO_ATOMICS__ +#if !defined(__TINYC__) && !defined(EMSCRIPTEN) && !defined(__wasi__) && !__STDC_NO_ATOMICS__ && !defined(__DJGPP) #include "quickjs-c-atomics.h" #define CONFIG_ATOMICS #endif