1 /* 2 * David Leonard, 1998. Public Domain. <david.leonard@csee.uq.edu.au> 3 * 4 * $MirOS: src/lib/libpthread/uthread/uthread_autoinit.c,v 1.2 2013/10/31 20:06:38 tg Exp $ 5 * $OpenBSD: uthread_autoinit.c,v 1.12 2003/01/31 18:48:03 marc Exp $ 6 */ 7 8 9 #include <stdio.h> 10 #include <pthread.h> 11 #include "pthread_private.h" 12 13 /* 14 * Use C++'s static instance constructor to initialise threads. 15 */ 16 #ifdef __cplusplus 17 class Init { 18 public: Init()19 Init() { 20 _thread_init(); 21 } 22 }; 23 Init _thread_initialiser; 24 #endif /* C++ */ 25 26 /* 27 * This construct places the function in the __CTOR_LIST__ entry in the 28 * object, and later the collect2 stage of linkage will inform __main (from 29 * libgcc.a) to call it. 30 */ 31 #if defined(__GNUC__) 32 extern void _thread_init_constructor(void) __attribute__((__constructor__)); 33 34 void _thread_init_constructor()35_thread_init_constructor() 36 { 37 _thread_init(); 38 } 39 #endif /* GNU C */ 40 41 /* 42 * Dummy symbol referenced by uthread_init.o so this compilation unit 43 * is always loaded from archives. 44 */ 45 int _thread_autoinit_dummy_decl = 0; 46 47