RE: FD_SETSIZE and sizeof(fd_set) - thanks for a simple solution

2016-06-23 Thread Steven Bardwell
> > > > > > 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 
> > > > > > #undef FD_SETSIZE
> > > > > > #define FD_SETSIZE 256
> > > > > > #include 
> > > > > > #include 
> > > > > >
> > > > > > 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



Re: FD_SETSIZE and sizeof(fd_set)

2016-06-23 Thread Corinna Vinschen
On Jun 23 14:01, Corinna Vinschen wrote:
> On Jun 23 13:55, Corinna Vinschen wrote:
> > On Jun 23 13:52, Corinna Vinschen wrote:
> > > On Jun 23 11:36, Steven Bardwell wrote:
> > > > > >
> > > > > > 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 
> > > > > > #undef FD_SETSIZE
> > > > > > #define FD_SETSIZE 256
> > > > > > #include 
> > > > > > #include 
> > > > > >
> > > > > > main()
> > > > > > {
> > > > > > fd_set rfds;
> > > > > > fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
> > > > > > fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
> > > > > > }
> > > > > >
> > > > > > Steve Bardwell
> > > > > >
> > > > > >
> > > > > 
> > > > > I don't know if this is still the case, but when I looked into this 
> > > > > years ago I
> > > > > found that it was not possible to change the size of the fd set in 
> > > > > linux, it's
> > > > > fixed at 1024 (generally), unless you rebuild the kernel.
> > > > > 
> > > > > Secondly, in the windows api, their version of an fd_set is more like 
> > > > > a poll()
> > > > > implementation, you can fake out any size you want since the size of 
> > > > > the
> > > > > array is the first entry.
> > > > > 
> > > > > I can't speak for the cygwin implementations, but if they offer 
> > > > > poll() or,
> > > > > better, epoll(), use those.
> > > > > 
> > > > > -lee
> > > > 
> > > > 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.
> > > 
> > > In my case it prints 'sizeof(fd_set)=8', which is correct.  For
> > > historical reasons and an ill-advised compatibility with old cruft,
> > > fd_set is an array of bit per descriptor.  8 * 8 = 256.
> > 
> > Now that's embarassing.  I guess I shgould go to primary school again.
> > 
> > Hang on, I 'll have a nother look while I'nm trying to get the red out of
> > my face...
> 
> 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,

Oh no, we don't have to.  sys/select.h is included via sys/types.h
*iff* __BSD_VISIBLE is set.  __BSD_VISIBLE is set by default unless
you set some feature macro like _POSIX_C_SOURCE.  Have a look into
 for a description.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


Re: FD_SETSIZE and sizeof(fd_set)

2016-06-23 Thread Corinna Vinschen
On Jun 23 13:55, Corinna Vinschen wrote:
> On Jun 23 13:52, Corinna Vinschen wrote:
> > On Jun 23 11:36, Steven Bardwell wrote:
> > > > >
> > > > > 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 
> > > > > #undef FD_SETSIZE
> > > > > #define FD_SETSIZE 256
> > > > > #include 
> > > > > #include 
> > > > >
> > > > > main()
> > > > > {
> > > > > fd_set rfds;
> > > > > fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
> > > > > fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
> > > > > }
> > > > >
> > > > > Steve Bardwell
> > > > >
> > > > >
> > > > 
> > > > I don't know if this is still the case, but when I looked into this 
> > > > years ago I
> > > > found that it was not possible to change the size of the fd set in 
> > > > linux, it's
> > > > fixed at 1024 (generally), unless you rebuild the kernel.
> > > > 
> > > > Secondly, in the windows api, their version of an fd_set is more like a 
> > > > poll()
> > > > implementation, you can fake out any size you want since the size of the
> > > > array is the first entry.
> > > > 
> > > > I can't speak for the cygwin implementations, but if they offer poll() 
> > > > or,
> > > > better, epoll(), use those.
> > > > 
> > > > -lee
> > > 
> > > 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.
> > 
> > In my case it prints 'sizeof(fd_set)=8', which is correct.  For
> > historical reasons and an ill-advised compatibility with old cruft,
> > fd_set is an array of bit per descriptor.  8 * 8 = 256.
> 
> Now that's embarassing.  I guess I shgould go to primary school again.
> 
> Hang on, I 'll have a nother look while I'nm trying to get the red out of
> my face...

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

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


Re: FD_SETSIZE and sizeof(fd_set)

2016-06-23 Thread Corinna Vinschen
On Jun 23 13:52, Corinna Vinschen wrote:
> On Jun 23 11:36, Steven Bardwell wrote:
> > > >
> > > > 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 
> > > > #undef FD_SETSIZE
> > > > #define FD_SETSIZE 256
> > > > #include 
> > > > #include 
> > > >
> > > > main()
> > > > {
> > > > fd_set rfds;
> > > > fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
> > > > fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
> > > > }
> > > >
> > > > Steve Bardwell
> > > >
> > > >
> > > 
> > > I don't know if this is still the case, but when I looked into this years 
> > > ago I
> > > found that it was not possible to change the size of the fd set in linux, 
> > > it's
> > > fixed at 1024 (generally), unless you rebuild the kernel.
> > > 
> > > Secondly, in the windows api, their version of an fd_set is more like a 
> > > poll()
> > > implementation, you can fake out any size you want since the size of the
> > > array is the first entry.
> > > 
> > > I can't speak for the cygwin implementations, but if they offer poll() or,
> > > better, epoll(), use those.
> > > 
> > > -lee
> > 
> > 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.
> 
> In my case it prints 'sizeof(fd_set)=8', which is correct.  For
> historical reasons and an ill-advised compatibility with old cruft,
> fd_set is an array of bit per descriptor.  8 * 8 = 256.

Now that's embarassing.  I guess I shgould go to primary school again.

Hang on, I 'll have a nother look while I'nm trying to get the red out of
my face...


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


Re: FD_SETSIZE and sizeof(fd_set)

2016-06-23 Thread Corinna Vinschen
On Jun 23 11:36, Steven Bardwell wrote:
> > >
> > > 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 
> > > #undef FD_SETSIZE
> > > #define FD_SETSIZE 256
> > > #include 
> > > #include 
> > >
> > > main()
> > > {
> > > fd_set rfds;
> > > fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
> > > fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
> > > }
> > >
> > > Steve Bardwell
> > >
> > >
> > 
> > I don't know if this is still the case, but when I looked into this years 
> > ago I
> > found that it was not possible to change the size of the fd set in linux, 
> > it's
> > fixed at 1024 (generally), unless you rebuild the kernel.
> > 
> > Secondly, in the windows api, their version of an fd_set is more like a 
> > poll()
> > implementation, you can fake out any size you want since the size of the
> > array is the first entry.
> > 
> > I can't speak for the cygwin implementations, but if they offer poll() or,
> > better, epoll(), use those.
> > 
> > -lee
> 
> 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.

In my case it prints 'sizeof(fd_set)=8', which is correct.  For
historical reasons and an ill-advised compatibility with old cruft,
fd_set is an array of bit per descriptor.  8 * 8 = 256.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


RE: FD_SETSIZE and sizeof(fd_set)

2016-06-23 Thread Steven Bardwell
> >
> > 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 
> > #undef FD_SETSIZE
> > #define FD_SETSIZE 256
> > #include 
> > #include 
> >
> > main()
> > {
> > fd_set rfds;
> > fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
> > fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
> > }
> >
> > Steve Bardwell
> >
> >
> 
> I don't know if this is still the case, but when I looked into this years ago 
> I
> found that it was not possible to change the size of the fd set in linux, it's
> fixed at 1024 (generally), unless you rebuild the kernel.
> 
> Secondly, in the windows api, their version of an fd_set is more like a poll()
> implementation, you can fake out any size you want since the size of the
> array is the first entry.
> 
> I can't speak for the cygwin implementations, but if they offer poll() or,
> better, epoll(), use those.
> 
> -lee

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.

Steve Bardwell



Re: FD_SETSIZE and sizeof(fd_set)

2016-06-23 Thread Lee Dilkie



On 6/23/2016 6:54 AM, Steven Bardwell wrote:




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 
#undef FD_SETSIZE
#define FD_SETSIZE 256
#include 
#include 

main()
{
fd_set rfds;
fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
}

Steve Bardwell




I don't know if this is still the case, but when I looked into this years ago I 
found that it was not possible to change the size of the fd set in linux, it's 
fixed at 1024 (generally), unless you rebuild the kernel.

Secondly, in the windows api, their version of an fd_set is more like a poll() 
implementation, you can fake out any size you want since the size of the array 
is the first entry.

I can't speak for the cygwin implementations, but if they offer poll() or, 
better, epoll(), use those.

-lee

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



RE: FD_SETSIZE and sizeof(fd_set)

2016-06-23 Thread Steven Bardwell
> >
> > There are (of course) a lot of other included files, and
> >  is one of them. In my code it comes  AFTER  the
> > redefinition of FD_SETSIZE and .  I don't think this
> > could be the issue.
> 
> It is if you are mixing Windows API and Cygwin.
> 
> Just look at sys/select.h and you'll understand.
> --
> René Berber



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 
#undef FD_SETSIZE
#define FD_SETSIZE 256
#include 
#include 

main()
{
fd_set rfds;
fprintf(stdout, "FD_SETSIZE=%d\n", FD_SETSIZE);
fprintf(stdout, "sizeof(fd_set)=%d\n", sizeof(fd_set));
}

Steve Bardwell


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: FD_SETSIZE and sizeof(fd_set)

2016-06-22 Thread René Berber
Back to the list, and please keep replies there.

> 
> There are (of course) a lot of other included files, and
>  is one of them. In my code it comes  AFTER  the
> redefinition of FD_SETSIZE and .  I don't think this
> could be the issue.

It is if you are mixing Windows API and Cygwin.

Just look at sys/select.h and you'll understand.
-- 
René Berber



--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: FD_SETSIZE and sizeof(fd_set)

2016-06-22 Thread René Berber
On 6/22/2016 5:19 PM, Steven Bardwell wrote:

> I am running into a problem with the fd_set structure that someone may know 
> the answer to. 
> 
> I would like to be able to call select() on more than 64 open files, so I 
> have done the following:
> 
> 1)   the include section of the program has the code:
> 
> #undef FD_SETSIZE
> #define FD_SETSIZE 256
> #include 

Wrong include file, use

#include 

(which is the one that actually has the definition of fd_set, and uses
FD_SETSIZE).
-- 
René Berber


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple