summaryrefslogtreecommitdiffstats
path: root/lib/libc_r
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-05-11 08:13:42 +0000
committeralfred <alfred@FreeBSD.org>2002-05-11 08:13:42 +0000
commit7124e5c22328527f1d26b9c57ac87be19a5e96ea (patch)
treee368c183c3cfc675a31d5b74642dc275259e29e3 /lib/libc_r
parent4cc86e854d8ac81cc5fc7184e53cf23f622e0fd5 (diff)
downloadFreeBSD-src-7124e5c22328527f1d26b9c57ac87be19a5e96ea.zip
FreeBSD-src-7124e5c22328527f1d26b9c57ac87be19a5e96ea.tar.gz
Use GCC's __attribute__ ((constructor)) mechanism to invoke the pthread
startup code rather than a static C++ object since c++ seems to be broken. This doesn't seem to work for staticically linked program just yet, I'll give that some more work when I get a chance.
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/uthread/Makefile.inc2
-rw-r--r--lib/libc_r/uthread/uthread_autoinit.c (renamed from lib/libc_r/uthread/uthread_autoinit.cc)42
2 files changed, 8 insertions, 36 deletions
diff --git a/lib/libc_r/uthread/Makefile.inc b/lib/libc_r/uthread/Makefile.inc
index 1ec09c5..f9ee7f6 100644
--- a/lib/libc_r/uthread/Makefile.inc
+++ b/lib/libc_r/uthread/Makefile.inc
@@ -29,7 +29,7 @@ SRCS+= \
uthread_attr_setscope.c \
uthread_attr_setstackaddr.c \
uthread_attr_setstacksize.c \
- uthread_autoinit.cc \
+ uthread_autoinit.c \
uthread_bind.c \
uthread_cancel.c \
uthread_cap_get_fd.c \
diff --git a/lib/libc_r/uthread/uthread_autoinit.cc b/lib/libc_r/uthread/uthread_autoinit.c
index b04caff..31e2d48 100644
--- a/lib/libc_r/uthread/uthread_autoinit.cc
+++ b/lib/libc_r/uthread/uthread_autoinit.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2002 Alfred Perlstein <alfred@freebsd.org>.
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
*
@@ -33,41 +34,20 @@
*/
/*
- * This module uses the magic of C++ static constructors to initialize the
+ * This module uses GCC extentions to initialize the
* threads package at program start-up time.
- *
- * Note: Because of a bug in certain versions of "/usr/lib/c++rt0.o", you
- * should _not_ enclose the body of this module in an "#ifdef _THREAD_SAFE"
- * conditional.
*/
-extern "C" void _thread_init(void);
-
-/*
- * First, we declare a class with a constructor.
- */
-class _thread_init_invoker {
-public:
- _thread_init_invoker(); /* Constructor declaration. */
-};
+void _thread_init_hack(void) __attribute__ ((constructor));
-/*
- * Here is the definition of the constructor. All it does is call the
- * threads initialization function, "_thread_init".
- */
-_thread_init_invoker::_thread_init_invoker()
+void
+_thread_init_hack(void)
{
+
_thread_init();
}
/*
- * Here is a single, static instance of our "_thread_init_invoker" class.
- * The mere existance of this instance will result in its constructor
- * being called, automatically, at program start-up time.
- */
-static _thread_init_invoker the_thread_init_invoker;
-
-/*
* For the shared version of the threads library, the above is sufficient.
* But for the archive version of the library, we need a little bit more.
* Namely, we must arrange for this particular module to be pulled in from
@@ -76,14 +56,6 @@ static _thread_init_invoker the_thread_init_invoker;
* referenced (as an extern) from libc/stdlib/exit.c. This will always
* create a need for this module, ensuring that it is present in the
* executable.
- *
- * We know that, if the user does _anything_ at all with threads, then the
- * "uthread_init.c" module will be linked in. That is the case because
- * "uthread_init.c" is the module that defines all of the global variables
- * used by the threads library. The presence of "uthread_init.c" will, in
- * turn, force this module to be linked in. And the presence of this module
- * in the executable will result in the constructor being invoked, and
- * "_thread_init" being called.
*/
-extern "C" int _thread_autoinit_dummy_decl; /* Declare with "C" linkage */
+extern int _thread_autoinit_dummy_decl;
int _thread_autoinit_dummy_decl = 0;
OpenPOWER on IntegriCloud