File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010void init_thread _P ((void ));
1111int start_new_thread _P ((void (* )(void * ), void * ) );
1212void exit_thread _P ((void ));
13+ void _exit_thread _P ((void ));
1314
1415typedef void * type_lock ;
1516
@@ -20,7 +21,15 @@ int acquire_lock _P((type_lock, int));
2021#define NOWAIT_LOCK 0
2122void release_lock _P ((type_lock ));
2223
24+ typedef void * type_sema ;
25+
26+ type_sema allocate_sema _P ((int ));
27+ void free_sema _P ((type_sema ));
28+ void down_sema _P ((type_sema ));
29+ void up_sema _P ((type_sema ));
30+
2331void exit_prog _P ((int ));
32+ void _exit_prog _P ((int ));
2433
2534#undef _P
2635
Original file line number Diff line number Diff line change 1010void init_thread _P ((void ));
1111int start_new_thread _P ((void (* )(void * ), void * ) );
1212void exit_thread _P ((void ));
13+ void _exit_thread _P ((void ));
1314
1415typedef void * type_lock ;
1516
@@ -20,7 +21,15 @@ int acquire_lock _P((type_lock, int));
2021#define NOWAIT_LOCK 0
2122void release_lock _P ((type_lock ));
2223
24+ typedef void * type_sema ;
25+
26+ type_sema allocate_sema _P ((int ));
27+ void free_sema _P ((type_sema ));
28+ void down_sema _P ((type_sema ));
29+ void up_sema _P ((type_sema ));
30+
2331void exit_prog _P ((int ));
32+ void _exit_prog _P ((int ));
2433
2534#undef _P
2635
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3131
3232#include "thread.h"
3333
34+ int threads_started = 0 ;
35+
3436object * ThreadError ;
3537
3638
@@ -177,6 +179,8 @@ t_bootstrap(args_raw)
177179 object * args = (object * ) args_raw ;
178180 object * func , * arg , * res ;
179181
182+ threads_started ++ ;
183+
180184 restore_thread ((void * )NULL );
181185 func = gettupleitem (args , 0 );
182186 arg = gettupleitem (args , 1 );
@@ -230,7 +234,7 @@ thread_exit_prog(self, args)
230234 int sts ;
231235 if (!getargs (args , "i" , & sts ))
232236 return NULL ;
233- goaway (sts );
237+ goaway (sts ); /* Calls exit_prog(sts) or _exit_prog(sts) */
234238 for (;;) { } /* Should not be reached */
235239}
236240
Original file line number Diff line number Diff line change @@ -361,6 +361,10 @@ fatal(msg)
361361
362362/* Clean up and exit */
363363
364+ #ifdef USE_THREAD
365+ extern int threads_started ;
366+ #endif
367+
364368void
365369goaway (sts )
366370 int sts ;
@@ -375,7 +379,10 @@ goaway(sts)
375379
376380 (void ) save_thread ();
377381 donecalls ();
378- exit_prog (sts );
382+ if (threads_started )
383+ _exit_prog (sts );
384+ else
385+ exit_prog (sts );
379386
380387#else /* USE_THREAD */
381388
You can’t perform that action at this time.
0 commit comments