diff --git GNUmakefile GNUmakefile index 12f3ee7..665e7ad 100644 --- GNUmakefile +++ GNUmakefile @@ -1,5 +1,5 @@ CXX = g++ -CXXFLAGS = -Wall -g -DPAL_DEBUG +CXXFLAGS = -Wall -g #-DPAL_DEBUG .PHONY: build clean diff --git tema3-checker-lin/_test/common.h tema3-checker-lin/_test/common.h index 06e444a..d1c6345 100755 --- tema3-checker-lin/_test/common.h +++ tema3-checker-lin/_test/common.h @@ -45,7 +45,13 @@ typedef LPVOID w_ptr_t; typedef LONG (*w_exception_handler_t)(PEXCEPTION_POINTERS); -#elif defined (__linux__) +#elif defined (__linux__) || defined (__APPLE__) + +#if defined (__linux__) +#define SIGFAULT SIGSEGV +#elif defined (__APPLE__) +#define SIGFAULT SIGBUS +#endif typedef enum { FALSE = -1, diff --git tema3-checker-lin/_test/common_lin.c tema3-checker-lin/_test/common_lin.c index 80e5016..ae7a6a4 100755 --- tema3-checker-lin/_test/common_lin.c +++ tema3-checker-lin/_test/common_lin.c @@ -23,7 +23,7 @@ size_t w_get_page_size(void) } /* - * empty SIGSEGV handler - does nothing, successfully + * empty SIGFAULT handler - does nothing, successfully * for testing purposes only; it would not make sense using it */ @@ -32,7 +32,7 @@ void empty_exception_handler(int signum, siginfo_t *info, void *context) } /* - * set exception handler (catch SIGSEGV signal) + * set exception handler (catch SIGFAULT signal) */ static struct sigaction previous_action; @@ -42,10 +42,10 @@ w_boolean_t w_set_exception_handler(w_exception_handler_t handler) static struct sigaction sa; sa.sa_sigaction = handler; sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGSEGV); + sigaddset(&sa.sa_mask, SIGFAULT); sa.sa_flags = SA_SIGINFO; - if (sigaction(SIGSEGV, &sa, &previous_action) < 0) + if (sigaction(SIGFAULT, &sa, &previous_action) < 0) return FALSE; return TRUE; @@ -56,7 +56,7 @@ w_boolean_t w_get_current_exception_handler(w_exception_handler_t *phandler) struct sigaction sa; sigemptyset(&sa.sa_mask); - if (sigaction(SIGSEGV, NULL, &sa) < 0) + if (sigaction(SIGFAULT, NULL, &sa) < 0) return FALSE; *phandler = sa.sa_sigaction; diff --git tema3-checker-lin/_test/util.h tema3-checker-lin/_test/util.h index 776715a..c0aa11d 100755 --- tema3-checker-lin/_test/util.h +++ tema3-checker-lin/_test/util.h @@ -41,7 +41,7 @@ static VOID PrintLastError(const PCHAR message) PrintLastError(call_description); \ } while (0) -#elif defined (__linux__) +#elif defined (__linux__) || defined (__APPLE__) /* error printing macro */ #define ERR(call_description) \ diff --git tema3-checker-lin/_test/vmsim.h tema3-checker-lin/_test/vmsim.h index 372e1d9..3186daa 100755 --- tema3-checker-lin/_test/vmsim.h +++ tema3-checker-lin/_test/vmsim.h @@ -54,7 +54,7 @@ FUNC_DECL_PREFIX w_boolean_t vm_free(w_ptr_t start); #if defined _WIN32 LONG vmsim_exception_handler(PEXCEPTION_POINTERS eptr); -#elif defined __linux__ +#elif defined (__linux__) || defined (__APPLE__) void vmsim_exception_handler(int sig, siginfo_t *siginfo, void *aux); #else #error "Unknown platform" diff --git tema3-checker-lin/_test/vmsim_aux.h tema3-checker-lin/_test/vmsim_aux.h index 564613c..c59c1f3 100755 --- tema3-checker-lin/_test/vmsim_aux.h +++ tema3-checker-lin/_test/vmsim_aux.h @@ -31,7 +31,7 @@ void vmsim_test_set_num_faults(size_t num_faults); #include LONG vmsim_test_exception_handler(PEXCEPTION_POINTERS info); -#elif defined (__linux__) +#elif defined (__linux__) || defined (__APPLE__) #include #include @@ -46,4 +46,4 @@ void vmsim_test_segv_handler(int signum, siginfo_t *info, void *context); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git tema3-checker-lin/_test/vmsim_test_lin.c tema3-checker-lin/_test/vmsim_test_lin.c index 4812804..104357e 100755 --- tema3-checker-lin/_test/vmsim_test_lin.c +++ tema3-checker-lin/_test/vmsim_test_lin.c @@ -19,18 +19,16 @@ static size_t sig_handler_num_calls; /* - * SIGSEGV handler + * SIGFAULT handler */ void vmsim_test_segv_handler(int signum, siginfo_t *info, void *context) { w_exception_handler_t handler; - if (signum != SIGSEGV) + if (signum != SIGFAULT) return; - if (info->si_signo != SIGSEGV) - return; - if (info->si_code != SEGV_ACCERR) + if (info->si_signo != SIGFAULT) return; sig_handler_num_calls++;