2004-05-08 03:11:51 +02:00
|
|
|
#include "precompiled.h"
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2005-01-25 00:08:30 +01:00
|
|
|
#include "lib.h"
|
2004-03-03 00:56:51 +01:00
|
|
|
#include "sysdep.h"
|
2005-09-10 16:28:55 +02:00
|
|
|
#if CPU_IA32
|
|
|
|
# include "ia32.h"
|
|
|
|
#endif
|
2005-09-14 18:58:10 +02:00
|
|
|
#if OS_WIN
|
|
|
|
# include "win/wcpu.h"
|
|
|
|
#endif
|
2005-09-10 16:28:55 +02:00
|
|
|
|
|
|
|
|
2004-07-15 21:59:27 +02:00
|
|
|
#include <memory.h>
|
2004-07-25 13:30:05 +02:00
|
|
|
#include <stdarg.h>
|
2004-03-03 00:56:51 +01:00
|
|
|
|
2004-06-03 03:43:33 +02:00
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
#if !HAVE_C99
|
2004-06-03 03:43:33 +02:00
|
|
|
|
|
|
|
float fminf(float a, float b)
|
|
|
|
{
|
|
|
|
return (a < b)? a : b;
|
|
|
|
}
|
|
|
|
|
|
|
|
float fmaxf(float a, float b)
|
|
|
|
{
|
|
|
|
return (a > b)? a : b;
|
|
|
|
}
|
|
|
|
|
2005-11-07 03:45:25 +01:00
|
|
|
#endif
|
|
|
|
|
2005-10-19 22:26:53 +02:00
|
|
|
|
2005-11-07 03:45:25 +01:00
|
|
|
// no C99, and not running on IA-32 (where this is defined to ia32_rint)
|
|
|
|
// => need to implement our fallback version.
|
|
|
|
#if !HAVE_C99 && !defined(rint)
|
2005-10-19 22:26:53 +02:00
|
|
|
|
|
|
|
inline float rintf(float f)
|
|
|
|
{
|
|
|
|
return (float)(int)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double rint(double d)
|
|
|
|
{
|
|
|
|
return (double)(int)d;
|
|
|
|
}
|
|
|
|
|
2004-06-03 03:43:33 +02:00
|
|
|
#endif
|
2005-09-10 16:28:55 +02:00
|
|
|
|
|
|
|
|
2005-11-07 03:45:25 +01:00
|
|
|
// float->int conversion: not using the ia32 version; just implement as a
|
|
|
|
// cast. (see USE_IA32_FLOAT_TO_INT definition for details)
|
2005-11-07 03:04:28 +01:00
|
|
|
#if !USE_IA32_FLOAT_TO_INT
|
|
|
|
|
|
|
|
i32 i32_from_float(float f)
|
|
|
|
{
|
|
|
|
return (i32)f;
|
|
|
|
}
|
|
|
|
|
|
|
|
i32 i32_from_double(double d)
|
|
|
|
{
|
|
|
|
return (i32)d;
|
|
|
|
}
|
|
|
|
|
|
|
|
i64 i64_from_double(double d)
|
|
|
|
{
|
|
|
|
return (i64)d;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|