sysconf cleanup

Howland Craig D (Craig) howland@LGSInnovations.com
Mon Nov 24 15:31:00 GMT 2008


sysconf.c was missing many (71) of the variables that POSIX requires of
it
(see
http://www.opengroup.org/onlinepubs/009695399/functions/sysconf.html),
so I re-wrote it to include them all.  Rather than doing lots of
hand editing to put in the missing cases, I deleted all the cases in
the switch and programmatically generated the new ones from the list
in the Opengroup man page.  This makes the patch show almost the whole
file as being changed.
 
Since all of the _SC defines were already in unistd.h, I did not check
to see if any of the items should be ifdef'd with a POSIX version
because none of the _SC defines in unistd.h are.
 
As noted in the ChangeLog entry, 5 of the cases are present but
commented out.
_SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX are supposed to return
something from getgrgid and getpwuid, but since newlib does not have
those, I left them out as there is not a value that I know how to get.
_SC_XBS5_ILP32_OFF32, _SC_XBS5_ILP32_OFFBIG, and _SC_XBS5_LPBIG_OFFBIG
cases ran into a problem with their values being defined, but not
as numbers.  (They are redefined as other macros which never get
values.)
Since they didn't work before, I didn't bother to try and fix them.
 
As part of this, I had to correct 3 of the _SC_ values for so-called
"legacy" defines in sys/unistd.h to remove duplication.  (Opengroup
shows different returns for the legacy items, so the duplication that
was
in place made no sense.)
 
This change might address the problem just asked about in an email
titled "Compatibility with Debian 4.0?", where sysconf(_SC_PAGE_SIZE)
returned -1, since _SC_PAGE_SIZE did not previously have a case.
 
Craig Howland
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sysconf.patch
Type: application/octet-stream
Size: 24349 bytes
Desc: sysconf.patch
URL: <http://sourceware.org/pipermail/newlib/attachments/20081124/97946434/attachment.obj>


More information about the Newlib mailing list