tests/rt_sigpending.c: fix for systems where _NSIG > 16 * sizeof(long)

* tests/rt_sigsuspend.c (iterate): Do not assume that size will be less
than sizeof(long) on the second iteration.
This commit is contained in:
Дмитрий Левин 2016-04-20 04:32:04 +00:00
parent d424c765f7
commit c8cc0f2a87

View File

@ -48,11 +48,13 @@ k_sigsuspend(const sigset_t *const set, const unsigned long size)
static void static void
iterate(const char *const text, const int sig, iterate(const char *const text, const int sig,
const void *set, unsigned int size) const void *const set, unsigned int size)
{ {
for (;;) { const void *mask;
for (mask = set;; size >>= 1, mask += size) {
raise(sig); raise(sig);
assert(k_sigsuspend(set, size) == -1); assert(k_sigsuspend(mask, size) == -1);
if (EINTR == errno) { if (EINTR == errno) {
tprintf("rt_sigsuspend(%s, %u) = ? ERESTARTNOHAND" tprintf("rt_sigsuspend(%s, %u) = ? ERESTARTNOHAND"
" (To be restarted if no handler)\n", " (To be restarted if no handler)\n",
@ -61,16 +63,14 @@ iterate(const char *const text, const int sig,
if (size < sizeof(long)) if (size < sizeof(long))
tprintf("rt_sigsuspend(%p, %u)" tprintf("rt_sigsuspend(%p, %u)"
" = -1 EINVAL (%m)\n", " = -1 EINVAL (%m)\n",
set, size); mask, size);
else else
tprintf("rt_sigsuspend(%s, %u)" tprintf("rt_sigsuspend(%s, %u)"
" = -1 EINVAL (%m)\n", " = -1 EINVAL (%m)\n",
text, size); set == mask ? text : "~[]", size);
} }
if (!size) if (!size)
break; break;
size >>= 1;
set += size;
} }
} }