public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jeff Johnston <jjohnstn@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] Builtin enable return code with SYS_EXIT_EXTENDED
Date: Mon, 26 Nov 2018 15:08:00 -0000 [thread overview]
Message-ID: <20181126150817.124529.qmail@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2d6b71ee6d3459658ebe73c5cb262023b86f472e
commit 2d6b71ee6d3459658ebe73c5cb262023b86f472e
Author: Matthew Malcomson <matthew.malcomson@arm.com>
Date: Fri Nov 16 11:45:48 2018 +0000
Builtin enable return code with SYS_EXIT_EXTENDED
A previous commit introduced the ability to use the semi-hosting
SYS_EXIT_EXTENDED operation to libgloss, this commit adds the same
ability to the sys/arm/ backend so that building newlib only will
provide the same capabilities.
Diff:
---
newlib/libc/sys/arm/syscalls.c | 62 +++++++++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 19 deletions(-)
diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c
index 87ddca7..b521074 100644
--- a/newlib/libc/sys/arm/syscalls.c
+++ b/newlib/libc/sys/arm/syscalls.c
@@ -30,7 +30,7 @@ int _stat (const char *, struct stat *);
int _fstat (int, struct stat *);
void * _sbrk (ptrdiff_t);
pid_t _getpid (void);
-int _kill (int, int) __attribute__((__noreturn__));
+int _kill (int, int);
void _exit (int);
int _close (int);
int _swiclose (int);
@@ -49,6 +49,7 @@ static int error (int);
static int get_errno (void);
static int remap_handle (int);
static int findslot (int);
+static int _kill_shared (int, int, int) __attribute__((__noreturn__));
/* Register name faking - works in collusion with the linker. */
register char * stack_ptr asm ("sp");
@@ -424,21 +425,35 @@ _close (int file)
return wrap (_swiclose (file));
}
-int
-_kill (int pid, int sig)
+static int
+_kill_shared (int pid, int sig, int reason)
{
- (void)pid; (void)sig;
+ (void) pid; (void) sig;
#ifdef ARM_RDI_MONITOR
/* Note: The pid argument is thrown away. */
- switch (sig) {
- case SIGABRT:
- do_AngelSWI (AngelSWI_Reason_ReportException,
- (void *) ADP_Stopped_RunTimeError);
- __builtin_unreachable();
- default:
- do_AngelSWI (AngelSWI_Reason_ReportException,
- (void *) ADP_Stopped_ApplicationExit);
- }
+ 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
@@ -446,15 +461,24 @@ _kill (int pid, int sig)
__builtin_unreachable();
}
+int
+_kill (int pid, int sig)
+{
+ if (sig == SIGABRT)
+ _kill_shared (pid, sig, ADP_Stopped_RunTimeError);
+ else
+ _kill_shared (pid, sig, ADP_Stopped_ApplicationExit);
+}
+
void
_exit (int status)
{
- /* There is only one SWI for both _exit and _kill. For _exit, call
- the SWI with the second argument set to -1, an invalid value for
- signum, so that the SWI handler can distinguish the two calls.
- Note: The RDI implementation of _kill throws away both its
- arguments. */
- _kill(status, -1);
+ /* The same SWI is used for both _exit and _kill.
+ For _exit, call the SWI with "reason" set to ADP_Stopped_ApplicationExit
+ to mark a standard exit.
+ Note: The RDI implementation of _kill_shared throws away all its
+ arguments and all implementations ignore the first argument. */
+ _kill_shared (-1, status, ADP_Stopped_ApplicationExit);
}
pid_t
reply other threads:[~2018-11-26 15:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181126150817.124529.qmail@sourceware.org \
--to=jjohnstn@sourceware.org \
--cc=newlib-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).