signal: Provide generic signal_pre_select().
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 7 Oct 2014 19:16:16 +0000 (19:16 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 8 Feb 2015 15:05:13 +0000 (16:05 +0100)
Identical copies of this function exist in afs.c, gui.c, audiod.c and
server.c. This commit defines a generic version as an inline function
in signal.h and gets rid of the copies.

afs.c
audiod.c
gui.c
server.c
signal.h

diff --git a/afs.c b/afs.c
index a21a99d..1d23c9f 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -28,8 +28,8 @@
 #include "ipc.h"
 #include "list.h"
 #include "sched.h"
-#include "signal.h"
 #include "fd.h"
+#include "signal.h"
 #include "mood.h"
 #include "sideband.h"
 #include "command.h"
@@ -719,12 +719,6 @@ static int open_afs_tables(void)
        return ret;
 }
 
-static void signal_pre_select(struct sched *s, void *context)
-{
-       struct signal_task *st = context;
-       para_fd_set(st->fd, &s->rfds, &s->max_fileno);
-}
-
 static int afs_signal_post_select(struct sched *s, __a_unused void *context)
 {
        int signum, ret;
index 77d21f3..4285dd5 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -990,12 +990,6 @@ err:
        exit(EXIT_FAILURE);
 }
 
-static void signal_pre_select(struct sched *s, void *context)
-{
-       struct signal_task *st = context;
-       para_fd_set(st->fd, &s->rfds, &s->max_fileno);
-}
-
 static int signal_post_select(struct sched *s, void *context)
 {
        struct signal_task *st = context;
diff --git a/gui.c b/gui.c
index 5d1a1b6..620367e 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -1132,12 +1132,6 @@ static int input_post_select(__a_unused struct sched *s, __a_unused void *contex
        return 0;
 }
 
-static void signal_pre_select(struct sched *s, void *context)
-{
-       struct signal_task *st = context;
-       para_fd_set(st->fd, &s->rfds, &s->max_fileno);
-}
-
 static void print_scroll_msg(void)
 {
        unsigned lines_total, filled = ringbuffer_filled(bot_win_rb);
index 6c2cbb8..a048cfd 100644 (file)
--- a/server.c
+++ b/server.c
@@ -227,12 +227,6 @@ out:
        exit(EXIT_FAILURE);
 }
 
-static void signal_pre_select(struct sched *s, void *context)
-{
-       struct signal_task *st = context;
-       para_fd_set(st->fd, &s->rfds, &s->max_fileno);
-}
-
 /*
  * called when server gets SIGHUP or when client invokes hup command.
  */
index 1e562af..643c148 100644 (file)
--- a/signal.h
+++ b/signal.h
@@ -16,6 +16,12 @@ struct signal_task {
        struct task *task;
 };
 
+_static_inline_ void signal_pre_select(struct sched *s, void *context)
+{
+       struct signal_task *st = context;
+       para_fd_set(st->fd, &s->rfds, &s->max_fileno);
+}
+
 int para_signal_init(void);
 void para_sigaction(int sig, void (*handler)(int));
 void para_install_sighandler(int);