public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] upstream OpenBSD: arc4random: Add support for building arc4random with MSVC. Date: Sat, 10 Sep 2022 19:01:30 +0000 (GMT) [thread overview] Message-ID: <20220910190130.673023858C83@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ef76759d7f361ef78063e4770b42c7bd93dd3f56 commit ef76759d7f361ef78063e4770b42c7bd93dd3f56 Author: bcook <bcook@openbsd.org> Date: Thu Sep 10 18:53:50 2015 +0000 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@ 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/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);
reply other threads:[~2022-09-10 19:01 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220910190130.673023858C83@sourceware.org \ --to=corinna@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).