Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 2 | include/common/epoll.h |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 3 | epoll definitions for older libc. |
| 4 | |
| 5 | Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu |
| 6 | |
| 7 | This library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation, version 2.1 |
| 10 | exclusively. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | Lesser General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public |
| 18 | License along with this library; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * Those constants were found both in glibc and in the Linux kernel. |
| 24 | * They are provided here because the epoll() syscall is featured in |
| 25 | * some kernels but in not often included in the glibc, so it needs |
| 26 | * just a basic definition. |
| 27 | */ |
| 28 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 29 | #ifndef _COMMON_EPOLL_H |
| 30 | #define _COMMON_EPOLL_H |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 31 | |
Willy Tarreau | 014b4fe | 2006-10-15 22:57:13 +0200 | [diff] [blame] | 32 | #include <sys/types.h> |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 33 | #include <linux/unistd.h> |
| 34 | |
| 35 | #include <common/config.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 36 | |
| 37 | /* epoll_ctl() commands */ |
| 38 | #ifndef EPOLL_CTL_ADD |
| 39 | #define EPOLL_CTL_ADD 1 |
| 40 | #define EPOLL_CTL_DEL 2 |
| 41 | #define EPOLL_CTL_MOD 3 |
| 42 | #endif |
| 43 | |
| 44 | /* events types (bit fields) */ |
| 45 | #ifndef EPOLLIN |
| 46 | #define EPOLLIN 1 |
| 47 | #define EPOLLPRI 2 |
| 48 | #define EPOLLOUT 4 |
| 49 | #define EPOLLERR 8 |
| 50 | #define EPOLLHUP 16 |
| 51 | #define EPOLLONESHOT (1 << 30) |
| 52 | #define EPOLLET (1 << 31) |
| 53 | #endif |
| 54 | |
| 55 | struct epoll_event { |
| 56 | uint32_t events; |
| 57 | union { |
| 58 | void *ptr; |
| 59 | int fd; |
| 60 | uint32_t u32; |
| 61 | uint64_t u64; |
| 62 | } data; |
| 63 | }; |
| 64 | |
| 65 | |
| 66 | #if defined(__powerpc__) || defined(__powerpc64__) |
| 67 | #define __NR_epoll_create 236 |
| 68 | #define __NR_epoll_ctl 237 |
| 69 | #define __NR_epoll_wait 238 |
| 70 | #elif defined(__sparc__) || defined(__sparc64__) |
| 71 | #define __NR_epoll_create 193 |
| 72 | #define __NR_epoll_ctl 194 |
| 73 | #define __NR_epoll_wait 195 |
| 74 | #elif defined(__x86_64__) |
| 75 | #define __NR_epoll_create 213 |
| 76 | #define __NR_epoll_ctl 214 |
| 77 | #define __NR_epoll_wait 215 |
| 78 | #elif defined(__alpha__) |
| 79 | #define __NR_epoll_create 407 |
| 80 | #define __NR_epoll_ctl 408 |
| 81 | #define __NR_epoll_wait 409 |
| 82 | #elif defined (__i386__) |
| 83 | #define __NR_epoll_create 254 |
| 84 | #define __NR_epoll_ctl 255 |
| 85 | #define __NR_epoll_wait 256 |
| 86 | #else |
| 87 | #warning unsupported architecture, guessing __NR_epoll_create=254 like x86... |
| 88 | #define __NR_epoll_create 254 |
| 89 | #define __NR_epoll_ctl 255 |
| 90 | #define __NR_epoll_wait 256 |
| 91 | #endif |
| 92 | |
| 93 | extern int epoll_create(int size); |
| 94 | extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event * event); |
| 95 | extern int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout); |
| 96 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 97 | #endif /* _COMMON_EPOLL_H */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 98 | |
| 99 | |
| 100 | /* |
| 101 | * Local variables: |
| 102 | * c-indent-level: 8 |
| 103 | * c-basic-offset: 8 |
| 104 | * End: |
| 105 | */ |