glibc/sysdeps/mach/hurd/mips/exc2signal.c

98 lines
2.6 KiB
C
Raw Normal View History

1994-07-09 09:24:37 +02:00
/* Translate Mach exception codes into signal numbers. MIPS version.
1997-06-21 03:43:54 +02:00
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
1994-07-09 09:24:37 +02:00
1997-06-21 03:43:54 +02:00
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
1994-07-09 09:24:37 +02:00
1997-06-21 03:43:54 +02:00
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
1994-07-09 09:24:37 +02:00
1997-06-21 03:43:54 +02:00
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
1994-07-09 09:24:37 +02:00
#include <hurd.h>
#include <hurd/signal.h>
#include <mach/exception.h>
/* Translate the Mach exception codes, as received in an `exception_raise' RPC,
into a signal number and signal subcode. */
void
1997-06-21 03:43:54 +02:00
_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
1994-07-09 09:24:37 +02:00
{
1997-06-21 03:43:54 +02:00
detail->error = 0;
1997-06-21 03:43:54 +02:00
switch (detail->exc)
1994-07-09 09:24:37 +02:00
{
default:
*signo = SIGIOT;
1997-06-21 03:43:54 +02:00
detail->code = detail->exc;
1994-07-09 09:24:37 +02:00
break;
case EXC_BAD_ACCESS:
1997-06-21 03:43:54 +02:00
if (detail->exc_code == KERN_PROTECTION_FAILURE)
1994-07-09 09:24:37 +02:00
*signo = SIGSEGV;
else
*signo = SIGBUS;
1997-06-21 03:43:54 +02:00
detail->code = detail->exc_subcode;
detail->error = detail->exc_code;
1994-07-09 09:24:37 +02:00
break;
case EXC_BAD_INSTRUCTION:
*signo = SIGILL;
1997-06-21 03:43:54 +02:00
if (detail->exc_code == EXC_MIPS_II)
detail->code = detail->exc_subcode;
1994-07-09 09:24:37 +02:00
else
1997-06-21 03:43:54 +02:00
detail->code = 0;
1994-07-09 09:24:37 +02:00
break;
case EXC_ARITHMETIC:
1997-06-21 03:43:54 +02:00
switch (detail->exc_code)
1994-07-09 09:24:37 +02:00
{
case EXC_MIPS_OV: /* integer overflow */
*signo = SIGFPE;
1997-06-21 03:43:54 +02:00
detail->code = detail->exc_subcode;
1994-07-09 09:24:37 +02:00
break;
default:
*signo = SIGFPE;
1997-06-21 03:43:54 +02:00
detail->code = 0;
1994-07-09 09:24:37 +02:00
break;
case EXC_MIPS_INT:
/* Subcode is the fp_status word saved by the hardware.
Give an error code corresponding to the first bit set. */
1997-06-21 03:43:54 +02:00
if (detail->exc_subcode == EXC_MIPS_FLT_UNIMP)
1994-07-09 09:24:37 +02:00
*signo = SIGILL;
else
*signo = SIGFPE;
1997-06-21 03:43:54 +02:00
detail->code = detail->exc_subcode;
1994-07-09 09:24:37 +02:00
break;
}
break;
case EXC_EMULATION:
/* 3.0 doesn't give this one, why, I don't know. */
*signo = SIGEMT;
1997-06-21 03:43:54 +02:00
detail->code = 0;
1994-07-09 09:24:37 +02:00
break;
case EXC_SOFTWARE:
*signo = SIGEMT;
1997-06-21 03:43:54 +02:00
detail->code = 0;
1994-07-09 09:24:37 +02:00
break;
case EXC_BREAKPOINT:
*signo = SIGTRAP;
1997-06-21 03:43:54 +02:00
detail->code = 0;
1994-07-09 09:24:37 +02:00
break;
}
}