the macro NGROUPS_MAX issue
Robin Getz
rgetz at blackfin.uclinux.org
Wed Dec 14 15:14:16 UTC 2005
Aubrey pointed out on the uClinux-dev mailing list, and I thought that
there might be some thoughts here:
in the file ./uClibc/libc/inet/rpc/auth_unix.c:authunix_create_default(void)
http://www.uclibc.org/cgi-bin/viewcvs.cgi/trunk/uClibc/libc/inet/rpc/auth_unix.c?rev=12740&view=markup
has the lines:
int max_nr_groups = sysconf (_SC_NGROUPS_MAX);
gid_t gids[max_nr_groups];
where the function sysconf is defined in:
./uClibc/libc/unistd/sysconf.c:
__sysconf(int name)
http://www.uclibc.org/cgi-bin/viewcvs.cgi/trunk/uClibc/libc/unistd/sysconf.c?rev=12654&view=markup
has the lines:
case _SC_NGROUPS_MAX:
#ifdef NGROUPS_MAX
return NGROUPS_MAX;
#else
RETURN_NEG_1;
#endif
Since uClibc/libc/unistd/sysconf.c includes limits.h at line 22
limits.h includes bits/posix1_lim.h at line 144
(bits/posix1_lim.h only defines NGROUPS_MAX as 8 as a minimum maximum
required by POSIX when there is no local definition of it.)
bits/posix1_lim.h includes bits/local_lim.h at line 130
bits/local_lim.h includes linux/limits.h at line 36
NGROUPS_MAX is defined in linux/limits.h at line 6
Since we (and most others) are using uClibc for linux, NGROUPS_MAX from
linux/limits.h is the "local" definition.
The mainline kernel folks have increased NGROUPS_MAX of the kernel:
./linux-2.6.x/include/linux/limits.h
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;h=eaf2e099f1257f356264b278711068f25bb8e5f0;hb=be0d9b6c7aeaad1683059c00131cabd4c894c17c;f=include/linux/limits.h
----
#define NGROUPS_MAX 65536 /* supplemental group IDs are available */
----
the above code in
./uClibc/libc/inet/rpc/auth_unix.c:authunix_create_default(void) (and one
other place in uClibc that I found) places a 64k object on the stack -
something no-mmu devices don't really like.
Would there be any objections to refactoring this with a malloc in the
general case?
If so - any objections to refactoring this with a malloc for MMU=n?
Thanks
-Robin
More information about the uClibc
mailing list