Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / m4 / siginfo.m4
1 # siginfo.m4 serial 1 (gettext-0.11)
2 dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 # Determine how to determine the precise cause of a signal, for example
8 # division by zero.
9 # - SUSV2 and POSIX specify the use of sigaction with SA_SIGINFO and a member
10 #   void (*)(int sig, siginfo_t *info, void *context) sa_sigaction.
11 #   Linux (2.2.x and newer) and Solaris implement this.
12 #   Linux (2.4.x and newer) on i386, m68k, sparc, sparc64, ia64 actually
13 #   deliver FPE_INTDIV.
14 # - Without SA_SIGINFO:
15 #   - Linux on m68k calls the handler as
16 #     void (*)(int sig, int code, struct sigcontext* scp).
17 #     For division by zero, code would be VEC_ZERODIV<<2.
18 #   - Linux on sparc calls the handler either as
19 #     void (*)(int sig, int code, struct sigcontext* scp),
20 #     code for division by zero would be SUBSIG_IDIVZERO, or as
21 #     void (*)(int sig, siginfo_t *info, void *context).
22 #     Which one depends on a process specific flag in the kernel.
23 #   - Linux on sparc64 always calls the handler as
24 #     void (*)(int sig, siginfo_t *info, void *context).
25 #   - FreeBSD on i386 calls the handler as
26 #     void (*)(int sig, int code, void* scp, char* addr).
27 #     For division by zero, code would be FPE_INTDIV.
28 #   - SunOS 4 calls the handler as
29 #     void (*)(int sig, int code, void* scp, char* addr).
30 #   - Solaris?
31 #   - Irix 5, OSF/1, AIX call the handler as
32 #     void (*)(int sig, int code, struct sigcontext *scp).
33 # These are so many OS and CPU dependencies that we don't bother, and rely
34 # only on SA_SIGINFO.
35 AC_DEFUN([gt_SIGINFO],
36 [
37   AC_CACHE_CHECK([for signal handlers with siginfo_t], gt_cv_siginfo_t,
38     [AC_TRY_COMPILE([
39 #include <signal.h>], [
40 struct sigaction action;
41 siginfo_t info;
42 action.sa_flags = SA_SIGINFO;
43 action.sa_sigaction = (void *) 0;
44 ], gt_cv_siginfo_t=yes, gt_cv_siginfo_t=no)])
45   if test $gt_cv_siginfo_t = yes; then
46     AC_DEFINE(HAVE_SIGINFO, 1,
47       [Define to 1 if <signal.h> defines the siginfo_t type,
48    and struct sigaction has the sa_sigaction member and the SA_SIGINFO flag.])
49   fi
50 ])