delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/11/29/11:05:00

Date: Fri, 29 Nov 2002 15:29:19 +0000
From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
Sender: rich AT phekda DOT freeserve DOT co DOT uk
To: djgpp-workers AT delorie DOT com
X-Mailer: Emacs 21.3.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
Subject: _Exit function, revision 2 [PATCH]
Message-Id: <E18Hn1C-0000se-00@phekda.freeserve.co.uk>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Here's a new revision of the _Exit function patch:

* Code now goes under ansi/c99/stdlib.
* Code is now an assembler stub.
* Test program included.

OK to commit?

Thanks, bye, Rich =]

Index: include/stdlib.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/stdlib.h,v
retrieving revision 1.12
diff -p -u -3 -r1.12 stdlib.h
--- include/stdlib.h	17 Oct 2002 23:00:24 -0000	1.12
+++ include/stdlib.h	29 Nov 2002 15:20:49 -0000
@@ -46,6 +46,7 @@ __DJ_wchar_t
 #define _WCHAR_T
 #endif
 
+void	_Exit(int _status) __attribute__((noreturn));
 void	abort(void) __attribute__((noreturn));
 int	abs(int _i);
 int	atexit(void (*_func)(void));
Index: wc204.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc204.txi,v
retrieving revision 1.121
diff -p -u -3 -r1.121 wc204.txi
--- wc204.txi	28 Nov 2002 09:06:29 -0000	1.121
+++ wc204.txi	29 Nov 2002 15:23:20 -0000
@@ -782,3 +782,6 @@ The @code{int_n_cs_precedes}, @code{int_
 @code{int_n_sign_posn}, @code{int_p_cs_precedes},
 @code{int_p_sep_by_space} and @code{int_p_sign_posn} members were added
 to @code{struct lconv}, to comply with the C99 standard.
+
+@findex _Exit
+The function @code{_Exit} was added.
--- /dev/null	2002-11-29 15:25:11.000000000 +0000
+++ src/libc/ansi/c99/stdlib/makefile	2002-11-29 15:10:24.000000000 +0000
@@ -0,0 +1,6 @@
+# Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details
+TOP=../../..
+
+SRC += _exit.S
+
+include $(TOP)/../makefile.inc
--- /dev/null	2002-11-29 15:25:11.000000000 +0000
+++ src/libc/ansi/c99/stdlib/_exit.S	2002-11-29 15:10:12.000000000 +0000
@@ -0,0 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
+	.global	__Exit
+__Exit:
+	jmp	__exit
--- /dev/null	2002-11-29 15:25:11.000000000 +0000
+++ src/libc/ansi/c99/stdlib/_exit.txh	2002-11-28 11:30:54.000000000 +0000
@@ -0,0 +1,36 @@
+@node _Exit, process
+@subheading Syntax
+
+@example
+#include <stdlib.h>
+
+void _Exit(int exit_code);
+@end example
+
+@subheading Description
+
+This function exits the program, returning @var{exit_code} to the
+calling process.  No additional processing (such as closing file
+descriptors or calls to the static destructor functions) is done, and
+any @code{atexit} functions are not called; only the hardware interrupt
+handlers are unhooked, to prevent system crashes.
+
+@subheading Return Value
+
+This function does not return.
+
+@subheading Portability
+
+@portability !ansi-c89, ansi-c99, !posix-1003.2-1992, posix-1003.1-2001
+
+@port-note ansi-c99 Depending on the implementation, @code{_Exit} may do the additional processing described above.
+
+@subheading Example
+
+@example
+if (argc < 4)
+@{
+  print_usage();
+  _Exit(1);
+@}
+@end example
--- /dev/null	2002-11-29 15:25:11.000000000 +0000
+++ tests/libc/ansi/c99/stdlib/makefile	2002-11-29 15:19:32.000000000 +0000
@@ -0,0 +1,5 @@
+TOP=../../..
+
+SRC += t-_exit.c
+
+include $(TOP)/../makefile.inc
--- /dev/null	2002-11-29 15:25:11.000000000 +0000
+++ tests/libc/ansi/c99/stdlib/t-_exit.c	2002-11-29 15:22:34.000000000 +0000
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+oops (void)
+{
+  puts("Oops. This shouldn't be happening.");
+}
+
+int
+main (void)
+{
+  atexit(oops);
+
+  _Exit(EXIT_SUCCESS);
+
+  /* Shouldn't be reached! */
+  puts("Well, what's happened here, I wonder?");
+  return(EXIT_FAILURE);
+}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019