Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Apr 2001 20:32:11 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Robert Watson <rwatson@FreeBSD.org>
Cc:        dd@FreeBSD.org, freebsd-doc@FreeBSD.org, bde@FreeBSD.org
Subject:   Re: docs/26003: getgroups(2) lists NGROUPS_MAX but not syslimits.h
Message-ID:  <Pine.BSF.4.21.0104011858330.14800-100000@besplex.bde.org>
In-Reply-To: <Pine.NEB.3.96L.1010331222140.65399B-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 31 Mar 2001, Robert Watson wrote:

> Dunno -- I guess this leads to a number of questions of specification-land
> -- is NGROUPS_MAX supposed to be exposed to the application, if so, how
> should the application go about including things to get the value, etc. 
> Bruce might have a good answer, if not a correct one, so I've CC'd him
> :-). 

In POSIX.1-1996:

1) NGROUPS_MAX is defined in <limits.h>.  (<sys/syslimits.h> is BSD
   implementation detail, so it shouldn't be documented.)

2) NGROUPS_MAX is a "Run-Time Increasable Value".  This means that
   applications may find that the actual maximum number of groups is
   larger than their compile time value of NGROUPS_MAX.  The run time
   maximum is given by sysconf(_SC_NGROUPS_MAX).

3) Unlike some other POSIX limits, NGROUPS_MAX must be defined at
   compile time, although its value is almost useless if its run time
   value is larger.  A footnote says that future revisions of POSIX.1
   are expected to permit omitting the definition of NGROUPS_MAX from
   <limits.h> to indicate that its value is variable.

The easiest way to use most of the POSIX limits is to never use them.
For NGROUPS_MAX, strictly conforming POSIX programs don't even have
the option of using an ifdef tangle to optimize the case where the
compile time limit applies, since it is impossible to know at compile
time whether it applies -- dynamic allocation must always be used.
NGROUPS_MAX is useful at most as a hint.

In FreeBSD, NGROUPS_MAX doesn't actually vary at runtime (unless someone
compiles the kernel with a new value).  getgroups.2 reflects this by
mentioning NGROUPS_MAX.  POSIX only says that EINVAL is returned when
the array is too small to hold all the groups.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0104011858330.14800-100000>