Commit d49f9f5b authored by Simon Marlow's avatar Simon Marlow

avoid platform dependencies: my_uintptr_t ==> StgWord

parent 1b6b0ba3
......@@ -13,14 +13,6 @@
#include <sys/types.h>
#include <sys/mman.h>
/* no C99 header stdint.h on OpenBSD? */
#if defined(openbsd_HOST_OS)
typedef unsigned long my_uintptr_t;
#else
#include <stdint.h>
typedef uintptr_t my_uintptr_t;
#endif
lnat getPageSize (void)
{
static lnat pageSize = 0;
......@@ -38,13 +30,13 @@ lnat getPageSize (void)
void setExecutable (void *p, lnat len, rtsBool exec)
{
my_uintptr_t pageSize = getPageSize();
StgWord pageSize = getPageSize();
/* malloced memory isn't executable by default on OpenBSD */
my_uintptr_t mask = ~(pageSize - 1);
my_uintptr_t startOfFirstPage = ((my_uintptr_t)p ) & mask;
my_uintptr_t startOfLastPage = ((my_uintptr_t)p + len - 1) & mask;
my_uintptr_t size = startOfLastPage - startOfFirstPage + pageSize;
StgWord mask = ~(pageSize - 1);
StgWord startOfFirstPage = ((StgWord)p ) & mask;
StgWord startOfLastPage = ((StgWord)p + len - 1) & mask;
StgWord size = startOfLastPage - startOfFirstPage + pageSize;
if (mprotect((void*)startOfFirstPage, (size_t)size,
(exec ? PROT_EXEC : 0) | PROT_READ | PROT_WRITE) != 0) {
barf("makeExecutable: failed to protect 0x%p\n", p);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment