Added SDL_fmod() and SDL_fmodf()

This commit is contained in:
Sam Lantinga 2017-11-04 17:35:03 -07:00
parent 6cf065753c
commit bcdf8b916b
20 changed files with 349 additions and 88 deletions

View File

@ -639,8 +639,8 @@ if(LIBC)
_ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
_stricmp _strnicmp sscanf _stricmp _strnicmp sscanf
acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf
copysign copysignf cos cosf fabs fabsf floor floorf log logf copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf
pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf) log logf pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
string(TOUPPER ${_FN} _UPPER) string(TOUPPER ${_FN} _UPPER)
set(HAVE_${_UPPER} 1) set(HAVE_${_UPPER} 1)
endforeach() endforeach()

View File

@ -414,6 +414,7 @@
<ClCompile Include="..\..\src\joystick\windows\SDL_windowsjoystick.c" /> <ClCompile Include="..\..\src\joystick\windows\SDL_windowsjoystick.c" />
<ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c" /> <ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c" />
<ClCompile Include="..\..\src\libm\e_atan2.c" /> <ClCompile Include="..\..\src\libm\e_atan2.c" />
<ClCompile Include="..\..\src\libm\e_fmod.c" />
<ClCompile Include="..\..\src\libm\e_log.c" /> <ClCompile Include="..\..\src\libm\e_log.c" />
<ClCompile Include="..\..\src\libm\e_pow.c" /> <ClCompile Include="..\..\src\libm\e_pow.c" />
<ClCompile Include="..\..\src\libm\e_rem_pio2.c" /> <ClCompile Include="..\..\src\libm\e_rem_pio2.c" />

View File

@ -444,6 +444,7 @@
<ClCompile Include="..\..\src\audio\wasapi\SDL_wasapi.c" /> <ClCompile Include="..\..\src\audio\wasapi\SDL_wasapi.c" />
<ClCompile Include="..\..\src\video\SDL_vulkan_utils.c" /> <ClCompile Include="..\..\src\video\SDL_vulkan_utils.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowsvulkan.c" /> <ClCompile Include="..\..\src\video\windows\SDL_windowsvulkan.c" />
<ClCompile Include="..\..\src\libm\e_fmod.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\src\main\windows\version.rc" /> <ResourceCompile Include="..\..\src\main\windows\version.rc" />

2
configure vendored
View File

@ -16688,7 +16688,7 @@ if test "x$ac_cv_lib_m_pow" = xyes; then :
LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm" LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"
fi fi
for ac_func in acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf fabs fabsf floor floorf log logf pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf for ac_func in acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf log logf pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

View File

@ -271,7 +271,7 @@ if test x$enable_libc = xyes; then
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll) AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll)
AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"]) AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf fabs fabsf floor floorf log logf pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf) AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf log logf pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"]) AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
AC_CHECK_FUNCS(iconv) AC_CHECK_FUNCS(iconv)

View File

@ -148,6 +148,8 @@
#cmakedefine HAVE_FABSF 1 #cmakedefine HAVE_FABSF 1
#cmakedefine HAVE_FLOOR 1 #cmakedefine HAVE_FLOOR 1
#cmakedefine HAVE_FLOORF 1 #cmakedefine HAVE_FLOORF 1
#cmakedefine HAVE_FMOD 1
#cmakedefine HAVE_FMODF 1
#cmakedefine HAVE_LOG 1 #cmakedefine HAVE_LOG 1
#cmakedefine HAVE_LOGF 1 #cmakedefine HAVE_LOGF 1
#cmakedefine HAVE_POW 1 #cmakedefine HAVE_POW 1

View File

@ -153,6 +153,8 @@
#undef HAVE_FABSF #undef HAVE_FABSF
#undef HAVE_FLOOR #undef HAVE_FLOOR
#undef HAVE_FLOORF #undef HAVE_FLOORF
#undef HAVE_FMOD
#undef HAVE_FMODF
#undef HAVE_LOG #undef HAVE_LOG
#undef HAVE_LOGF #undef HAVE_LOGF
#undef HAVE_POW #undef HAVE_POW

View File

@ -84,20 +84,32 @@
#define HAVE_STRNCASECMP 1 #define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1 #define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1 #define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1

View File

@ -85,19 +85,32 @@
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1 #define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1 #define HAVE_M_PI 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1 #define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1

View File

@ -87,15 +87,33 @@
#define HAVE_STRNCASECMP 1 #define HAVE_STRNCASECMP 1
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1 #define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1 #define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1
@ -107,10 +125,6 @@
#define HAVE_NANOSLEEP 1 #define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1 #define HAVE_SYSCONF 1
#define HAVE_SYSCTLBYNAME 1 #define HAVE_SYSCTLBYNAME 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_ACOS 1
#define HAVE_ASIN 1
/* Enable various audio drivers */ /* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_COREAUDIO 1 #define SDL_AUDIO_DRIVER_COREAUDIO 1

View File

@ -83,19 +83,32 @@
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1 #define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1 #define HAVE_M_PI 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1 #define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1

View File

@ -125,30 +125,41 @@ typedef unsigned int uintptr_t;
#define HAVE_STRNCMP 1 #define HAVE_STRNCMP 1
#define HAVE__STRICMP 1 #define HAVE__STRICMP 1
#define HAVE__STRNICMP 1 #define HAVE__STRNICMP 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_CEIL 1 #define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEILF 1
#define HAVE__COPYSIGN 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1
#define HAVE_SQRTF 1 #define HAVE_SQRTF 1
#define HAVE_TAN 1 #define HAVE_TAN 1
#define HAVE_TANF 1 #define HAVE_TANF 1
#define HAVE__COPYSIGN 1
#if defined(_MSC_VER) #if defined(_MSC_VER)
/* These functions were added with the VC++ 2013 C runtime library */ /* These functions were added with the VC++ 2013 C runtime library */
#if _MSC_VER >= 1800 #if _MSC_VER >= 1800
#define HAVE_STRTOLL 1 #define HAVE_STRTOLL 1
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#endif #endif
/* This function is available with at least the VC++ 2008 C runtime library */ /* This function is available with at least the VC++ 2008 C runtime library */
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400

View File

@ -142,17 +142,29 @@ typedef unsigned int uintptr_t;
#define HAVE_VSNPRINTF 1 #define HAVE_VSNPRINTF 1
//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead //#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead
#define HAVE_M_PI 1 #define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1 #define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1 #define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE__COPYSIGN 1 #define HAVE__COPYSIGN 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_POW 1 #define HAVE_POW 1
//#define HAVE_SCALBN 1 #define HAVE_POWF 1
#define HAVE__SCALB 1 #define HAVE__SCALB 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1

View File

@ -80,14 +80,32 @@
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
#define HAVE_VSNPRINTF 1 #define HAVE_VSNPRINTF 1
#define HAVE_M_PI 1 #define HAVE_M_PI 1
#define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1
#define HAVE_ATAN2F 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
#define HAVE_CEILF 1
#define HAVE_COPYSIGN 1 #define HAVE_COPYSIGN 1
#define HAVE_COPYSIGNF 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FABSF 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_LOGF 1
#define HAVE_POW 1
#define HAVE_POWF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1

View File

@ -518,6 +518,8 @@ extern DECLSPEC double SDLCALL SDL_fabs(double x);
extern DECLSPEC float SDLCALL SDL_fabsf(float x); extern DECLSPEC float SDLCALL SDL_fabsf(float x);
extern DECLSPEC double SDLCALL SDL_floor(double x); extern DECLSPEC double SDLCALL SDL_floor(double x);
extern DECLSPEC float SDLCALL SDL_floorf(float x); extern DECLSPEC float SDLCALL SDL_floorf(float x);
extern DECLSPEC double SDLCALL SDL_fmod(double x, double y);
extern DECLSPEC float SDLCALL SDL_fmodf(float x, float y);
extern DECLSPEC double SDLCALL SDL_log(double x); extern DECLSPEC double SDLCALL SDL_log(double x);
extern DECLSPEC float SDLCALL SDL_logf(float x); extern DECLSPEC float SDLCALL SDL_logf(float x);
extern DECLSPEC double SDLCALL SDL_pow(double x, double y); extern DECLSPEC double SDLCALL SDL_pow(double x, double y);

View File

@ -658,3 +658,5 @@
#define SDL_logf SDL_logf_REAL #define SDL_logf SDL_logf_REAL
#define SDL_powf SDL_powf_REAL #define SDL_powf SDL_powf_REAL
#define SDL_scalbnf SDL_scalbnf_REAL #define SDL_scalbnf SDL_scalbnf_REAL
#define SDL_fmod SDL_fmod_REAL
#define SDL_fmodf SDL_fmodf_REAL

View File

@ -692,3 +692,5 @@ SDL_DYNAPI_PROC(float,SDL_floorf,(float a),(a),return)
SDL_DYNAPI_PROC(float,SDL_logf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_logf,(float a),(a),return)
SDL_DYNAPI_PROC(float,SDL_powf,(float a, float b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_powf,(float a, float b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_scalbnf,(float a, int b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_scalbnf,(float a, int b),(a,b),return)
SDL_DYNAPI_PROC(double,SDL_fmod,(double a, double b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_fmodf,(float a, float b),(a,b),return)

144
src/libm/e_fmod.c Normal file
View File

@ -0,0 +1,144 @@
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* __ieee754_fmod(x,y)
* Return x mod y in exact arithmetic
* Method: shift and subtract
*/
#include "math_libm.h"
#include "math_private.h"
static const double one = 1.0, Zero[] = {0.0, -0.0,};
double attribute_hidden __ieee754_fmod(double x, double y)
{
int32_t n,hx,hy,hz,ix,iy,sx,i;
u_int32_t lx,ly,lz;
EXTRACT_WORDS(hx,lx,x);
EXTRACT_WORDS(hy,ly,y);
sx = hx&0x80000000; /* sign of x */
hx ^=sx; /* |x| */
hy &= 0x7fffffff; /* |y| */
/* purge off exception values */
if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */
((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */
return (x*y)/(x*y);
if(hx<=hy) {
if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */
if(lx==ly)
return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/
}
/* determine ix = ilogb(x) */
if(hx<0x00100000) { /* subnormal x */
if(hx==0) {
for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
} else {
for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
}
} else ix = (hx>>20)-1023;
/* determine iy = ilogb(y) */
if(hy<0x00100000) { /* subnormal y */
if(hy==0) {
for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
} else {
for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
}
} else iy = (hy>>20)-1023;
/* set up {hx,lx}, {hy,ly} and align y to x */
if(ix >= -1022)
hx = 0x00100000|(0x000fffff&hx);
else { /* subnormal x, shift x to normal */
n = -1022-ix;
if(n<=31) {
hx = (hx<<n)|(lx>>(32-n));
lx <<= n;
} else {
hx = lx<<(n-32);
lx = 0;
}
}
if(iy >= -1022)
hy = 0x00100000|(0x000fffff&hy);
else { /* subnormal y, shift y to normal */
n = -1022-iy;
if(n<=31) {
hy = (hy<<n)|(ly>>(32-n));
ly <<= n;
} else {
hy = ly<<(n-32);
ly = 0;
}
}
/* fix point fmod */
n = ix - iy;
while(n--) {
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
else {
if((hz|lz)==0) /* return sign(x)*0 */
return Zero[(u_int32_t)sx>>31];
hx = hz+hz+(lz>>31); lx = lz+lz;
}
}
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
if(hz>=0) {hx=hz;lx=lz;}
/* convert back to floating value and restore the sign */
if((hx|lx)==0) /* return sign(x)*0 */
return Zero[(u_int32_t)sx>>31];
while(hx<0x00100000) { /* normalize x */
hx = hx+hx+(lx>>31); lx = lx+lx;
iy -= 1;
}
if(iy>= -1022) { /* normalize output */
hx = ((hx-0x00100000)|((iy+1023)<<20));
INSERT_WORDS(x,hx|sx,lx);
} else { /* subnormal output */
n = -1022 - iy;
if(n<=20) {
lx = (lx>>n)|((u_int32_t)hx<<(32-n));
hx >>= n;
} else if (n<=31) {
lx = (hx<<(32-n))|(lx>>n); hx = sx;
} else {
lx = hx>>(n-32); hx = sx;
}
INSERT_WORDS(x,hx|sx,lx);
x *= one; /* create necessary signal */
}
return x; /* exact output */
}
/*
* wrapper fmod(x,y)
*/
#ifndef _IEEE_LIBM
double fmod(double x, double y)
{
double z = __ieee754_fmod(x, y);
if (_LIB_VERSION == _IEEE_ || isnan(y) || isnan(x))
return z;
if (y == 0.0)
return __kernel_standard(x, y, 27); /* fmod(x,0) */
return z;
}
#else
strong_alias(__ieee754_fmod, fmod)
#endif
libm_hidden_def(fmod)

View File

@ -61,17 +61,9 @@ double scalbln(double x, long n)
} }
libm_hidden_def(scalbln) libm_hidden_def(scalbln)
#if LONG_MAX == INT_MAX
/* strong_alias(scalbln, scalbn) - "error: conflicting types for 'scalbn'"
* because it tries to declare "typeof(scalbln) scalbn;"
* which tries to give "long" parameter to scalbn.
* Doing it by hand:
*/
__typeof(scalbn) scalbn __attribute__((alias("scalbln")));
#else
double scalbn(double x, int n) double scalbn(double x, int n)
{ {
return scalbln(x, n); return scalbln(x, n);
} }
#endif
libm_hidden_def(scalbn) libm_hidden_def(scalbn)

View File

@ -148,7 +148,7 @@ SDL_ceilf(float x)
#if defined(HAVE_CEILF) #if defined(HAVE_CEILF)
return ceilf(x); return ceilf(x);
#else #else
return (float)ceil((float)x); return (float)SDL_ceil((float)x);
#endif #endif
} }
@ -240,6 +240,26 @@ SDL_floorf(float x)
#endif #endif
} }
double
SDL_fmod(double x, double y)
{
#if defined(HAVE_FMOD)
return fmod(x, y);
#else
return SDL_uclibc_fmod(x, y);
#endif
}
float
SDL_fmodf(float x, float y)
{
#if defined(HAVE_FMODF)
return fmodf(x, y);
#else
return (float)SDL_fmod((double)x, (double)y);
#endif
}
double double
SDL_log(double x) SDL_log(double x)
{ {