cmogstored 1.8.1 - use default system stack size
[cmogstored.git] / selfwake.h
blobbe8c2ff380bd9e87d639cff4bd1e0c45043e9e09
1 /*
2 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
3 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
4 */
5 #if defined(HAVE_KQUEUE)
6 # define MOG_SELFPIPE 1
7 #elif (defined(HAVE_EPOLL_WAIT) && defined(HAVE_PPOLL)) \
8 || defined(HAVE_EPOLL_PWAIT)
9 # define MOG_SELFPIPE 0
10 #else
11 # define MOG_SELFPIPE 1
12 #endif
14 struct mog_selfwake {
15 struct mog_queue *queue;
16 struct mog_fd *writer;
19 /* only for pipe */
20 struct mog_selfpipe {
21 struct mog_fd *reader; /* points to mog_selfwake */
24 #if MOG_SELFPIPE
25 struct mog_fd * mog_selfwake_new(void);
26 void mog_selfwake_trigger(struct mog_fd *);
27 void mog_selfwake_drain(struct mog_fd *);
28 #define mog_selfwake_put(mfd) mog_fd_put((mfd))
29 static inline void mog_selfwake_interrupt(void) {}
30 void mog_selfwake_wait(struct mog_fd *);
31 #else /* use Linux-only facilities like epoll_pwait or ppoll */
32 static inline void mog_selfwake_wait(struct mog_fd *mfd)
34 mog_sleep(-1);
36 static inline struct mog_fd * mog_selfwake_new(void) { return NULL; }
37 static inline void mog_selfwake_trigger(struct mog_fd *mfd) {}
38 static inline void mog_selfwake_drain(struct mog_fd *mfd) {}
39 static inline void mog_selfwake_put(struct mog_fd *mfd) {}
40 static inline void mog_selfwake_interrupt(void)
42 CHECK(int, 0, kill(getpid(), SIGURG));
44 #endif /* Linux-only stuff */