From 39bfcdf5956a2977a277398bc247b3fc481cf85c Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Mon, 6 Jan 2020 12:21:40 -0500 Subject: [PATCH] Fix build with MinGW tooling. (#514) Courtesy of @Eli-Zaretskii, these fixes should unblock people from building tree-sitter with MinGW. I don't think this is an unreasonable maintenance burden, especially given the Emacs project's interest in using tree-sitter, but @maxbrunsfeld gets the final call. --- lib/src/atomic.h | 4 ++-- lib/src/bits.h | 2 +- lib/src/stack.c | 2 +- script/build-lib | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/atomic.h b/lib/src/atomic.h index 301ee367..7bd0e850 100644 --- a/lib/src/atomic.h +++ b/lib/src/atomic.h @@ -12,11 +12,11 @@ static inline size_t atomic_load(const volatile size_t *p) { } static inline uint32_t atomic_inc(volatile uint32_t *p) { - return InterlockedIncrement(p); + return InterlockedIncrement((long volatile *)p); } static inline uint32_t atomic_dec(volatile uint32_t *p) { - return InterlockedDecrement(p); + return InterlockedDecrement((long volatile *)p); } #else diff --git a/lib/src/bits.h b/lib/src/bits.h index 3bec455d..ce7a7155 100644 --- a/lib/src/bits.h +++ b/lib/src/bits.h @@ -7,7 +7,7 @@ static inline uint32_t bitmask_for_index(uint16_t id) { return (1u << (31 - id)); } -#ifdef _WIN32 +#if defined _WIN32 && !defined __GNUC__ #include diff --git a/lib/src/stack.c b/lib/src/stack.c index 3e842c99..ade15775 100644 --- a/lib/src/stack.c +++ b/lib/src/stack.c @@ -11,7 +11,7 @@ #define MAX_NODE_POOL_SIZE 50 #define MAX_ITERATOR_COUNT 64 -#ifdef _WIN32 +#if defined _WIN32 && !defined __GNUC__ #define inline __forceinline #else #define inline static inline __attribute__((always_inline)) diff --git a/script/build-lib b/script/build-lib index 2dee0af9..83fa69d8 100755 --- a/script/build-lib +++ b/script/build-lib @@ -10,7 +10,7 @@ fi ${CC} \ -c \ -O3 \ - -std=c99 \ + -std=gnu99 \ $CFLAGS \ -I lib/src \ -I lib/include \