|
1 | 1 | #include "thread.h" |
2 | 2 |
|
| 3 | +<<<<<<< thread.c |
| 4 | +#ifndef DEBUG |
| 5 | +#define DEBUG |
| 6 | +#endif |
| 7 | + |
3 | 8 | #ifdef DEBUG |
4 | 9 | #define dprintf(args) printf args |
5 | 10 | #else |
6 | 11 | #define dprintf(args) |
7 | 12 | #endif |
8 | 13 |
|
| 14 | +======= |
| 15 | +#ifdef DEBUG |
| 16 | +#define dprintf(args) printf args |
| 17 | +#else |
| 18 | +#define dprintf(args) |
| 19 | +#endif |
| 20 | + |
| 21 | +>>>>>>> 2.3 |
9 | 22 | #ifdef __sgi |
10 | 23 | #include <stdlib.h> |
11 | 24 | #include <stdio.h> |
@@ -59,6 +72,83 @@ struct lock { |
59 | 72 |
|
60 | 73 | static int initialized; |
61 | 74 |
|
| 75 | +<<<<<<< thread.c |
| 76 | +#ifdef __sgi |
| 77 | +/* |
| 78 | + * This routine is called as a signal handler when another thread |
| 79 | + * exits. When that happens, we must see whether we have to exit as |
| 80 | + * well (because of an exit_prog()) or whether we should continue on. |
| 81 | + */ |
| 82 | +static void exit_sig _P0() |
| 83 | +{ |
| 84 | + dprintf(("exit_sig called\n")); |
| 85 | + if (exiting && getpid() == my_pid) { |
| 86 | + dprintf(("already exiting\n")); |
| 87 | + return; |
| 88 | + } |
| 89 | + if (do_exit) { |
| 90 | + dprintf(("exiting in exit_sig\n")); |
| 91 | + exit_thread(); |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +/* |
| 96 | + * This routine is called when a process calls exit(). If that wasn't |
| 97 | + * done from the library, we do as if an exit_prog() was intended. |
| 98 | + */ |
| 99 | +static void maybe_exit _P0() |
| 100 | +{ |
| 101 | + dprintf(("maybe_exit called\n")); |
| 102 | + if (exiting) { |
| 103 | + dprintf(("already exiting\n")); |
| 104 | + return; |
| 105 | + } |
| 106 | + exit_prog(0); |
| 107 | +} |
| 108 | +#endif |
| 109 | + |
| 110 | +/* |
| 111 | + * Initialization. |
| 112 | + */ |
| 113 | +void init_thread _P0() |
| 114 | +{ |
| 115 | +#ifdef __sgi |
| 116 | + struct sigaction s; |
| 117 | +#endif |
| 118 | + |
| 119 | + dprintf(("init_thread called\n")); |
| 120 | + if (initialized) |
| 121 | + return; |
| 122 | + initialized = 1; |
| 123 | + |
| 124 | +#ifdef __sgi |
| 125 | + my_pid = getpid(); /* so that we know which is the main thread */ |
| 126 | + atexit(maybe_exit); |
| 127 | + s.sa_handler = exit_sig; |
| 128 | + sigemptyset(&s.sa_mask); |
| 129 | + sigaddset(&s.sa_mask, SIGUSR1); |
| 130 | + s.sa_flags = 0; |
| 131 | + sigaction(SIGUSR1, &s, 0); |
| 132 | + prctl(PR_SETEXITSIG, SIGUSR1); |
| 133 | + usconfig(CONF_ARENATYPE, US_SHAREDONLY); |
| 134 | + /*usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);*/ |
| 135 | + shared_arena = usinit(tmpnam(0)); |
| 136 | + count_lock = usnewlock(shared_arena); |
| 137 | + (void) usinitlock(count_lock); |
| 138 | + wait_lock = usnewlock(shared_arena); |
| 139 | +#endif |
| 140 | +#ifdef sun |
| 141 | + lwp_setstkcache(STACKSIZE, NSTACKS); |
| 142 | +#endif |
| 143 | +#ifdef C_THREADS |
| 144 | + cthread_init(); |
| 145 | +#endif |
| 146 | +} |
| 147 | + |
| 148 | +/* |
| 149 | + * Thread support. |
| 150 | + */ |
| 151 | +======= |
62 | 152 | #ifdef __sgi |
63 | 153 | /* |
64 | 154 | * This routine is called as a signal handler when another thread |
@@ -134,6 +224,7 @@ void init_thread _P0() |
134 | 224 | /* |
135 | 225 | * Thread support. |
136 | 226 | */ |
| 227 | +>>>>>>> 2.3 |
137 | 228 | int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg) |
138 | 229 | { |
139 | 230 | #ifdef sun |
|
0 commit comments