public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: cygwin@cygwin.com
Subject: Re: Typo in <sys/select.h>?
Date: Tue, 5 Jul 2022 17:51:27 -0400	[thread overview]
Message-ID: <1c3256fd-ed7b-8ee3-adcd-b1d8ef2fff84@cornell.edu> (raw)
In-Reply-To: <DM8PR09MB70954B30D740E778EB65BA41A5819@DM8PR09MB7095.namprd09.prod.outlook.com>

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.  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?

> Now, this is the relevant part of sys/param.h looks like this:
> ----------------------
> /* Max number of open files.  The Posix version is OPEN_MAX.  */
> /* Number of fds is virtually unlimited in cygwin, but we must provide
>     some reasonable value for Posix conformance */
> #define NOFILE          8192
> ----------------------
> 
> So it's either "<= NOFILE" that was actually meant to be there in the comment (or,
> an equivalent "should NOT be > NOFILE"), or FD_SETSIZE should have been defined as 8192,
> if the comment is actually correct.  Or maybe I'm missing something here :-)

I suspect that the comment was actually meant as written.  On FreeBSD, NOFILE is 
defined to be OPEN_MAX, which is 64.  On Cygwin, however, it wouldn't make sense 
to follow that comment since, as noted in your quote from sys/param.h, there is 
effectively no limit on open files on Cygwin.  (Cygwin maintains a dynamically 
growing table of file descriptors.)

Ken

  parent reply	other threads:[~2022-07-05 21:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 14:13 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-05 14:55 ` Andrey Repin
2022-07-05 21:51 ` Ken Brown [this message]
2022-07-06  7:42   ` Corinna Vinschen
2022-07-06 14:01     ` Jon Turney
2022-07-06 14:15       ` Corinna Vinschen
2022-07-06 14:22         ` Corinna Vinschen
2022-07-05 15:11 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 13:19 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 14:17 ` Corinna Vinschen
2022-07-06 14:17 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 14:26 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 15:07 ` Corinna Vinschen
2022-07-06 15:57 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2022-07-06 17:03 ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c3256fd-ed7b-8ee3-adcd-b1d8ef2fff84@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).