On Jul 5 17:51, Ken Brown wrote: > On 7/5/2022 10:13 AM, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote: > > Hi, > > > > There's some inconsistency between <sys/select.h> and <sys/param.h>: > > > > sys/select.h has this: > > ----------------------- > > /* > > * Select uses bit masks of file descriptors in longs. > > * These macros manipulate such bit fields (the filesystem macros use > > chars). > > * FD_SETSIZE may be defined by the user, but the default here > > * should be >= NOFILE (param.h). > > */ > > #ifndef FD_SETSIZE > > #define FD_SETSIZE 64 > > #endif > > ---------------------- > > I think Cygwin's FD macros are based on FreeBSD. The most recent > <sys/select.h> on FreeBSD says: > > --------------------------------------------------------------------- > /* > * Select uses bit masks of file descriptors in longs. These macros > * manipulate such bit fields (the filesystem macros use chars). > * FD_SETSIZE may be defined by the user, but the default here should > * be enough for most uses. > */ > #ifndef FD_SETSIZE > #define FD_SETSIZE 1024 > #endif > --------------------------------------------------------------------- > > NOFILE isn't mentioned. Maybe Cygwin (or really newlib) should also remove > the reference to NOFILE and, perhaps, change the default FD_SETSIZE to 1024.
NOFILE is the old BSD variant of OPEN_MAX. In Cygwin it's defined a bit weird because the values of NOFILE and OPEN_MAX don't correspond. While NOFILE is the arbitrary value 8192 (whereever I took that from back in 2003), OPEN_MAX is __OPEN_MAX which is the historical arbitrary value 3200. Linux doesn't define OPEN_MAX (X11 does for some reason) and NOFILE is based on OPEN_AX, i. e. #if !defined NOFILE && defined OPEN_MAX # define NOFILE OPEN_MAX #endif We should probably do the same on the master branch. In theory there should be no source anymore actually requiring on of these macros. > But Cygwin isn't the only newlib target, so there might be good reasons to > keep it at 64. > > Corinna, WDYT? Or should the discussion be moved to the newlib list? I guess we can change FD_SETSIZE to 1024 as on Linux, albeit this has no real meaning on Cygwin. On Linux, select(2) is really only capable to handle file descriptors numbers up to descriptor number 1023, but Cygwin doesn't have this problem. FD_SETSIZE == 64 was only something to save space. The bigger FD_SETSIZE, the bigger are the default fd_sets, something you don't want on small targets. So, yeah, something like #ifndef FD_SETSIZE # ifdef __CYGWIN__ # define FD_SETSIZE 1024 # else # define FD_SETSIZE 64 # endif #endif would be ok for master. Corinna -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple