lwp: Simplify lwpSigWait() interface

lwpSigWait() was designed to resemble sigwait().  It doesn't anymore.
Drop the awkward argument, and use the return value instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2020-12-27 09:42:55 +01:00
parent d89bda9998
commit 8a04586048
3 changed files with 9 additions and 10 deletions

View file

@ -64,7 +64,7 @@ void lwpYield(void);
int lwpSleepFd(int fd, int flags, struct timeval *timeout); int lwpSleepFd(int fd, int flags, struct timeval *timeout);
int lwpSleepUntil(time_t until); int lwpSleepUntil(time_t until);
void lwpWakeup(struct lwpProc *); void lwpWakeup(struct lwpProc *);
int lwpSigWait(int *sig); int lwpSigWait(void);
void *lwpGetUD(struct lwpProc *); void *lwpGetUD(struct lwpProc *);
void lwpSetUD(struct lwpProc *, char *ud); void lwpSetUD(struct lwpProc *, char *ud);
int lwpSetPriority(int prio); int lwpSetPriority(int prio);

View file

@ -117,13 +117,13 @@ empth_sleep(time_t until)
int int
empth_wait_for_signal(void) empth_wait_for_signal(void)
{ {
int sig, err; int sig;
time_t now; time_t now;
ef_make_stale(); ef_make_stale();
for (;;) { for (;;) {
err = lwpSigWait(&sig); sig = lwpSigWait();
if (CANT_HAPPEN(err)) { if (CANT_HAPPEN(sig < 0)) {
time(&now); time(&now);
lwpSleepUntil(now + 60); lwpSleepUntil(now + 60);
continue; continue;

View file

@ -138,17 +138,17 @@ lwpGetSig(void)
/* /*
* Wait until one of the signals passed to lwpInitSigWait() arrives. * Wait until one of the signals passed to lwpInitSigWait() arrives.
* Assign its number to *@sig and return 0. * Return its signal number.
* If another thread is already waiting for signals, return EBUSY * If another thread is already waiting for signals, return -1
* without waiting. * without waiting.
*/ */
int int
lwpSigWait(int *sig) lwpSigWait(void)
{ {
int res; int res;
if (LwpSigWaiter) if (LwpSigWaiter)
return EBUSY; return -1;
for (;;) { for (;;) {
res = lwpGetSig(); res = lwpGetSig();
if (res > 0) if (res > 0)
@ -157,8 +157,7 @@ lwpSigWait(int *sig)
LwpSigWaiter = LwpCurrent; LwpSigWaiter = LwpCurrent;
lwpReschedule(); lwpReschedule();
} }
*sig = res; return res;
return 0;
} }
/* /*