2007-02-18 12:40:09 +01:00
|
|
|
$NetBSD: patch-ag,v 1.6 2007/02/18 11:40:10 wiz Exp $
|
2002-08-01 15:36:08 +02:00
|
|
|
|
2007-02-18 12:40:09 +01:00
|
|
|
--- pth_lib.c.orig 2006-06-08 17:54:03.000000000 +0000
|
2002-08-01 15:36:08 +02:00
|
|
|
+++ pth_lib.c
|
2003-05-02 13:49:47 +02:00
|
|
|
@@ -37,10 +37,11 @@ long pth_version(void)
|
2002-08-01 15:36:08 +02:00
|
|
|
|
|
|
|
/* implicit initialization support */
|
|
|
|
intern int pth_initialized = FALSE;
|
|
|
|
+intern int pth_explicit_initialize = FALSE;
|
|
|
|
#if cpp
|
|
|
|
#define pth_implicit_init() \
|
|
|
|
if (!pth_initialized) \
|
|
|
|
- pth_init();
|
2003-05-02 13:49:47 +02:00
|
|
|
+ pth__init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PTH_EX
|
|
|
|
@@ -55,19 +56,13 @@ static void pth_ex_terminate(ex_t *ex)
|
|
|
|
}
|
2002-08-01 15:36:08 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
-/* initialize the package */
|
|
|
|
-int pth_init(void)
|
2003-05-02 13:49:47 +02:00
|
|
|
+int pth__init(void)
|
2002-08-01 15:36:08 +02:00
|
|
|
{
|
|
|
|
pth_attr_t t_attr;
|
|
|
|
|
|
|
|
- /* support for implicit initialization calls
|
|
|
|
- and to prevent multiple explict initialization, too */
|
|
|
|
- if (pth_initialized)
|
2003-05-02 13:49:47 +02:00
|
|
|
- return pth_error(FALSE, EPERM);
|
2002-08-01 15:36:08 +02:00
|
|
|
- else
|
|
|
|
- pth_initialized = TRUE;
|
|
|
|
+ pth_initialized = TRUE;
|
|
|
|
|
|
|
|
- pth_debug1("pth_init: enter");
|
|
|
|
+ pth_debug1("pth__init: enter");
|
|
|
|
|
2003-05-02 13:49:47 +02:00
|
|
|
/* initialize syscall wrapping */
|
|
|
|
pth_syscall_init();
|
|
|
|
@@ -131,10 +126,29 @@ int pth_init(void)
|
2002-08-01 15:36:08 +02:00
|
|
|
pth_mctx_switch(&pth_main->mctx, &pth_sched->mctx);
|
|
|
|
|
|
|
|
/* came back, so let's go home... */
|
|
|
|
- pth_debug1("pth_init: leave");
|
|
|
|
+ pth_debug1("pth__init: leave");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/* initialize the package */
|
|
|
|
+int pth_init(void)
|
|
|
|
+{
|
|
|
|
+ int rv;
|
|
|
|
+
|
|
|
|
+ /* support for implicit initialization calls
|
|
|
|
+ and to prevent multiple explict initialization, too */
|
|
|
|
+ if (pth_initialized) {
|
|
|
|
+ /* if we've already explicitly initialized then error */
|
|
|
|
+ if (pth_explicit_initialize)
|
2003-05-02 13:49:47 +02:00
|
|
|
+ return pth_error(FALSE, EPERM);
|
2002-10-14 13:49:54 +02:00
|
|
|
+ rv = TRUE;
|
2002-08-01 15:36:08 +02:00
|
|
|
+ } else {
|
|
|
|
+ rv = pth__init();
|
|
|
|
+ pth_explicit_initialize = TRUE;
|
|
|
|
+ }
|
2002-10-14 13:49:54 +02:00
|
|
|
+ return rv;
|
2002-08-01 15:36:08 +02:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* kill the package internals */
|
|
|
|
int pth_kill(void)
|
|
|
|
{
|
2007-02-18 12:40:09 +01:00
|
|
|
@@ -146,6 +160,7 @@ int pth_kill(void)
|
2002-08-01 15:36:08 +02:00
|
|
|
pth_thread_cleanup(pth_main);
|
|
|
|
pth_scheduler_kill();
|
|
|
|
pth_initialized = FALSE;
|
|
|
|
+ pth_explicit_initialize = FALSE;
|
|
|
|
pth_tcb_free(pth_sched);
|
|
|
|
pth_tcb_free(pth_main);
|
2003-05-02 13:49:47 +02:00
|
|
|
pth_syscall_kill();
|