Merge pull request #4 from apache/fix-windows-build
Fix hyper build for Windows
diff --git a/.gitignore b/.gitignore
index 425b33e..5cc0eb6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,9 @@
*.so
*.o
*.d
-.rebar
\ No newline at end of file
+*.dll
+*.exp
+*.lib
+*.pdb
+*.swp
+.rebar
diff --git a/c_src/hyper_carray.c b/c_src/hyper_carray.c
index 896f409..1db1377 100644
--- a/c_src/hyper_carray.c
+++ b/c_src/hyper_carray.c
@@ -55,7 +55,11 @@
uint8_t *items;
};
+#ifdef _WIN32
+typedef struct hyper_carray *carray_ptr;
+#else
typedef struct hyper_carray *restrict carray_ptr;
+#endif
#define HYPER_CARRAY_SIZE sizeof(struct hyper_carray)
@@ -84,16 +88,22 @@
memset(*arr, 0, header_size);
(*arr)->precision = precision;
(*arr)->size = nitems;
- (*arr)->items = res + header_size;
+ (*arr)->items = (uint8_t *) res + header_size;
}
/*
* Given an hyper_carray and a valid index, set the value at that index to
* max(current value, given value).
*/
+#ifdef _WIN32
+static void carray_merge_item(carray_ptr arr,
+ unsigned int index,
+ unsigned int value)
+#else
static inline void carray_merge_item(carray_ptr arr,
unsigned int index,
unsigned int value)
+#endif
{
uint8_t *item = arr->items + index;
*item = (value > *item) ? value : *item;
diff --git a/rebar.config b/rebar.config
index 6015992..6d6df3c 100644
--- a/rebar.config
+++ b/rebar.config
@@ -9,6 +9,7 @@
]}.
{port_env, [
- {"CC", "cc"},
- {"CFLAGS", "$CFLAGS -std=c99 -Wall -Werror -O3"}
+ {"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
+ "CFLAGS", "$CFLAGS -std=c99 -Wall -Werror -O3"},
+ {"win32", "CXXFLAGS", "$CXXFLAGS /O2 /DNDEBUG"}
]}.