5 #include "lwp_threads.h"
8 struct _reent libc_globl_reent
;
10 extern void _wrapup_reent(struct _reent
*);
11 extern void _reclaim_reent(struct _reent
*);
13 int __libc_create_hook(lwp_cntrl
*curr_thr
,lwp_cntrl
*create_thr
)
15 create_thr
->libc_reent
= NULL
;
19 int __libc_start_hook(lwp_cntrl
*curr_thr
,lwp_cntrl
*start_thr
)
23 ptr
= (struct _reent
*)calloc(1,sizeof(struct _reent
));
27 _REENT_INIT_PTR((ptr
));
30 start_thr
->libc_reent
= ptr
;
34 int __libc_delete_hook(lwp_cntrl
*curr_thr
, lwp_cntrl
*delete_thr
)
38 if(curr_thr
==delete_thr
)
41 ptr
= (struct _reent
*)delete_thr
->libc_reent
;
43 if(ptr
&& ptr
!=&libc_globl_reent
) {
48 delete_thr
->libc_reent
= 0;
50 if(curr_thr
==delete_thr
) _REENT
= 0;
55 void __libc_init(int reentrant
)
57 libc_globl_reent
= (struct _reent
)_REENT_INIT((libc_globl_reent
));
58 _REENT
= &libc_globl_reent
;
61 __lwp_thread_setlibcreent((void*)&_REENT
);
62 libc_reentrant
= reentrant
;
68 if(!__sys_state_up(__sys_state_get())) return;
69 if(_REENT
!=&libc_globl_reent
) {
70 _wrapup_reent(&libc_globl_reent
);
71 _REENT
= &libc_globl_reent
;