1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <syscall.h>
#include <signal.h>
#include <errno.h>
extern void ___sig_restore();
extern void ___masksig_restore();
#ifdef PTHREAD_KERNEL
#pragma weak machdep_sys_sigaction = __machdep_sys_sigaction
int
__machdep_sys_sigaction(int sig,struct sigaction * new, struct sigaction * old)
{
if (new) {
if (new->sa_flags & SA_NOMASK)
new->sa_restorer=___sig_restore;
else
new->sa_restorer=___masksig_restore;
}
#if defined(__PIC__) || defined (__pic__)
__asm__ volatile ("pushl %%ebx\n\t"
"movl %%edi,%%ebx\n\t"
"int $0x80\n\t"
"popl %%ebx"
:"=a" (sig)
:"0" (SYS_sigaction),"D" (sig),"c" (new),"d" (old));
#else
__asm__("int $0x80":"=a" (sig)
:"0" (SYS_sigaction),"b" (sig),"c" (new),"d" (old));
#endif
return sig;
}
#else /* PTHREAD_KERNEL */
#ifdef _POSIX_THREADS
#pragma weak __sigaction
#endif
int
__sigaction(int sig,struct sigaction * new, struct sigaction * old)
{
if (new) {
if (new->sa_flags & SA_NOMASK)
new->sa_restorer=___sig_restore;
else
new->sa_restorer=___masksig_restore;
}
#if defined(__PIC__) || defined (__pic__)
__asm__ volatile ("pushl %%ebx\n\t"
"movl %%edi,%%ebx\n\t"
"int $0x80\n\t"
"popl %%ebx"
:"=a" (sig)
:"0" (SYS_sigaction),"D" (sig),"c" (new),"d" (old));
#else
__asm__("int $0x80":"=a" (sig)
:"0" (SYS_sigaction),"b" (sig),"c" (new),"d" (old));
#endif
if (sig>=0)
return 0;
errno = -sig;
return -1;
}
#include <gnu-stabs.h>
#ifdef weak_alias
weak_alias (__sigaction, sigaction);
#endif
#endif /* PTHREAD_KERNEL */
|