This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/3] Move __atexit_lock definition

Patch checked in.

-- Jeff J.

On 05/04/2013 10:11 AM, Sebastian Huber wrote:
Interchange declaration and definition of __atexit_lock.  If someone
calls exit() there is no need to pull in atexit().  If someone calls
atexit() he expects that someone also uses exit() to invoke the
registered handler.

2013-05-04  Sebastian Huber <>

	* libc/stdlib/__atexit.c (__atexit_lock): Declare.
	* libc/stdlib/__call_atexit.c (__atexit_lock): Define.
  newlib/libc/stdlib/__atexit.c      |    5 ++++-
  newlib/libc/stdlib/__call_atexit.c |    4 +---
  2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/newlib/libc/stdlib/__atexit.c b/newlib/libc/stdlib/__atexit.c
index 4687d00..1caf2e5 100644
--- a/newlib/libc/stdlib/__atexit.c
+++ b/newlib/libc/stdlib/__atexit.c
@@ -10,7 +10,10 @@

  /* Make this a weak reference to avoid pulling in malloc.  */
  void * malloc(size_t) _ATTRIBUTE((__weak__));
-__LOCK_INIT_RECURSIVE(, __atexit_lock);
+#ifndef __SINGLE_THREAD__
+extern _LOCK_RECURSIVE_T __atexit_lock;

   * Register a function to be performed at exit or on shared library unload.
diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c
index 4c45063..a21dd57 100644
--- a/newlib/libc/stdlib/__call_atexit.c
+++ b/newlib/libc/stdlib/__call_atexit.c
@@ -11,9 +11,7 @@
  /* Make this a weak reference to avoid pulling in free.  */
  void free(void *) _ATTRIBUTE((__weak__));

-#ifndef __SINGLE_THREAD__
-extern _LOCK_RECURSIVE_T __atexit_lock;
+__LOCK_INIT_RECURSIVE(, __atexit_lock);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]