250 |
|
#include <fcntl.h> |
251 |
|
#include <sys/mman.h> |
252 |
|
|
253 |
– |
static caddr_t page = 0; |
253 |
|
static int page_size; |
254 |
< |
static int handler_called = 0; |
254 |
> |
static volatile char * page = 0; |
255 |
> |
static volatile int handler_called = 0; |
256 |
|
|
257 |
|
static bool sigsegv_test_handler(sigsegv_address_t fault_address, sigsegv_address_t instruction_address) |
258 |
|
{ |
259 |
|
handler_called++; |
260 |
|
if ((fault_address - 123) != page) |
261 |
|
exit(1); |
262 |
< |
if (mprotect((caddr_t)((unsigned long)fault_address & -page_size), page_size, PROT_READ | PROT_WRITE) != 0) |
262 |
> |
if (mprotect((char *)((unsigned long)fault_address & -page_size), page_size, PROT_READ | PROT_WRITE) != 0) |
263 |
|
exit(1); |
264 |
|
return true; |
265 |
|
} |
271 |
|
return 1; |
272 |
|
|
273 |
|
page_size = getpagesize(); |
274 |
< |
page = (caddr_t)mmap(0, page_size, PROT_READ, MAP_PRIVATE, zero_fd, 0); |
274 |
> |
page = (char *)mmap(0, page_size, PROT_READ, MAP_PRIVATE, zero_fd, 0); |
275 |
|
if (page == MAP_FAILED) |
276 |
|
return 1; |
277 |
|
|