comparison test/thunk/test_thunk.c @ 377:51af8ec8d8e6

- simplified thunk-test memory error handling (sigaction setup not needed for this single-threaded test; did also set mutually exclusive union members)
author Tassilo Philipp
date Mon, 28 Dec 2020 14:09:09 +0100
parents 451299d50c1a
children fccbb45a2dae
comparison
equal deleted inserted replaced
376:041cb6ad4d50 377:51af8ec8d8e6
114 114
115 int main() 115 int main()
116 { 116 {
117 dcTest_initPlatform(); 117 dcTest_initPlatform();
118 118
119 #if defined(DC__OS_MacOSX) 119 /* handle possible mem access errors */
120 /* Memory access errors can result into SIGBUS */ 120 signal(SIGBUS, segv_handler);
121 signal(SIGBUS, segv_handler);
122
123 struct sigaction sigAct;
124 sigfillset(&(sigAct.sa_mask));
125 sigAct.sa_sigaction = segv_handler;
126 /* we need to enable SA_ONSTACK which allows faulting on the stack */
127 sigAct.sa_flags = SA_SIGINFO|SA_RESTART|SA_ONSTACK;
128 sigaction(SIGSEGV, &sigAct, NULL);
129 #else
130 signal(SIGSEGV, segv_handler); 121 signal(SIGSEGV, segv_handler);
131 #endif
132 122
133 printf("Allocating ...\n"); 123 printf("Allocating ...\n");
134 printf("... W^X memory: "); 124 printf("... W^X memory: ");
135 test_wx(); 125 test_wx();
136 printf("... heap memory: "); 126 printf("... heap memory: ");