[PATCH] D28849: [compiler-rt] [test] Fix page address logic in clear_cache_test
Michał Górny via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 21 14:06:16 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292729: [test] Fix page address logic in clear_cache_test (authored by mgorny).
Changed prior to commit:
https://reviews.llvm.org/D28849?vs=85208&id=85248#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28849
Files:
compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
Index: compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
===================================================================
--- compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
+++ compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
exit(1);
}
+
+static uintptr_t get_page_size() {
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ return si.dwPageSize;
+}
#else
+#include <unistd.h>
#include <sys/mman.h>
extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+ return sysconf(_SC_PAGE_SIZE);
+}
#endif
@@ -56,8 +67,9 @@
int main()
{
// make executable the page containing execution_buffer
- char* start = (char*)((uintptr_t)execution_buffer & (-4095));
- char* end = (char*)((uintptr_t)(&execution_buffer[128+4096]) & (-4095));
+ uintptr_t page_size = get_page_size();
+ char* start = (char*)((uintptr_t)execution_buffer & (-page_size));
+ char* end = (char*)((uintptr_t)(&execution_buffer[128+page_size]) & (-page_size));
#if defined(_WIN32)
DWORD dummy_oldProt;
MEMORY_BASIC_INFORMATION b;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28849.85248.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170121/288ef234/attachment.bin>
More information about the cfe-commits
mailing list