[Pixman] [PATCH 1/8] test: random data from file. Globals variables.
bansan85
legarrec.vincent at gmail.com
Wed Dec 13 19:41:32 UTC 2017
---
test/utils-prng.c | 4 ++++
test/utils-prng.h | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/test/utils-prng.c b/test/utils-prng.c
index c27b5be..1d62129 100644
--- a/test/utils-prng.c
+++ b/test/utils-prng.c
@@ -31,6 +31,10 @@
#include <xmmintrin.h>
#endif
+const uint8_t *random_data;
+size_t size_data;
+size_t running_data;
+
void smallprng_srand_r (smallprng_t *x, uint32_t seed)
{
uint32_t i;
diff --git a/test/utils-prng.h b/test/utils-prng.h
index f9ae8dd..98022d8 100644
--- a/test/utils-prng.h
+++ b/test/utils-prng.h
@@ -79,6 +79,11 @@
/*****************************************************************************/
+/* Used if random data from file. */
+extern const uint8_t *random_data;
+extern size_t size_data;
+extern size_t running_data;
+
#ifdef HAVE_GCC_VECTOR_EXTENSIONS
typedef uint32_t uint32x4 __attribute__ ((vector_size(16)));
typedef uint8_t uint8x16 __attribute__ ((vector_size(16)));
@@ -111,6 +116,24 @@ typedef union
/*****************************************************************************/
+static force_inline uint8_t
+get_rand_data_8() {
+ uint8_t retour = random_data[running_data];
+ running_data = (running_data + 1) % size_data;
+ return retour;
+}
+
+static force_inline uint32_t
+get_rand_data_32() {
+ /* Do not use 4 get_rand_data_8 () in the same line
+ * to be sure of the execution order. */
+ uint8_t un = get_rand_data_8();
+ uint8_t deux = get_rand_data_8();
+ uint8_t trois = get_rand_data_8();
+ uint8_t quatre = get_rand_data_8();
+ return (un << 24) + (deux << 16) + (trois << 8) + (quatre);
+}
+
static force_inline uint32_t
smallprng_rand_r (smallprng_t *x)
{
--
2.15.0
More information about the Pixman
mailing list