summaryrefslogtreecommitdiff
path: root/lib/rand-isaac.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
commit71cd8e3a743046573744123777061b64881bf372 (patch)
tree82522befe647f4fff186a5630cad0cad33f8ef53 /lib/rand-isaac.c
parentc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff)
downloadcoreutils-upstream.tar.gz
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'lib/rand-isaac.c')
-rw-r--r--lib/rand-isaac.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/rand-isaac.c b/lib/rand-isaac.c
index c03242f6..b698ea80 100644
--- a/lib/rand-isaac.c
+++ b/lib/rand-isaac.c
@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
- Copyright (C) 1999-2014 Free Software Foundation, Inc.
+ Copyright (C) 1999-2015 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software: you can redistribute it and/or modify
@@ -35,6 +35,18 @@
#include "rand-isaac.h"
#include <limits.h>
+#include <string.h>
+
+/* If the platform supports unaligned access,
+ then don't have -fsanitize=undefined warn about it. */
+#undef ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED
+#if !_STRING_ARCH_unaligned \
+ || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
+# define ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED /* empty */
+#else
+# define ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED \
+ __attribute__ ((__no_sanitize_undefined__))
+#endif
/* The minimum of two sizes A and B. */
static inline size_t
@@ -81,7 +93,7 @@ ind (isaac_word const *m, isaac_word x)
}
/* Use and update *S to generate random data to fill RESULT. */
-void
+void ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED
isaac_refill (struct isaac_state *s, isaac_word result[ISAAC_WORDS])
{
/* Caches of S->a and S->b. */
@@ -96,7 +108,7 @@ isaac_refill (struct isaac_state *s, isaac_word result[ISAAC_WORDS])
/* The central step. S->m is the whole state array, while M is a
pointer to the current word. OFF is the offset from M to the
- word ISAAC_WORDS/2 words away in the SM array, i.e. +/-
+ word ISAAC_WORDS/2 words away in the SM array, i.e., +/-
ISAAC_WORDS/2. A and B are state variables, and R the result.
This updates A, B, M[I], and R[I]. */
#define ISAAC_STEP(i, off, mix) \