Skip to content

Commit 032100b

Browse files
committed
devkitPPC: call destructors
1 parent d051cd5 commit 032100b

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

dkppc/patches/newlib-4.3.0.20230120.patch

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10065,6 +10065,45 @@ index df966f929..106d99e94 100644
1006510065
#include <_ansi.h>
1006610066
#include <reent.h>
1006710067
#include <newlib.h>
10068+
diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c
10069+
index 710440389..985e720bf 100644
10070+
--- a/newlib/libc/stdlib/__call_atexit.c
10071+
+++ b/newlib/libc/stdlib/__call_atexit.c
10072+
@@ -21,6 +21,7 @@ struct _atexit *__atexit = _NULL;
10073+
10074+
#ifdef _WANT_REGISTER_FINI
10075+
10076+
+#if 0
10077+
/* If "__libc_fini" is defined, finalizers (either
10078+
"__libc_fini_array", or "_fini", as appropriate) will be run after
10079+
all user-specified atexit handlers. For example, you can define
10080+
@@ -36,6 +37,7 @@ struct _atexit *__atexit = _NULL;
10081+
used with multiple BSPs, some of which register finalizers from
10082+
startup code, while others defer to the C library. */
10083+
extern char __libc_fini __attribute__((weak));
10084+
+#endif
10085+
10086+
/* Register the application finalization function with atexit. These
10087+
finalizers should run last. Therefore, we want to call atexit as
10088+
@@ -46,6 +48,7 @@ register_fini(void) __attribute__((constructor (0)));
10089+
static void
10090+
register_fini(void)
10091+
{
10092+
+#if 0
10093+
if (&__libc_fini) {
10094+
#ifdef _HAVE_INITFINI_ARRAY
10095+
extern void __libc_fini_array (void);
10096+
@@ -55,6 +58,10 @@ register_fini(void)
10097+
atexit (_fini);
10098+
#endif
10099+
}
10100+
+#else
10101+
+ extern void __fini (void);
10102+
+ atexit (__fini);
10103+
+#endif
10104+
}
10105+
10106+
#endif /* _WANT_REGISTER_FINI */
1006810107
diff --git a/newlib/libc/stdlib/mlock.c b/newlib/libc/stdlib/mlock.c
1006910108
index 23aa10173..ba88eb9fb 100644
1007010109
--- a/newlib/libc/stdlib/mlock.c

dkppc/scripts/build-gcc.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ then
144144
--target=$target \
145145
--prefix=$prefix \
146146
--enable-newlib-mb \
147+
--enable-newlib-register-fini \
147148
|| { echo "Error configuring newlib"; exit 1; }
148149
touch configured-newlib
149150
fi

0 commit comments

Comments
 (0)