about summary refs log tree commit diff
path: root/stdlib/exit.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-03-08 19:53:12 +0000
committerUlrich Drepper <drepper@redhat.com>2009-03-08 19:53:12 +0000
commit610e67ed5af7e1acf2f96bb964cc2131af570a3d (patch)
tree14daa2846118122a858f3f498a525456a7d74ba0 /stdlib/exit.c
parent130ca12eb3d9b2fec32847699ca08ea25aec9130 (diff)
downloadglibc-610e67ed5af7e1acf2f96bb964cc2131af570a3d.tar.gz
glibc-610e67ed5af7e1acf2f96bb964cc2131af570a3d.tar.xz
glibc-610e67ed5af7e1acf2f96bb964cc2131af570a3d.zip
* stdlib/Makefile (routines): Add quick_exit, at_quick_exit, and
	cxa_at_quick_exit.
	(static-only-routines): Add at_quick_exit.
	* stdlib/Versions: Export quick_exit and __cxa_at_quick_exit for
	GLIBC_2.10.
	* stdlib/quick_exit.c: New file.
	* stdlib/at_quick_exit.c: New file.
	* stdlib/cxa_at_quick_exit.c: New file.
	* stdlib/cxa_atexit.c (__cxa_atexit): Move body to new function.  Call
	it appropriately.
	(__internal_atexit): New function.
	(__new_exitfn): Now takes parameter to point to the list to use.
	* stdlib/cxa_finalize.c: Remove quick_exit handlers, don't call them.
	* stdlib/exit.c (__run_exit_handlers): New function.  Split from...
	(exit): ...here.  Just call __run_exit_handlers appropriately.
	* stdlib/exit.h: Declare __quick_exit_funcs, __run_exit_handlers,
	__internal_atexit, __cxa_at_quick_exit.  Adjust __new_exitfn.
	* stdlib/on_exit.c: Adjust call to __new_exitfn.
	* stdlib/stdlib.h: Declare at_quick_exit and quick_exit.
Diffstat (limited to 'stdlib/exit.c')
-rw-r--r--stdlib/exit.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/stdlib/exit.c b/stdlib/exit.c
index bc4cb0fd08..539ae4bd7e 100644
--- a/stdlib/exit.c
+++ b/stdlib/exit.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,95,96,97,99,2001,2002,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1991,95,96,97,99,2001,2002,2005,2009
+   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
@@ -30,20 +31,22 @@ DEFINE_HOOK (__libc_atexit, (void))
    in the reverse of the order in which they were registered
    perform stdio cleanup, and terminate program execution with STATUS.  */
 void
-exit (int status)
+attribute_hidden
+__run_exit_handlers (int status, struct exit_function_list **listp,
+		     bool run_list_atexit)
 {
   /* We do it this way to handle recursive calls to exit () made by
      the functions registered with `atexit' and `on_exit'. We call
      everyone on the list and use the status value in the last
      exit (). */
-  while (__exit_funcs != NULL)
+  while (*listp != NULL)
     {
-      struct exit_function_list *old;
+      struct exit_function_list *cur = *listp;
 
-      while (__exit_funcs->idx > 0)
+      while (cur->idx > 0)
 	{
 	  const struct exit_function *const f =
-	    &__exit_funcs->fns[--__exit_funcs->idx];
+	    &cur->fns[--cur->idx];
 	  switch (f->flavor)
 	    {
 	      void (*atfct) (void);
@@ -77,16 +80,23 @@ exit (int status)
 	    }
 	}
 
-      old = __exit_funcs;
-      __exit_funcs = __exit_funcs->next;
-      if (__exit_funcs != NULL)
+      *listp = cur->next;
+      if (*listp != NULL)
 	/* Don't free the last element in the chain, this is the statically
 	   allocate element.  */
-	free (old);
+	free (cur);
     }
 
-  RUN_HOOK (__libc_atexit, ());
+  if (run_list_atexit)
+    RUN_HOOK (__libc_atexit, ());
 
   _exit (status);
 }
+
+
+void
+exit (int status)
+{
+  __run_exit_handlers (status, __exit_funcs, true);
+}
 libc_hidden_def (exit)