Index: runtime/cmake/LibompHandleFlags.cmake =================================================================== --- runtime/cmake/LibompHandleFlags.cmake +++ runtime/cmake/LibompHandleFlags.cmake @@ -50,6 +50,7 @@ libomp_append(flags_local /GS LIBOMP_HAVE_GS_FLAG) libomp_append(flags_local /EHsc LIBOMP_HAVE_EHSC_FLAG) libomp_append(flags_local /Oy- LIBOMP_HAVE_OY__FLAG) + libomp_append(flags_local -mrtm LIBOMP_HAVE_MRTM_FLAG) # Intel(R) C Compiler flags libomp_append(flags_local /Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) libomp_append(flags_local -Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG) Index: runtime/cmake/config-ix.cmake =================================================================== --- runtime/cmake/config-ix.cmake +++ runtime/cmake/config-ix.cmake @@ -73,13 +73,18 @@ libomp_check_architecture_flag(-mmic LIBOMP_HAVE_MMIC_FLAG) libomp_check_architecture_flag(-m32 LIBOMP_HAVE_M32_FLAG) if(WIN32) - # Check Windows MSVC style flags. - check_c_compiler_flag(/TP LIBOMP_HAVE_TP_FLAG) - check_cxx_compiler_flag(/EHsc LIBOMP_HAVE_EHSC_FLAG) - check_cxx_compiler_flag(/GS LIBOMP_HAVE_GS_FLAG) - check_cxx_compiler_flag(/Oy- LIBOMP_HAVE_Oy__FLAG) - check_cxx_compiler_flag(/arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) - check_cxx_compiler_flag(/Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) + if(MSVC) + # Check Windows MSVC style flags. + check_c_compiler_flag(/TP LIBOMP_HAVE_TP_FLAG) + check_cxx_compiler_flag(/EHsc LIBOMP_HAVE_EHSC_FLAG) + check_cxx_compiler_flag(/GS LIBOMP_HAVE_GS_FLAG) + check_cxx_compiler_flag(/Oy- LIBOMP_HAVE_Oy__FLAG) + check_cxx_compiler_flag(/arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG) + check_cxx_compiler_flag(/Qsafeseh LIBOMP_HAVE_QSAFESEH_FLAG) + endif() + if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + check_c_compiler_flag(-mrtm LIBOMP_HAVE_MRTM_FLAG) + endif() # It is difficult to create a dummy masm assembly file # and then check the MASM assembler to see if these flags exist and work, # so we assume they do for Windows. Index: runtime/src/kmp.h =================================================================== --- runtime/src/kmp.h +++ runtime/src/kmp.h @@ -544,11 +544,15 @@ #if KMP_OS_WINDOWS #define USE_CBLKDATA +#if !defined(__MINGW32__) #pragma warning(push) #pragma warning(disable : 271 310) +#endif #include +#if !defined(__MINGW32__) #pragma warning(pop) #endif +#endif #if KMP_OS_UNIX #include @@ -560,7 +564,7 @@ // GROUP_AFFINITY is already defined for _MSC_VER>=1600 (VS2010 and later). #if KMP_OS_WINDOWS -#if _MSC_VER < 1600 +#if _MSC_VER < 1600 && !defined(__MINGW32__) typedef struct GROUP_AFFINITY { KAFFINITY Mask; WORD Group; Index: runtime/src/kmp_affinity.h =================================================================== --- runtime/src/kmp_affinity.h +++ runtime/src/kmp_affinity.h @@ -375,26 +375,26 @@ mask[i / BITS_PER_MASK_T] &= ~((mask_t)1 << (i % BITS_PER_MASK_T)); } void zero() override { - for (size_t i = 0; i < __kmp_num_proc_groups; ++i) + for (size_t i = 0; i < static_cast(__kmp_num_proc_groups); ++i) mask[i] = 0; } void copy(const KMPAffinity::Mask *src) override { const Mask *convert = static_cast(src); - for (size_t i = 0; i < __kmp_num_proc_groups; ++i) + for (size_t i = 0; i < static_cast(__kmp_num_proc_groups); ++i) mask[i] = convert->mask[i]; } void bitwise_and(const KMPAffinity::Mask *rhs) override { const Mask *convert = static_cast(rhs); - for (size_t i = 0; i < __kmp_num_proc_groups; ++i) + for (size_t i = 0; i < static_cast(__kmp_num_proc_groups); ++i) mask[i] &= convert->mask[i]; } void bitwise_or(const KMPAffinity::Mask *rhs) override { const Mask *convert = static_cast(rhs); - for (size_t i = 0; i < __kmp_num_proc_groups; ++i) + for (size_t i = 0; i < static_cast(__kmp_num_proc_groups); ++i) mask[i] |= convert->mask[i]; } void bitwise_not() override { - for (size_t i = 0; i < __kmp_num_proc_groups; ++i) + for (size_t i = 0; i < static_cast(__kmp_num_proc_groups); ++i) mask[i] = ~(mask[i]); } int begin() const override { Index: runtime/src/kmp_dispatch.cpp =================================================================== --- runtime/src/kmp_dispatch.cpp +++ runtime/src/kmp_dispatch.cpp @@ -24,7 +24,7 @@ #include "kmp_itt.h" #include "kmp_stats.h" #include "kmp_str.h" -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !KMP_COMPILER_CLANG #include #endif #include "kmp_lock.h" @@ -478,7 +478,7 @@ /* commonly used term: (2 nproc - 1)/(2 nproc) */ DBL x; -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !KMP_COMPILER_CLANG /* Linux* OS already has 64-bit computation by default for long double, and on Windows* OS on Intel(R) 64, /Qlong_double doesn't work. On Windows* OS on IA-32 architecture, we need to set precision to 64-bit @@ -573,7 +573,7 @@ pr->u.p.count = tc - __kmp_dispatch_guided_remaining( tc, GUIDED_ANALYTICAL_WORKAROUND, cross) - cross * chunk; -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !KMP_COMPILER_CLANG // restore FPCW _control87(oldFpcw, _MCW_PC); #endif @@ -1625,7 +1625,7 @@ case kmp_sch_guided_analytical_chunked: { T chunkspec = pr->u.p.parm1; UT chunkIdx; -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !KMP_COMPILER_CLANG /* for storing original FPCW value for Windows* OS on IA-32 architecture 8-byte version */ unsigned int oldFpcw; @@ -1662,7 +1662,7 @@ Windows* OS. This check works around the possible effect that init != 0 for chunkIdx == 0. */ -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !KMP_COMPILER_CLANG /* If we haven't already done so, save original FPCW and set precision to 64-bit, as Windows* OS on IA-32 architecture defaults to 53-bit */ @@ -1690,7 +1690,7 @@ } // if } // if } // while (1) -#if KMP_OS_WINDOWS && KMP_ARCH_X86 +#if KMP_OS_WINDOWS && KMP_ARCH_X86 && !KMP_COMPILER_CLANG /* restore FPCW if necessary AC: check fpcwSet flag first because oldFpcw can be uninitialized here */ Index: runtime/src/kmp_io.cpp =================================================================== --- runtime/src/kmp_io.cpp +++ runtime/src/kmp_io.cpp @@ -27,11 +27,15 @@ #include "kmp_str.h" #if KMP_OS_WINDOWS +#if !defined(__MINGW32__) #pragma warning(push) #pragma warning(disable : 271 310) +#endif #include +#if !defined(__MINGW32__) #pragma warning(pop) #endif +#endif /* ------------------------------------------------------------------------ */ Index: runtime/src/kmp_lock.cpp =================================================================== --- runtime/src/kmp_lock.cpp +++ runtime/src/kmp_lock.cpp @@ -1716,7 +1716,7 @@ /* RTM Adaptive locks */ -#if KMP_COMPILER_ICC && __INTEL_COMPILER >= 1300 +#if (KMP_COMPILER_ICC && __INTEL_COMPILER >= 1300) || KMP_COMPILER_CLANG #include #define SOFT_ABORT_MASK (_XABORT_RETRY | _XABORT_CONFLICT | _XABORT_EXPLICIT) Index: runtime/src/kmp_os.h =================================================================== --- runtime/src/kmp_os.h +++ runtime/src/kmp_os.h @@ -246,7 +246,7 @@ #define KMP_EXPORT extern /* export declaration in guide libraries */ -#if __GNUC__ >= 4 +#if __GNUC__ >= 4 && !defined(__MINGW32__) #define __forceinline __inline #endif @@ -296,7 +296,7 @@ #define KMP_NORETURN __attribute__((noreturn)) #endif -#if KMP_OS_WINDOWS +#if KMP_OS_WINDOWS && !defined(__GNUC__) #define KMP_ALIGN(bytes) __declspec(align(bytes)) #define KMP_THREAD_LOCAL __declspec(thread) #define KMP_ALIAS /* Nothing */ @@ -356,10 +356,12 @@ #if KMP_ASM_INTRINS && KMP_OS_WINDOWS +#if !defined(__MINGW32__) #pragma intrinsic(InterlockedExchangeAdd) #pragma intrinsic(InterlockedCompareExchange) #pragma intrinsic(InterlockedExchange) #pragma intrinsic(InterlockedExchange64) +#endif // Using InterlockedIncrement / InterlockedDecrement causes a library loading // ordering problem, so we use InterlockedExchangeAdd instead. Index: runtime/src/kmp_platform.h =================================================================== --- runtime/src/kmp_platform.h +++ runtime/src/kmp_platform.h @@ -82,7 +82,7 @@ #define KMP_ARCH_MIPS64 0 #if KMP_OS_WINDOWS -#if defined _M_AMD64 +#if defined(_M_AMD64) || defined(__x86_64) #undef KMP_ARCH_X86_64 #define KMP_ARCH_X86_64 1 #else Index: runtime/src/kmp_safe_c_api.h =================================================================== --- runtime/src/kmp_safe_c_api.h +++ runtime/src/kmp_safe_c_api.h @@ -15,7 +15,7 @@ // Not every unsafe call listed here is handled now, but keeping everything // in one place should be handy for future maintenance. -#if KMP_OS_WINDOWS +#if KMP_OS_WINDOWS && !defined(__MINGW32__) #define RSIZE_MAX_STR (4UL << 10) // 4KB Index: runtime/src/kmp_settings.cpp =================================================================== --- runtime/src/kmp_settings.cpp +++ runtime/src/kmp_settings.cpp @@ -5517,7 +5517,7 @@ for (int bit = init_mask->begin(); bit != init_mask->end(); bit = init_mask->next(bit)) num_bits_in_mask++; - exactly_one_group = (num_bits_in_group == num_bits_in_mask); + exactly_one_group = (num_bits_in_group == static_cast(num_bits_in_mask)); } KMP_CPU_FREE(init_mask); } Index: runtime/src/kmp_utility.cpp =================================================================== --- runtime/src/kmp_utility.cpp +++ runtime/src/kmp_utility.cpp @@ -375,7 +375,11 @@ case 'I': case 'i': { pid_t id = getpid(); +#if KMP_ARCH_X86_64 && defined(__MINGW32__) + snp_result = KMP_SNPRINTF(pos, end - pos + 1, "%0*lld", width, id); +#else snp_result = KMP_SNPRINTF(pos, end - pos + 1, "%0*d", width, id); +#endif if (snp_result >= 0 && snp_result <= end - pos) { while (*pos) ++pos; Index: runtime/src/kmp_wrapper_getpid.h =================================================================== --- runtime/src/kmp_wrapper_getpid.h +++ runtime/src/kmp_wrapper_getpid.h @@ -39,7 +39,9 @@ // "process.h". #include // Let us simulate Unix. +#ifndef __MINGW32__ typedef int pid_t; +#endif #define getpid _getpid #define __kmp_gettid() GetCurrentThreadId() Index: runtime/src/kmp_wrapper_malloc.h =================================================================== --- runtime/src/kmp_wrapper_malloc.h +++ runtime/src/kmp_wrapper_malloc.h @@ -93,7 +93,9 @@ // Include alloca() declaration. #if KMP_OS_WINDOWS #include // Windows* OS: _alloca() declared in "malloc.h". +#ifndef __MINGW32__ #define alloca _alloca // Allow to use alloca() with no underscore. +#endif #elif KMP_OS_FREEBSD || KMP_OS_NETBSD // Declared in "stdlib.h". #elif KMP_OS_UNIX Index: runtime/src/libomp.rc.var =================================================================== --- runtime/src/libomp.rc.var +++ runtime/src/libomp.rc.var @@ -11,7 +11,7 @@ ////===----------------------------------------------------------------------===// // -#include "winres.h" +#include "winresrc.h" #include "kmp_config.h" LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // English (U.S.) resources Index: runtime/src/thirdparty/ittnotify/ittnotify_static.c =================================================================== --- runtime/src/thirdparty/ittnotify/ittnotify_static.c +++ runtime/src/thirdparty/ittnotify/ittnotify_static.c @@ -12,7 +12,11 @@ #include "ittnotify_config.h" #if ITT_PLATFORM==ITT_PLATFORM_WIN +#if defined(__MINGW32__) +#include +#else #define PATH_MAX 512 +#endif #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ #include #include @@ -28,7 +32,9 @@ #include "ittnotify.h" #include "legacy/ittnotify.h" +#if !defined(__MINGW32__) #include "disable_warnings.h" +#endif static const char api_version[] = API_VERSION "\0\n@(#) $Revision: 481659 $\n"; @@ -190,7 +196,7 @@ #pragma pack(pop) -#if ITT_PLATFORM==ITT_PLATFORM_WIN +#if ITT_PLATFORM==ITT_PLATFORM_WIN && !defined(__MINGW32__) #pragma warning(push) #pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ @@ -213,7 +219,7 @@ {NULL, NULL, NULL, NULL, __itt_group_none} }; -#if ITT_PLATFORM==ITT_PLATFORM_WIN +#if ITT_PLATFORM==ITT_PLATFORM_WIN && !defined(__MINGW32__) #pragma warning(pop) #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ @@ -248,7 +254,7 @@ ITT_EXTERN_C void _N_(error_handler)(__itt_error_code, va_list args); #endif /* ITT_NOTIFY_EXT_REPORT */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN +#if ITT_PLATFORM==ITT_PLATFORM_WIN && !defined(__MINGW32__) #pragma warning(push) #pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ @@ -274,7 +280,7 @@ va_end(args); } -#if ITT_PLATFORM==ITT_PLATFORM_WIN +#if ITT_PLATFORM==ITT_PLATFORM_WIN && !defined(__MINGW32__) #pragma warning(pop) #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ @@ -1009,7 +1015,7 @@ *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; } -#if ITT_PLATFORM==ITT_PLATFORM_WIN +#if ITT_PLATFORM==ITT_PLATFORM_WIN && !defined(__MINGW32__) #pragma warning(push) #pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ #pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ @@ -1187,7 +1193,7 @@ return prev; } -#if ITT_PLATFORM==ITT_PLATFORM_WIN +#if ITT_PLATFORM==ITT_PLATFORM_WIN && !defined(__MINGW32__) #pragma warning(pop) #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ Index: runtime/src/z_Windows_NT_util.cpp =================================================================== --- runtime/src/z_Windows_NT_util.cpp +++ runtime/src/z_Windows_NT_util.cpp @@ -887,6 +887,7 @@ return 1e9 * __kmp_win32_tick * now.QuadPart; } +extern "C" void *__stdcall __kmp_launch_worker(void *arg) { volatile void *stack_data; void *exit_val;