mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-26 16:41:36 +00:00
Added SDL_isinf(), SDL_isinff(), SDL_isnan(), and SDL_isnanf()
This commit is contained in:
@@ -930,7 +930,11 @@ SDL3_0.0.0 {
|
||||
SDL_iscntrl;
|
||||
SDL_isdigit;
|
||||
SDL_isgraph;
|
||||
SDL_isinf;
|
||||
SDL_isinff;
|
||||
SDL_islower;
|
||||
SDL_isnan;
|
||||
SDL_isnanf;
|
||||
SDL_isprint;
|
||||
SDL_ispunct;
|
||||
SDL_isspace;
|
||||
|
||||
@@ -955,7 +955,11 @@
|
||||
#define SDL_iscntrl SDL_iscntrl_REAL
|
||||
#define SDL_isdigit SDL_isdigit_REAL
|
||||
#define SDL_isgraph SDL_isgraph_REAL
|
||||
#define SDL_isinf SDL_isinf_REAL
|
||||
#define SDL_isinff SDL_isinff_REAL
|
||||
#define SDL_islower SDL_islower_REAL
|
||||
#define SDL_isnan SDL_isnan_REAL
|
||||
#define SDL_isnanf SDL_isnanf_REAL
|
||||
#define SDL_isprint SDL_isprint_REAL
|
||||
#define SDL_ispunct SDL_ispunct_REAL
|
||||
#define SDL_isspace SDL_isspace_REAL
|
||||
|
||||
@@ -964,7 +964,11 @@ SDL_DYNAPI_PROC(int,SDL_isblank,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_iscntrl,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isdigit,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isgraph,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isinf,(double a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isinff,(float a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_islower,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isnan,(double a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isnanf,(float a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isprint,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ispunct,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isspace,(int a),(a),return)
|
||||
|
||||
@@ -26,21 +26,25 @@
|
||||
|
||||
/* Math routines from uClibc: http://www.uclibc.org */
|
||||
|
||||
double SDL_uclibc_atan(double x);
|
||||
double SDL_uclibc_atan2(double y, double x);
|
||||
double SDL_uclibc_copysign(double x, double y);
|
||||
double SDL_uclibc_cos(double x);
|
||||
double SDL_uclibc_exp(double x);
|
||||
double SDL_uclibc_fabs(double x);
|
||||
double SDL_uclibc_floor(double x);
|
||||
double SDL_uclibc_fmod(double x, double y);
|
||||
double SDL_uclibc_log(double x);
|
||||
double SDL_uclibc_log10(double x);
|
||||
double SDL_uclibc_modf(double x, double *y);
|
||||
double SDL_uclibc_pow(double x, double y);
|
||||
double SDL_uclibc_scalbn(double x, int n);
|
||||
double SDL_uclibc_sin(double x);
|
||||
double SDL_uclibc_sqrt(double x);
|
||||
double SDL_uclibc_tan(double x);
|
||||
extern double SDL_uclibc_atan(double x);
|
||||
extern double SDL_uclibc_atan2(double y, double x);
|
||||
extern double SDL_uclibc_copysign(double x, double y);
|
||||
extern double SDL_uclibc_cos(double x);
|
||||
extern double SDL_uclibc_exp(double x);
|
||||
extern double SDL_uclibc_fabs(double x);
|
||||
extern double SDL_uclibc_floor(double x);
|
||||
extern double SDL_uclibc_fmod(double x, double y);
|
||||
extern int SDL_uclibc_isinf(double x);
|
||||
extern int SDL_uclibc_isinff(float x);
|
||||
extern int SDL_uclibc_isnan(double x);
|
||||
extern int SDL_uclibc_isnanf(float x);
|
||||
extern double SDL_uclibc_log(double x);
|
||||
extern double SDL_uclibc_log10(double x);
|
||||
extern double SDL_uclibc_modf(double x, double *y);
|
||||
extern double SDL_uclibc_pow(double x, double y);
|
||||
extern double SDL_uclibc_scalbn(double x, int n);
|
||||
extern double SDL_uclibc_sin(double x);
|
||||
extern double SDL_uclibc_sqrt(double x);
|
||||
extern double SDL_uclibc_tan(double x);
|
||||
|
||||
#endif /* math_libm_h_ */
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define libm_hidden_proto(x)
|
||||
#define libm_hidden_def(x)
|
||||
#define strong_alias(x, y)
|
||||
#define weak_alias(x, y)
|
||||
|
||||
#if !defined(SDL_PLATFORM_HAIKU) && !defined(SDL_PLATFORM_PSP) && !defined(SDL_PLATFORM_3DS) && !defined(SDL_PLATFORM_PS2) /* already defined in a system header. */
|
||||
typedef unsigned int u_int32_t;
|
||||
@@ -38,6 +39,14 @@ typedef unsigned int u_int32_t;
|
||||
#define fabs SDL_uclibc_fabs
|
||||
#define floor SDL_uclibc_floor
|
||||
#define __ieee754_fmod SDL_uclibc_fmod
|
||||
#undef __isinf
|
||||
#define __isinf SDL_uclibc_isinf
|
||||
#undef __isinff
|
||||
#define __isinff SDL_uclibc_isinff
|
||||
#undef __isnan
|
||||
#define __isnan SDL_uclibc_isnan
|
||||
#undef __isnanf
|
||||
#define __isnanf SDL_uclibc_isnanf
|
||||
#define __ieee754_log SDL_uclibc_log
|
||||
#define __ieee754_log10 SDL_uclibc_log10
|
||||
#define modf SDL_uclibc_modf
|
||||
@@ -181,48 +190,45 @@ do { \
|
||||
} while (0)
|
||||
|
||||
/* ieee style elementary functions */
|
||||
extern double
|
||||
__ieee754_sqrt(double)
|
||||
attribute_hidden;
|
||||
extern double __ieee754_acos(double) attribute_hidden;
|
||||
extern double __ieee754_acosh(double) attribute_hidden;
|
||||
extern double __ieee754_log(double) attribute_hidden;
|
||||
extern double __ieee754_atanh(double) attribute_hidden;
|
||||
extern double __ieee754_asin(double) attribute_hidden;
|
||||
extern double __ieee754_atan2(double, double) attribute_hidden;
|
||||
extern double __ieee754_exp(double) attribute_hidden;
|
||||
extern double __ieee754_cosh(double) attribute_hidden;
|
||||
extern double __ieee754_fmod(double, double) attribute_hidden;
|
||||
extern double __ieee754_pow(double, double) attribute_hidden;
|
||||
extern double __ieee754_lgamma_r(double, int *) attribute_hidden;
|
||||
extern double __ieee754_gamma_r(double, int *) attribute_hidden;
|
||||
extern double __ieee754_lgamma(double) attribute_hidden;
|
||||
extern double __ieee754_gamma(double) attribute_hidden;
|
||||
extern double __ieee754_log10(double) attribute_hidden;
|
||||
extern double __ieee754_sinh(double) attribute_hidden;
|
||||
extern double __ieee754_hypot(double, double) attribute_hidden;
|
||||
extern double __ieee754_j0(double) attribute_hidden;
|
||||
extern double __ieee754_j1(double) attribute_hidden;
|
||||
extern double __ieee754_y0(double) attribute_hidden;
|
||||
extern double __ieee754_y1(double) attribute_hidden;
|
||||
extern double __ieee754_jn(int, double) attribute_hidden;
|
||||
extern double __ieee754_yn(int, double) attribute_hidden;
|
||||
extern double __ieee754_remainder(double, double) attribute_hidden;
|
||||
extern int32_t __ieee754_rem_pio2(double, double *) attribute_hidden;
|
||||
extern double __ieee754_sqrt(double) attribute_hidden;
|
||||
extern double __ieee754_acos(double) attribute_hidden;
|
||||
extern double __ieee754_acosh(double) attribute_hidden;
|
||||
extern double __ieee754_log(double) attribute_hidden;
|
||||
extern double __ieee754_atanh(double) attribute_hidden;
|
||||
extern double __ieee754_asin(double) attribute_hidden;
|
||||
extern double __ieee754_atan2(double, double) attribute_hidden;
|
||||
extern double __ieee754_exp(double) attribute_hidden;
|
||||
extern double __ieee754_cosh(double) attribute_hidden;
|
||||
extern double __ieee754_fmod(double, double) attribute_hidden;
|
||||
extern double __ieee754_pow(double, double) attribute_hidden;
|
||||
extern double __ieee754_lgamma_r(double, int *) attribute_hidden;
|
||||
extern double __ieee754_gamma_r(double, int *) attribute_hidden;
|
||||
extern double __ieee754_lgamma(double) attribute_hidden;
|
||||
extern double __ieee754_gamma(double) attribute_hidden;
|
||||
extern double __ieee754_log10(double) attribute_hidden;
|
||||
extern double __ieee754_sinh(double) attribute_hidden;
|
||||
extern double __ieee754_hypot(double, double) attribute_hidden;
|
||||
extern double __ieee754_j0(double) attribute_hidden;
|
||||
extern double __ieee754_j1(double) attribute_hidden;
|
||||
extern double __ieee754_y0(double) attribute_hidden;
|
||||
extern double __ieee754_y1(double) attribute_hidden;
|
||||
extern double __ieee754_jn(int, double) attribute_hidden;
|
||||
extern double __ieee754_yn(int, double) attribute_hidden;
|
||||
extern double __ieee754_remainder(double, double) attribute_hidden;
|
||||
extern int32_t __ieee754_rem_pio2(double, double *) attribute_hidden;
|
||||
#if defined(_SCALB_INT)
|
||||
extern double __ieee754_scalb(double, int) attribute_hidden;
|
||||
extern double __ieee754_scalb(double, int) attribute_hidden;
|
||||
#else
|
||||
extern double __ieee754_scalb(double, double) attribute_hidden;
|
||||
extern double __ieee754_scalb(double, double) attribute_hidden;
|
||||
#endif
|
||||
|
||||
/* fdlibm kernel function */
|
||||
#ifndef _IEEE_LIBM
|
||||
extern double __kernel_standard(double, double, int) attribute_hidden;
|
||||
extern double __kernel_standard(double, double, int) attribute_hidden;
|
||||
#endif
|
||||
extern double __kernel_sin(double, double, int) attribute_hidden;
|
||||
extern double __kernel_cos(double, double) attribute_hidden;
|
||||
extern double __kernel_tan(double, double, int) attribute_hidden;
|
||||
extern int32_t __kernel_rem_pio2(const double *, double *, int, int, const unsigned int,
|
||||
const int32_t *) attribute_hidden;
|
||||
extern double __kernel_sin(double, double, int) attribute_hidden;
|
||||
extern double __kernel_cos(double, double) attribute_hidden;
|
||||
extern double __kernel_tan(double, double, int) attribute_hidden;
|
||||
extern int32_t __kernel_rem_pio2(const double *, double *, int, int, const unsigned int, const int32_t *) attribute_hidden;
|
||||
|
||||
#endif /* _MATH_PRIVATE_H_ */
|
||||
|
||||
24
src/libm/s_isinf.c
Normal file
24
src/libm/s_isinf.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "SDL_internal.h"
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
/*
|
||||
* isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
|
||||
* no branching!
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
int __isinf(double x)
|
||||
{
|
||||
int32_t hx,lx;
|
||||
EXTRACT_WORDS(hx,lx,x);
|
||||
lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
|
||||
lx |= -lx;
|
||||
return ~(lx >> 31) & (hx >> 30);
|
||||
}
|
||||
libm_hidden_def(__isinf)
|
||||
24
src/libm/s_isinff.c
Normal file
24
src/libm/s_isinff.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "SDL_internal.h"
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
/*
|
||||
* isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0;
|
||||
* no branching!
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
int __isinff (float x)
|
||||
{
|
||||
int32_t ix,t;
|
||||
GET_FLOAT_WORD(ix,x);
|
||||
t = ix & 0x7fffffff;
|
||||
t ^= 0x7f800000;
|
||||
t |= -t;
|
||||
return ~(t >> 31) & (ix >> 30);
|
||||
}
|
||||
libm_hidden_def(__isinff)
|
||||
31
src/libm/s_isnan.c
Normal file
31
src/libm/s_isnan.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "SDL_internal.h"
|
||||
/*
|
||||
* ====================================================
|
||||
* 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.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* isnan(x) returns 1 is x is nan, else 0;
|
||||
* no branching!
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
int __isnan(double x)
|
||||
{
|
||||
int32_t hx,lx;
|
||||
EXTRACT_WORDS(hx,lx,x);
|
||||
hx &= 0x7fffffff;
|
||||
hx |= (u_int32_t)(lx|(-lx))>>31;
|
||||
hx = 0x7ff00000 - hx;
|
||||
return (int)(((u_int32_t)hx)>>31);
|
||||
}
|
||||
weak_alias(__isnan, isnan)
|
||||
libm_hidden_def(__isnan)
|
||||
33
src/libm/s_isnanf.c
Normal file
33
src/libm/s_isnanf.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "SDL_internal.h"
|
||||
/* s_isnanf.c -- float version of s_isnan.c.
|
||||
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ====================================================
|
||||
* 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.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* isnanf(x) returns 1 is x is nan, else 0;
|
||||
* no branching!
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "math_private.h"
|
||||
|
||||
int __isnanf(float x)
|
||||
{
|
||||
int32_t ix;
|
||||
GET_FLOAT_WORD(ix,x);
|
||||
ix &= 0x7fffffff;
|
||||
ix = 0x7f800000 - ix;
|
||||
return (int)(((u_int32_t)(ix))>>31);
|
||||
}
|
||||
libm_hidden_def(__isnanf)
|
||||
@@ -272,6 +272,46 @@ float SDL_fmodf(float x, float y)
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_bool SDL_isinf(double x)
|
||||
{
|
||||
#ifdef HAVE_ISINF
|
||||
return isinf(x);
|
||||
#else
|
||||
return SDL_uclibc_isinf(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_bool SDL_isinff(float x)
|
||||
{
|
||||
#ifdef HAVE_ISINF_FLOAT_MACRO
|
||||
return isinf(x);
|
||||
#elif defined(HAVE_ISINFF)
|
||||
return isinff(x);
|
||||
#else
|
||||
return SDL_uclibc_isinff(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_bool SDL_isnan(double x)
|
||||
{
|
||||
#ifdef HAVE_ISNAN
|
||||
return isnan(x);
|
||||
#else
|
||||
return SDL_uclibc_isnan(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_bool SDL_isnanf(float x)
|
||||
{
|
||||
#ifdef HAVE_ISNAN_FLOAT_MACRO
|
||||
return isnan(x);
|
||||
#elif defined(HAVE_ISNANF)
|
||||
return isnanf(x);
|
||||
#else
|
||||
return SDL_uclibc_isnanf(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
double SDL_log(double x)
|
||||
{
|
||||
#ifdef HAVE_LOG
|
||||
|
||||
Reference in New Issue
Block a user