Skip to content

Commit 0c7238b

Browse files
committedJul 18, 2017
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 llvm-svn: 308355
1 parent 12149e2 commit 0c7238b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎openmp/runtime/src/kmp_os.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,16 @@ template <> struct traits_t<unsigned long long> {
243243
#define __forceinline __inline
244244
#endif
245245

246-
#define PAGE_SIZE (0x4000)
246+
#if KMP_OS_WINDOWS
247+
#include <windows.h>
247248

248-
#if KMP_OS_LINUX
249-
#define KMP_GET_PAGE_SIZE() getpagesize()
249+
static inline int KMP_GET_PAGE_SIZE(void) {
250+
SYSTEM_INFO si;
251+
GetSystemInfo(&si);
252+
return si.dwPageSize;
253+
}
250254
#else
251-
// TODO: find the corresponding function to getpagesize() in Windows
252-
// and use it whenever possible.
253-
#define KMP_GET_PAGE_SIZE() PAGE_SIZE
255+
#define KMP_GET_PAGE_SIZE() getpagesize()
254256
#endif
255257

256258
#define PAGE_ALIGNED(_addr) \
@@ -304,8 +306,6 @@ enum kmp_mem_fence_type {
304306

305307
#if KMP_ASM_INTRINS && KMP_OS_WINDOWS
306308

307-
#include <Windows.h>
308-
309309
#pragma intrinsic(InterlockedExchangeAdd)
310310
#pragma intrinsic(InterlockedCompareExchange)
311311
#pragma intrinsic(InterlockedExchange)

0 commit comments

Comments
 (0)
Please sign in to comment.