Skip to content

Commit

Permalink
Use GetSystemTimeAsFileTime on older Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dkeehl committed Jun 2, 2020
1 parent 30737f5 commit fc8e6b1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ requirements are:
a Mac, you can install this with `brew install coreutils`.

On Windows, it has been reported that installing via `MSYS2` works
(https://www.msys2.org/). On Raspberry Pi, you can bootstrap via Racket.
(https://www.msys2.org/). On Windows older than Windows 8, you may need to
set an environment variable `OLD_WIN=1` or modify it in `config.mk`.

On Raspberry Pi, you can bootstrap via Racket.

By default, code generation is via Chez Scheme. You can use Racket instead,
by setting the environment variable `IDRIS2_CG=racket` before running `make`.
Expand Down
3 changes: 3 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ PREFIX ?= $(HOME)/.idris2

CC ?= clang

# For Windows targets. Set to 1 to support Windows 7.
OLD_WIN ?= 0

##################################################################

RANLIB ?= ranlib
Expand Down
3 changes: 3 additions & 0 deletions support/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ SRCS = $(wildcard *.c)
ifeq ($(OS), windows)
SRCS += windows/win_utils.c windows/win_hack.c
LDFLAGS += -lws2_32
ifeq ($(OLD_WIN), 1)
CFLAGS += -D_OLD_WIN
endif
endif
OBJS = $(SRCS:.c=.o)
DEPS = $(OBJS:.o=.d)
Expand Down
5 changes: 5 additions & 0 deletions support/c/windows/win_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ FILE *win32_u8popen(const char *path, const char *mode)
void win32_gettime(int64_t* sec, int64_t* nsec)
{
FILETIME ft;
#ifdef _OLD_WIN
GetSystemTimeAsFileTime(&ft);
#else
// For Windows NT 6.2 or higher
GetSystemTimePreciseAsFileTime(&ft);
#endif
ULARGE_INTEGER t;
t.HighPart = ft.dwHighDateTime;
t.LowPart = ft.dwLowDateTime;
Expand Down

0 comments on commit fc8e6b1

Please sign in to comment.