1275970Scy/*
2275970Scy * Copyright 2003-2009 Niels Provos <provos@citi.umich.edu>
3275970Scy * Copyright 2009-2012 Niels Provos and Nick Mathewson
4275970Scy *
5275970Scy * Redistribution and use in source and binary forms, with or without
6275970Scy * modification, are permitted provided that the following conditions
7275970Scy * are met:
8275970Scy * 1. Redistributions of source code must retain the above copyright
9275970Scy *    notice, this list of conditions and the following disclaimer.
10275970Scy * 2. Redistributions in binary form must reproduce the above copyright
11275970Scy *    notice, this list of conditions and the following disclaimer in the
12275970Scy *    documentation and/or other materials provided with the distribution.
13275970Scy * 3. The name of the author may not be used to endorse or promote products
14275970Scy *    derived from this software without specific prior written permission.
15275970Scy *
16275970Scy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17275970Scy * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18275970Scy * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19275970Scy * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20275970Scy * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21275970Scy * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22275970Scy * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23275970Scy * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24275970Scy * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25275970Scy * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26275970Scy */
27275970Scy#include "evconfig-private.h"
28275970Scy#include <stdint.h>
29275970Scy
30275970Scy#include <sys/param.h>
31275970Scy#include <sys/types.h>
32275970Scy#include <sys/syscall.h>
33275970Scy#include <sys/epoll.h>
34275970Scy#include <unistd.h>
35275970Scy#include <errno.h>
36275970Scy
37275970Scyint
38275970Scyepoll_create(int size)
39275970Scy{
40275970Scy#if !defined(__NR_epoll_create) && defined(__NR_epoll_create1)
41275970Scy	if (size <= 0) {
42275970Scy		errno = EINVAL;
43275970Scy		return -1;
44275970Scy	}
45275970Scy	return (syscall(__NR_epoll_create1, 0));
46275970Scy#else
47275970Scy	return (syscall(__NR_epoll_create, size));
48275970Scy#endif
49275970Scy}
50275970Scy
51275970Scyint
52275970Scyepoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
53275970Scy{
54275970Scy
55275970Scy	return (syscall(__NR_epoll_ctl, epfd, op, fd, event));
56275970Scy}
57275970Scy
58275970Scyint
59275970Scyepoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
60275970Scy{
61275970Scy#if !defined(__NR_epoll_wait) && defined(__NR_epoll_pwait)
62275970Scy	return (syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0));
63275970Scy#else
64275970Scy	return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout));
65275970Scy#endif
66275970Scy}
67