[Openmp-commits] [openmp] r308355 - For KMP_PAGE_SIZE, use getpagesize() on Unix, GetSystemInfo() on Windows
Dimitry Andric via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jul 18 13:31:19 PDT 2017
Author: dim
Date: Tue Jul 18 13:31:19 2017
New Revision: 308355
URL: http://llvm.org/viewvc/llvm-project?rev=308355&view=rev
Log:
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
Modified:
openmp/trunk/runtime/src/kmp_os.h
Modified: openmp/trunk/runtime/src/kmp_os.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_os.h?rev=308355&r1=308354&r2=308355&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_os.h (original)
+++ openmp/trunk/runtime/src/kmp_os.h Tue Jul 18 13:31:19 2017
@@ -243,14 +243,16 @@ template <> struct traits_t<unsigned lon
#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)
More information about the Openmp-commits
mailing list