From 86110d6edadef2d9fbcd3ee0d008696bfcf7dcd4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 9 Feb 2017 13:45:12 +0100 Subject: os: Add NotifyFd interfaces Backported from X.org: commit 0c41b7af4ab0c8d22b88f201293f59524d1e7317 Author: Keith Packard Date: Wed Nov 11 22:02:02 2015 -0800 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 Signed-off-by: Keith Packard Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/include/os.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nx-X11/programs/Xserver/include') diff --git a/nx-X11/programs/Xserver/include/os.h b/nx-X11/programs/Xserver/include/os.h index 0fd687d18..dfcc639d3 100644 --- a/nx-X11/programs/Xserver/include/os.h +++ b/nx-X11/programs/Xserver/include/os.h @@ -147,6 +147,19 @@ extern void AddEnabledDevice(int /*fd*/); extern 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 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 void OnlyListenToOneClient(ClientPtr /*client*/); extern void ListenToAllClients(void); -- cgit v1.2.3