Update to LGPL v2.1.
[jlayton/glibc.git] / sysdeps / mach / hurd / alpha / exc2signal.c
1 /* Translate Mach exception codes into signal numbers.  Alpha version.
2    Copyright (C) 1994, 1997 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #include <hurd.h>
21 #include <hurd/signal.h>
22 #include <mach/exception.h>
23
24 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
25    into a signal number and signal subcode.  */
26
27 void
28 _hurd_exception2signal (int exception, int code, int subcode,
29                         int *signo, long int *sigcode, int *error)
30 {
31   *error = 0;
32
33   switch (exception)
34     {
35     default:
36       *signo = SIGIOT;
37       *sigcode = exception;
38       break;
39
40     case EXC_BAD_ACCESS:
41       if (code == KERN_PROTECTION_FAILURE)
42         *signo = SIGSEGV;
43       else
44         *signo = SIGBUS;
45       *sigcode = subcode;
46       *error = code;
47       break;
48
49     case EXC_BAD_INSTRUCTION:
50       *signo = SIGILL;
51       *sigcode = code;
52       break;
53
54     case EXC_ARITHMETIC:
55       *signo = SIGFPE;
56       *sigcode = code;
57       break;
58       break;
59
60     case EXC_EMULATION:
61       /* 3.0 doesn't give this one, why, I don't know.  */
62       *signo = SIGEMT;
63       *sigcode = code;
64       break;
65
66     case EXC_SOFTWARE:
67       *signo = SIGEMT;
68       *sigcode = code;
69       break;
70
71     case EXC_BREAKPOINT:
72       *signo = SIGTRAP;
73       *sigcode = code;
74       break;
75     }
76 }