diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2018-05-21 14:39:40 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2018-05-21 16:33:34 +0300 |
commit | 72ec206080350e75a87780895f246f5c4f52e790 (patch) | |
tree | 76a4813d2adf5b054d6a322142bd6ac9542bd44d /events.h | |
parent | 12c8541a416a73e989f536f2358c369301524825 (diff) |
events: Import event handling library from omap3-isp-live
The omap3-isp-live project [1] includes a generic event handling library
that implements a select-based loop. Instead of reinventing the wheel,
import the library and use it.
The original license hasn't been modified, and includes both GPL-2.0+
and LGPL-2.1+ code. The sole copyright owner is Laurent Pinchart.
[1] git://git.ideasonboard.org/omap3-isp-live.git
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'events.h')
-rw-r--r-- | events.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/events.h b/events.h new file mode 100644 index 0000000..b80cd75 --- /dev/null +++ b/events.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Generic Event Handling + * + * Copyright (C) 2018 Laurent Pinchart + * + * This file comes from the omap3-isp-live project + * (git://git.ideasonboard.org/omap3-isp-live.git) + * + * Copyright (C) 2010-2011 Ideas on board SPRL + * + * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com> + */ + +#ifndef __EVENTS_H__ +#define __EVENTS_H__ + +#include <stdbool.h> +#include <sys/select.h> + +#include "list.h" + +struct events { + struct list_entry events; + bool done; + + int maxfd; + fd_set rfds; + fd_set wfds; + fd_set efds; +}; + +enum event_type { + EVENT_READ = 1, + EVENT_WRITE = 2, + EVENT_EXCEPTION = 4, +}; + +void events_watch_fd(struct events *events, int fd, enum event_type type, + void(*callback)(void *), void *priv); +void events_unwatch_fd(struct events *events, int fd); + +bool events_loop(struct events *events); +void events_stop(struct events *events); + +void events_init(struct events *events); + +#endif |