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 2016-03-22 18:59, Craig Howland wrote:
On 03/22/2016 06:51 PM, Joel Sherrill wrote:
+ANSI_SYNOPSIS
+    #include <stdlib.h>
+    long int random(void);
+    void srandom(unsigned int <[seed]>);
The needed '#define _XOPEN_SOURCE 500 /* or any value > 500*/' before
the #include is missing.  (Since the portability section quotes POSIX, I
chose a POSIX gate.)  Unless we want to show them in the manner of GLIBC
man pages. Their presentation for random(3):
  "Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

        random(), srandom(), initstate(), setstate(): _SVID_SOURCE ||
        _BSD_SOURCE || _XOPEN_SOURCE >= 500".
Put another way, now that Yaakov cleaned up all the gating, we really
should also clean up the documentation, too, and we need to decide on
the approach which should be taken, since there is not one approach
currently.

Based on the style of the Linux man-pages, I would recommend putting it directly in the synopsis (before the #include) *iff* there is only one guard which enables it (not counting that _GNU_SOURCE enables almost every other macro). If multiple options will enable a declaration, then it should be noted in either ANSI_SYNOPSIS (if that won't break the document parser) or PORTABILITY.

--
Yaakov


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