project64/Source/Common/Platform.cpp

44 lines
822 B
C++
Raw Normal View History

2021-04-12 09:41:28 +00:00
#include "Platform.h"
2022-10-03 08:04:42 +00:00
#include <stdarg.h>
2021-04-12 09:41:28 +00:00
#include <stdint.h>
#include <stdio.h>
2016-01-04 06:49:33 +00:00
#ifndef _WIN32
int _vscprintf(const char * format, va_list pargs)
2016-01-04 06:49:33 +00:00
{
2016-01-17 05:57:08 +00:00
int retval;
va_list argcopy;
va_copy(argcopy, pargs);
2021-04-12 11:35:39 +00:00
retval = vsnprintf(nullptr, 0, format, argcopy);
2016-01-17 05:57:08 +00:00
va_end(argcopy);
return retval;
2016-01-04 06:49:33 +00:00
}
#endif
#ifdef _MSC_VER
#include <float.h>
int fesetround(int RoundType)
{
2022-10-03 08:04:42 +00:00
static const unsigned int msRound[4] = {_RC_NEAR, _RC_CHOP, _RC_UP, _RC_DOWN};
int32_t res = _controlfp(msRound[RoundType], _MCW_RC);
2022-10-03 08:04:42 +00:00
if (res == _RC_NEAR)
{
return FE_TONEAREST;
}
if (res == _RC_CHOP)
{
return FE_TOWARDZERO;
}
if (res == _RC_UP)
{
return FE_UPWARD;
}
if (res == _RC_DOWN)
{
return FE_DOWNWARD;
}
return FE_TONEAREST;
}
#endif