mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 15:09:31 +03:00
fix compilation under Intel C compiler (icc)
This commit is contained in:
parent
e8d7c80c74
commit
9d7ac76d93
3 changed files with 27 additions and 11 deletions
|
@ -54,7 +54,7 @@ endif()
|
||||||
# Process options
|
# Process options
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
if(CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel")
|
||||||
set(MI_USE_CXX "ON")
|
set(MI_USE_CXX "ON")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -96,25 +96,34 @@ endif()
|
||||||
if(MI_USE_CXX MATCHES "ON")
|
if(MI_USE_CXX MATCHES "ON")
|
||||||
message(STATUS "Use the C++ compiler to compile (MI_USE_CXX=ON)")
|
message(STATUS "Use the C++ compiler to compile (MI_USE_CXX=ON)")
|
||||||
set_source_files_properties(${mi_sources} PROPERTIES LANGUAGE CXX )
|
set_source_files_properties(${mi_sources} PROPERTIES LANGUAGE CXX )
|
||||||
set_source_files_properties(src/static.c test/test-api.c PROPERTIES LANGUAGE CXX )
|
set_source_files_properties(src/static.c test/test-api.c test/test-stress PROPERTIES LANGUAGE CXX )
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang|Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang|Clang")
|
||||||
list(APPEND mi_cflags -Wno-deprecated)
|
list(APPEND mi_cflags -Wno-deprecated)
|
||||||
endif()
|
endif()
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
||||||
|
list(APPEND mi_cflags -Kc++)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
|
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
|
||||||
list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas)
|
list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas)
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||||
|
list(APPEND mi_cflags -Wno-invalid-memory-model)
|
||||||
|
list(APPEND mi_cflags -fvisibility=hidden)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
||||||
|
list(APPEND mi_cflags -Wall -fvisibility=hidden)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU|Intel")
|
||||||
if(MI_LOCAL_DYNAMIC_TLS MATCHES "ON")
|
if(MI_LOCAL_DYNAMIC_TLS MATCHES "ON")
|
||||||
list(APPEND mi_cflags -ftls-model=local-dynamic)
|
list(APPEND mi_cflags -ftls-model=local-dynamic)
|
||||||
else()
|
else()
|
||||||
list(APPEND mi_cflags -ftls-model=initial-exec)
|
list(APPEND mi_cflags -ftls-model=initial-exec)
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
|
||||||
list(APPEND mi_cflags -Wno-invalid-memory-model)
|
|
||||||
list(APPEND mi_cflags -fvisibility=hidden)
|
|
||||||
list(APPEND mi_cflags -fbranch-target-load-optimize)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# extra needed libraries
|
# extra needed libraries
|
||||||
|
|
|
@ -255,7 +255,6 @@ static void* atomic_exchange_ptr(volatile void** p, void* newval) {
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdatomic.h>
|
|
||||||
|
|
||||||
static void* thread_entry(void* param) {
|
static void* thread_entry(void* param) {
|
||||||
stress((uintptr_t)param);
|
stress((uintptr_t)param);
|
||||||
|
@ -275,8 +274,16 @@ static void run_os_threads(size_t nthreads) {
|
||||||
custom_free(threads);
|
custom_free(threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <atomic>
|
||||||
|
static void* atomic_exchange_ptr(volatile void** p, void* newval) {
|
||||||
|
return std::atomic_exchange_explicit((volatile std::atomic<void*>*)p, newval, std::memory_order_acquire);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#include <stdatomic.h>
|
||||||
static void* atomic_exchange_ptr(volatile void** p, void* newval) {
|
static void* atomic_exchange_ptr(volatile void** p, void* newval) {
|
||||||
return atomic_exchange_explicit((volatile _Atomic(void*)*)p, newval, memory_order_acquire);
|
return atomic_exchange_explicit((volatile _Atomic(void*)*)p, newval, memory_order_acquire);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue