2006-06-26 00:48:02 +00:00
|
|
|
/*
|
2011-08-22 15:12:02 +00:00
|
|
|
* include/common/epoll.h
|
|
|
|
* epoll definitions for older libc.
|
|
|
|
*
|
2012-11-11 16:42:00 +00:00
|
|
|
* Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
|
2011-08-22 15:12:02 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
|
|
* exclusively.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2005-12-18 00:11:29 +00:00
|
|
|
/*
|
|
|
|
* Those constants were found both in glibc and in the Linux kernel.
|
|
|
|
* They are provided here because the epoll() syscall is featured in
|
|
|
|
* some kernels but in not often included in the glibc, so it needs
|
|
|
|
* just a basic definition.
|
|
|
|
*/
|
|
|
|
|
2006-06-29 15:53:05 +00:00
|
|
|
#ifndef _COMMON_EPOLL_H
|
|
|
|
#define _COMMON_EPOLL_H
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2019-05-22 17:24:06 +00:00
|
|
|
#if defined (__linux__) && defined(USE_EPOLL)
|
2011-08-22 15:12:02 +00:00
|
|
|
|
|
|
|
#ifndef USE_MY_EPOLL
|
|
|
|
#include <sys/epoll.h>
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <errno.h>
|
2006-10-15 20:57:13 +00:00
|
|
|
#include <sys/types.h>
|
2006-06-29 16:54:54 +00:00
|
|
|
#include <linux/unistd.h>
|
2011-08-22 15:12:02 +00:00
|
|
|
#include <sys/syscall.h>
|
2006-06-29 16:54:54 +00:00
|
|
|
#include <common/config.h>
|
2011-08-22 15:12:02 +00:00
|
|
|
#include <common/syscall.h>
|
2005-12-18 00:11:29 +00:00
|
|
|
|
|
|
|
/* epoll_ctl() commands */
|
2006-06-16 22:04:47 +00:00
|
|
|
#ifndef EPOLL_CTL_ADD
|
2005-12-18 00:11:29 +00:00
|
|
|
#define EPOLL_CTL_ADD 1
|
|
|
|
#define EPOLL_CTL_DEL 2
|
|
|
|
#define EPOLL_CTL_MOD 3
|
2006-06-16 22:04:47 +00:00
|
|
|
#endif
|
2005-12-18 00:11:29 +00:00
|
|
|
|
|
|
|
/* events types (bit fields) */
|
2006-06-16 22:04:47 +00:00
|
|
|
#ifndef EPOLLIN
|
2005-12-18 00:11:29 +00:00
|
|
|
#define EPOLLIN 1
|
|
|
|
#define EPOLLPRI 2
|
|
|
|
#define EPOLLOUT 4
|
|
|
|
#define EPOLLERR 8
|
|
|
|
#define EPOLLHUP 16
|
|
|
|
#define EPOLLONESHOT (1 << 30)
|
|
|
|
#define EPOLLET (1 << 31)
|
2006-06-16 22:04:47 +00:00
|
|
|
#endif
|
2005-12-18 00:11:29 +00:00
|
|
|
|
|
|
|
struct epoll_event {
|
2006-06-26 00:48:02 +00:00
|
|
|
uint32_t events;
|
|
|
|
union {
|
|
|
|
void *ptr;
|
|
|
|
int fd;
|
|
|
|
uint32_t u32;
|
|
|
|
uint64_t u64;
|
|
|
|
} data;
|
2005-12-18 00:11:29 +00:00
|
|
|
};
|
|
|
|
|
2019-05-22 17:24:06 +00:00
|
|
|
#if defined(USE_LINUX_VSYSCALL) && defined(__linux__) && defined(__i386__)
|
2011-08-22 15:12:02 +00:00
|
|
|
/* Those are our self-defined functions */
|
|
|
|
extern int epoll_create(int size);
|
|
|
|
extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event * event);
|
|
|
|
extern int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout);
|
2005-12-18 00:11:29 +00:00
|
|
|
#else
|
2011-08-22 15:12:02 +00:00
|
|
|
|
|
|
|
/* We'll define a syscall, so for this we need __NR_splice. It should have
|
|
|
|
* been provided by syscall.h.
|
|
|
|
*/
|
|
|
|
#if !defined(__NR_epoll_ctl)
|
2005-12-18 00:11:29 +00:00
|
|
|
#warning unsupported architecture, guessing __NR_epoll_create=254 like x86...
|
|
|
|
#define __NR_epoll_create 254
|
|
|
|
#define __NR_epoll_ctl 255
|
|
|
|
#define __NR_epoll_wait 256
|
2011-08-22 15:12:02 +00:00
|
|
|
#endif /* __NR_epoll_ctl */
|
2005-12-18 00:11:29 +00:00
|
|
|
|
2011-08-22 15:12:02 +00:00
|
|
|
static inline _syscall1 (int, epoll_create, int, size);
|
|
|
|
static inline _syscall4 (int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event);
|
|
|
|
static inline _syscall4 (int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout);
|
|
|
|
#endif /* VSYSCALL */
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2011-08-22 15:12:02 +00:00
|
|
|
#endif /* USE_MY_EPOLL */
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2019-05-22 17:24:06 +00:00
|
|
|
#endif /* __linux__ && USE_EPOLL */
|
2011-08-22 15:12:02 +00:00
|
|
|
|
|
|
|
#endif /* _COMMON_EPOLL_H */
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-indent-level: 8
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|