This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] Add simple versions of random() and srandom()
- From: Craig Howland <howland at LGSInnovations dot com>
- To: <newlib at sourceware dot org>
- Date: Tue, 22 Mar 2016 19:59:34 -0400
- Subject: Re: [PATCH] Add simple versions of random() and srandom()
- Authentication-results: sourceware.org; auth=none
- References: <1458687116-16115-1-git-send-email-joel at rtems dot org>
On 03/22/2016 06:51 PM, Joel Sherrill wrote:
Prototypes also added for initstate() and setstate() but they
were not implemented.
If they were not implemented, the prototypes should not be there. Or if they
are, commented out as TDB or not supplied as an explicit reminder that they are
not real.
---
newlib/libc/include/stdlib.h | 6 ++
... [snip]
diff --git a/newlib/libc/stdlib/random.c b/newlib/libc/stdlib/random.c
new file mode 100644
index 0000000..27ee5af
--- /dev/null
+++ b/newlib/libc/stdlib/random.c
@@ -0,0 +1,86 @@
+/*
+FUNCTION
+<<random>>, <<srandom>>---pseudo-random numbers
+
+INDEX
+ random
+INDEX
+ srandom
+
+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.
+
+TRAD_SYNOPSIS
+ #include <stdlib.h>
+ long int rand();
+
+ void srandon(<[seed]>)
+ unsigned int <[seed]>;
Get rid of the traditional synopsis. It is ignored by the document generation
stuff, so it's better not to have it, to avoid maintaining something that is not
used.