Blame libevent/epoll_sub.c

Packit e9ba0d
/*
Packit e9ba0d
 * Copyright 2003-2009 Niels Provos <provos@citi.umich.edu>
Packit e9ba0d
 * Copyright 2009-2012 Niels Provos and Nick Mathewson
Packit e9ba0d
 *
Packit e9ba0d
 * Redistribution and use in source and binary forms, with or without
Packit e9ba0d
 * modification, are permitted provided that the following conditions
Packit e9ba0d
 * are met:
Packit e9ba0d
 * 1. Redistributions of source code must retain the above copyright
Packit e9ba0d
 *    notice, this list of conditions and the following disclaimer.
Packit e9ba0d
 * 2. Redistributions in binary form must reproduce the above copyright
Packit e9ba0d
 *    notice, this list of conditions and the following disclaimer in the
Packit e9ba0d
 *    documentation and/or other materials provided with the distribution.
Packit e9ba0d
 * 3. The name of the author may not be used to endorse or promote products
Packit e9ba0d
 *    derived from this software without specific prior written permission.
Packit e9ba0d
 *
Packit e9ba0d
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
Packit e9ba0d
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Packit e9ba0d
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Packit e9ba0d
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit e9ba0d
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Packit e9ba0d
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit e9ba0d
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit e9ba0d
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit e9ba0d
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Packit e9ba0d
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit e9ba0d
 */
Packit e9ba0d
#include <stdint.h>
Packit e9ba0d
Packit e9ba0d
#include <sys/param.h>
Packit e9ba0d
#include <sys/types.h>
Packit e9ba0d
#include <sys/syscall.h>
Packit e9ba0d
#include <sys/epoll.h>
Packit e9ba0d
#include <unistd.h>
Packit e9ba0d
#include <errno.h>
Packit e9ba0d
Packit e9ba0d
int
Packit e9ba0d
epoll_create(int size)
Packit e9ba0d
{
Packit e9ba0d
#if !defined(__NR_epoll_create) && defined(__NR_epoll_create1)
Packit e9ba0d
	if (size <= 0) {
Packit e9ba0d
		errno = EINVAL;
Packit e9ba0d
		return -1;
Packit e9ba0d
	}
Packit e9ba0d
	return (syscall(__NR_epoll_create1, 0));
Packit e9ba0d
#else
Packit e9ba0d
	return (syscall(__NR_epoll_create, size));
Packit e9ba0d
#endif
Packit e9ba0d
}
Packit e9ba0d
Packit e9ba0d
int
Packit e9ba0d
epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
Packit e9ba0d
{
Packit e9ba0d
Packit e9ba0d
	return (syscall(__NR_epoll_ctl, epfd, op, fd, event));
Packit e9ba0d
}
Packit e9ba0d
Packit e9ba0d
int
Packit e9ba0d
epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
Packit e9ba0d
{
Packit e9ba0d
#if !defined(__NR_epoll_wait) && defined(__NR_epoll_pwait)
Packit e9ba0d
	return (syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0));
Packit e9ba0d
#else
Packit e9ba0d
	return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout));
Packit e9ba0d
#endif
Packit e9ba0d
}