summaryrefslogtreecommitdiff
path: root/events.h
blob: b0b8fa864c7f369caa02ff1954e3c7560d9a3f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* 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, enum event_type type);

bool events_loop(struct events *events);
void events_stop(struct events *events);

void events_init(struct events *events);
void events_cleanup(struct events *events);

#endif