fdManager uses poll() on Windows and RTEMS too

RTEMS needs to use the "new" network stack
Windows has poll since Vista
Don't use poll on cygwin: it emulates poll() using select().
This commit is contained in:
2025-01-23 10:30:38 +01:00
parent 57c0295024
commit cbbbd67843
2 changed files with 26 additions and 21 deletions

View File

@ -19,28 +19,33 @@
// 1) This library is not thread safe // 1) This library is not thread safe
// //
#include <algorithm>
#define instantiateRecourceLib #define instantiateRecourceLib
#include "epicsAssert.h" #include "epicsAssert.h"
#include "epicsThread.h" #include "epicsThread.h"
#include "fdManager.h" #include "fdManager.h"
#include "locationException.h" #include "locationException.h"
using std :: max;
fdManager fileDescriptorManager;
static const unsigned mSecPerSec = 1000u;
static const unsigned uSecPerSec = 1000u * mSecPerSec;
#ifdef FDMGR_USE_POLL #ifdef FDMGR_USE_POLL
#ifdef _WIN32
#define poll WSAPoll
#endif
static const int PollEvents[] = { // must match fdRegType static const int PollEvents[] = { // must match fdRegType
POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR, POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR,
POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR, POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR,
POLLPRI}; POLLPRI};
#endif #endif
#ifdef FDMGR_USE_SELECT
#include <algorithm>
using std :: max;
#endif
fdManager fileDescriptorManager;
static const unsigned mSecPerSec = 1000u;
static const unsigned uSecPerSec = 1000u * mSecPerSec;
// //
// fdManager::fdManager() // fdManager::fdManager()
// //

View File

@ -19,18 +19,6 @@
#ifndef fdManagerH_included #ifndef fdManagerH_included
#define fdManagerH_included #define fdManagerH_included
#if !defined(FDMGR_USE_POLL) && !defined(FDMGR_USE_SELECT)
#if defined(__linux__)
#define FDMGR_USE_POLL
#else
#define FDMGR_USE_SELECT
#endif
#endif
#ifdef FDMGR_USE_POLL
#include <poll.h>
#endif
#include "libComAPI.h" // reset share lib defines #include "libComAPI.h" // reset share lib defines
#include "tsDLList.h" #include "tsDLList.h"
#include "resourceLib.h" #include "resourceLib.h"
@ -38,6 +26,18 @@
#include "osiSock.h" #include "osiSock.h"
#include "epicsTimer.h" #include "epicsTimer.h"
#if !defined(FDMGR_USE_POLL) && !defined(FDMGR_USE_SELECT)
#if defined(__linux__) || _WIN32_WINNT >= 0x600 || (defined(__rtems__) && !defined(RTEMS_LEGACY_STACK))
#define FDMGR_USE_POLL
#else
#define FDMGR_USE_SELECT
#endif
#endif
#if defined(FDMGR_USE_POLL) && !defined(_WIN32)
#include <poll.h>
#endif
enum fdRegType {fdrRead, fdrWrite, fdrException, fdrNEnums}; enum fdRegType {fdrRead, fdrWrite, fdrException, fdrNEnums};
// //