X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=interpreters%2Fglulxe%2Fosdepend.c;h=bcd4beb7c2f4dc9454023e4c8a885a67bf96d974;hb=75009f8f40bbb580194e1722db76f4644bf18641;hp=8c720dd55cd3feab1f2edb61bb36d0f303cb7ad0;hpb=89081782541e85e079f64839ffb26b4e74273eb7;p=projects%2Fchimara%2Fchimara.git diff --git a/interpreters/glulxe/osdepend.c b/interpreters/glulxe/osdepend.c index 8c720dd..bcd4beb 100644 --- a/interpreters/glulxe/osdepend.c +++ b/interpreters/glulxe/osdepend.c @@ -51,7 +51,7 @@ void glulx_setrandom(glui32 seed) /* Return a random number in the range 0 to 2^32-1. */ glui32 glulx_random() { - return random(); + return (random() << 16) ^ random(); } #endif /* OS_UNIX */ @@ -88,7 +88,7 @@ static void lo_seed_random(glui32 seed); /* Return a random number in the range 0 to 2^32-1. */ glui32 glulx_random() { - return lo_random(); + return (lo_random() << 16) ^ lo_random(); } /* Set the random-number seed; zero means use as random a source as @@ -139,7 +139,7 @@ void glulx_setrandom(glui32 seed) /* Return a random number in the range 0 to 2^32-1. */ glui32 glulx_random() { - return rand(); + return (rand() << 24) ^ (rand() << 12) ^ rand(); } #endif /* WIN32 */ @@ -193,3 +193,33 @@ void glulx_sort(void *addr, int count, int size, { qsort(addr, count, size, (int (*)(const void *, const void *))comparefunc); } + +#ifdef FLOAT_SUPPORT +#include + +#ifdef FLOAT_COMPILE_SAFER_POWF + +/* This wrapper handles all special cases, even if the underlying + powf() function doesn't. */ +gfloat32 glulx_powf(gfloat32 val1, gfloat32 val2) +{ + if (val1 == 1.0f) + return 1.0f; + else if ((val2 == 0.0f) || (val2 == -0.0f)) + return 1.0f; + else if ((val1 == -1.0f) && isinf(val2)) + return 1.0f; + return powf(val1, val2); +} + +#else /* FLOAT_COMPILE_SAFER_POWF */ + +/* This is the standard powf() function, unaltered. */ +gfloat32 glulx_powf(gfloat32 val1, gfloat32 val2) +{ + return powf(val1, val2); +} + +#endif /* FLOAT_COMPILE_SAFER_POWF */ + +#endif /* FLOAT_SUPPORT */