2004-05-07 18:11:51 -07:00
|
|
|
#include "precompiled.h"
|
2004-03-02 15:56:51 -08:00
|
|
|
|
2005-01-24 15:08:30 -08:00
|
|
|
#include "lib.h"
|
2004-03-02 15:56:51 -08:00
|
|
|
#include "sysdep.h"
|
2005-09-10 07:28:55 -07:00
|
|
|
#if CPU_IA32
|
|
|
|
|
# include "ia32.h"
|
|
|
|
|
#endif
|
2005-09-14 09:58:10 -07:00
|
|
|
#if OS_WIN
|
|
|
|
|
# include "win/wcpu.h"
|
|
|
|
|
#endif
|
2005-09-10 07:28:55 -07:00
|
|
|
|
|
|
|
|
|
2004-07-15 12:59:27 -07:00
|
|
|
#include <memory.h>
|
2004-07-25 04:30:05 -07:00
|
|
|
#include <stdarg.h>
|
2004-03-02 15:56:51 -08:00
|
|
|
|
2004-06-02 18:43:33 -07:00
|
|
|
|
2005-08-09 09:23:19 -07:00
|
|
|
#if !HAVE_C99
|
2004-06-02 18:43:33 -07: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-06 18:45:25 -08:00
|
|
|
#endif
|
|
|
|
|
|
2005-10-19 13:26:53 -07:00
|
|
|
|
2005-11-06 18:45:25 -08: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 13:26:53 -07:00
|
|
|
|
|
|
|
|
inline float rintf(float f)
|
|
|
|
|
{
|
|
|
|
|
return (float)(int)f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline double rint(double d)
|
|
|
|
|
{
|
|
|
|
|
return (double)(int)d;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-02 18:43:33 -07:00
|
|
|
#endif
|
2005-09-10 07:28:55 -07:00
|
|
|
|
|
|
|
|
|
2005-11-06 18:45:25 -08: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-06 18:04:28 -08: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
|