From owner-svn-src-head@freebsd.org Tue Jul 26 20:11:30 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4726BA414D; Tue, 26 Jul 2016 20:11:30 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 987D218EA; Tue, 26 Jul 2016 20:11:30 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6QKBTAi043259; Tue, 26 Jul 2016 20:11:29 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6QKBTDp043256; Tue, 26 Jul 2016 20:11:29 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201607262011.u6QKBTDp043256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Tue, 26 Jul 2016 20:11:29 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2016 20:11:30 -0000 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;