summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-11-11 22:02:02 -0800
committerAdam Jackson <ajax@redhat.com>2015-12-01 13:55:03 -0500
commit0c41b7af4ab0c8d22b88f201293f59524d1e7317 (patch)
tree18b3bd8756e4156994578645a3b66164ebdc2efc /include
parente10ba9e4b52269b2ac75c4802dce4ca47d169657 (diff)
os: Add NotifyFd interfaces
This provides a callback-based interface to monitor file descriptors beyond the usual client and device interfaces. Modules within the server using file descriptors for reading and/or writing can call Bool SetNotifyFd(int fd, NotifyFdProcPtr notify_fd, int mask, void *data); mask can be any combination of X_NOTIFY_READ and X_NOTIFY_WRITE. When 'fd' becomes readable or writable, the notify_fd function will be called with the 'fd', the ready conditions and 'data' values as arguments, When the module no longer needs to monitor the fd, it will call void RemoveNotifyFd(int fd); RemoveNotifyFd may be called from the notify function. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'include')
-rw-r--r--include/os.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/os.h b/include/os.h
index 9937f2ea5..aed2e2f99 100644
--- a/include/os.h
+++ b/include/os.h
@@ -154,6 +154,19 @@ extern _X_EXPORT void AddEnabledDevice(int /*fd */ );
extern _X_EXPORT void RemoveEnabledDevice(int /*fd */ );
+typedef void (*NotifyFdProcPtr)(int fd, int ready, void *data);
+
+#define X_NOTIFY_NONE 0
+#define X_NOTIFY_READ 1
+#define X_NOTIFY_WRITE 2
+
+extern _X_EXPORT Bool SetNotifyFd(int fd, NotifyFdProcPtr notify_fd, int mask, void *data);
+
+static inline void RemoveNotifyFd(int fd)
+{
+ (void) SetNotifyFd(fd, NULL, X_NOTIFY_NONE, NULL);
+}
+
extern _X_EXPORT int OnlyListenToOneClient(ClientPtr /*client */ );
extern _X_EXPORT void ListenToAllClients(void);