comparison src/main.c @ 1738:808dd5257146

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 91a65afb5d77
children
comparison
equal deleted inserted replaced
1737:fad7d30676c3 1738:808dd5257146
702 * crash otherwise. 702 * crash otherwise.
703 * Ideas for improvement are welcome ;) 703 * Ideas for improvement are welcome ;)
704 */ 704 */
705 /* FIXME: this probably needs some better ifdefs. Please report any compilation problems */ 705 /* FIXME: this probably needs some better ifdefs. Please report any compilation problems */
706 706
707 #ifdef SIGBUS 707 #if defined(SIGBUS) && defined(SA_SIGINFO)
708 static void sigbus_handler_cb(int signum, siginfo_t *info, void *context) 708 static void sigbus_handler_cb(int signum, siginfo_t *info, void *context)
709 { 709 {
710 unsigned long pagesize = sysconf(_SC_PAGE_SIZE); 710 unsigned long pagesize = sysconf(_SC_PAGE_SIZE);
711 DEBUG_1("SIGBUS %p", info->si_addr); 711 DEBUG_1("SIGBUS %p", info->si_addr);
712 mmap((void *)(((unsigned long)info->si_addr / pagesize) * pagesize), pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 712 mmap((void *)(((unsigned long)info->si_addr / pagesize) * pagesize), pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
713 } 713 }
714 #endif 714 #endif
715 715
716 static void setup_sigbus_handler(void) 716 static void setup_sigbus_handler(void)
717 { 717 {
718 #ifdef SIGBUS 718 #if defined(SIGBUS) && defined(SA_SIGINFO)
719 struct sigaction sigbus_action; 719 struct sigaction sigbus_action;
720 sigfillset(&sigbus_action.sa_mask); 720 sigfillset(&sigbus_action.sa_mask);
721 sigbus_action.sa_sigaction = sigbus_handler_cb; 721 sigbus_action.sa_sigaction = sigbus_handler_cb;
722 sigbus_action.sa_flags = SA_SIGINFO; 722 sigbus_action.sa_flags = SA_SIGINFO;
723 723