Merge pull request #143 from melted/eliminate_pthread_dep

Remove dependency on pthreads on Windows
This commit is contained in:
Niklas Larsson 2020-05-24 20:36:27 +02:00 committed by GitHub
commit 21f1e54c1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#ifdef _WIN32
extern char **_environ;
#include "windows/win_utils.h"
#define environ _environ
#else
extern char** environ;
@ -42,19 +43,27 @@ void idris2_putStr(char* f) {
}
void idris2_sleep(int sec) {
#ifdef _WIN32
win32_sleep(sec*1000);
#else
struct timespec t;
t.tv_sec = sec;
t.tv_nsec = 0;
nanosleep(&t, NULL);
#endif
}
void idris2_usleep(int usec) {
#ifdef _WIN32
win32_sleep(usec/1000);
#else
struct timespec t;
t.tv_sec = usec / 1000000;
t.tv_nsec = (usec % 1000000) * 1000;
nanosleep(&t, NULL);
#endif
}
int idris2_time() {

View File

@ -64,3 +64,7 @@ void win32_gettime(int64_t* sec, int64_t* nsec)
*sec = t.QuadPart / 10000000;
*sec -= 11644473600; // LDAP epoch to Unix epoch
}
void win32_sleep(int ms) {
Sleep(ms);
}

View File

@ -7,3 +7,4 @@ int win_fpoll(FILE *h);
FILE *win32_u8fopen(const char *path, const char *mode);
FILE *win32_u8popen(const char *path, const char *mode);
void win32_gettime(int64_t* sec, int64_t* nsec);
void win32_sleep(int ms);