summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>1996-02-17 02:19:37 +0000
committerjdp <jdp@FreeBSD.org>1996-02-17 02:19:37 +0000
commit448ae4843b7fbbfdcdd3aa4af331e67f206898d0 (patch)
tree412527a2ab9060dadeba81b4bd75f9f0bda285a7 /lib/libkse/thread
parentfb73b6f0d595f0cdc9e9387cd6a0e3dfbdfcf60e (diff)
downloadFreeBSD-src-448ae4843b7fbbfdcdd3aa4af331e67f206898d0.zip
FreeBSD-src-448ae4843b7fbbfdcdd3aa4af331e67f206898d0.tar.gz
Added a new module "uthread_autoinit.cc". This is a small C++ module.
It uses a static constructor to call _thread_init() at program start-up time. That eliminates the need for any initialization hooks in crt0.o. Added a symbol reference in "uthread_init.c", to ensure that the new module will always be pulled in when the archive version of the library is used. In "Makefile.inc", defined CPLUSPLUSLIB, so that the constructor will be properly invoked in the shared library. Suggested by: Christopher Provenzano, Peter Wemm, and others.
Diffstat (limited to 'lib/libkse/thread')
-rw-r--r--lib/libkse/thread/Makefile.inc5
-rw-r--r--lib/libkse/thread/thr_init.c12
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/libkse/thread/Makefile.inc b/lib/libkse/thread/Makefile.inc
index a3f6ff9..f37a21f 100644
--- a/lib/libkse/thread/Makefile.inc
+++ b/lib/libkse/thread/Makefile.inc
@@ -1,4 +1,6 @@
-# $Id$
+# $Id: Makefile.inc,v 1.1 1996/01/22 00:23:03 julian Exp $
+
+CPLUSPLUSLIB= cpluspluslib
# uthread sources
.PATH: ${.CURDIR}/uthread
@@ -6,6 +8,7 @@
SRCS+= \
uthread_accept.c \
uthread_attr_setcreatesuspend.c \
+ uthread_autoinit.cc \
uthread_bind.c \
uthread_clean.c \
uthread_close.c \
diff --git a/lib/libkse/thread/thr_init.c b/lib/libkse/thread/thr_init.c
index d044063..6139935 100644
--- a/lib/libkse/thread/thr_init.c
+++ b/lib/libkse/thread/thr_init.c
@@ -202,6 +202,18 @@ _thread_main(int argc, char *argv[], char *env)
_thread_init();
return (main(argc, argv, env));
}
+#else
+/*
+ * Force our auto-initialization module to be pulled in from the library,
+ * by referencing a symbol that is defined in it.
+ *
+ * The auto-initialization module is a small C++ module. It has a static
+ * constructor that calls _thread_init() automatically, at the beginning
+ * of program execution. That eliminates the need for any special hooks
+ * in crt0.o.
+ */
+extern int _thread_autoinit_dummy_decl;
+static int *_thread_autoinit_dummy_ref = &_thread_autoinit_dummy_decl;
#endif
#else
/*
OpenPOWER on IntegriCloud