summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaan <daanl@outlook.com>2020-04-06 10:56:53 -0700
committerdaan <daanl@outlook.com>2020-04-06 10:56:53 -0700
commit0a3e5bb69980f29373337e564a80d77de1b80af0 (patch)
tree7a9e5ce236deb0c7a8e1f96c1a5acfa16a2f27c7
parent0f3bd05fd5a9471ddb9f7fe42b40a561b7e3650b (diff)
further fixes to compile on mingw without warnings (issue #217)
-rw-r--r--ide/vs2019/mimalloc-override.vcxproj2
-rw-r--r--include/mimalloc.h13
-rw-r--r--src/os.c2
-rw-r--r--test/main-override.cpp2
4 files changed, 13 insertions, 6 deletions
diff --git a/ide/vs2019/mimalloc-override.vcxproj b/ide/vs2019/mimalloc-override.vcxproj
index 17b6f4c..a0e79fb 100644
--- a/ide/vs2019/mimalloc-override.vcxproj
+++ b/ide/vs2019/mimalloc-override.vcxproj
@@ -254,4 +254,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/include/mimalloc.h b/include/mimalloc.h
index e6f68b6..b99b668 100644
--- a/include/mimalloc.h
+++ b/include/mimalloc.h
@@ -42,13 +42,18 @@ terms of the MIT license. A copy of the license can be found in the file
#else
#define mi_decl_export __declspec(dllimport)
#endif
- #if (_MSC_VER >= 1900) && !defined(__EDG__)
- #define mi_decl_restrict __declspec(allocator) __declspec(restrict)
+ #if defined(__MINGW32__)
+ #define mi_decl_restrict
+ #define mi_attr_malloc __attribute__((malloc))
#else
- #define mi_decl_restrict __declspec(restrict)
+ #if (_MSC_VER >= 1900) && !defined(__EDG__)
+ #define mi_decl_restrict __declspec(allocator) __declspec(restrict)
+ #else
+ #define mi_decl_restrict __declspec(restrict)
+ #endif
+ #define mi_attr_malloc
#endif
#define mi_cdecl __cdecl
- #define mi_attr_malloc
#define mi_attr_alloc_size(s)
#define mi_attr_alloc_size2(s1,s2)
#define mi_attr_alloc_align(p)
diff --git a/src/os.c b/src/os.c
index 512df5b..1765a94 100644
--- a/src/os.c
+++ b/src/os.c
@@ -866,6 +866,8 @@ static void* mi_os_alloc_huge_os_pagesx(void* addr, size_t size, int numa_node)
params[0].ULong = (unsigned)numa_node;
return (*pVirtualAlloc2)(GetCurrentProcess(), addr, size, flags, PAGE_READWRITE, params, 1);
}
+ #else
+ UNUSED(numa_node);
#endif
// otherwise use regular virtual alloc on older windows
return VirtualAlloc(addr, size, flags, PAGE_READWRITE);
diff --git a/test/main-override.cpp b/test/main-override.cpp
index fdd79d2..734e4c9 100644
--- a/test/main-override.cpp
+++ b/test/main-override.cpp
@@ -168,7 +168,7 @@ void heap_thread_free_large_worker() {
void heap_thread_free_large() {
for (int i = 0; i < 100; i++) {
- shared_p = mi_malloc(2*1024*1024 + 1);
+ shared_p = mi_malloc_aligned(2*1024*1024 + 1, 8);
auto t1 = std::thread(heap_thread_free_large_worker);
t1.join();
}