[Common] Add fesetround to Platform.cpp
This commit is contained in:
parent
554333711f
commit
99e6df4612
|
@ -1,7 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
int _vscprintf (const char * format, va_list pargs)
|
||||
int _vscprintf(const char * format, va_list pargs)
|
||||
{
|
||||
int retval;
|
||||
va_list argcopy;
|
||||
|
@ -10,4 +10,19 @@ int _vscprintf (const char * format, va_list pargs)
|
|||
va_end(argcopy);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h>
|
||||
|
||||
int fesetround(int RoundType)
|
||||
{
|
||||
static const unsigned int msRound[4] = { _RC_NEAR, _RC_CHOP, _RC_UP, _RC_DOWN };
|
||||
int32_t res = _controlfp(msRound[RoundType], _MCW_RC);
|
||||
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
|
||||
|
|
|
@ -7,8 +7,17 @@
|
|||
#define _stricmp strcasecmp
|
||||
#define _strnicmp strncasecmp
|
||||
#define _snprintf snprintf
|
||||
#define _isnan isnan
|
||||
#define GetCurrentThreadId pthread_self
|
||||
|
||||
int _vscprintf (const char * format, va_list pargs);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//FPU rounding code
|
||||
#ifdef _WIN32
|
||||
typedef enum { FE_TONEAREST = 0, FE_TOWARDZERO, FE_UPWARD, FE_DOWNWARD } eRoundType;
|
||||
int fesetround(int RoundType);
|
||||
#else
|
||||
#include <fenv.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue