summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/nios/crtend.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-07-16 11:09:34 +0000
committerEric Andersen <andersen@codepoet.org>2004-07-16 11:09:34 +0000
commitc3d50a69839f8d80fc7244fde6e4a57e5e39dd36 (patch)
treec9e27baac7541384b806cce0845f28c1f59b5a2e /libc/sysdeps/linux/nios/crtend.c
parent3cf731bf40f153a73373798085d1f45a80b972d6 (diff)
Pete Popov writes:
Hi Erik, I'm not sure why the NIOS support is not in uClibc -- perhaps the patch was rejected or never submitted? In any case, I'm playing with some NIOS stuff and created this patch against 0.9.26. The work was done by Microtronix. I'm not sure who else contributed to it. It would be great to have the NIOS support available in uClibc so developers don't have to go searching for these bits. Pete
Diffstat (limited to 'libc/sysdeps/linux/nios/crtend.c')
-rw-r--r--libc/sysdeps/linux/nios/crtend.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/nios/crtend.c b/libc/sysdeps/linux/nios/crtend.c
new file mode 100644
index 000000000..26af229af
--- /dev/null
+++ b/libc/sysdeps/linux/nios/crtend.c
@@ -0,0 +1,43 @@
+#include <errno.h>
+#include <stdlib.h>
+/*
+static void (*__CTOR_END__[1]) __P((void))
+ __attribute__((section(".ctors"))) = { (void *)-1 };
+
+static void (*__DTOR_END__[1]) __P((void))
+ __attribute__((__unused__))
+ __attribute__((section(".dtors"))) = { (void *)0 };
+*/
+extern void (*__CTOR_END__[]) __P((void));
+static void __do_global_ctors_aux __P((void));
+
+static void
+__do_global_ctors_aux()
+{
+ void (**p)(void) = __CTOR_END__ - 1;
+
+ while (*p)
+ (**p--)();
+}
+
+static void dummy_init(void) __attribute__((section(".trash")));
+
+void
+dummy_init(void)
+{
+ static int initialized = 0;
+ static void (*volatile call__ctors)(void) = __do_global_ctors_aux;
+ /*
+ * Call global constructors.
+ * Arrange to call global destructors at exit.
+ */
+ /* prevent function pointer constant propagation */
+ __asm__ __volatile__ (".section .init");
+
+ if (!initialized) {
+ initialized = 1;
+ (*call__ctors)();
+ }
+ __asm__ __volatile__ (".section .trash");
+
+} \ No newline at end of file