summaryrefslogtreecommitdiffstats
path: root/src/gallium/tests/unit/translate_test.c
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-08-12 22:07:37 +0200
committerLuca Barbieri <[email protected]>2010-08-12 22:10:09 +0200
commitb9abe7f62c09c0395214b9447032323b3846b2cf (patch)
tree17f44232c2831917827a350f99beac2a83f8f8f9 /src/gallium/tests/unit/translate_test.c
parent4d946c4e8adf3f0ac447b6a9a6caf17392b816cd (diff)
translate_test: fix compilation on non-POSIX platforms
Use a kludgy function based on rand() instead of drand48()
Diffstat (limited to 'src/gallium/tests/unit/translate_test.c')
-rw-r--r--src/gallium/tests/unit/translate_test.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/gallium/tests/unit/translate_test.c b/src/gallium/tests/unit/translate_test.c
index a6f0f548976..960c70f2b50 100644
--- a/src/gallium/tests/unit/translate_test.c
+++ b/src/gallium/tests/unit/translate_test.c
@@ -30,6 +30,20 @@
#include <util/u_cpu_detect.h>
#include <rtasm/rtasm_cpu.h>
+/* don't use this for serious use */
+static double rand_double()
+{
+ const double rm = (double)RAND_MAX + 1;
+ double div = 1;
+ double v = 0;
+ for(unsigned i = 0; i < 4; ++i)
+ {
+ div *= rm;
+ v += (double)rand() / div;
+ }
+ return v;
+}
+
int main(int argc, char** argv)
{
struct translate *(*create_fn)(const struct translate_key *key) = 0;
@@ -129,17 +143,17 @@ int main(int argc, char** argv)
key.element[0].type = TRANSLATE_ELEMENT_NORMAL;
key.element[0].instance_divisor = 0;
- srand48(4359025);
+ srand(4359025);
/* avoid negative values that work badly when converted to unsigned format*/
- for (i = 0; i < buffer_size / sizeof(unsigned); ++i)
- ((unsigned*)byte_buffer)[i] = mrand48() & 0x7f7f7f7f;
+ for (i = 0; i < buffer_size; ++i)
+ byte_buffer[i] = rand() & 0x7f7f7f7f;
for (i = 0; i < buffer_size / sizeof(float); ++i)
- float_buffer[i] = (float)drand48();
+ float_buffer[i] = (float)rand_double();
for (i = 0; i < buffer_size / sizeof(double); ++i)
- double_buffer[i] = drand48();
+ double_buffer[i] = rand_double();
for (output_format = 1; output_format < PIPE_FORMAT_COUNT; ++output_format)
{