diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-01 18:00:04 +0000 | 
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-01 18:00:04 +0000 | 
| commit | 83eb4d5219f920fde59c9edd9204664f0c2f9f36 (patch) | |
| tree | fd5a550be29c0c45d303cb10ea78b528dbe7978f /libc/sysdeps/linux/mips/sigaction.c | |
| parent | 0e4d4dd89170d47a662f1cd0de1b4f3a5dbc1f2d (diff) | |
| download | uClibc-alpine-83eb4d5219f920fde59c9edd9204664f0c2f9f36.tar.bz2 uClibc-alpine-83eb4d5219f920fde59c9edd9204664f0c2f9f36.tar.xz  | |
fix sigset_t size for mips (it's the only arch with 128 signals).
fix _NSIG for it.
better document what's going on in sigaction().
seems to not induce any actual code changes (sans mips).
Diffstat (limited to 'libc/sysdeps/linux/mips/sigaction.c')
| -rw-r--r-- | libc/sysdeps/linux/mips/sigaction.c | 52 | 
1 files changed, 29 insertions, 23 deletions
diff --git a/libc/sysdeps/linux/mips/sigaction.c b/libc/sysdeps/linux/mips/sigaction.c index edd265438..ca39740af 100644 --- a/libc/sysdeps/linux/mips/sigaction.c +++ b/libc/sysdeps/linux/mips/sigaction.c @@ -47,36 +47,42 @@ static void restore (void) __asm__ ("__restore");     If OACT is not NULL, put the old action for SIG in *OACT.  */  int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)  { -    int result; -    struct kernel_sigaction kact, koact; - -    if (act) { -	kact.k_sa_handler = act->sa_handler; -	memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask)); -	kact.sa_flags = act->sa_flags; +	int result; +	struct kernel_sigaction kact, koact; +	enum { +		SIGSET_MIN_SIZE = sizeof(kact.sa_mask) < sizeof(act->sa_mask) +				? sizeof(kact.sa_mask) : sizeof(act->sa_mask) +	}; + +	if (act) { +		kact.k_sa_handler = act->sa_handler; +		memcpy (&kact.sa_mask, &act->sa_mask, SIGSET_MIN_SIZE); +		kact.sa_flags = act->sa_flags;  # ifdef HAVE_SA_RESTORER  #  if _MIPS_SIM == _ABIO32 -	kact.sa_restorer = act->sa_restorer; +		kact.sa_restorer = act->sa_restorer;  #  else -	kact.sa_restorer = &restore_rt; +		kact.sa_restorer = &restore_rt;  #  endif  # endif -    } - -    /* XXX The size argument hopefully will have to be changed to the -       real size of the user-level sigset_t.  */ -    result = __syscall_rt_sigaction(sig, act ? __ptrvalue (&kact) : NULL, -	    oact ? __ptrvalue (&koact) : NULL, _NSIG / 8); - -    if (oact && result >= 0) { -	oact->sa_handler = koact.k_sa_handler; -	memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask)); -	oact->sa_flags = koact.sa_flags; +	} + +	/* NB: kernel (as of 2.6.25) will return EINVAL +	 * if sizeof(kact.sa_mask) does not match kernel's sizeof(sigset_t) */ +	result = __syscall_rt_sigaction(sig, +			act ? __ptrvalue (&kact) : NULL, +			oact ? __ptrvalue (&koact) : NULL, +			sizeof(kact.sa_mask)); + +	if (oact && result >= 0) { +		oact->sa_handler = koact.k_sa_handler; +		memcpy (&oact->sa_mask, &koact.sa_mask, SIGSET_MIN_SIZE); +		oact->sa_flags = koact.sa_flags;  # ifdef HAVE_SA_RESTORER -	oact->sa_restorer = koact.sa_restorer; +		oact->sa_restorer = koact.sa_restorer;  # endif -    } -    return result; +	} +	return result;  }  | 
