mirror of
https://github.com/fltk/fltk.git
synced 2026-05-10 14:19:02 +08:00
Restore use of build option FLTK_USE_POLL
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
# if USE_POLL
|
||||
|
||||
# include <poll.h>
|
||||
static pollfd *pollfds = 0;
|
||||
|
||||
# else
|
||||
# if HAVE_SYS_SELECT_H
|
||||
@@ -52,7 +51,9 @@ static pollfd *pollfds = 0;
|
||||
|
||||
class Fl_Unix_Screen_Driver : public Fl_Screen_Driver {
|
||||
public:
|
||||
# if !USE_POLL
|
||||
# if USE_POLL
|
||||
static pollfd *pollfds;
|
||||
# else
|
||||
static fd_set fdsets[3];
|
||||
# endif
|
||||
static int maxfd;
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#include <sys/time.h>
|
||||
#include "Fl_Unix_Screen_Driver.H"
|
||||
|
||||
#if !USE_POLL
|
||||
#if USE_POLL
|
||||
pollfd *Fl_Unix_Screen_Driver::pollfds = NULL;
|
||||
#else
|
||||
fd_set Fl_Unix_Screen_Driver::fdsets[3];
|
||||
#endif
|
||||
int Fl_Unix_Screen_Driver::maxfd = 0;
|
||||
|
||||
@@ -723,18 +723,18 @@ void Fl_Unix_System_Driver::add_fd(int n, int events, void (*cb)(int, void*), vo
|
||||
# if USE_POLL
|
||||
pollfd *tpoll;
|
||||
|
||||
if (!pollfds) tpoll = (pollfd*)malloc(fd_array_size*sizeof(pollfd));
|
||||
else tpoll = (pollfd*)realloc(pollfds, fd_array_size*sizeof(pollfd));
|
||||
if (!Fl_Unix_Screen_Driver::pollfds) tpoll = (pollfd*)malloc(fd_array_size*sizeof(pollfd));
|
||||
else tpoll = (pollfd*)realloc(Fl_Unix_Screen_Driver::pollfds, fd_array_size*sizeof(pollfd));
|
||||
|
||||
if (!tpoll) return;
|
||||
pollfds = tpoll;
|
||||
Fl_Unix_Screen_Driver::pollfds = tpoll;
|
||||
# endif
|
||||
}
|
||||
Fl_Unix_Screen_Driver::fd[i].cb = cb;
|
||||
Fl_Unix_Screen_Driver::fd[i].arg = v;
|
||||
# if USE_POLL
|
||||
pollfds[i].fd = n;
|
||||
pollfds[i].events = events;
|
||||
Fl_Unix_Screen_Driver::pollfds[i].fd = n;
|
||||
Fl_Unix_Screen_Driver::pollfds[i].events = events;
|
||||
# else
|
||||
Fl_Unix_Screen_Driver::fd[i].fd = n;
|
||||
Fl_Unix_Screen_Driver::fd[i].events = events;
|
||||
@@ -756,10 +756,10 @@ void Fl_Unix_System_Driver::remove_fd(int n, int events) {
|
||||
# endif
|
||||
for (i=j=0; i<Fl_Unix_Screen_Driver::nfds; i++) {
|
||||
# if USE_POLL
|
||||
if (pollfds[i].fd == n) {
|
||||
int e = pollfds[i].events & ~events;
|
||||
if (Fl_Unix_Screen_Driver::pollfds[i].fd == n) {
|
||||
int e = Fl_Unix_Screen_Driver::pollfds[i].events & ~events;
|
||||
if (!e) continue; // if no events left, delete this fd
|
||||
pollfds[j].events = e;
|
||||
Fl_Unix_Screen_Driver::pollfds[j].events = e;
|
||||
}
|
||||
# else
|
||||
if (Fl_Unix_Screen_Driver::fd[i].fd == n) {
|
||||
@@ -773,7 +773,7 @@ void Fl_Unix_System_Driver::remove_fd(int n, int events) {
|
||||
if (j<i) {
|
||||
Fl_Unix_Screen_Driver::fd[j] = Fl_Unix_Screen_Driver::fd[i];
|
||||
# if USE_POLL
|
||||
pollfds[j] = pollfds[i];
|
||||
Fl_Unix_Screen_Driver::pollfds[j] = Fl_Unix_Screen_Driver::pollfds[i];
|
||||
# endif
|
||||
}
|
||||
j++;
|
||||
|
||||
Reference in New Issue
Block a user