[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2491] patch #8556: Fix atexit.c - make atexit work
From: |
Senthil Kumar Selvaraj |
Subject: |
[avr-libc-commit] [2491] patch #8556: Fix atexit.c - make atexit work |
Date: |
Wed, 07 Oct 2015 07:02:24 +0000 |
Revision: 2491
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2491
Author: saaadhu
Date: 2015-10-07 07:02:22 +0000 (Wed, 07 Oct 2015)
Log Message:
-----------
patch #8556: Fix atexit.c - make atexit work
Ticket Links:
------------
http://savannah.gnu.org/patch/?8556
Modified Paths:
--------------
trunk/avr-libc/ChangeLog
trunk/avr-libc/NEWS
trunk/avr-libc/libc/stdlib/atexit.c
Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog 2015-10-06 12:45:41 UTC (rev 2490)
+++ trunk/avr-libc/ChangeLog 2015-10-07 07:02:22 UTC (rev 2491)
@@ -1,3 +1,12 @@
+2015-10-07 Georg-Johann Lay <address@hidden>
+
+ patch #8556: Fix atexit.c
+ * libc/stdlib/atexit.c (__atexit_fini): Rename to...
+ (atexit_fini): ...this. Make static, naked, and used.
+ Move to section .fini8. Outsource worker code to...
+ (atexit_finido): ...this new function.
+ (atexit_p): Renamed from __atexit_p. Make static.
+
2015-10-06 Georg-Johann Lay <address@hidden>
patch #8728: Use __extension__ with long long
Modified: trunk/avr-libc/NEWS
===================================================================
--- trunk/avr-libc/NEWS 2015-10-06 12:45:41 UTC (rev 2490)
+++ trunk/avr-libc/NEWS 2015-10-07 07:02:22 UTC (rev 2491)
@@ -41,6 +41,7 @@
Mapping Enable bit (EEMAPEN)
[#8731] Header file for atmega644a
[#8728] Use __extension__ with long long
+ [#8556] Fix atexit.c
* Other changes:
Modified: trunk/avr-libc/libc/stdlib/atexit.c
===================================================================
--- trunk/avr-libc/libc/stdlib/atexit.c 2015-10-06 12:45:41 UTC (rev 2490)
+++ trunk/avr-libc/libc/stdlib/atexit.c 2015-10-07 07:02:22 UTC (rev 2491)
@@ -28,7 +28,11 @@
#include <stdlib.h>
-struct atexit_s { void (*fun) (void); struct atexit_s *next; } *__atexit_p;
+static struct atexit_s
+{
+ void (*fun) (void);
+ struct atexit_s *next;
+} *atexit_p;
int
atexit (void (*fun) (void))
@@ -37,18 +41,30 @@
if (!new_as)
return 1;
new_as->fun = fun;
- new_as->next = __atexit_p;
- __atexit_p = new_as;
+ new_as->next = atexit_p;
+ atexit_p = new_as;
return 0;
}
-void __attribute__((section(".fini6a")))
-__atexit_fini (void)
+/* Don't inline this code as naked to arrange for the very unlikely case
+ that it needs a frame. This won't work as naked function. */
+
+static void __attribute__((__noinline__))
+atexit_finido (void)
{
- while (__atexit_p)
+ while (atexit_p)
{
- void (*fun) (void) = __atexit_p->fun;
- __atexit_p = __atexit_p->next;
+ void (*fun) (void) = atexit_p->fun;
+ atexit_p = atexit_p->next;
(*fun) ();
}
}
+
+/* Run functions registered by atexit in .fini8 so that they are
+ sequenced before static destructors which run in .fini6. */
+
+static void __attribute__((__naked__, __used__, __section__(".fini8")))
+atexit_fini (void)
+{
+ atexit_finido ();
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2491] patch #8556: Fix atexit.c - make atexit work,
Senthil Kumar Selvaraj <=