X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=HDkoy8nVGSlQ8hj3yB7KrO4G9R2BjyPQX18Ls+kcGCK513H+rFRnr +KZ82heUhaRb07kAYAsqsJw/NTUjaAq1ImcTnLOsrymYvB4DYCikZ7VFW5wHI39g e1V25ydT2NNPur8TmOce6k+eFZ8F62Vxz2Peo+oG5V0n34JdyuXQE4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=tiGyX7PsjDwa+RkEiMlZnTiaAfk=; b=D0fVQYcn2cs10V7NIP3eZZqZob46 nImaUuFOwzebAVS2SiLtvpBoGz3Skh0zJSNYusH5TryF02aKIUFXrcaQVK1+8yYY JfU3wt18brOxfgu+0LEICYFRKjLjSUS0iXqTUHCfOau47zi8f3/ncRh17xBqx3Kk MYLaLqBx53JiQf4= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-96.3 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_PBL,RCVD_IN_SORBS_DUL,RDNS_DYNAMIC autolearn=ham version=3.3.2 spammy=Hx-languages-length:2572, sua, offer, face X-HELO: calimero.vinschen.de Date: Thu, 23 Jun 2016 14:06:53 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: FD_SETSIZE and sizeof(fd_set) Message-ID: <20160623120653.GC5996@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <59cb34fb-3173-4af9-1b6d-17cef98b7934 AT mitel DOT com> <20160623115249 DOT GF15373 AT calimero DOT vinschen DOT de> <20160623115538 DOT GA5996 AT calimero DOT vinschen DOT de> <20160623120159 DOT GB5996 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ghzN8eJ9Qlbqn3iT" Content-Disposition: inline In-Reply-To: <20160623120159.GB5996@calimero.vinschen.de> User-Agent: Mutt/1.6.1 (2016-04-27) --ghzN8eJ9Qlbqn3iT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=3D%d\n", FD_SETSIZE); > > > > > > fprintf(stdout, "sizeof(fd_set)=3D%d\n", sizeof(fd_set)= ); > > > > > > } > > > > > > > > > > > > Steve Bardwell > > > > > > > > > > > > > > > > >=20 > > > > > I don't know if this is still the case, but when I looked into th= is years ago I > > > > > found that it was not possible to change the size of the fd set i= n linux, it's > > > > > fixed at 1024 (generally), unless you rebuild the kernel. > > > > >=20 > > > > > 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. > > > > >=20 > > > > > I can't speak for the cygwin implementations, but if they offer p= oll() or, > > > > > better, epoll(), use those. > > > > >=20 > > > > > -lee > > > >=20 > > > > For what it's worth, this 'program' works as expected in SUA. The s= ize > > > > of the fd_set changes depending on the value of FD_SETSIZE. > > >=20 > > > In my case it prints 'sizeof(fd_set)=3D8', 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 =3D 256. > >=20 > > Now that's embarassing. I guess I shgould go to primary school again. > >=20 > > Hang on, I 'll have a nother look while I'nm trying to get the red out = of > > my face... >=20 > 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 --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --ghzN8eJ9Qlbqn3iT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXa9DdAAoJEPU2Bp2uRE+gSJMQAJylc76OyVzwHc/e8GQnC04N ol8RnHmrhHYEhz73HG+YpSXqMjPIhK5j1WESEmgxuSeUK6d1NtiYRu/F9ZHcPmyD 3mUFQ0JNSGkz+ALuMZ1IG3yg3jgF46abPFR90boOGSjhe16cKMpGe8E7RqxZcFH/ GQh14oOGs7WEh/ynNpIp/wi9+yIHfHrQo72ypNrbe5OYfatQMwnXuaRzvgqrbI9x E43XqyzIJzTiOXHSOhQWALY98Z4lo+YzFKs8pSoyphzA0E2fGj09VLVX3o+xDNjE w+HCGVFlZ20aer3QcaxFgNMqetL7s3VsEbERgNHE7/kBh6qb+8e2dwTtZo35vJxV /uQnVroww4oYYXjndCCKI8W/q2GK6F7KuOl7E95O4TUsCiyeGm7idmnJs4qoeq/N rQcK8e2YNkj3nHdhYCpTeTKPvVmElKgvY4sjN8X5uEHJeT6dtPzFnD4PAwos4WTN 3kdwIF/a8EL4DJyRaTTP9KPPolcjCB9OW6pJkpQtYHeNdGG1RrfjcxJAWYZOv0vt bx0UyqE1EizCoB7ueF/p66amAGA/LlKN1tM6NzsQibFGRIsYDplvSfI0nNjNx3lP SNEToTFKxibweFCbYTsjoFk/T0W+jFIPpTRCLR4c/xb4eLkgTLUVsOGZPtiVAoHL M13DnnVT5wR0cpJTDmJK =sILO -----END PGP SIGNATURE----- --ghzN8eJ9Qlbqn3iT--