]> git.pond.sub.org Git - empserver/commitdiff
lwp: Simplify lwpSigWait() interface
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Dec 2020 08:42:55 +0000 (09:42 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 17 Jan 2021 20:24:28 +0000 (21:24 +0100)
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>
include/lwp.h
src/lib/empthread/lwp.c
src/lib/lwp/sig.c

index e115ad704446b41f2788b521a6c9be52cf2d54cc..23033f3b67d2142d44507a556f33f95cb2c82910 100644 (file)
@@ -64,7 +64,7 @@ void lwpYield(void);
 int lwpSleepFd(int fd, int flags, struct timeval *timeout);
 int lwpSleepUntil(time_t until);
 void lwpWakeup(struct lwpProc *);
-int lwpSigWait(int *sig);
+int lwpSigWait(void);
 void *lwpGetUD(struct lwpProc *);
 void lwpSetUD(struct lwpProc *, char *ud);
 int lwpSetPriority(int prio);
index d26eae7c889c03c2325e12a55841f2df46973730..3737ac0df7a5258ba7e14b011884fa0b3f029c87 100644 (file)
@@ -117,13 +117,13 @@ empth_sleep(time_t until)
 int
 empth_wait_for_signal(void)
 {
-    int sig, err;
+    int sig;
     time_t now;
 
     ef_make_stale();
     for (;;) {
-       err = lwpSigWait(&sig);
-       if (CANT_HAPPEN(err)) {
+       sig = lwpSigWait();
+       if (CANT_HAPPEN(sig < 0)) {
            time(&now);
            lwpSleepUntil(now + 60);
            continue;
index 40991ce004100c3cda01bf552437aa58e4b1d673..50f7f5ab000aad3a739916526d0fc92dfa2721fb 100644 (file)
@@ -138,17 +138,17 @@ lwpGetSig(void)
 
 /*
  * Wait until one of the signals passed to lwpInitSigWait() arrives.
- * Assign its number to *@sig and return 0.
- * If another thread is already waiting for signals, return EBUSY
+ * Return its signal number.
+ * If another thread is already waiting for signals, return -1
  * without waiting.
  */
 int
-lwpSigWait(int *sig)
+lwpSigWait(void)
 {
     int res;
 
     if (LwpSigWaiter)
-       return EBUSY;
+       return -1;
     for (;;) {
        res = lwpGetSig();
        if (res > 0)
@@ -157,8 +157,7 @@ lwpSigWait(int *sig)
        LwpSigWaiter = LwpCurrent;
        lwpReschedule();
     }
-    *sig = res;
-    return 0;
+    return res;
 }
 
 /*