1 |
#include "private/pthread_support.h" |
#include "private/pthread_support.h" |
2 |
|
|
3 |
#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \ |
#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \ |
4 |
&& !defined(GC_IRIX_THREADS) && !defined(GC_WIN32_THREADS) \ |
&& !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS) |
|
&& !defined(GC_DARWIN_THREADS) && !defined(GC_AIX_THREADS) |
|
5 |
|
|
6 |
#include <signal.h> |
#include <signal.h> |
7 |
#include <semaphore.h> |
#include <semaphore.h> |
100 |
|
|
101 |
sem_t GC_suspend_ack_sem; |
sem_t GC_suspend_ack_sem; |
102 |
|
|
103 |
|
void GC_suspend_handler_inner(ptr_t sig_arg); |
104 |
|
|
105 |
|
#if defined(IA64) || defined(HP_PA) |
106 |
|
extern void GC_with_callee_saves_pushed(); |
107 |
|
|
108 |
|
void GC_suspend_handler(int sig) |
109 |
|
{ |
110 |
|
int old_errno = errno; |
111 |
|
GC_with_callee_saves_pushed(GC_suspend_handler_inner, (ptr_t)(word)sig); |
112 |
|
errno = old_errno; |
113 |
|
} |
114 |
|
|
115 |
|
#else |
116 |
|
/* We believe that in all other cases the full context is already */ |
117 |
|
/* in the signal handler frame. */ |
118 |
void GC_suspend_handler(int sig) |
void GC_suspend_handler(int sig) |
119 |
{ |
{ |
120 |
|
int old_errno = errno; |
121 |
|
GC_suspend_handler_inner((ptr_t)(word)sig); |
122 |
|
errno = old_errno; |
123 |
|
} |
124 |
|
#endif |
125 |
|
|
126 |
|
void GC_suspend_handler_inner(ptr_t sig_arg) |
127 |
|
{ |
128 |
|
int sig = (int)(word)sig_arg; |
129 |
int dummy; |
int dummy; |
130 |
pthread_t my_thread = pthread_self(); |
pthread_t my_thread = pthread_self(); |
131 |
GC_thread me; |
GC_thread me; |
392 |
} |
} |
393 |
} |
} |
394 |
for (i = 0; i < n_live_threads; i++) { |
for (i = 0; i < n_live_threads; i++) { |
395 |
if (0 != (code = sem_wait(&GC_suspend_ack_sem))) { |
while (0 != (code = sem_wait(&GC_suspend_ack_sem))) { |
396 |
GC_err_printf1("Sem_wait returned %ld\n", (unsigned long)code); |
if (errno != EINTR) { |
397 |
ABORT("sem_wait for handler failed"); |
GC_err_printf1("Sem_wait returned %ld\n", (unsigned long)code); |
398 |
|
ABORT("sem_wait for handler failed"); |
399 |
|
} |
400 |
} |
} |
401 |
} |
} |
402 |
# ifdef PARALLEL_MARK |
# ifdef PARALLEL_MARK |