compile as C++ under msvc

This commit is contained in:
daan 2019-07-18 19:52:29 -07:00
parent e94143c47c
commit 12e0a04052
7 changed files with 22 additions and 17 deletions

View file

@ -19,10 +19,6 @@ terms of the MIT license. A copy of the license can be found in the file
// Override system malloc
// ------------------------------------------------------
#if defined(_MSC_VER)
#pragma warning(disable:4273) // inconsistent dll linking
#endif
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__MACH__)
// use aliasing to alias the exported function to one of our `mi_` functions
#if (defined(__GNUC__) && __GNUC__ >= 9)
@ -62,6 +58,9 @@ terms of the MIT license. A copy of the license can be found in the file
MI_INTERPOSE_MI(strdup),
MI_INTERPOSE_MI(strndup)
};
#elif defined(_MSC_VER)
// cannot override malloc unless using a dll.
// we just override new/delete which does work in a static library.
#else
// On all other systems forward to our API
void* malloc(size_t size) mi_attr_noexcept MI_FORWARD1(mi_malloc, size);
@ -94,7 +93,7 @@ terms of the MIT license. A copy of the license can be found in the file
void* operator new (std::size_t n, const std::nothrow_t& tag) noexcept { UNUSED(tag); return mi_new_nothrow(n); }
void* operator new[](std::size_t n, const std::nothrow_t& tag) noexcept { UNUSED(tag); return mi_new_nothrow(n); }
#if (__cplusplus >= 201402L)
#if (__cplusplus >= 201402L || _MSC_VER >= 1916)
void operator delete (void* p, std::size_t n) MI_FORWARD02(mi_free_size,p,n);
void operator delete[](void* p, std::size_t n) MI_FORWARD02(mi_free_size,p,n);
#endif

View file

@ -105,7 +105,7 @@ static size_t mi_good_commit_size(size_t size) {
}
// Return if a pointer points into a region reserved by us.
bool mi_is_in_heap_region(const void* p) {
bool mi_is_in_heap_region(const void* p) mi_attr_noexcept {
size_t count = mi_atomic_read(&regions_count);
for (size_t i = 0; i < count; i++) {
uint8_t* start = (uint8_t*)mi_atomic_read_ptr(&regions[i].start);