aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/kmp_os.h
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2017-07-18 20:31:19 +0000
committerDimitry Andric <dimitry@andric.com>2017-07-18 20:31:19 +0000
commit4efa4a63cf355c2373772d229f7ad5c008d1147e (patch)
treec595ec693ace8510b5f4f85a0407077c38f2daa6 /runtime/src/kmp_os.h
parenta07d8b0a6615069c509d43fb3a918f1d47814bba (diff)
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
Diffstat (limited to 'runtime/src/kmp_os.h')
-rw-r--r--runtime/src/kmp_os.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/runtime/src/kmp_os.h b/runtime/src/kmp_os.h
index 566e0f1..b8ae152 100644
--- a/runtime/src/kmp_os.h
+++ b/runtime/src/kmp_os.h
@@ -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)