This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: sysconf cleanup


On Sat 11/22/2008 7:02 AM, Corinna Vinschen [vinschen@redhat.com] wrote:
>This change breaks backward compatibility with Cygwin's sysconf.cc
>implementation.
>
>On Nov 21 21:19, Howland Craig D (Craig) wrote:
>> _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.)
>
>They are defined as their newer counterparts _SC_V6_ILP32_OFF32 (92),
>_SC_V6_ILP32_OFFBIG (93), _SC_V6_LP64_OFF64 (94) and
_SC_V6_LPBIG_OFFBIG
>(95) so I don't understand why they should "never get values".  I don't
>see a reason to give them different values than their counterparts.
>
Sorry, I was unclear in the problem statement here.  I will elaborate.
 
Your specific comment about the values for the _SC defines falls under
a following paragraph (see below).
 
The problem referred to in this paragraph is related to the values that
are supposed to be returned by sysconf()--_XBS5_ILP32_OFF32,
_XBS5_ILP32_OFFBIG, and _XBS5_LPBIG_OFFBIG--when the mentioned _SC
defines are given to sysconf().  These 3 _XBS5 defines do not have
proper values.  Each of those 3 got defined as other macro names which
end up being bad.  The following lines from libc/include/sys/features.h
show the problem:
 
/* #define _POSIX_V6_ILP32_OFF32                    -1 */
#define _XBS5_ILP32_OFF32                       _POSIX_V6_ILP32_OFF32
#define _POSIX_V6_ILP32_OFFBIG                       1
#define _XBS5_ILP32_OFFBIG                      _POSIX_V6_ILP32_OFFBIG
/* #define _POSIX_V6_LP64_OFF64                     -1 */
#define _XBS5_LP64_OFF64                        _POSIX_V6_LP64_OFF64
/* #define _POSIX_V6_LPBIG_OFFBIG                   -1 */
#define _XBS5_LPBIG_OFFBIG                      _POSIX_V6_LPBIG_OFFBIG
 
For some reason unknown to me, 3 of the 4 _POSIX_V6 defines are
commented out.  This means that 3 of the 4 _XBS5 defines are defined,
yet without a numerical value.  Because of this problem I commented out
the cases for them in my proposed revision.  It would naturally be
better to fix the problem with sys/features.h than commenting out the
cases in sysconf.c, but nothing is lost as they weren't in sysconf.c
before,
anyway.  I figured that that problem could be cleaned up later.  The
patch that you supplied (below) would take care of this.
 
>> Since they didn't work before, I didn't bother to try and fix them.
>
>How did they not work before?  They have valid values.
Again, I apologize for being so terse as to be unclear.  To hopefully
be clear:  Since those specific 3 _SC defines (_SC_XBS5_ILP32_OFF32,
_SC_XBS5_ILP32_OFFBIG, and _SC_XBS5_LPBIG_OFFBIG) were not in the
case list in sysconf.c before, I decided for the moment to comment
out the newly-added cases for them because of the _XBS5* value problems
(because I am not sure how to properly fix the _XBS5* problem).  Nothing
is lost since the cases were not there before, but it would be nice to
straighten out the _XBS5* problem so that those missing cases can be
added (uncommented).  Your features.h patch allows this to happen.
>
>> 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.)
>
>I don't see what you mean.  The XBS5 values are all equivalent to the
>V6 values in sys/unistd.h as well as in sys/features.h.  You can use
>one or the other.
Well maybe they are supposed to be, but they are not, as mentioned
above.  Your patch corrects this.
>
>What probably *should* be fixed are the definitions in sys/features.h
so
>that either the three _POSIX_V6_* values are defined to -1 instead of
>being undefined, or to undefine the _XBS5_* values if their _POSIX_V6_
>counterpart is undefined.  Below is a patch using the first solution.
I agree.
>
>But please don't change the values for the _SC_XBS5_* defines.
Given your patch that makes the _XBS5* values match the _POSIX_V6
values,
this can certainly be done.  But one question.  The unistd.h definition 
(http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html)
clearly spells out that "The two constants _SC_PAGESIZE and
_SC_PAGE_SIZE
may be defined to have the same value."  It says nothing about
_SC_XBS5*,
the clear implication being that no other values may duplicate each
other.
Are we OK with duplicating the values when the intent appears for there
to not be duplicates?
 
In anticipation that the answer to that question is yes, I have
attached an amended patch file for the proposed sysconf.c changes which
includes your features.h modification, but discards my earlier unistd.h
mod.  The sysconf.c changes have been enhanced to allow for the
_SC_XBS5_* values to match the respective _SC_POSIX* values, or not.
>
>
>Corinna
>
>
>	* libc/include/sys/features.h (_POSIX_V6_ILP32_OFF32): Always
define.
>	(_POSIX_V6_LP64_OFF64): Ditto.
>	(_POSIX_V6_LPBIG_OFFBIG): Ditto.
>
>
>Index: libc/include/sys/features.h
>===================================================================
>RCS file: /cvs/src/src/newlib/libc/include/sys/features.h,v
>retrieving revision 1.14
>diff -u -p -r1.14 features.h
>--- libc/include/sys/features.h	16 Oct 2008 21:53:58 -0000
1.14
>+++ libc/include/sys/features.h	22 Nov 2008 11:58:29 -0000
>@@ -150,13 +150,13 @@ extern "C" {
> /* #define _POSIX2_PBS_TRACK			    -1 */
> #define _POSIX2_SW_DEV				200112L
> #define _POSIX2_UPE				200112L
>-/* #define _POSIX_V6_ILP32_OFF32		    -1 */
>+#define _POSIX_V6_ILP32_OFF32			    -1
> #define _XBS5_ILP32_OFF32			_POSIX_V6_ILP32_OFF32
> #define _POSIX_V6_ILP32_OFFBIG			     1
> #define _XBS5_ILP32_OFFBIG			_POSIX_V6_ILP32_OFFBIG
>-/* #define _POSIX_V6_LP64_OFF64			    -1 */
>+#define _POSIX_V6_LP64_OFF64			    -1
> #define _XBS5_LP64_OFF64			_POSIX_V6_LP64_OFF64
>-/* #define _POSIX_V6_LPBIG_OFFBIG		    -1 */
>+#define _POSIX_V6_LPBIG_OFFBIG			    -1
> #define _XBS5_LPBIG_OFFBIG			_POSIX_V6_LPBIG_OFFBIG
> #define _XOPEN_CRYPT				     1
> #define _XOPEN_ENH_I18N				     1
>
>-- 
>Corinna Vinschen
>Cygwin Project Co-Leader
>Red Hat
>

Attachment: sysconf.patch
Description: sysconf.patch


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]