delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/07/06/03:43:31

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAF4F3853543
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1657093409;
bh=UqewxEFEQVdHsL/zHKsmV9+0uoj7MpKrWo0ke0B8oEA=;
h=Date:From:To:Subject:References:In-Reply-To:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
Reply-To:From;
b=ck6V01YBKe1mVcrTdOzVGBKyhfyuJ3IRE4X6SHJrAPLcTfKh6z8v59fnUw4Qzmcww
8ikyZ2ic4oqx1C0+9DPh23LlWVPx1yPtwCz68myaCjVVCIO427TCncxyyIWOTNKwy2
D264TYglGT0NxBgUsN7aN872aC3b1LlFlv1tLlZg=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 260E83857C49
Authentication-Results: sourceware.org;
dmarc=fail (p=none dis=none) header.from=cygwin.com
Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com
Date: Wed, 6 Jul 2022 09:42:56 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Typo in <sys/select.h>?
Message-ID: <YsU9APd87h5vUJtZ@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <DM8PR09MB70954B30D740E778EB65BA41A5819 AT DM8PR09MB7095 DOT namprd09 DOT prod DOT outlook DOT com>
<1c3256fd-ed7b-8ee3-adcd-b1d8ef2fff84 AT cornell DOT edu>
MIME-Version: 1.0
In-Reply-To: <1c3256fd-ed7b-8ee3-adcd-b1d8ef2fff84@cornell.edu>
X-Provags-ID: V03:K1:0owdtmqJLRjf2oyFyooFBK0u1NTiwtZy41jCcMqyLU2K58ToYq1
dJNPB/e1P+joAhM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N, KAM_ASCII_DIVIDERS, KAM_DMARC_NONE, KAM_DMARC_STATUS,
RCVD_IN_DNSWL_NONE, SPF_FAIL, SPF_HELO_NONE, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019