This is the mail archive of the 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 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 @@
+<<random>>, <<srandom>>---pseudo-random numbers
+	random
+	srandom
+	#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.
+	#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.

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