~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to ports/sysdeps/mach/hurd/mips/exc2signal.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Translate Mach exception codes into signal numbers.  MIPS version.
2
 
   Copyright (C) 1996, 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 (struct hurd_signal_detail *detail, int *signo)
29
 
{
30
 
  detail->error = 0;
31
 
 
32
 
  switch (detail->exc)
33
 
    {
34
 
    default:
35
 
      *signo = SIGIOT;
36
 
      detail->code = detail->exc;
37
 
      break;
38
 
      
39
 
    case EXC_BAD_ACCESS:
40
 
      if (detail->exc_code == KERN_PROTECTION_FAILURE)
41
 
        *signo = SIGSEGV;
42
 
      else
43
 
        *signo = SIGBUS;
44
 
      detail->code = detail->exc_subcode;
45
 
      detail->error = detail->exc_code;
46
 
      break;
47
 
 
48
 
    case EXC_BAD_INSTRUCTION:
49
 
      *signo = SIGILL;
50
 
      if (detail->exc_code == EXC_MIPS_II)
51
 
        detail->code = detail->exc_subcode;
52
 
      else
53
 
        detail->code = 0;
54
 
      break;
55
 
      
56
 
    case EXC_ARITHMETIC:
57
 
      switch (detail->exc_code)
58
 
        {
59
 
        case EXC_MIPS_OV:       /* integer overflow */
60
 
          *signo = SIGFPE;
61
 
          detail->code = detail->exc_subcode;
62
 
          break;
63
 
 
64
 
        default:
65
 
          *signo = SIGFPE;
66
 
          detail->code = 0;
67
 
          break;
68
 
 
69
 
        case EXC_MIPS_INT:
70
 
          /* Subcode is the fp_status word saved by the hardware.
71
 
             Give an error code corresponding to the first bit set.  */
72
 
          if (detail->exc_subcode == EXC_MIPS_FLT_UNIMP)
73
 
            *signo = SIGILL;
74
 
          else
75
 
            *signo = SIGFPE;
76
 
          detail->code = detail->exc_subcode;
77
 
          break;
78
 
        }
79
 
      break;
80
 
 
81
 
    case EXC_EMULATION:         
82
 
      /* 3.0 doesn't give this one, why, I don't know.  */
83
 
      *signo = SIGEMT;
84
 
      detail->code = 0;
85
 
      break;
86
 
 
87
 
    case EXC_SOFTWARE:
88
 
      *signo = SIGEMT;
89
 
      detail->code = 0;
90
 
      break;
91
 
      
92
 
    case EXC_BREAKPOINT:
93
 
      *signo = SIGTRAP;
94
 
      detail->code = 0;
95
 
      break;
96
 
    }
97
 
}