Blame sysdeps/unix/sysv/linux/sys/epoll.h

Packit 6c4009
/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef	_SYS_EPOLL_H
Packit 6c4009
#define	_SYS_EPOLL_H	1
Packit 6c4009
Packit 6c4009
#include <stdint.h>
Packit 6c4009
#include <sys/types.h>
Packit 6c4009
Packit 6c4009
#include <bits/types/sigset_t.h>
Packit 6c4009
Packit 6c4009
/* Get the platform-dependent flags.  */
Packit 6c4009
#include <bits/epoll.h>
Packit 6c4009
Packit 6c4009
#ifndef __EPOLL_PACKED
Packit 6c4009
# define __EPOLL_PACKED
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
enum EPOLL_EVENTS
Packit 6c4009
  {
Packit 6c4009
    EPOLLIN = 0x001,
Packit 6c4009
#define EPOLLIN EPOLLIN
Packit 6c4009
    EPOLLPRI = 0x002,
Packit 6c4009
#define EPOLLPRI EPOLLPRI
Packit 6c4009
    EPOLLOUT = 0x004,
Packit 6c4009
#define EPOLLOUT EPOLLOUT
Packit 6c4009
    EPOLLRDNORM = 0x040,
Packit 6c4009
#define EPOLLRDNORM EPOLLRDNORM
Packit 6c4009
    EPOLLRDBAND = 0x080,
Packit 6c4009
#define EPOLLRDBAND EPOLLRDBAND
Packit 6c4009
    EPOLLWRNORM = 0x100,
Packit 6c4009
#define EPOLLWRNORM EPOLLWRNORM
Packit 6c4009
    EPOLLWRBAND = 0x200,
Packit 6c4009
#define EPOLLWRBAND EPOLLWRBAND
Packit 6c4009
    EPOLLMSG = 0x400,
Packit 6c4009
#define EPOLLMSG EPOLLMSG
Packit 6c4009
    EPOLLERR = 0x008,
Packit 6c4009
#define EPOLLERR EPOLLERR
Packit 6c4009
    EPOLLHUP = 0x010,
Packit 6c4009
#define EPOLLHUP EPOLLHUP
Packit 6c4009
    EPOLLRDHUP = 0x2000,
Packit 6c4009
#define EPOLLRDHUP EPOLLRDHUP
Packit 6c4009
    EPOLLEXCLUSIVE = 1u << 28,
Packit 6c4009
#define EPOLLEXCLUSIVE EPOLLEXCLUSIVE
Packit 6c4009
    EPOLLWAKEUP = 1u << 29,
Packit 6c4009
#define EPOLLWAKEUP EPOLLWAKEUP
Packit 6c4009
    EPOLLONESHOT = 1u << 30,
Packit 6c4009
#define EPOLLONESHOT EPOLLONESHOT
Packit 6c4009
    EPOLLET = 1u << 31
Packit 6c4009
#define EPOLLET EPOLLET
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl().  */
Packit 6c4009
#define EPOLL_CTL_ADD 1	/* Add a file descriptor to the interface.  */
Packit 6c4009
#define EPOLL_CTL_DEL 2	/* Remove a file descriptor from the interface.  */
Packit 6c4009
#define EPOLL_CTL_MOD 3	/* Change file descriptor epoll_event structure.  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
typedef union epoll_data
Packit 6c4009
{
Packit 6c4009
  void *ptr;
Packit 6c4009
  int fd;
Packit 6c4009
  uint32_t u32;
Packit 6c4009
  uint64_t u64;
Packit 6c4009
} epoll_data_t;
Packit 6c4009
Packit 6c4009
struct epoll_event
Packit 6c4009
{
Packit 6c4009
  uint32_t events;	/* Epoll events */
Packit 6c4009
  epoll_data_t data;	/* User data variable */
Packit 6c4009
} __EPOLL_PACKED;
Packit 6c4009
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Creates an epoll instance.  Returns an fd for the new instance.
Packit 6c4009
   The "size" parameter is a hint specifying the number of file
Packit 6c4009
   descriptors to be associated with the new instance.  The fd
Packit 6c4009
   returned by epoll_create() should be closed with close().  */
Packit 6c4009
extern int epoll_create (int __size) __THROW;
Packit 6c4009
Packit 6c4009
/* Same as epoll_create but with an FLAGS parameter.  The unused SIZE
Packit 6c4009
   parameter has been dropped.  */
Packit 6c4009
extern int epoll_create1 (int __flags) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Manipulate an epoll instance "epfd". Returns 0 in case of success,
Packit 6c4009
   -1 in case of error ( the "errno" variable will contain the
Packit 6c4009
   specific error code ) The "op" parameter is one of the EPOLL_CTL_*
Packit 6c4009
   constants defined above. The "fd" parameter is the target of the
Packit 6c4009
   operation. The "event" parameter describes which events the caller
Packit 6c4009
   is interested in and any associated user data.  */
Packit 6c4009
extern int epoll_ctl (int __epfd, int __op, int __fd,
Packit 6c4009
		      struct epoll_event *__event) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Wait for events on an epoll instance "epfd". Returns the number of
Packit 6c4009
   triggered events returned in "events" buffer. Or -1 in case of
Packit 6c4009
   error with the "errno" variable set to the specific error code. The
Packit 6c4009
   "events" parameter is a buffer that will contain triggered
Packit 6c4009
   events. The "maxevents" is the maximum number of events to be
Packit 6c4009
   returned ( usually size of "events" ). The "timeout" parameter
Packit 6c4009
   specifies the maximum wait time in milliseconds (-1 == infinite).
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern int epoll_wait (int __epfd, struct epoll_event *__events,
Packit 6c4009
		       int __maxevents, int __timeout);
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Same as epoll_wait, but the thread's signal mask is temporarily
Packit 6c4009
   and atomically replaced with the one provided as parameter.
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern int epoll_pwait (int __epfd, struct epoll_event *__events,
Packit 6c4009
			int __maxevents, int __timeout,
Packit 6c4009
			const __sigset_t *__ss);
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* sys/epoll.h */