about summary refs log tree commit diff
path: root/stdlib/cxa_atexit.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/cxa_atexit.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/cxa_atexit.c')
-rw-r--r--stdlib/cxa_atexit.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/stdlib/cxa_atexit.c b/stdlib/cxa_atexit.c
index 3bdf871e53..767f08e66b 100644
--- a/stdlib/cxa_atexit.c
+++ b/stdlib/cxa_atexit.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2001,2002,2005,2006,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
@@ -26,13 +26,13 @@
 
 #undef __cxa_atexit
 
-/* Register a function to be called by exit or when a shared library
-   is unloaded.  This function is only called from code generated by
-   the C++ compiler.  */
+
 int
-__cxa_atexit (void (*func) (void *), void *arg, void *d)
+attribute_hidden
+__internal_atexit (void (*func) (void *), void *arg, void *d,
+		   struct exit_function_list **listp)
 {
-  struct exit_function *new = __new_exitfn ();
+  struct exit_function *new = __new_exitfn (listp);
 
   if (new == NULL)
     return -1;
@@ -47,6 +47,16 @@ __cxa_atexit (void (*func) (void *), void *arg, void *d)
   new->flavor = ef_cxa;
   return 0;
 }
+
+
+/* Register a function to be called by exit or when a shared library
+   is unloaded.  This function is only called from code generated by
+   the C++ compiler.  */
+int
+__cxa_atexit (void (*func) (void *), void *arg, void *d)
+{
+  return __internal_atexit (func, arg, d, &__exit_funcs);
+}
 INTDEF(__cxa_atexit)
 
 
@@ -59,7 +69,7 @@ struct exit_function_list *__exit_funcs = &initial;
 uint64_t __new_exitfn_called;
 
 struct exit_function *
-__new_exitfn (void)
+__new_exitfn (struct exit_function_list **listp)
 {
   struct exit_function_list *p = NULL;
   struct exit_function_list *l;
@@ -68,7 +78,7 @@ __new_exitfn (void)
 
   __libc_lock_lock (lock);
 
-  for (l = __exit_funcs; l != NULL; p = l, l = l->next)
+  for (l = *listp; l != NULL; p = l, l = l->next)
     {
       for (i = l->idx; i > 0; --i)
 	if (l->fns[i - 1].flavor != ef_free)
@@ -92,8 +102,8 @@ __new_exitfn (void)
 	    calloc (1, sizeof (struct exit_function_list));
 	  if (p != NULL)
 	    {
-	      p->next = __exit_funcs;
-	      __exit_funcs = p;
+	      p->next = *listp;
+	      *listp = p;
 	    }
 	}