| 168 | |
| 169 | |
| 170 | int sigwait(sigset_t *setp, int *sigp) |
| 171 | { |
| 172 | if (memcmp(setp,&sigwait_set,sizeof(sigwait_set))) |
| 173 | sigwait_setup(setp); /* Init or change of set */ |
| 174 | |
| 175 | for (;;) |
| 176 | { |
| 177 | /* |
| 178 | This is a fast, not 100% portable implementation to find the signal. |
| 179 | Because the handler is blocked there should be at most 1 bit set, but |
| 180 | the specification on this is somewhat shady so we use a set instead a |
| 181 | single variable. |
| 182 | */ |
| 183 | |
| 184 | ulong *ptr= (ulong*) &px_recd; |
| 185 | ulong *end=ptr+sizeof(px_recd)/sizeof(ulong); |
| 186 | |
| 187 | for ( ; ptr != end ; ptr++) |
| 188 | { |
| 189 | if (*ptr) |
| 190 | { |
| 191 | ulong set= *ptr; |
| 192 | int found= (int) ((char*) ptr - (char*) &px_recd)*8+1; |
| 193 | while (!(set & 1)) |
| 194 | { |
| 195 | found++; |
| 196 | set>>=1; |
| 197 | } |
| 198 | *sigp=found; |
| 199 | sigdelset(&px_recd,found); |
| 200 | return 0; |
| 201 | } |
| 202 | } |
| 203 | sigsuspend(&rev_sigwait_set); |
| 204 | } |
| 205 | return 0; |
| 206 | } |
| 207 | #else /* !DONT_USE_SIGSUSPEND */ |
| 208 | |
| 209 | /**************************************************************************** |
no test coverage detected