This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: FD_SETSIZE and sizeof(fd_set) - thanks for a simple solution
- From: Steven Bardwell <SBardwell at lbmsys dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Thu, 23 Jun 2016 12:07:09 +0000
- Subject: RE: FD_SETSIZE and sizeof(fd_set) - thanks for a simple solution
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp dot mailfrom=SBardwell at lbmsys dot com;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
> > > > > > Here is a "program" that shows the issue I am worried about. It is so
> simple
> > > > > that I must be overlooking something really obvious:
> > > > > >
> > > > > > #include <stdio.h>
> > > > > > #undef FD_SETSIZE
> > > > > > #define FD_SETSIZE 256
> > > > > > #include <sys/types.h>
> > > > > > #include <sys/select.h>
> > > > > >
> > > > > > main()
> > > > > > {
> > > > > > fd_set rfds;
> > > > > > fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
> > > > > > fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
> > > > > > }
> > > > > >
> > > > > > Steve Bardwell
> > > > > >
> > > > For what it's worth, this 'program' works as expected in SUA. The size
> > > > of the fd_set changes depending on the value of FD_SETSIZE.
> > >
> Oh yeah, the inclusion of stdio.h also includes sys/select.h so the
> first (default) definition of FD_SETSIZE to 64 rules. In theory it
> shouldn't do that so we might have to change it in the newlib headers,
> but for th time being, just define FD_SETSIZE before including any
> system header.
>
>
> Corinna
Brilliant! Thanks so much for figuring this out.
Steve Bardwell