From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 673023858C83; Sat, 10 Sep 2022 19:01:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 673023858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662836490; bh=7hZfXBGkQ6ITxE0WmB2UF1LAxpseOAxZnwFphxObu/U=; h=From:To:Subject:Date:From; b=Op7wqYfAHiZH6o38A2bbdOe50vUdQEN38PgwH/6KIoiKZg45VDSOBxhgwAVzQP+od 1Qvv+vhGpY3/2eggG+yOQ/GxP0dPz8KF9HN8YagAXzpMWVTU3bpc2mrtJ7CYKWL42k bYEpPMg3TBNPrH3L3IJtnxZuI6z7TsRZ/dDt6FH8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] upstream OpenBSD: arc4random: Add support for building arc4random with MSVC. X-Act-Checkin: newlib-cygwin X-Git-Author: bcook X-Git-Refname: refs/heads/master X-Git-Oldrev: 783133b753d8c62077a575a9b1adb3f334615d02 X-Git-Newrev: ef76759d7f361ef78063e4770b42c7bd93dd3f56 Message-Id: <20220910190130.673023858C83@sourceware.org> Date: Sat, 10 Sep 2022 19:01:30 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Def76759d7f3= 61ef78063e4770b42c7bd93dd3f56 commit ef76759d7f361ef78063e4770b42c7bd93dd3f56 Author: bcook Date: Thu Sep 10 18:53:50 2015 +0000 upstream OpenBSD: arc4random: Add support for building arc4random with = MSVC. =20 By default, MSVC's stdlib.h defines min(), so we need to spell out some= thing less common to avoid picking it up. =20 ok deraadt@ beck@ miod@ Diff: --- newlib/libc/stdlib/arc4random.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/newlib/libc/stdlib/arc4random.c b/newlib/libc/stdlib/arc4rando= m.c index 7bd9e7c5e..5247f5125 100644 --- a/newlib/libc/stdlib/arc4random.c +++ b/newlib/libc/stdlib/arc4random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random.c,v 1.52 2015/01/16 16:48:51 deraadt Exp $ */ +/* $OpenBSD: arc4random.c,v 1.53 2015/09/10 18:53:50 bcook Exp $ */ =20 /* * Copyright (c) 1996, David Mazieres @@ -36,12 +36,13 @@ #define KEYSTREAM_ONLY #include "chacha_private.h" =20 -#define min(a, b) ((a) < (b) ? (a) : (b)) -#ifdef __GNUC__ +#define minimum(a, b) ((a) < (b) ? (a) : (b)) + +#if defined(__GNUC__) || defined(_MSC_VER) #define inline __inline -#else /* !__GNUC__ */ +#else /* __GNUC__ || _MSC_VER */ #define inline -#endif /* !__GNUC__ */ +#endif /* !__GNUC__ && !_MSC_VER */ =20 #define KEYSZ 32 #define IVSZ 8 @@ -130,7 +131,7 @@ _rs_rekey(u_char *dat, size_t datlen) if (dat) { size_t i, m; =20 - m =3D min(datlen, KEYSZ + IVSZ); + m =3D minimum(datlen, KEYSZ + IVSZ); for (i =3D 0; i < m; i++) rsx->rs_buf[i] ^=3D dat[i]; } @@ -150,7 +151,7 @@ _rs_random_buf(void *_buf, size_t n) _rs_stir_if_needed(n); while (n > 0) { if (rs->rs_have > 0) { - m =3D min(n, rs->rs_have); + m =3D minimum(n, rs->rs_have); keystream =3D rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have; memcpy(buf, keystream, m);