aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-11 13:00:24 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-11 13:00:24 +0100
commita49a31b3f72d9a744c3bb53f60f7f39614eb7f35 (patch)
treeace290b79d51d65a64d55d0c27cfad6d96be055b /src/libutil/util.c
parentb38a1ad26bbbc0a40bbdddf2b7d6dea6c3bd049a (diff)
downloadrspamd-a49a31b3f72d9a744c3bb53f60f7f39614eb7f35.tar.gz
rspamd-a49a31b3f72d9a744c3bb53f60f7f39614eb7f35.zip
[Feature] Add limit for number of URLs in Lua
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r--src/libutil/util.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 55696c212..ecdd7b2b9 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -2624,17 +2624,22 @@ xoroshiro_rotl (const guint64 x, int k) {
return (x << k) | (x >> (64 - k));
}
-
gdouble
rspamd_random_double_fast (void)
{
- const guint64 s0 = xorshifto_seed[0];
- guint64 s1 = xorshifto_seed[1];
+ return rspamd_random_double_fast_seed (xorshifto_seed);
+}
+
+gdouble
+rspamd_random_double_fast_seed (guint64 seed[2])
+{
+ const guint64 s0 = seed[0];
+ guint64 s1 = seed[1];
const guint64 result = s0 + s1;
s1 ^= s0;
- xorshifto_seed[0] = xoroshiro_rotl(s0, 55) ^ s1 ^ (s1 << 14);
- xorshifto_seed[1] = xoroshiro_rotl (s1, 36);
+ seed[0] = xoroshiro_rotl(s0, 55) ^ s1 ^ (s1 << 14);
+ seed[1] = xoroshiro_rotl (s1, 36);
return rspamd_double_from_int64 (result);
}