summaryrefslogtreecommitdiff
path: root/lib/libc_r/uthread
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1998-12-10 00:33:55 +0000
committerDavid Leonard <d@cvs.openbsd.org>1998-12-10 00:33:55 +0000
commit2ae7d9d676817895acb58a95f45ed88e4626c04d (patch)
tree93e88f6dac31d3d18da4591080f494ff3f158769 /lib/libc_r/uthread
parentac86a0e364b3332ce6c007a699a31f788a636999 (diff)
split automatic init into own file
Diffstat (limited to 'lib/libc_r/uthread')
-rw-r--r--lib/libc_r/uthread/Makefile.inc5
-rw-r--r--lib/libc_r/uthread/uthread_autoinit.c53
-rw-r--r--lib/libc_r/uthread/uthread_init.c18
3 files changed, 56 insertions, 20 deletions
diff --git a/lib/libc_r/uthread/Makefile.inc b/lib/libc_r/uthread/Makefile.inc
index 196cddca170..62b4c96a931 100644
--- a/lib/libc_r/uthread/Makefile.inc
+++ b/lib/libc_r/uthread/Makefile.inc
@@ -1,5 +1,5 @@
-# $Id: Makefile.inc,v 1.2 1998/11/09 03:13:18 d Exp $
-# $OpenBSD: Makefile.inc,v 1.2 1998/11/09 03:13:18 d Exp $
+# $Id: Makefile.inc,v 1.3 1998/12/10 00:33:54 d Exp $
+# $OpenBSD: Makefile.inc,v 1.3 1998/12/10 00:33:54 d Exp $
# uthread sources
.PATH: ${.CURDIR}/uthread
@@ -17,6 +17,7 @@ SRCS+= \
uthread_attr_setdetachstate.c \
uthread_attr_setstackaddr.c \
uthread_attr_setstacksize.c \
+ uthread_autoinit.c \
uthread_bind.c \
uthread_clean.c \
uthread_close.c \
diff --git a/lib/libc_r/uthread/uthread_autoinit.c b/lib/libc_r/uthread/uthread_autoinit.c
new file mode 100644
index 00000000000..6cebea471ac
--- /dev/null
+++ b/lib/libc_r/uthread/uthread_autoinit.c
@@ -0,0 +1,53 @@
+
+#include <stdio.h>
+#include <pthread.h>
+#include "pthread_private.h"
+
+extern void _thread_init __P((void));
+
+#ifdef __cplusplus
+/*
+ * Use C++ static initialiser
+ */
+class Init {
+public:
+ Init() { _thread_init(); }
+};
+Init _thread_initialiser;
+#endif /* C++ */
+
+/*
+ * a.out ld.so initialisation
+ */
+extern void _thread_dot_init __P((void)) asm(".init");
+void
+_thread_dot_init()
+{
+ _thread_init();
+}
+
+#ifdef mips
+/*
+ * elf ld.so initialisation
+ */
+extern int _init() __attribute__((constructor,section (".dynamic")));
+int
+_init()
+{
+ _thread_init();
+ return 0;
+}
+#endif /* mips */
+
+#ifdef _GNUC_
+/*
+ * GNU CTOR_LIST constructor
+ */
+void _thread_init_constructor __P((void)) __attribute__((constructor));
+void
+_thread_init_constructor()
+{
+ _thread_init();
+}
+#endif /* GNU C */
+
diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c
index 84148b4f567..e25a70c0afa 100644
--- a/lib/libc_r/uthread/uthread_init.c
+++ b/lib/libc_r/uthread/uthread_init.c
@@ -296,22 +296,4 @@ _thread_init(void)
return;
}
-
-/*
- * Use the a.out .init symbol to start the thread package going
- */
-extern void __init_threads __P((void)) asm(".init");
-void __init_threads() {
- _thread_init();
-}
-
-/*
- * Use elf's ld.so _init symbol to start the thread package going
- */
-extern int _init __P((void));
-int _init() {
- _thread_init();
- return 0;
-}
-
#endif _THREAD_SAFE