212 |
|
dnl Checks for library functions. |
213 |
|
AC_CHECK_FUNCS(strdup cfmakeraw) |
214 |
|
AC_CHECK_FUNCS(clock_gettime timer_create) |
215 |
+ |
AC_CHECK_FUNCS(sigaction signal) |
216 |
|
|
217 |
|
dnl Select system-dependant source files. |
218 |
|
SERIALSRC=serial_unix.cpp |
329 |
|
] |
330 |
|
) |
331 |
|
|
332 |
< |
dnl Check if extended signals are supported. |
333 |
< |
AC_CACHE_CHECK("whether your system supports extended signal handlers", |
334 |
< |
ac_cv_have_extended_signals, [ |
332 |
> |
dnl Check signal handlers need to be reinstalled |
333 |
> |
AC_CACHE_CHECK("whether signal handlers need to be reinstalled", |
334 |
> |
ac_cv_signal_need_reinstall, [ |
335 |
> |
AC_LANG_SAVE |
336 |
> |
AC_LANG_CPLUSPLUS |
337 |
> |
AC_TRY_RUN([ |
338 |
> |
#include <stdlib.h> |
339 |
> |
#ifdef HAVE_UNISTD_H |
340 |
> |
#include <unistd.h> |
341 |
> |
#endif |
342 |
> |
#include <signal.h> |
343 |
> |
static int handled_signal = 0; |
344 |
> |
RETSIGTYPE sigusr1_handler(int) { handled_signal++; } |
345 |
> |
int main(void) { /* returns 0 if signals need not to be reinstalled */ |
346 |
> |
signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1); |
347 |
> |
exit(handled_signal == 2); |
348 |
> |
} |
349 |
> |
], |
350 |
> |
[ac_cv_signal_need_reinstall=yes], |
351 |
> |
[ac_cv_signal_need_reinstall=no] |
352 |
> |
) |
353 |
> |
AC_LANG_RESTORE |
354 |
> |
] |
355 |
> |
) |
356 |
> |
AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall") |
357 |
> |
|
358 |
> |
dnl Check if sigaction handlers need to be reinstalled |
359 |
> |
AC_CACHE_CHECK("whether sigaction handlers need to be reinstalled", |
360 |
> |
ac_cv_sigaction_need_reinstall, [ |
361 |
|
AC_LANG_SAVE |
362 |
|
AC_LANG_CPLUSPLUS |
363 |
|
AC_TRY_RUN([ |
337 |
– |
#include <unistd.h> |
364 |
|
#include <stdlib.h> |
365 |
+ |
#ifdef HAVE_UNISTD_H |
366 |
+ |
#include <unistd.h> |
367 |
+ |
#endif |
368 |
|
#include <signal.h> |
369 |
< |
#include <fcntl.h> |
370 |
< |
#include <sys/mman.h> |
371 |
< |
|
372 |
< |
static volatile caddr_t mem = 0; |
373 |
< |
static int zero_fd = -1; |
374 |
< |
|
375 |
< |
static RETSIGTYPE segfault_handler(int, siginfo_t * sip, void *) |
376 |
< |
{ if ((caddr_t)(sip->si_addr) != mem) exit(1); |
348 |
< |
munmap(mem, getpagesize()); close(zero_fd); exit(0); } |
349 |
< |
|
350 |
< |
int main() |
351 |
< |
{ if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1); |
352 |
< |
if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1); |
353 |
< |
struct sigaction sa; sa.sa_sigaction = segfault_handler; sa.sa_flags = SA_SIGINFO; |
354 |
< |
sigaction(SIGSEGV, &sa, 0); |
355 |
< |
mem[0] = 0; |
356 |
< |
exit(1); // should not be reached |
369 |
> |
static int handled_signal = 0; |
370 |
> |
RETSIGTYPE sigusr1_handler(int) { handled_signal++; } |
371 |
> |
typedef RETSIGTYPE (*signal_handler)(int); |
372 |
> |
static signal_handler mysignal(int sig, signal_handler handler) { |
373 |
> |
struct sigaction old_sa; |
374 |
> |
struct sigaction new_sa; |
375 |
> |
new_sa.sa_handler = handler; |
376 |
> |
return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler); |
377 |
|
} |
378 |
+ |
int main(void) { /* returns 0 if signals need not to be reinstalled */ |
379 |
+ |
mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1); |
380 |
+ |
exit(handled_signal == 2); |
381 |
+ |
} |
382 |
+ |
], |
383 |
+ |
[ac_cv_sigaction_need_reinstall=yes], |
384 |
+ |
[ac_cv_sigaction_need_reinstall=no] |
385 |
+ |
) |
386 |
+ |
AC_LANG_RESTORE |
387 |
+ |
] |
388 |
+ |
) |
389 |
+ |
AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall") |
390 |
+ |
|
391 |
+ |
dnl Check if extended signals are supported. |
392 |
+ |
AC_CACHE_CHECK("whether your system supports extended signal handlers", |
393 |
+ |
ac_cv_have_extended_signals, [ |
394 |
+ |
AC_LANG_SAVE |
395 |
+ |
AC_LANG_CPLUSPLUS |
396 |
+ |
AC_TRY_RUN([ |
397 |
+ |
#define HAVE_SIGINFO_T 1 |
398 |
+ |
#define CONFIGURE_TEST |
399 |
+ |
#include "sigsegv.cpp" |
400 |
|
], |
401 |
|
[ac_cv_have_extended_signals=yes], |
402 |
|
[ac_cv_have_extended_signals=no] |
408 |
|
|
409 |
|
dnl Otherwise, check for subterfuges. |
410 |
|
if [[ "x$ac_cv_have_extended_signals" = "xno" ]]; then |
411 |
< |
case "$target_os" in |
412 |
< |
linux*) |
413 |
< |
if [[ "x$HAVE_I386" = "xyes" ]]; then |
414 |
< |
AC_CACHE_CHECK("whether we then have a subterfuge for your system", |
415 |
< |
ac_cv_have_sigcontext_hack, [ |
416 |
< |
AC_LANG_SAVE |
417 |
< |
AC_LANG_CPLUSPLUS |
418 |
< |
AC_TRY_RUN([ |
419 |
< |
#include <unistd.h> |
420 |
< |
#include <signal.h> |
421 |
< |
#include <fcntl.h> |
422 |
< |
#include <sys/mman.h> |
423 |
< |
|
424 |
< |
static volatile caddr_t mem = 0; |
425 |
< |
static int zero_fd = -1; |
384 |
< |
|
385 |
< |
static RETSIGTYPE segfault_handler(int, struct sigcontext scs) |
386 |
< |
{ if ((caddr_t)(scs.cr2) != mem) exit(1); |
387 |
< |
munmap(mem, getpagesize()); close(zero_fd); exit(0); } |
388 |
< |
|
389 |
< |
int main() |
390 |
< |
{ if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1); |
391 |
< |
if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1); |
392 |
< |
struct sigaction sa; sa.sa_flags = 0; |
393 |
< |
sa.sa_handler = (RETSIGTYPE (*)(int))segfault_handler; |
394 |
< |
sigaction(SIGSEGV, &sa, 0); |
395 |
< |
mem[0] = 0; |
396 |
< |
exit(1); // should not be reached |
397 |
< |
} |
398 |
< |
], |
399 |
< |
[ac_cv_have_sigcontext_hack=yes], |
400 |
< |
[ac_cv_have_sigcontext_hack=no] |
401 |
< |
) |
402 |
< |
AC_LANG_RESTORE |
403 |
< |
]) |
404 |
< |
AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, $ac_cv_have_sigcontext_hack) |
405 |
< |
elif [[ "x$HAVE_POWERPC" = "xyes" ]]; then |
406 |
< |
AC_CACHE_CHECK("whether we then have a subterfuge for your system", |
407 |
< |
ac_cv_have_sigcontext_hack, [ |
408 |
< |
AC_LANG_SAVE |
409 |
< |
AC_LANG_CPLUSPLUS |
410 |
< |
AC_TRY_RUN([ |
411 |
< |
#include <unistd.h> |
412 |
< |
#include <signal.h> |
413 |
< |
#include <fcntl.h> |
414 |
< |
#include <sys/mman.h> |
415 |
< |
|
416 |
< |
static volatile caddr_t mem = 0; |
417 |
< |
static int zero_fd = -1; |
418 |
< |
|
419 |
< |
static RETSIGTYPE segfault_handler(int, struct sigcontext_struct *scs) |
420 |
< |
{ if ((caddr_t)(scs->regs->dar) != mem) exit(1); |
421 |
< |
munmap(mem, getpagesize()); close(zero_fd); exit(0); } |
422 |
< |
|
423 |
< |
int main() |
424 |
< |
{ if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1); |
425 |
< |
if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1); |
426 |
< |
struct sigaction sa; sa.sa_flags = 0; |
427 |
< |
sa.sa_handler = (RETSIGTYPE (*)(int))segfault_handler; |
428 |
< |
sigaction(SIGSEGV, &sa, 0); |
429 |
< |
mem[0] = 0; |
430 |
< |
exit(1); // should not be reached |
431 |
< |
} |
432 |
< |
], |
433 |
< |
[ac_cv_have_sigcontext_hack=yes], |
434 |
< |
[ac_cv_have_sigcontext_hack=no] |
435 |
< |
) |
436 |
< |
AC_LANG_RESTORE |
437 |
< |
]) |
438 |
< |
AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, $ac_cv_have_sigcontext_hack) |
439 |
< |
fi |
440 |
< |
;; |
441 |
< |
netbsd*) |
442 |
< |
if [[ "x$HAVE_M68K" = "xyes" ]]; then |
443 |
< |
AC_CACHE_CHECK("whether we then have a subterfuge for your system", |
444 |
< |
ac_cv_have_sigcontext_hack, [ |
445 |
< |
AC_LANG_SAVE |
446 |
< |
AC_LANG_CPLUSPLUS |
447 |
< |
AC_TRY_RUN([ |
448 |
< |
#include <unistd.h> |
449 |
< |
#include <signal.h> |
450 |
< |
#include <fcntl.h> |
451 |
< |
#include <sys/mman.h> |
452 |
< |
|
453 |
< |
static volatile caddr_t mem = 0; |
454 |
< |
static int zero_fd = -1; |
455 |
< |
|
456 |
< |
static RETSIGTYPE segfault_handler(int, int code) |
457 |
< |
{ if ((caddr_t)code != mem) exit(1); |
458 |
< |
munmap(mem, getpagesize()); close(zero_fd); exit(0); } |
459 |
< |
|
460 |
< |
int main() |
461 |
< |
{ if ((zero_fd = open("/dev/zero", O_RDWR)) < 0) exit(1); |
462 |
< |
if ((mem = (caddr_t)mmap(0, getpagesize(), PROT_READ, MAP_PRIVATE, zero_fd, 0)) == (caddr_t)MAP_FAILED) exit(1); |
463 |
< |
struct sigaction sa; sa.sa_flags = 0; |
464 |
< |
sa.sa_handler = (RETSIGTYPE (*)(int))segfault_handler; |
465 |
< |
sigaction(SIGSEGV, &sa, 0); |
466 |
< |
mem[0] = 0; |
467 |
< |
exit(1); // should not be reached |
468 |
< |
} |
469 |
< |
], |
470 |
< |
[ac_cv_have_sigcontext_hack=yes], |
471 |
< |
[ac_cv_have_sigcontext_hack=no] |
472 |
< |
) |
473 |
< |
AC_LANG_RESTORE |
474 |
< |
]) |
475 |
< |
AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, $ac_cv_have_sigcontext_hack) |
476 |
< |
fi |
477 |
< |
;; |
478 |
< |
esac |
411 |
> |
AC_CACHE_CHECK("whether we then have a subterfuge for your system", |
412 |
> |
ac_cv_have_sigcontext_hack, [ |
413 |
> |
AC_LANG_SAVE |
414 |
> |
AC_LANG_CPLUSPLUS |
415 |
> |
AC_TRY_RUN([ |
416 |
> |
#define HAVE_SIGCONTEXT_SUBTERFUGE 1 |
417 |
> |
#define CONFIGURE_TEST |
418 |
> |
#include "sigsegv.cpp" |
419 |
> |
], |
420 |
> |
[ac_cv_have_sigcontext_hack=yes], |
421 |
> |
[ac_cv_have_sigcontext_hack=no] |
422 |
> |
) |
423 |
> |
AC_LANG_RESTORE |
424 |
> |
]) |
425 |
> |
AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack") |
426 |
|
fi |
427 |
|
|
428 |
|
dnl Can we do Video on SEGV Signals ? |