April 2024 | ||||||
Mo | Tu | We | Th | Fr | Sa | Su |
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 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
001: /* Copyright (C) 2002-2008, 2010, 2011 Free Software Foundation, Inc. 002: This file is part of the GNU C Library. 003: 004: The GNU C Library is free software; you can redistribute it and/or 005: modify it under the terms of the GNU Lesser General Public 006: License as published by the Free Software Foundation; either 007: version 2.1 of the License, or (at your option) any later version. 008: 009: The GNU C Library is distributed in the hope that it will be useful, 010: but WITHOUT ANY WARRANTY; without even the implied warranty of 011: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012: Lesser General Public License for more details. 013: 014: You should have received a copy of the GNU Lesser General Public 015: License along with the GNU C Library; if not, write to the Free 016: Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 017: 02111-1307 USA. */ 018: 019: #ifndef _SYS_EPOLL_H 020: #define _SYS_EPOLL_H 1 021: 022: #include <stdint.h> 023: #include <sys/types.h> 024: 025: /* Get __sigset_t. */ 026: #include <bits/sigset.h> 027: 028: #ifndef __sigset_t_defined 029: # define __sigset_t_defined 030: typedef __sigset_t sigset_t; 031: #endif 032: 033: 034: /* Flags to be passed to epoll_create1. */ 035: enum 036: { 037: EPOLL_CLOEXEC = 02000000, 038: #define EPOLL_CLOEXEC EPOLL_CLOEXEC 039: EPOLL_NONBLOCK = 04000 040: #define EPOLL_NONBLOCK EPOLL_NONBLOCK 041: }; 042: 043: 044: enum EPOLL_EVENTS 045: { 046: EPOLLIN = 0x001, 047: #define EPOLLIN EPOLLIN 048: EPOLLPRI = 0x002, 049: #define EPOLLPRI EPOLLPRI 050: EPOLLOUT = 0x004, 051: #define EPOLLOUT EPOLLOUT 052: EPOLLRDNORM = 0x040, 053: #define EPOLLRDNORM EPOLLRDNORM 054: EPOLLRDBAND = 0x080, 055: #define EPOLLRDBAND EPOLLRDBAND 056: EPOLLWRNORM = 0x100, 057: #define EPOLLWRNORM EPOLLWRNORM 058: EPOLLWRBAND = 0x200, 059: #define EPOLLWRBAND EPOLLWRBAND 060: EPOLLMSG = 0x400, 061: #define EPOLLMSG EPOLLMSG 062: EPOLLERR = 0x008, 063: #define EPOLLERR EPOLLERR 064: EPOLLHUP = 0x010, 065: #define EPOLLHUP EPOLLHUP 066: EPOLLRDHUP = 0x2000, 067: #define EPOLLRDHUP EPOLLRDHUP 068: EPOLLONESHOT = 1u << 30, 069: #define EPOLLONESHOT EPOLLONESHOT 070: EPOLLET = 1u << 31 071: #define EPOLLET EPOLLET 072: }; 073: 074: 075: /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ 076: #define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */ 077: #define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */ 078: #define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */ 079: 080: 081: typedef union epoll_data 082: { 083: void *ptr; 084: int fd; 085: uint32_t u32; 086: uint64_t u64; 087: } epoll_data_t; 088: 089: struct epoll_event 090: { 091: uint32_t events; /* Epoll events */ 092: epoll_data_t data; /* User data variable */ 093: } __attribute__ ((__packed__)); 094: 095: 096: __BEGIN_DECLS 097: 098: /* Creates an epoll instance. Returns an fd for the new instance. 099: The "size" parameter is a hint specifying the number of file 100: descriptors to be associated with the new instance. The fd 101: returned by epoll_create() should be closed with close(). */ 102: extern int epoll_create (int __size) __THROW; 103: 104: /* Same as epoll_create but with an FLAGS parameter. The unused SIZE 105: parameter has been dropped. */ 106: extern int epoll_create1 (int __flags) __THROW; 107: 108: 109: /* Manipulate an epoll instance "epfd". Returns 0 in case of success, 110: -1 in case of error ( the "errno" variable will contain the 111: specific error code ) The "op" parameter is one of the EPOLL_CTL_* 112: constants defined above. The "fd" parameter is the target of the 113: operation. The "event" parameter describes which events the caller 114: is interested in and any associated user data. */ 115: extern int epoll_ctl (int __epfd, int __op, int __fd, 116: struct epoll_event *__event) __THROW; 117: 118: 119: /* Wait for events on an epoll instance "epfd". Returns the number of 120: triggered events returned in "events" buffer. Or -1 in case of 121: error with the "errno" variable set to the specific error code. The 122: "events" parameter is a buffer that will contain triggered 123: events. The "maxevents" is the maximum number of events to be 124: returned ( usually size of "events" ). The "timeout" parameter 125: specifies the maximum wait time in milliseconds (-1 == infinite). 126: 127: This function is a cancellation point and therefore not marked with 128: __THROW. */ 129: extern int epoll_wait (int __epfd, struct epoll_event *__events, 130: int __maxevents, int __timeout); 131: 132: 133: /* Same as epoll_wait, but the thread's signal mask is temporarily 134: and atomically replaced with the one provided as parameter. 135: 136: This function is a cancellation point and therefore not marked with 137: __THROW. */ 138: extern int epoll_pwait (int __epfd, struct epoll_event *__events, 139: int __maxevents, int __timeout, 140: __const __sigset_t *__ss); 141: 142: __END_DECLS 143: 144: #endif /* sys/epoll.h */ 145: