Displaying 7 results from an estimated 7 matches for "result_starstar".
2018 Dec 28
2
[PATCH v2 nbdkit] common: Improve pseudo-random number generation.
v2:
- Fix seeding.
- Add a test that nbdkit-random-plugin is producing something
which looks at least somewhat random.
Rich.
2018 Dec 31
1
Re: [PATCH v2 nbdkit] common: Improve pseudo-random number generation.
...our times means that random_state is guaranteed to have at
least three non-zero values, which was a documented prerequisite of the
seeding.
> +/* Returns 64 random bits. Updates the state. */
> +static inline uint64_t
> +xrandom (struct random_state *state)
> +{
> + const uint64_t result_starstar = rotl (state->s[1] * 5, 7) * 9;
> + const uint64_t t = state->s[1] << 17;
> +
> + state->s[2] ^= state->s[0];
> + state->s[3] ^= state->s[1];
> + state->s[1] ^= state->s[2];
> + state->s[0] ^= state->s[3];
> +
> + state->s[2] ^=...
2018 Dec 28
1
[PATCH nbdkit] common: Improve pseudo-random number generation.
...need those.
+ */
+
+struct random_state {
+ uint64_t s[4];
+};
+
+static inline uint64_t
+rotl (const uint64_t x, int k)
+{
+ return (x << k) | (x >> (64 - k));
+}
+
+/* Returns 64 random bits. Updates the state. */
+uint64_t
+xrandom (struct random_state *state)
+{
+ const uint64_t result_starstar = rotl (state->s[1] * 5, 7) * 9;
+ const uint64_t t = state->s[1] << 17;
+
+ state->s[2] ^= state->s[0];
+ state->s[3] ^= state->s[1];
+ state->s[1] ^= state->s[2];
+ state->s[0] ^= state->s[3];
+
+ state->s[2] ^= t;
+
+ state->s[3] = rotl (state->...
2018 Dec 28
0
[PATCH v2 nbdkit] common: Improve pseudo-random number generation.
...;seed);
+ state->s[3] = snext (&seed);
+}
+
+static inline uint64_t
+rotl (const uint64_t x, int k)
+{
+ return (x << k) | (x >> (64 - k));
+}
+
+/* Returns 64 random bits. Updates the state. */
+static inline uint64_t
+xrandom (struct random_state *state)
+{
+ const uint64_t result_starstar = rotl (state->s[1] * 5, 7) * 9;
+ const uint64_t t = state->s[1] << 17;
+
+ state->s[2] ^= state->s[0];
+ state->s[3] ^= state->s[1];
+ state->s[1] ^= state->s[2];
+ state->s[0] ^= state->s[3];
+
+ state->s[2] ^= t;
+
+ state->s[3] = rotl (state->...
2019 Jan 01
3
[PATCH nbdkit] include: Annotate function parameters with attribute((nonnull)).
Should we use attribute((nonnull)) at all? There's a very interesting
history of this in libvirt -- try looking at commit eefb881 plus the
commits referencing eefb881 -- but it does seem to work for me using
recent GCC and Clang.
I only did a few functions because annotating them gets old quickly...
Rich.
2019 Jan 02
0
[PATCH nbdkit v2 1/2] Annotate internal function parameters with attribute((nonnull)).
...tate *state)
{
state->s[0] = snext (&seed);
@@ -83,7 +83,7 @@ rotl (const uint64_t x, int k)
}
/* Returns 64 random bits. Updates the state. */
-static inline uint64_t
+static inline uint64_t __attribute__((__nonnull__ (1)))
xrandom (struct random_state *state)
{
const uint64_t result_starstar = rotl (state->s[1] * 5, 7) * 9;
diff --git a/common/regions/regions.h b/common/regions/regions.h
index ca9b3d5..4fcaf09 100644
--- a/common/regions/regions.h
+++ b/common/regions/regions.h
@@ -76,25 +76,30 @@ struct regions {
size_t nr_regions;
};
-extern void init_regions (struct regions...
2019 Jan 02
4
[PATCH nbdkit v2 0/2] Use of attribute(()).
v1 was here:
https://www.redhat.com/archives/libguestfs/2019-January/msg00008.html
In v2 I have provided two patches:
The first patch extends attribute((nonnull)) to most internal
functions, but not to the external API.
The second patch uses a macro so that attribute((format)) is only used
in the public API on GCC or Clang. At least in theory these headers
could be used by a C compiler which