diff options
author | Brent Cook <bcook@cvs.openbsd.org> | 2015-09-10 18:53:51 +0000 |
---|---|---|
committer | Brent Cook <bcook@cvs.openbsd.org> | 2015-09-10 18:53:51 +0000 |
commit | 0267a6d0468dae0acbac4d807136d6187750f72f (patch) | |
tree | 0086e57d5a4841675fdc3703c873e51a2a20eb99 | |
parent | 90b4e90be391af63dce8f55c5332d284d315adbb (diff) |
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@
-rw-r--r-- | lib/libc/crypt/arc4random.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/libc/crypt/arc4random.c b/lib/libc/crypt/arc4random.c index 75cdff3bc4b..5afc6a15ab0 100644 --- a/lib/libc/crypt/arc4random.c +++ b/lib/libc/crypt/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 @@ -127,7 +128,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]; } @@ -147,7 +148,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); |