[PATCH] Add simple versions of random() and srandom()

Yaakov Selkowitz yselkowitz@cygwin.com
Wed Mar 23 02:20:00 GMT 2016


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



More information about the Newlib mailing list