aboutsummaryrefslogtreecommitdiff
path: root/libgloss/arm/_kill.c
blob: 69f9856537a9312ff4d6bc1ccdca38e22e7de50f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <_ansi.h>
#include <signal.h>
#include "swi.h"

int _kill_shared (int, int, int) __attribute__((__noreturn__));
int _kill (int, int);

int
_kill (int pid, int sig)
{
  if (sig == SIGABRT)
    _kill_shared (pid, sig, ADP_Stopped_RunTimeError);
  else
    _kill_shared (pid, sig, ADP_Stopped_ApplicationExit);
}

int
_kill_shared (int pid, int sig, int reason)
{
  (void) pid; (void) sig;
#ifdef ARM_RDI_MONITOR
  /* Note: The pid argument is thrown away.  */
  int block[2];
  block[1] = sig;
  block[0] = reason;
  int insn;

#if SEMIHOST_V2
  if (_has_ext_exit_extended ())
    {
      insn = AngelSWI_Reason_ReportExceptionExtended;
    }
  else
#endif
    {
      insn = AngelSWI_Reason_ReportException;
    }

#if SEMIHOST_V2
if (_has_ext_exit_extended ())
  do_AngelSWI (insn, block);
else
#endif
  do_AngelSWI (insn, (void*)block[0]);

#else
  asm ("swi %a0" :: "i" (SWI_Exit));
#endif

  __builtin_unreachable();
}