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
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
#if MSC_VERSION
|
2004-06-02 17:12:48 +02:00
|
|
|
|
|
|
|
double round(double x)
|
|
|
|
{
|
|
|
|
return (long)(x + 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2005-09-10 16:28:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
void memcpy2(void* dst, const void* src, size_t nbytes)
|
|
|
|
{
|
|
|
|
#if CPU_IA32
|
|
|
|
ia32_memcpy(dst, src, nbytes);
|
|
|
|
#else
|
|
|
|
memcpy(dst, src, nbytes);
|
|
|
|
#endif
|
2005-09-14 18:58:10 +02: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
|
|
|
|
}
|