summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread/uthread_autoinit.c
blob: 1601d2098c985ad3638244bc70b91143e513d492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * David Leonard, 1998. Public Domain. <david.leonard@csee.uq.edu.au>
 *
 * $OpenBSD: uthread_autoinit.c,v 1.11 2003/01/31 04:46:17 marc Exp $
 */


#include <stdio.h>
#include <pthread.h>
#include "pthread_private.h"

/*
 * Use C++'s static instance constructor to initialise threads.
 */
#ifdef __cplusplus
class Init {
public:
	Init() { 
		_thread_init();
	}
};
Init _thread_initialiser;
#endif /* C++ */

/*
 * This construct places the function in the __CTOR_LIST__ entry in the
 * object, and later the collect2 stage of linkage will inform __main (from
 * libgcc.a) to call it.
 */
#if defined(__GNUC__)
extern void _thread_init_constructor(void) __attribute__((constructor));
extern void _GLOBAL_$I$_thread_init_constructor(void);

void
_thread_init_constructor()
{
	_thread_init();
}
#endif /* GNU C */

/*
 * Dummy symbol referenced by uthread_init.o so this compilation unit 
 * is always loaded from archives.
 */
int _thread_autoinit_dummy_decl = 0;