update from main archive 960910
[glibc.git] / sysdeps / mach / hurd / mips / exc2signal.c
blobf907c89cf001adfe9377b20e6317761d8b863c37
1 /* Translate Mach exception codes into signal numbers. MIPS version.
2 Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 #include <hurd.h>
21 #include <hurd/signal.h>
22 #include <mach/exception.h>
24 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
25 into a signal number and signal subcode. */
27 void
28 _hurd_exception2signal (int exception, int code, int subcode,
29 int *signo, long int *sigcode, int *error)
31 *error = 0;
33 switch (exception)
35 default:
36 *signo = SIGIOT;
37 *sigcode = exception;
38 break;
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;
49 case EXC_BAD_INSTRUCTION:
50 *signo = SIGILL;
51 if (code == EXC_MIPS_II)
52 *sigcode = code;
53 else
54 *sigcode = 0;
55 break;
57 case EXC_ARITHMETIC:
58 switch (code)
60 case EXC_MIPS_OV: /* integer overflow */
61 *signo = SIGFPE;
62 *sigcode = EXC_MIPS_FLT_OVERFLOW;
63 break;
65 default:
66 *signo = SIGFPE;
67 *sigcode = 0;
68 break;
70 case EXC_MIPS_INT:
71 /* Subcode is the fp_status word saved by the hardware.
72 Give an error code corresponding to the first bit set. */
73 if (subcode == EXC_MIPS_FLT_UNIMP)
74 *signo = SIGILL;
75 else
76 *signo = SIGFPE;
77 *sigcode = subcode;
78 break;
80 break;
82 case EXC_EMULATION:
83 /* 3.0 doesn't give this one, why, I don't know. */
84 *signo = SIGEMT;
85 *sigcode = 0;
86 break;
88 case EXC_SOFTWARE:
89 *signo = SIGEMT;
90 *sigcode = 0;
91 break;
93 case EXC_BREAKPOINT:
94 *signo = SIGTRAP;
95 *sigcode = code;
96 break;