For KMP_PAGE_SIZE, use getpagesize() on Unix, GetSystemInfo() on Windows
Summary: The kmp_os.h header is defining the `PAGE_SIZE` macro unconditionally, even while it is only used directly after its definition, for the Windows implementation of the `KMP_GET_PAGE_SIZE()` macro. On at least FreeBSD, but likely all other BSDs too, this macro conflicts with the one defined in system headers, so remove it, since nothing else uses it. Make all Unixes use `getpagesize()` instead, and use `GetSystemInfo()` for the Windows case. Reviewers: jlpeyton, jcownie, emaste, AndreyChurbanov Reviewed By: AndreyChurbanov Subscribers: AndreyChurbanov, hfinkel, zturner Differential Revision: https://reviews.llvm.org/D35072 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@308355 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -243,14 +243,16 @@ template <> struct traits_t<unsigned long long> {
|
||||
#define __forceinline __inline
|
||||
#endif
|
||||
|
||||
#define PAGE_SIZE (0x4000)
|
||||
#if KMP_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
|
||||
#if KMP_OS_LINUX
|
||||
#define KMP_GET_PAGE_SIZE() getpagesize()
|
||||
static inline int KMP_GET_PAGE_SIZE(void) {
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
return si.dwPageSize;
|
||||
}
|
||||
#else
|
||||
// TODO: find the corresponding function to getpagesize() in Windows
|
||||
// and use it whenever possible.
|
||||
#define KMP_GET_PAGE_SIZE() PAGE_SIZE
|
||||
#define KMP_GET_PAGE_SIZE() getpagesize()
|
||||
#endif
|
||||
|
||||
#define PAGE_ALIGNED(_addr) \
|
||||
@@ -304,8 +306,6 @@ enum kmp_mem_fence_type {
|
||||
|
||||
#if KMP_ASM_INTRINS && KMP_OS_WINDOWS
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#pragma intrinsic(InterlockedExchangeAdd)
|
||||
#pragma intrinsic(InterlockedCompareExchange)
|
||||
#pragma intrinsic(InterlockedExchange)
|
||||
|
||||
Reference in New Issue
Block a user