glibc/sysdeps/mach/hurd/i386/exc2signal.c
Paul Eggert 5a82c74822 Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:

sed -ri '
  s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
  s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
  $(find $(git ls-files) -prune -type f \
      ! -name '*.po' \
      ! -name 'ChangeLog*' \
      ! -path COPYING ! -path COPYING.LIB \
      ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
      ! -path manual/texinfo.tex ! -path scripts/config.guess \
      ! -path scripts/config.sub ! -path scripts/install-sh \
      ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
      ! -path INSTALL ! -path  locale/programs/charmap-kw.h \
      ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
      ! '(' -name configure \
            -execdir test -f configure.ac -o -f configure.in ';' ')' \
      ! '(' -name preconfigure \
            -execdir test -f preconfigure.ac ';' ')' \
      -print)

and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:

  chmod a+x sysdeps/unix/sysv/linux/riscv/configure
  # Omit irrelevant whitespace and comment-only changes,
  # perhaps from a slightly-different Autoconf version.
  git checkout -f \
    sysdeps/csky/configure \
    sysdeps/hppa/configure \
    sysdeps/riscv/configure \
    sysdeps/unix/sysv/linux/csky/configure
  # Omit changes that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
  git checkout -f \
    sysdeps/powerpc/powerpc64/ppc-mcount.S \
    sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
  # Omit change that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
  git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 02:43:31 -07:00

167 lines
4.2 KiB
C

/* Translate Mach exception codes into signal numbers. i386 version.
Copyright (C) 1991-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#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
_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
{
detail->error = 0;
switch (detail->exc)
{
default:
*signo = SIGIOT;
detail->code = detail->exc;
break;
case EXC_BAD_ACCESS:
if (detail->exc_code == KERN_INVALID_ADDRESS
|| detail->exc_code == KERN_PROTECTION_FAILURE
|| detail->exc_code == KERN_WRITE_PROTECTION_FAILURE)
*signo = SIGSEGV;
else
*signo = SIGBUS;
detail->code = detail->exc_subcode;
detail->error = detail->exc_code;
break;
case EXC_BAD_INSTRUCTION:
*signo = SIGILL;
if (detail->exc_code == EXC_I386_INVOP)
detail->code = ILL_INVOPR_FAULT;
else if (detail->exc_code == EXC_I386_STKFLT)
detail->code = ILL_STACK_FAULT;
else
detail->code = 0;
break;
case EXC_ARITHMETIC:
switch (detail->exc_code)
{
case EXC_I386_DIV: /* integer divide by zero */
*signo = SIGFPE;
detail->code = FPE_INTDIV_FAULT;
break;
case EXC_I386_INTO: /* integer overflow */
*signo = SIGFPE;
detail->code = FPE_INTOVF_TRAP;
break;
/* These aren't anywhere documented or used in Mach 3.0. */
case EXC_I386_NOEXT:
case EXC_I386_EXTOVR:
default:
*signo = SIGFPE;
detail->code = 0;
break;
case EXC_I386_EXTERR:
/* Subcode is the fp_status word saved by the hardware.
Give an error code corresponding to the first bit set. */
if (detail->exc_subcode & FPS_IE)
{
*signo = SIGILL;
detail->code = ILL_FPEOPR_FAULT;
}
else if (detail->exc_subcode & FPS_DE)
{
*signo = SIGFPE;
detail->code = FPE_FLTDNR_FAULT;
}
else if (detail->exc_subcode & FPS_ZE)
{
*signo = SIGFPE;
detail->code = FPE_FLTDIV_FAULT;
}
else if (detail->exc_subcode & FPS_OE)
{
*signo = SIGFPE;
detail->code = FPE_FLTOVF_FAULT;
}
else if (detail->exc_subcode & FPS_UE)
{
*signo = SIGFPE;
detail->code = FPE_FLTUND_FAULT;
}
else if (detail->exc_subcode & FPS_PE)
{
*signo = SIGFPE;
detail->code = FPE_FLTINX_FAULT;
}
else
{
*signo = SIGFPE;
detail->code = 0;
}
break;
/* These two can only be arithmetic exceptions if we
are in V86 mode, which sounds like emulation to me.
(See Mach 3.0 i386/trap.c.) */
case EXC_I386_EMERR:
*signo = SIGFPE;
detail->code = FPE_EMERR_FAULT;
break;
case EXC_I386_BOUND:
*signo = SIGFPE;
detail->code = FPE_EMBND_FAULT;
break;
}
break;
case EXC_EMULATION:
/* 3.0 doesn't give this one, why, I don't know. */
*signo = SIGEMT;
detail->code = 0;
break;
case EXC_SOFTWARE:
/* The only time we get this in Mach 3.0
is for an out of bounds trap. */
if (detail->exc_code == EXC_I386_BOUND)
{
*signo = SIGFPE;
detail->code = FPE_SUBRNG_FAULT;
}
else
{
*signo = SIGEMT;
detail->code = 0;
}
break;
case EXC_BREAKPOINT:
*signo = SIGTRAP;
if (detail->exc_code == EXC_I386_SGL)
detail->code = DBG_SINGLE_TRAP;
else if (detail->exc_code == EXC_I386_BPT)
detail->code = DBG_BRKPNT_FAULT;
else
detail->code = 0;
break;
}
}
libc_hidden_def (_hurd_exception2signal)