poll.c

Cross-platform polling library for C
git clone git://git.finwo.net/lib/poll.c
Log | Files | Refs | README

fpoll.h (1053B)


      1 #ifndef __FINWO_POLL_H__
      2 #define __FINWO_POLL_H__
      3 
      4 #include <stdbool.h>
      5 
      6 #include "poll_compat.h"
      7 
      8 #ifndef FPOLL_STATUS
      9 #define FPOLL_STATUS        int
     10 #endif
     11 #define FPOLL_STATUS_OK     0
     12 #define FPOLL_STATUS_ERROR  1
     13 
     14 #ifndef FPOLL_EVENT
     15 #define FPOLL_EVENT         int
     16 #endif
     17 #define FPOLL_IN            POLLIN
     18 #define FPOLL_OUT           POLLOUT
     19 #define FPOLL_HUP           POLLHUP
     20 
     21 #ifndef FPOLL_FD
     22 #define FPOLL_FD            int
     23 #endif
     24 
     25 struct fpoll {
     26   struct pollfd *fds;
     27   void          **udata;
     28   int size;
     29   int limit;
     30   int remaining;
     31 };
     32 
     33 struct fpoll_ev {
     34   FPOLL_FD    fd;
     35   FPOLL_EVENT ev;
     36   void        *udata;
     37 };
     38 
     39 struct fpoll * fpoll_create();
     40 FPOLL_STATUS   fpoll_close(struct fpoll *descriptor);
     41 int            fpoll_wait(struct fpoll *descriptor, struct fpoll_ev *evs, int max_evs, int timeout);
     42 FPOLL_STATUS   fpoll_add(struct fpoll *descriptor, FPOLL_EVENT events, FPOLL_FD filedescriptor, void *udata);
     43 FPOLL_STATUS   fpoll_del(struct fpoll *descriptor, FPOLL_EVENT events, FPOLL_FD filedescriptor);
     44 
     45 #endif // __FINWO_POLL_H__