diff options
author | Manuel Bentele | 2020-10-16 17:15:49 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-16 17:15:49 +0200 |
commit | 969496f15e1e0359e26c2c6e995ad4ef82720f86 (patch) | |
tree | 358466216630eb10e8ee91b9ede490424f6db848 /inc/dnbd3/shared/fdsignal.h | |
parent | [FUSE] turn on compiler optimization to fix warning (diff) | |
download | dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.tar.gz dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.tar.xz dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.zip |
[BUILD] rewrite CMake build system to track changes of source files
This change restructures the source code directories, separates shared
form non-shared application code and adds CMake dependencies. These
dependencies allow the tracking of changes and trigger a rebuild of
those build targets where changed files are involved.
WARNING: Note that the support of the DNBD3_SERVER_AFL build option is
not supported yet. Thus, the option should be never turned on.
Diffstat (limited to 'inc/dnbd3/shared/fdsignal.h')
-rw-r--r-- | inc/dnbd3/shared/fdsignal.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/inc/dnbd3/shared/fdsignal.h b/inc/dnbd3/shared/fdsignal.h new file mode 100644 index 0000000..960a2a9 --- /dev/null +++ b/inc/dnbd3/shared/fdsignal.h @@ -0,0 +1,57 @@ +#ifndef _FD_SIGNAL_H_ +#define _FD_SIGNAL_H_ + +#define SIGNAL_OK (0) +#define SIGNAL_TIMEOUT (-2) +#define SIGNAL_ERROR (-1) + +typedef struct _dnbd3_signal dnbd3_signal_t; + +/** + * Create a new signal, nonblocking. + * @return NULL on error, pointer to dnbd3_signal_t on success. + */ +dnbd3_signal_t* signal_new(); + +/** + * Create a new signal, blocking. + * @return NULL on error, pointer to dnbd3_signal_t on success. + */ +dnbd3_signal_t* signal_newBlocking(); + +/** + * Trigger the given signal, so a wait or clear call will succeed. + * @return SIGNAL_OK on success, SIGNAL_ERROR on error + */ +int signal_call(const dnbd3_signal_t* const signal); + +/** + * Wait for given signal, with an optional timeout. + * If timeout == 0, just poll once. + * If timeout < 0, wait forever. + * @return > 0 telling how many times the signal was called, + * SIGNAL_TIMEOUT if the timeout was reached, + * SIGNAL_ERROR if some error occured + */ +int signal_wait(const dnbd3_signal_t* const signal, int timeoutMs); + +/** + * Clears any pending signals on this signal. + * @return number of signals that were pending, + * SIGNAL_ERROR if some error occured + */ +int signal_clear(const dnbd3_signal_t* const signal); + +/** + * Close the given signal. + */ +void signal_close(const dnbd3_signal_t* const signal); + +/** + * Get a file descriptor for the given signal that can be + * waited on using poll or similar. + * @return -1 if the signal is invalid + */ +int signal_getWaitFd(const dnbd3_signal_t* const signal); + +#endif |