2020-09-16 02:29:03 +08:00
|
|
|
#ifndef MYPOLL_H
|
|
|
|
#define MYPOLL_H
|
|
|
|
|
2020-09-16 03:01:01 +08:00
|
|
|
#include "config.h"
|
2020-09-16 02:29:03 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_POLL_H
|
2020-09-18 04:03:51 +08:00
|
|
|
#define SELECT_OR_POLL "poll"
|
2020-09-16 03:01:01 +08:00
|
|
|
|
2020-09-16 02:29:03 +08:00
|
|
|
#include <poll.h>
|
|
|
|
typedef struct pollfd pollfd_struct;
|
2020-09-16 03:01:01 +08:00
|
|
|
|
|
|
|
#define MYPOLL_READ POLLIN
|
|
|
|
#define MYPOLL_WRITE POLLOUT
|
|
|
|
|
2020-09-16 02:29:03 +08:00
|
|
|
#else
|
2020-09-16 03:01:01 +08:00
|
|
|
|
2020-09-18 04:03:51 +08:00
|
|
|
#define SELECT_OR_POLL "select"
|
2020-09-16 03:01:01 +08:00
|
|
|
#include <sys/select.h>
|
2020-09-16 02:29:03 +08:00
|
|
|
typedef struct mypollfd {
|
|
|
|
int fd;
|
|
|
|
short events;
|
|
|
|
short revents;
|
|
|
|
} pollfd_struct;
|
|
|
|
|
|
|
|
#define MYPOLL_READ (1<<1)
|
|
|
|
#define MYPOLL_WRITE (1<<2)
|
2020-09-16 03:01:01 +08:00
|
|
|
#endif
|
2020-09-16 02:29:03 +08:00
|
|
|
|
|
|
|
int mypoll(pollfd_struct* fds, int nfds, int timeout);
|
|
|
|
|
|
|
|
#endif
|