Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbcook <bcook@openbsd.org>2015-09-10 21:53:50 +0300
committerCorinna Vinschen <corinna@vinschen.de>2022-09-10 21:56:25 +0300
commitef76759d7f361ef78063e4770b42c7bd93dd3f56 (patch)
treeb0d3ee09e723429afcd175403a0a56b3c73e4d51 /newlib/libc/stdlib
parent783133b753d8c62077a575a9b1adb3f334615d02 (diff)
upstream OpenBSD: arc4random: Add support for building arc4random with MSVC.
By default, MSVC's stdlib.h defines min(), so we need to spell out something less common to avoid picking it up. ok deraadt@ beck@ miod@
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/arc4random.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/newlib/libc/stdlib/arc4random.c b/newlib/libc/stdlib/arc4random.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 $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -36,12 +36,13 @@
#define KEYSTREAM_ONLY
#include "chacha_private.h"
-#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 */
#define KEYSZ 32
#define IVSZ 8
@@ -130,7 +131,7 @@ _rs_rekey(u_char *dat, size_t datlen)
if (dat) {
size_t i, m;
- m = min(datlen, KEYSZ + IVSZ);
+ m = minimum(datlen, KEYSZ + IVSZ);
for (i = 0; i < m; i++)
rsx->rs_buf[i] ^= 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 = min(n, rs->rs_have);
+ m = minimum(n, rs->rs_have);
keystream = rsx->rs_buf + sizeof(rsx->rs_buf)
- rs->rs_have;
memcpy(buf, keystream, m);