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
|
|
|
|
2005-08-09 09:23:19 -07:00
|
|
|
#if MSC_VERSION
|
2004-06-02 08:12:48 -07:00
|
|
|
|
|
|
|
|
double round(double x)
|
|
|
|
|
{
|
|
|
|
|
return (long)(x + 0.5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
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-10-19 13:26:53 -07:00
|
|
|
|
|
|
|
|
#ifndef rint
|
|
|
|
|
|
|
|
|
|
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-10-19 13:26:53 -07:00
|
|
|
#endif // !HAVE_C99
|
|
|
|
|
|
2005-09-10 07:28:55 -07:00
|
|
|
|
2005-09-14 09:58:10 -07:00
|
|
|
// not possible with POSIX calls.
|
|
|
|
|
// called from ia32.cpp get_cpu_count
|
|
|
|
|
int on_each_cpu(void(*cb)())
|
|
|
|
|
{
|
|
|
|
|
#if OS_WIN
|
|
|
|
|
return wcpu_on_each_cpu(cb);
|
|
|
|
|
#else
|
|
|
|
|
// apparently not possible on non-Windows OSes because they seem to lack
|
|
|
|
|
// a CPU affinity API.
|
|
|
|
|
return ERR_NO_SYS;
|
|
|
|
|
#endif
|
|
|
|
|
}
|