1 /***************************************************************************** 2 * Written by Chris Dunlap <cdunlap@llnl.gov>. 3 * Copyright (C) 2007-2018 Lawrence Livermore National Security, LLC. 4 * Copyright (C) 2001-2007 The Regents of the University of California. 5 * UCRL-CODE-2002-009. 6 * 7 * This file is part of ConMan: The Console Manager. 8 * For details, see <https://dun.github.io/conman/>. 9 * 10 * ConMan is free software: you can redistribute it and/or modify it under 11 * the terms of the GNU General Public License as published by the Free 12 * Software Foundation, either version 3 of the License, or (at your option) 13 * any later version. 14 * 15 * ConMan is distributed in the hope that it will be useful, but WITHOUT 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18 * for more details. 19 * 20 * You should have received a copy of the GNU General Public License along 21 * with ConMan. If not, see <http://www.gnu.org/licenses/>. 22 *****************************************************************************/ 23 24 25 #ifndef _TPOLL_H 26 #define _TPOLL_H 27 28 #include <poll.h> 29 #include <sys/time.h> 30 31 32 /***************************************************************************** 33 * Data Types 34 *****************************************************************************/ 35 36 typedef struct tpoll * tpoll_t; 37 /* 38 * Opaque data pointer for a tpoll object. 39 */ 40 41 typedef void (*callback_f) (void *arg); 42 /* 43 * Function prototype for a timer callback function. 44 */ 45 46 typedef enum { 47 /* 48 * Data type for tpoll_zero() [how] parameter. 49 */ 50 TPOLL_ZERO_FDS = 0x01, /* zero fds but not timers */ 51 TPOLL_ZERO_TIMERS = 0x02, /* zero timers but not fds */ 52 TPOLL_ZERO_ALL = 0x03 /* zero both fds and timers */ 53 } tpoll_zero_t; 54 55 56 /***************************************************************************** 57 * Functions 58 *****************************************************************************/ 59 60 tpoll_t tpoll_create (int n); 61 62 void tpoll_destroy (tpoll_t tp); 63 64 int tpoll_zero (tpoll_t tp, tpoll_zero_t how); 65 66 int tpoll_clear (tpoll_t tp, int fd, short int events); 67 68 int tpoll_is_set (tpoll_t tp, int fd, short int events); 69 70 int tpoll_set (tpoll_t tp, int fd, short int events); 71 72 int tpoll_timeout_absolute (tpoll_t tp, callback_f cb, void *arg, 73 const struct timeval *tvp); 74 75 int tpoll_timeout_relative (tpoll_t tp, callback_f cb, void *arg, int ms); 76 77 int tpoll_timeout_cancel (tpoll_t tp, int id); 78 79 int tpoll (tpoll_t tp, int ms); 80 81 82 #endif /* !_TPOLL_H */ 83