Author: ed
Date: Tue Jul 26 20:11:29 2016
New Revision: 303342
URL: https://svnweb.freebsd.org/changeset/base/303342

Log:
  Fix typing of srandom() and initstate().
  
  POSIX requires that these functions have an unsigned int for their first
  argument; not an unsigned long.
  
  My reasoning is that we can safely change these functions without
  breaking the ABI. As far as I know, our supported architectures either
  use registers for passing function arguments that are at least as big as
  long (e.g., amd64), or int and long are of the same size (e.g., i386).
  
  Reviewed by:  ache
  Differential Revision:        https://reviews.freebsd.org/D6644

Modified:
  head/include/stdlib.h
  head/lib/libc/stdlib/random.3
  head/lib/libc/stdlib/random.c

Modified: head/include/stdlib.h
==============================================================================
--- head/include/stdlib.h       Tue Jul 26 18:27:48 2016        (r303341)
+++ head/include/stdlib.h       Tue Jul 26 20:11:29 2016        (r303342)
@@ -204,7 +204,7 @@ double       erand48(unsigned short[3]);
 /* char        *fcvt(double, int, int * __restrict, int * __restrict); */
 /* char        *gcvt(double, int, int * __restrict, int * __restrict); */
 int     grantpt(int);
-char   *initstate(unsigned long /* XSI requires u_int */, char *, long);
+char   *initstate(unsigned int, char *, size_t);
 long    jrand48(unsigned short[3]);
 char   *l64a(long);
 void    lcong48(unsigned short[7]);
@@ -227,7 +227,7 @@ int  setkey(const char *);
 #endif
 char   *setstate(/* const */ char *);
 void    srand48(long);
-void    srandom(unsigned long);
+void    srandom(unsigned int);
 int     unlockpt(int);
 #endif /* __XSI_VISIBLE */
 

Modified: head/lib/libc/stdlib/random.3
==============================================================================
--- head/lib/libc/stdlib/random.3       Tue Jul 26 18:27:48 2016        
(r303341)
+++ head/lib/libc/stdlib/random.3       Tue Jul 26 20:11:29 2016        
(r303342)
@@ -28,7 +28,7 @@
 .\"     @(#)random.3   8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd April 2, 2013
+.Dd July 26, 2016
 .Dt RANDOM 3
 .Os
 .Sh NAME
@@ -45,11 +45,11 @@
 .Ft long
 .Fn random void
 .Ft void
-.Fn srandom "unsigned long seed"
+.Fn srandom "unsigned int seed"
 .Ft void
 .Fn srandomdev void
 .Ft char *
-.Fn initstate "unsigned long seed" "char *state" "long n"
+.Fn initstate "unsigned int seed" "char *state" "size_t n"
 .Ft char *
 .Fn setstate "char *state"
 .Sh DESCRIPTION

Modified: head/lib/libc/stdlib/random.c
==============================================================================
--- head/lib/libc/stdlib/random.c       Tue Jul 26 18:27:48 2016        
(r303341)
+++ head/lib/libc/stdlib/random.c       Tue Jul 26 20:11:29 2016        
(r303342)
@@ -236,7 +236,7 @@ good_rand(uint32_t ctx)
  * for default usage relies on values produced by this routine.
  */
 void
-srandom(unsigned long x)
+srandom(unsigned int x)
 {
        int i, lim;
 
@@ -311,7 +311,7 @@ srandomdev(void)
  * complain about mis-alignment, but you should disregard these messages.
  */
 char *
-initstate(unsigned long seed, char *arg_state, long n)
+initstate(unsigned int seed, char *arg_state, size_t n)
 {
        char *ostate = (char *)(&state[-1]);
        uint32_t *int_arg_state = (uint32_t *)arg_state;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to