PERFORCE change 69957 for review
David Xu
davidxu at FreeBSD.org
Sat Jan 29 23:37:53 PST 2005
http://perforce.freebsd.org/chv.cgi?CH=69957
Change 69957 by davidxu at davidxu_tiger on 2005/01/30 07:37:21
Merge thr_autoinit.c
Affected files ...
.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#10 edit
Differences ...
==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_init.c#10 (text+ko) ====
@@ -72,8 +72,7 @@
int __pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
int __pthread_mutex_lock(pthread_mutex_t *);
int __pthread_mutex_trylock(pthread_mutex_t *);
-void _thread_init_hack(void);
-extern int _thread_state_running;
+void _thread_init_hack(void) __attribute__ ((constructor));
static void init_private(void);
static void init_main_thread(struct pthread *thread);
@@ -195,7 +194,29 @@
{DUAL_ENTRY(_pthread_sigmask)} /* PJT_SIGMASK */
};
-static int init_once = 0;
+extern int _thread_state_running;
+static int init_once = 0;
+
+/*
+ * 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
+ * the archive library at link time. To accomplish that, we define and
+ * initialize a variable, "_thread_autoinit_dummy_decl". This variable is
+ * 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.
+ */
+extern int _thread_autoinit_dummy_decl;
+int _thread_autoinit_dummy_decl = 0;
+
+void
+_thread_init_hack(void)
+{
+
+ _libpthread_init(NULL);
+}
+
/*
* Threaded process initialization.
@@ -357,11 +378,11 @@
size_t len;
int mib[2];
- umtx_init(&_mutex_static_lock);
- umtx_init(&_cond_static_lock);
- umtx_init(&_rwlock_static_lock);
- umtx_init(&_keytable_lock);
- umtx_init(&_thr_atfork_lock);
+ _thr_umtx_init(&_mutex_static_lock);
+ _thr_umtx_init(&_cond_static_lock);
+ _thr_umtx_init(&_rwlock_static_lock);
+ _thr_umtx_init(&_keytable_lock);
+ _thr_umtx_init(&_thr_atfork_lock);
_thr_spinlock_init();
_thr_list_init();
More information about the p4-projects
mailing list