comparison src/main.c @ 1777:56c019ed8746

Some systems do not have SA_SIGINFO (siginfo_t), like GNU/Hurd, so just test if defined or not. Patch by Michal iha (Bug ID: 2894271).
author zas_
date Fri, 04 Dec 2009 21:01:11 +0000
parents 9f3b7a089caf
children 261c16ca7da6
comparison
equal deleted inserted replaced
1776:f0e9f2dcfe8a 1777:56c019ed8746
707 * crash otherwise. 707 * crash otherwise.
708 * Ideas for improvement are welcome ;) 708 * Ideas for improvement are welcome ;)
709 */ 709 */
710 /* FIXME: this probably needs some better ifdefs. Please report any compilation problems */ 710 /* FIXME: this probably needs some better ifdefs. Please report any compilation problems */
711 711
712 #ifdef SIGBUS 712 #if defined(SIGBUS) && defined(SA_SIGINFO)
713 static void sigbus_handler_cb(int signum, siginfo_t *info, void *context) 713 static void sigbus_handler_cb(int signum, siginfo_t *info, void *context)
714 { 714 {
715 unsigned long pagesize = sysconf(_SC_PAGE_SIZE); 715 unsigned long pagesize = sysconf(_SC_PAGE_SIZE);
716 DEBUG_1("SIGBUS %p", info->si_addr); 716 DEBUG_1("SIGBUS %p", info->si_addr);
717 mmap((void *)(((unsigned long)info->si_addr / pagesize) * pagesize), pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 717 mmap((void *)(((unsigned long)info->si_addr / pagesize) * pagesize), pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
718 } 718 }
719 #endif 719 #endif
720 720
721 static void setup_sigbus_handler(void) 721 static void setup_sigbus_handler(void)
722 { 722 {
723 #ifdef SIGBUS 723 #if defined(SIGBUS) && defined(SA_SIGINFO)
724 struct sigaction sigbus_action; 724 struct sigaction sigbus_action;
725 sigfillset(&sigbus_action.sa_mask); 725 sigfillset(&sigbus_action.sa_mask);
726 sigbus_action.sa_sigaction = sigbus_handler_cb; 726 sigbus_action.sa_sigaction = sigbus_handler_cb;
727 sigbus_action.sa_flags = SA_SIGINFO; 727 sigbus_action.sa_flags = SA_SIGINFO;
728 728