Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jul 2016 20:11:29 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r303342 - in head: include lib/libc/stdlib
Message-ID:  <201607262011.u6QKBTDp043256@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607262011.u6QKBTDp043256>