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 3/22/2016 6:59 PM, Craig Howland wrote:
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.

Cygwin will be using the prototypes now.

---
   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

This results in nested comments and the file doesn't compile. I added
this information as a second note.

#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.

This is yet another pass. :)

+
+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.


Deleted.

Also added to CHEWOUT_FILES and stdlib.tex.

A v2 should be coming soon. There were lots of comments and I may have
missed something.

--joel


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