1
0
forked from 0ad/0ad
0ad/source/lib/sysdep/sysdep.cpp
janwas bc07b9ff0a file code v2 is now feature complete and works.
- adts: add basic benchmark to self-test; use fminf instead of MIN; fix
overly pessimistic invalidation in Landlord_Cached
- allocators: no longer complain if DynArray is full
- lib: warn if rand() min=max
- archive: bugfixes: plug leak, correctly handle 0-length files, carry
over flags when reading uncompressed file from archive
- file: expose file_get_sorted_dirents and implement file_enum in terms
of that
- file_cache: many bugfixes (especially related to CacheAllocator
freelist)
- vfs_optimizer: finish implementation of archive builder
- zip: correctly handle 0-length files
- tex: add tex_is_known_extension
- sysdep: add efficient fminf implementation (assumes P6+)

- config: update archive builder call site
- gamesetup: add call for delayed self tests
- entity: return JSVAL_VOID as per philip's suggestion

This was SVN commit r3553.
2006-02-23 07:55:32 +00:00

104 lines
1.5 KiB
C++
Executable File

#include "precompiled.h"
#include "lib.h"
#include "sysdep.h"
#if CPU_IA32
# include "ia32.h"
#endif
#if OS_WIN
# include "win/wcpu.h"
#endif
#include <memory.h>
#include <stdarg.h>
#if !HAVE_C99
// note: stupid VC7 gets arguments wrong when using __declspec(naked);
// we need to use DWORD PTR and esp-relative addressing.
#if HAVE_MS_ASM
__declspec(naked) float fminf(float, float)
{
__asm
{
fld DWORD PTR [esp+4]
fld DWORD PTR [esp+8]
fcomi st(0), st(1)
fcmovnb st(0), st(1)
fxch
fstp st(0)
ret
}
}
#else
float fminf(float a, float b)
{
return (a < b)? a : b;
}
#endif
#if HAVE_MS_ASM
__declspec(naked) float fmaxf(float, float)
{
__asm
{
fld DWORD PTR [esp+4]
fld DWORD PTR [esp+8]
fcomi st(0), st(1)
fcmovb st(0), st(1)
fxch
fstp st(0)
ret
}
}
#else
float fmaxf(float a, float b)
{
return (a > b)? a : b;
}
#endif
#endif // #if !HAVE_C99
// 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)
inline float rintf(float f)
{
return (float)(int)f;
}
inline double rint(double d)
{
return (double)(int)d;
}
#endif
// float->int conversion: not using the ia32 version; just implement as a
// cast. (see USE_IA32_FLOAT_TO_INT definition for details)
#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