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: [PATCH] Add simple versions of random() and srandom()


On Mar 23 15:20, Craig Howland wrote:
> On 03/23/2016 02:00 PM, Yaakov Selkowitz wrote:
> >On 2016-03-23 09:32, Craig Howland wrote:
> >>On 03/23/2016 01:04 AM, Yaakov Selkowitz wrote:
> >>>On 2016-03-22 17:51, Joel Sherrill wrote:
> >>>>Prototypes also added for initstate() and setstate() but they
> >>>>were not implemented.
> >>>
> >>>This should allow Cygwin to remove its own declarations of these
> >>>functions.
> >>>
> >>>>+#if __SVID_VISIBLE || __XSI_VISIBLE >= 4 || __BSD_VISIBLE
> >>>
> >>>#if __MISC_VISIBLE || __XSI_VISIBLE >= 500
> >>No, the value 4 is actually the right one.  At first look I had also
> >>thought that it needed to be 500, but it originated in issue 4 as an
> >>X/OPEN UNIX extension (see
> >>http://pubs.opengroup.org/onlinepubs/9699919799/functions/random.html),
> >>and was moved to BASE in issue 5.
> >
> >Just great, so we have conflicting documentation. :-(  I agree with your
> >assessment but Linux man-pages says it's >= 500:
> >
> >http://man7.org/linux/man-pages/man3/random.3.html
> >
> I have the same error in man random under RHEL6 (which likely comes from the
> URL you reference), but I went straight to POSIX to check under the
> assumption Joel had picked 4 with a reason.
> I just checked further, and their error does seem to be only in the man
> page.  At least with GLIBC 2.12 on RHEL6, the headers--referring only to the
> POSIX aspect--need either _XOPEN_SOURCE >= 500 || (defined(_XOPEN_SOURCE) &&
> defined(_XOPEN_SOURCE_EXTENDED). I've sent an email to report the bug on the
> manpage.  However, they might have purposely suppressed the additional
> clarifier:
> "_XOPEN_SOURCE_EXTENDED
>           If this macro is defined, and _XOPEN_SOURCE is defined, then
>           expose definitions corresponding to the XPG4v2 (SUSv1) UNIX
>           extensions (UNIX 95).  Defining _XOPEN_SOURCE with a value of 500
>           or more also produces the same effect as defining
>           _XOPEN_SOURCE_EXTENDED.  Use of _XOPEN_SOURCE_EXTENDED in new
>           source code should be avoided.
> 
>           Since defining _XOPEN_SOURCE with a value of 500 or more has the
>           same effect as defining _XOPEN_SOURCE_EXTENDED, the latter
>           (obsolete) feature test macro is generally not described in the
>           SYNOPSIS in man pages."
> 
> This email is to get the information into the record.  Joel's revised patch
> is sufficient for the user to get it to work.  (As the quote from the Linux
> man pages points out, new code should not be starting out with _XOPEN_SOURCE
> < 500, anyway.)

I'd still rather opt for correctness in the header if possible.
MISC+XPG4 seems the way to go:

  #if __MISC_VISIBLE || __XOPEN_VISIBLE >=4


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

Attachment: signature.asc
Description: PGP signature


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