2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll math functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2001-01-22 03:21:54 +01:00
|
|
|
#include "config.h"
|
2013-11-29 15:06:33 +01:00
|
|
|
#include "wine/port.h"
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2003-03-21 00:47:25 +01:00
|
|
|
#include <stdio.h>
|
2001-01-11 00:59:25 +01:00
|
|
|
#define __USE_ISOC9X 1
|
|
|
|
#define __USE_ISOC99 1
|
|
|
|
#include <math.h>
|
|
|
|
#ifdef HAVE_IEEEFP_H
|
|
|
|
#include <ieeefp.h>
|
|
|
|
#endif
|
|
|
|
|
2004-03-16 20:17:11 +01:00
|
|
|
#include "msvcrt.h"
|
2001-04-11 01:25:25 +02:00
|
|
|
|
2002-01-22 01:57:16 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2015-01-23 07:30:57 +01:00
|
|
|
#ifndef HAVE_FINITEF
|
|
|
|
#define finitef(x) isfinite(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_ISNANF
|
|
|
|
#ifdef HAVE_ISNAN
|
|
|
|
#define isnanf(x) isnan(x)
|
|
|
|
#else
|
|
|
|
#define isnanf(x) 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2015-03-24 10:51:12 +01:00
|
|
|
/* FIXME: Does not work with -NAN and -0. */
|
2001-01-11 00:59:25 +01:00
|
|
|
#ifndef signbit
|
2015-03-24 10:51:12 +01:00
|
|
|
#define signbit(x) ((x) < 0)
|
2001-01-11 00:59:25 +01:00
|
|
|
#endif
|
|
|
|
|
2010-05-12 17:15:29 +02:00
|
|
|
typedef int (CDECL *MSVCRT_matherr_func)(struct MSVCRT__exception *);
|
2014-12-08 13:35:25 +01:00
|
|
|
typedef double LDOUBLE; /* long double is just a double */
|
2001-01-11 00:59:25 +01:00
|
|
|
|
|
|
|
static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
|
|
|
|
|
2011-01-25 21:01:12 +01:00
|
|
|
static BOOL sse2_supported;
|
|
|
|
static BOOL sse2_enabled;
|
|
|
|
|
|
|
|
void msvcrt_init_math(void)
|
|
|
|
{
|
|
|
|
sse2_supported = sse2_enabled = IsProcessorFeaturePresent( PF_XMMI64_INSTRUCTIONS_AVAILABLE );
|
|
|
|
}
|
|
|
|
|
2010-08-25 14:46:05 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _set_SSE2_enable (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__set_SSE2_enable(int flag)
|
|
|
|
{
|
2011-01-25 21:01:12 +01:00
|
|
|
sse2_enabled = flag && sse2_supported;
|
|
|
|
return sse2_enabled;
|
2010-08-25 14:46:05 +02:00
|
|
|
}
|
|
|
|
|
2015-03-30 16:31:38 +02:00
|
|
|
#if defined(__x86_64__) || defined(__arm__) || _MSVCR_VER>=120
|
2010-05-01 16:32:19 +02:00
|
|
|
|
2012-08-16 18:03:27 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _chgsignf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT__chgsignf( float num )
|
|
|
|
{
|
|
|
|
/* FIXME: +-infinity,Nan not tested */
|
|
|
|
return -num;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _copysignf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT__copysignf( float num, float sign )
|
|
|
|
{
|
2015-03-24 10:51:12 +01:00
|
|
|
if (signbit(sign))
|
|
|
|
return signbit(num) ? num : -num;
|
|
|
|
return signbit(num) ? -num : num;
|
2012-08-16 18:03:27 +02:00
|
|
|
}
|
|
|
|
|
2015-03-30 16:31:38 +02:00
|
|
|
#endif
|
|
|
|
#if defined(__x86_64__) || defined(__arm__)
|
|
|
|
|
2012-08-16 18:03:27 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _finitef (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__finitef( float num )
|
|
|
|
{
|
|
|
|
return finitef(num) != 0; /* See comment for _isnan() */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _isnanf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
INT CDECL MSVCRT__isnanf( float num )
|
|
|
|
{
|
|
|
|
/* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
|
|
|
|
* Do the same, as the result may be used in calculations
|
|
|
|
*/
|
|
|
|
return isnanf(num) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _logbf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT__logbf( float num )
|
|
|
|
{
|
|
|
|
if (!finitef(num)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return logbf(num);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _nextafterf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT__nextafterf( float num, float next )
|
|
|
|
{
|
|
|
|
if (!finitef(num) || !finitef(next)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return nextafterf( num, next );
|
|
|
|
}
|
|
|
|
|
2010-05-01 16:32:19 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_acosf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_acosf( float x )
|
|
|
|
{
|
|
|
|
if (x < -1.0 || x > 1.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
/* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
|
|
|
|
* asin() uses a similar construction. This is bad because as x gets nearer to
|
|
|
|
* 1 the error in the expression "1 - x^2" can get relatively large due to
|
|
|
|
* cancellation. The sqrt() makes things worse. A safer way to calculate
|
|
|
|
* acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
|
|
|
|
return atan2f(sqrtf((1 - x) * (1 + x)), x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_asinf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_asinf( float x )
|
|
|
|
{
|
|
|
|
if (x < -1.0 || x > 1.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return atan2f(x, sqrtf((1 - x) * (1 + x)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_atanf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_atanf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return atanf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_atan2f (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_atan2f( float x, float y )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return atan2f(x,y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_cosf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_cosf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return cosf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_coshf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_coshf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return coshf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_expf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_expf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return expf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_fmodf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_fmodf( float x, float y )
|
|
|
|
{
|
|
|
|
if (!finitef(x) || !finitef(y)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return fmodf(x,y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_logf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_logf( float x)
|
|
|
|
{
|
|
|
|
if (x < 0.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return logf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_log10f (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_log10f( float x )
|
|
|
|
{
|
|
|
|
if (x < 0.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return log10f(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_powf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_powf( float x, float y )
|
|
|
|
{
|
|
|
|
/* FIXME: If x < 0 and y is not integral, set EDOM */
|
|
|
|
float z = powf(x,y);
|
|
|
|
if (!finitef(z)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_sinf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_sinf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return sinf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_sinhf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_sinhf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return sinhf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_sqrtf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_sqrtf( float x )
|
|
|
|
{
|
|
|
|
if (x < 0.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return sqrtf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_tanf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_tanf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return tanf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_tanhf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_tanhf( float x )
|
|
|
|
{
|
|
|
|
if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return tanhf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ceilf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_ceilf( float x )
|
|
|
|
{
|
|
|
|
return ceilf(x);
|
|
|
|
}
|
|
|
|
|
2013-09-03 21:24:27 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* fabsf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_fabsf( float x )
|
|
|
|
{
|
|
|
|
return fabsf(x);
|
|
|
|
}
|
|
|
|
|
2010-05-01 16:32:19 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* floorf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_floorf( float x )
|
|
|
|
{
|
|
|
|
return floorf(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* frexpf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT_frexpf( float x, int *exp )
|
|
|
|
{
|
|
|
|
return frexpf( x, exp );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _scalbf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCRT__scalbf(float num, MSVCRT_long power)
|
|
|
|
{
|
|
|
|
if (!finitef(num)) *MSVCRT__errno() = MSVCRT_EDOM;
|
|
|
|
return ldexpf(num, power);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* modff (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCRT_modff( float x, float *iptr )
|
|
|
|
{
|
|
|
|
return modff( x, iptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-01-14 17:36:23 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_acos (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_acos( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (x < -1.0 || x > 1.0 || !isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2008-08-29 02:11:53 +02:00
|
|
|
/* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
|
|
|
|
* asin() uses a similar construction. This is bad because as x gets nearer to
|
|
|
|
* 1 the error in the expression "1 - x^2" can get relatively large due to
|
|
|
|
* cancellation. The sqrt() makes things worse. A safer way to calculate
|
|
|
|
* acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
|
|
|
|
return atan2(sqrt((1 - x) * (1 + x)), x);
|
2006-01-14 17:36:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_asin (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_asin( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (x < -1.0 || x > 1.0 || !isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2008-08-29 02:11:53 +02:00
|
|
|
return atan2(x, sqrt((1 - x) * (1 + x)));
|
2006-01-14 17:36:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_atan (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_atan( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2015-03-24 11:09:50 +01:00
|
|
|
if (isnan(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return atan(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_atan2 (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_atan2( double x, double y )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return atan2(x,y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_cos (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_cos( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return cos(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_cosh (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_cosh( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return cosh(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_exp (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_exp( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2015-03-24 11:09:50 +01:00
|
|
|
if (isnan(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return exp(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_fmod (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_fmod( double x, double y )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(x) || !isfinite(y)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return fmod(x,y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_log (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_log( double x)
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (x < 0.0 || !isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return log(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_log10 (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_log10( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (x < 0.0 || !isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return log10(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_pow (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_pow( double x, double y )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
|
|
|
/* FIXME: If x < 0 and y is not integral, set EDOM */
|
|
|
|
double z = pow(x,y);
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(z)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_sin (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_sin( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return sin(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_sinh (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_sinh( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return sinh(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_sqrt (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_sqrt( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (x < 0.0 || !isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return sqrt(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_tan (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_tan( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return tan(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* MSVCRT_tanh (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_tanh( double x )
|
2006-01-14 17:36:23 +01:00
|
|
|
{
|
2015-03-24 11:09:50 +01:00
|
|
|
if (isnan(x)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2006-01-14 17:36:23 +01:00
|
|
|
return tanh(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
#if defined(__GNUC__) && defined(__i386__)
|
|
|
|
|
|
|
|
#define FPU_DOUBLE(var) double var; \
|
|
|
|
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
|
|
|
|
#define FPU_DOUBLES(var1,var2) double var1,var2; \
|
|
|
|
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
|
|
|
|
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIacos (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIacos(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_acos(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIasin (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIasin(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_asin(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIatan (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIatan(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_atan(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIatan2 (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIatan2(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLES(x,y);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_atan2(x,y);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIcos (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIcos(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_cos(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIcosh (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIcosh(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_cosh(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIexp (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIexp(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_exp(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIfmod (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIfmod(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLES(x,y);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_fmod(x,y);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIlog (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIlog(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_log(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIlog10 (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIlog10(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_log10(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIpow (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIpow(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLES(x,y);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_pow(x,y);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIsin (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIsin(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_sin(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIsinh (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIsinh(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_sinh(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CIsqrt (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CIsqrt(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_sqrt(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CItan (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CItan(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_tan(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _CItanh (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _CItanh(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
2006-01-14 17:36:23 +01:00
|
|
|
return MSVCRT_tanh(x);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2012-12-14 05:01:26 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _ftol (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
LONGLONG CDECL MSVCRT__ftol(void)
|
|
|
|
{
|
|
|
|
FPU_DOUBLE(x);
|
|
|
|
return (LONGLONG)x;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
#endif /* defined(__GNUC__) && defined(__i386__) */
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _fpclass (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
int CDECL MSVCRT__fpclass(double num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
#if defined(HAVE_FPCLASS) || defined(fpclass)
|
|
|
|
switch (fpclass( num ))
|
|
|
|
{
|
2004-04-08 21:49:49 +02:00
|
|
|
#ifdef FP_SNAN
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_SNAN: return MSVCRT__FPCLASS_SNAN;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_QNAN
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_QNAN: return MSVCRT__FPCLASS_QNAN;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_NINF
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_NINF: return MSVCRT__FPCLASS_NINF;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_PINF
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_PINF: return MSVCRT__FPCLASS_PINF;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_NDENORM
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_NDENORM: return MSVCRT__FPCLASS_ND;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_PDENORM
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_PDENORM: return MSVCRT__FPCLASS_PD;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_NZERO
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_NZERO: return MSVCRT__FPCLASS_NZ;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_PZERO
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_PZERO: return MSVCRT__FPCLASS_PZ;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_NNORM
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_NNORM: return MSVCRT__FPCLASS_NN;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
|
|
|
#ifdef FP_PNORM
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_PNORM: return MSVCRT__FPCLASS_PN;
|
2004-04-08 21:49:49 +02:00
|
|
|
#endif
|
2008-11-21 01:07:07 +01:00
|
|
|
default: return MSVCRT__FPCLASS_PN;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
#elif defined (fpclassify)
|
|
|
|
switch (fpclassify( num ))
|
|
|
|
{
|
2004-06-25 03:19:15 +02:00
|
|
|
case FP_NAN: return MSVCRT__FPCLASS_QNAN;
|
|
|
|
case FP_INFINITE: return signbit(num) ? MSVCRT__FPCLASS_NINF : MSVCRT__FPCLASS_PINF;
|
|
|
|
case FP_SUBNORMAL: return signbit(num) ?MSVCRT__FPCLASS_ND : MSVCRT__FPCLASS_PD;
|
|
|
|
case FP_ZERO: return signbit(num) ? MSVCRT__FPCLASS_NZ : MSVCRT__FPCLASS_PZ;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
2004-06-25 03:19:15 +02:00
|
|
|
return signbit(num) ? MSVCRT__FPCLASS_NN : MSVCRT__FPCLASS_PN;
|
2001-01-11 00:59:25 +01:00
|
|
|
#else
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(num))
|
2004-06-25 03:19:15 +02:00
|
|
|
return MSVCRT__FPCLASS_QNAN;
|
|
|
|
return num == 0.0 ? MSVCRT__FPCLASS_PZ : (num < 0 ? MSVCRT__FPCLASS_NN : MSVCRT__FPCLASS_PN);
|
2001-01-11 00:59:25 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _rotl (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int CDECL _rotl(unsigned int num, int shift)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
shift &= 31;
|
|
|
|
return (num << shift) | (num >> (32-shift));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _lrotl (MSVCRT.@)
|
|
|
|
*/
|
2010-03-29 00:00:26 +02:00
|
|
|
MSVCRT_ulong CDECL MSVCRT__lrotl(MSVCRT_ulong num, int shift)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
shift &= 0x1f;
|
|
|
|
return (num << shift) | (num >> (32-shift));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _lrotr (MSVCRT.@)
|
|
|
|
*/
|
2010-03-29 00:00:26 +02:00
|
|
|
MSVCRT_ulong CDECL MSVCRT__lrotr(MSVCRT_ulong num, int shift)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
shift &= 0x1f;
|
|
|
|
return (num >> shift) | (num << (32-shift));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _rotr (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int CDECL _rotr(unsigned int num, int shift)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
shift &= 0x1f;
|
|
|
|
return (num >> shift) | (num << (32-shift));
|
|
|
|
}
|
|
|
|
|
2011-05-01 12:52:22 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _rotl64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
unsigned __int64 CDECL _rotl64(unsigned __int64 num, int shift)
|
|
|
|
{
|
|
|
|
shift &= 63;
|
|
|
|
return (num << shift) | (num >> (64-shift));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _rotr64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
unsigned __int64 CDECL _rotr64(unsigned __int64 num, int shift)
|
|
|
|
{
|
|
|
|
shift &= 63;
|
|
|
|
return (num >> shift) | (num << (64-shift));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* abs (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT_abs( int n )
|
|
|
|
{
|
|
|
|
return n >= 0 ? n : -n;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* labs (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_long CDECL MSVCRT_labs( MSVCRT_long n )
|
|
|
|
{
|
|
|
|
return n >= 0 ? n : -n;
|
|
|
|
}
|
|
|
|
|
2014-08-29 18:31:18 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* llabs (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_longlong CDECL MSVCRT_llabs( MSVCRT_longlong n )
|
|
|
|
{
|
|
|
|
return n >= 0 ? n : -n;
|
|
|
|
}
|
|
|
|
|
2011-05-01 12:52:22 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _abs64 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
__int64 CDECL _abs64( __int64 n )
|
|
|
|
{
|
|
|
|
return n >= 0 ? n : -n;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _logb (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__logb(double num)
|
2011-05-01 12:52:22 +02:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2011-05-01 12:52:22 +02:00
|
|
|
return logb(num);
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _scalb (MSVCRT.@)
|
|
|
|
*/
|
2010-03-29 00:00:26 +02:00
|
|
|
double CDECL MSVCRT__scalb(double num, MSVCRT_long power)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2010-03-29 00:01:13 +02:00
|
|
|
return ldexp(num, power);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2006-01-14 17:40:29 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _hypot (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL _hypot(double x, double y)
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
/* FIXME: errno handling */
|
|
|
|
return hypot( x, y );
|
|
|
|
}
|
|
|
|
|
2010-05-01 16:32:19 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _hypotf (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
float CDECL MSVCRT__hypotf(float x, float y)
|
2010-05-01 16:32:19 +02:00
|
|
|
{
|
|
|
|
/* FIXME: errno handling */
|
|
|
|
return hypotf( x, y );
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:40:29 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* ceil (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_ceil( double x )
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
return ceil(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* floor (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_floor( double x )
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
return floor(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* fabs (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_fabs( double x )
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
return fabs(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* frexp (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_frexp( double x, int *exp )
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
return frexp( x, exp );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* modf (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_modf( double x, double *iptr )
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
return modf( x, iptr );
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _matherr (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT__matherr(struct MSVCRT__exception *e)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
if (e)
|
|
|
|
TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2,
|
|
|
|
e->retval);
|
|
|
|
else
|
|
|
|
TRACE("(null)\n");
|
|
|
|
if (MSVCRT_default_matherr_func)
|
|
|
|
return MSVCRT_default_matherr_func(e);
|
|
|
|
ERR(":Unhandled math error!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __setusermatherr (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
void CDECL MSVCRT___setusermatherr(MSVCRT_matherr_func func)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
MSVCRT_default_matherr_func = func;
|
|
|
|
TRACE(":new matherr handler %p\n", func);
|
|
|
|
}
|
|
|
|
|
2011-01-25 21:39:29 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* _statusfp2 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* Not exported by native msvcrt, added in msvcr80.
|
|
|
|
*/
|
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
void CDECL _statusfp2( unsigned int *x86_sw, unsigned int *sse2_sw )
|
|
|
|
{
|
|
|
|
#ifdef __GNUC__
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned long fpword;
|
|
|
|
|
|
|
|
if (x86_sw)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__( "fstsw %0" : "=m" (fpword) );
|
|
|
|
flags = 0;
|
|
|
|
if (fpword & 0x1) flags |= MSVCRT__SW_INVALID;
|
|
|
|
if (fpword & 0x2) flags |= MSVCRT__SW_DENORMAL;
|
|
|
|
if (fpword & 0x4) flags |= MSVCRT__SW_ZERODIVIDE;
|
|
|
|
if (fpword & 0x8) flags |= MSVCRT__SW_OVERFLOW;
|
|
|
|
if (fpword & 0x10) flags |= MSVCRT__SW_UNDERFLOW;
|
|
|
|
if (fpword & 0x20) flags |= MSVCRT__SW_INEXACT;
|
|
|
|
*x86_sw = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sse2_sw) return;
|
|
|
|
|
|
|
|
if (sse2_supported)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__( "stmxcsr %0" : "=m" (fpword) );
|
|
|
|
flags = 0;
|
|
|
|
if (fpword & 0x1) flags |= MSVCRT__SW_INVALID;
|
|
|
|
if (fpword & 0x2) flags |= MSVCRT__SW_DENORMAL;
|
|
|
|
if (fpword & 0x4) flags |= MSVCRT__SW_ZERODIVIDE;
|
|
|
|
if (fpword & 0x8) flags |= MSVCRT__SW_OVERFLOW;
|
|
|
|
if (fpword & 0x10) flags |= MSVCRT__SW_UNDERFLOW;
|
|
|
|
if (fpword & 0x20) flags |= MSVCRT__SW_INEXACT;
|
|
|
|
*sse2_sw = flags;
|
|
|
|
}
|
|
|
|
else *sse2_sw = 0;
|
|
|
|
#else
|
|
|
|
FIXME( "not implemented\n" );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* _statusfp (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int CDECL _statusfp(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-01-25 21:39:29 +01:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
unsigned int x86_sw, sse2_sw;
|
|
|
|
|
|
|
|
_statusfp2( &x86_sw, &sse2_sw );
|
|
|
|
/* FIXME: there's no definition for ambiguous status, just return all status bits for now */
|
|
|
|
return x86_sw | sse2_sw;
|
2001-01-11 00:59:25 +01:00
|
|
|
#else
|
2011-01-25 21:39:29 +01:00
|
|
|
FIXME( "not implemented\n" );
|
|
|
|
return 0;
|
2001-01-11 00:59:25 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _clearfp (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int CDECL _clearfp(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-01-25 21:59:45 +01:00
|
|
|
unsigned int flags = 0;
|
|
|
|
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
|
|
|
unsigned long fpword;
|
|
|
|
|
|
|
|
__asm__ __volatile__( "fnstsw %0; fnclex" : "=m" (fpword) );
|
|
|
|
if (fpword & 0x1) flags |= MSVCRT__SW_INVALID;
|
|
|
|
if (fpword & 0x2) flags |= MSVCRT__SW_DENORMAL;
|
|
|
|
if (fpword & 0x4) flags |= MSVCRT__SW_ZERODIVIDE;
|
|
|
|
if (fpword & 0x8) flags |= MSVCRT__SW_OVERFLOW;
|
|
|
|
if (fpword & 0x10) flags |= MSVCRT__SW_UNDERFLOW;
|
|
|
|
if (fpword & 0x20) flags |= MSVCRT__SW_INEXACT;
|
|
|
|
|
|
|
|
if (sse2_supported)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__( "stmxcsr %0" : "=m" (fpword) );
|
|
|
|
if (fpword & 0x1) flags |= MSVCRT__SW_INVALID;
|
|
|
|
if (fpword & 0x2) flags |= MSVCRT__SW_DENORMAL;
|
|
|
|
if (fpword & 0x4) flags |= MSVCRT__SW_ZERODIVIDE;
|
|
|
|
if (fpword & 0x8) flags |= MSVCRT__SW_OVERFLOW;
|
|
|
|
if (fpword & 0x10) flags |= MSVCRT__SW_UNDERFLOW;
|
|
|
|
if (fpword & 0x20) flags |= MSVCRT__SW_INEXACT;
|
|
|
|
fpword &= ~0x3f;
|
|
|
|
__asm__ __volatile__( "ldmxcsr %0" : : "m" (fpword) );
|
|
|
|
}
|
2001-01-11 00:59:25 +01:00
|
|
|
#else
|
2011-01-25 21:59:45 +01:00
|
|
|
FIXME( "not implemented\n" );
|
2001-01-11 00:59:25 +01:00
|
|
|
#endif
|
2011-01-25 21:59:45 +01:00
|
|
|
return flags;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2004-01-13 06:45:05 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __fpecode (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int * CDECL __fpecode(void)
|
2004-01-13 06:45:05 +01:00
|
|
|
{
|
|
|
|
return &msvcrt_get_thread_data()->fpecode;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* ldexp (MSVCRT.@)
|
|
|
|
*/
|
2009-05-23 11:49:09 +02:00
|
|
|
double CDECL MSVCRT_ldexp(double num, MSVCRT_long exp)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
double z = ldexp(num,exp);
|
|
|
|
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(z))
|
2002-07-19 05:24:50 +02:00
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
2001-01-11 00:59:25 +01:00
|
|
|
else if (z == 0 && signbit(z))
|
|
|
|
z = 0.0; /* Convert -0 -> +0 */
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _cabs (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT__cabs(struct MSVCRT__complex num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2004-03-16 20:17:11 +01:00
|
|
|
return sqrt(num.x * num.x + num.y * num.y);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _chgsign (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__chgsign(double num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
/* FIXME: +-infinity,Nan not tested */
|
|
|
|
return -num;
|
|
|
|
}
|
|
|
|
|
2011-01-25 21:01:12 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __control87_2 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* Not exported by native msvcrt, added in msvcr80.
|
|
|
|
*/
|
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
int CDECL __control87_2( unsigned int newval, unsigned int mask,
|
|
|
|
unsigned int *x86_cw, unsigned int *sse2_cw )
|
|
|
|
{
|
|
|
|
#ifdef __GNUC__
|
|
|
|
unsigned long fpword;
|
|
|
|
unsigned int flags;
|
|
|
|
|
|
|
|
if (x86_cw)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__( "fstcw %0" : "=m" (fpword) );
|
|
|
|
|
|
|
|
/* Convert into mask constants */
|
|
|
|
flags = 0;
|
|
|
|
if (fpword & 0x1) flags |= MSVCRT__EM_INVALID;
|
|
|
|
if (fpword & 0x2) flags |= MSVCRT__EM_DENORMAL;
|
|
|
|
if (fpword & 0x4) flags |= MSVCRT__EM_ZERODIVIDE;
|
|
|
|
if (fpword & 0x8) flags |= MSVCRT__EM_OVERFLOW;
|
|
|
|
if (fpword & 0x10) flags |= MSVCRT__EM_UNDERFLOW;
|
|
|
|
if (fpword & 0x20) flags |= MSVCRT__EM_INEXACT;
|
|
|
|
switch (fpword & 0xc00)
|
|
|
|
{
|
|
|
|
case 0xc00: flags |= MSVCRT__RC_UP|MSVCRT__RC_DOWN; break;
|
|
|
|
case 0x800: flags |= MSVCRT__RC_UP; break;
|
|
|
|
case 0x400: flags |= MSVCRT__RC_DOWN; break;
|
|
|
|
}
|
|
|
|
switch (fpword & 0x300)
|
|
|
|
{
|
|
|
|
case 0x0: flags |= MSVCRT__PC_24; break;
|
|
|
|
case 0x200: flags |= MSVCRT__PC_53; break;
|
|
|
|
case 0x300: flags |= MSVCRT__PC_64; break;
|
|
|
|
}
|
|
|
|
if (fpword & 0x1000) flags |= MSVCRT__IC_AFFINE;
|
|
|
|
|
|
|
|
TRACE( "x86 flags=%08x newval=%08x mask=%08x\n", flags, newval, mask );
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
flags = (flags & ~mask) | (newval & mask);
|
|
|
|
|
|
|
|
/* Convert (masked) value back to fp word */
|
|
|
|
fpword = 0;
|
|
|
|
if (flags & MSVCRT__EM_INVALID) fpword |= 0x1;
|
|
|
|
if (flags & MSVCRT__EM_DENORMAL) fpword |= 0x2;
|
|
|
|
if (flags & MSVCRT__EM_ZERODIVIDE) fpword |= 0x4;
|
|
|
|
if (flags & MSVCRT__EM_OVERFLOW) fpword |= 0x8;
|
|
|
|
if (flags & MSVCRT__EM_UNDERFLOW) fpword |= 0x10;
|
|
|
|
if (flags & MSVCRT__EM_INEXACT) fpword |= 0x20;
|
|
|
|
switch (flags & MSVCRT__MCW_RC)
|
|
|
|
{
|
|
|
|
case MSVCRT__RC_UP|MSVCRT__RC_DOWN: fpword |= 0xc00; break;
|
|
|
|
case MSVCRT__RC_UP: fpword |= 0x800; break;
|
|
|
|
case MSVCRT__RC_DOWN: fpword |= 0x400; break;
|
|
|
|
}
|
|
|
|
switch (flags & MSVCRT__MCW_PC)
|
|
|
|
{
|
|
|
|
case MSVCRT__PC_64: fpword |= 0x300; break;
|
|
|
|
case MSVCRT__PC_53: fpword |= 0x200; break;
|
|
|
|
case MSVCRT__PC_24: fpword |= 0x0; break;
|
|
|
|
}
|
|
|
|
if (flags & MSVCRT__IC_AFFINE) fpword |= 0x1000;
|
|
|
|
|
|
|
|
__asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
|
|
|
|
}
|
|
|
|
*x86_cw = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sse2_cw) return 1;
|
|
|
|
|
|
|
|
if (sse2_supported)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__( "stmxcsr %0" : "=m" (fpword) );
|
|
|
|
|
|
|
|
/* Convert into mask constants */
|
|
|
|
flags = 0;
|
|
|
|
if (fpword & 0x80) flags |= MSVCRT__EM_INVALID;
|
|
|
|
if (fpword & 0x100) flags |= MSVCRT__EM_DENORMAL;
|
|
|
|
if (fpword & 0x200) flags |= MSVCRT__EM_ZERODIVIDE;
|
|
|
|
if (fpword & 0x400) flags |= MSVCRT__EM_OVERFLOW;
|
|
|
|
if (fpword & 0x800) flags |= MSVCRT__EM_UNDERFLOW;
|
|
|
|
if (fpword & 0x1000) flags |= MSVCRT__EM_INEXACT;
|
|
|
|
switch (fpword & 0x6000)
|
|
|
|
{
|
|
|
|
case 0x6000: flags |= MSVCRT__RC_UP|MSVCRT__RC_DOWN; break;
|
|
|
|
case 0x4000: flags |= MSVCRT__RC_UP; break;
|
|
|
|
case 0x2000: flags |= MSVCRT__RC_DOWN; break;
|
|
|
|
}
|
|
|
|
switch (fpword & 0x8040)
|
|
|
|
{
|
|
|
|
case 0x0040: flags |= MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS; break;
|
|
|
|
case 0x8000: flags |= MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS; break;
|
|
|
|
case 0x8040: flags |= MSVCRT__DN_FLUSH; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE( "sse2 flags=%08x newval=%08x mask=%08x\n", flags, newval, mask );
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
flags = (flags & ~mask) | (newval & mask);
|
|
|
|
|
|
|
|
/* Convert (masked) value back to fp word */
|
|
|
|
fpword = 0;
|
|
|
|
if (flags & MSVCRT__EM_INVALID) fpword |= 0x80;
|
|
|
|
if (flags & MSVCRT__EM_DENORMAL) fpword |= 0x100;
|
|
|
|
if (flags & MSVCRT__EM_ZERODIVIDE) fpword |= 0x200;
|
|
|
|
if (flags & MSVCRT__EM_OVERFLOW) fpword |= 0x400;
|
|
|
|
if (flags & MSVCRT__EM_UNDERFLOW) fpword |= 0x800;
|
|
|
|
if (flags & MSVCRT__EM_INEXACT) fpword |= 0x1000;
|
|
|
|
switch (flags & MSVCRT__MCW_RC)
|
|
|
|
{
|
|
|
|
case MSVCRT__RC_UP|MSVCRT__RC_DOWN: fpword |= 0x6000; break;
|
|
|
|
case MSVCRT__RC_UP: fpword |= 0x4000; break;
|
|
|
|
case MSVCRT__RC_DOWN: fpword |= 0x2000; break;
|
|
|
|
}
|
|
|
|
switch (flags & MSVCRT__MCW_DN)
|
|
|
|
{
|
|
|
|
case MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS: fpword |= 0x0040; break;
|
|
|
|
case MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS: fpword |= 0x8000; break;
|
|
|
|
case MSVCRT__DN_FLUSH: fpword |= 0x8040; break;
|
|
|
|
}
|
|
|
|
__asm__ __volatile__( "ldmxcsr %0" : : "m" (fpword) );
|
|
|
|
}
|
|
|
|
*sse2_cw = flags;
|
|
|
|
}
|
|
|
|
else *sse2_cw = 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
#else
|
|
|
|
FIXME( "not implemented\n" );
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _control87 (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-01-25 21:01:12 +01:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
unsigned int x86_cw, sse2_cw;
|
2001-08-13 22:03:29 +02:00
|
|
|
|
2011-01-25 21:01:12 +01:00
|
|
|
__control87_2( newval, mask, &x86_cw, &sse2_cw );
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2011-01-25 21:01:12 +01:00
|
|
|
if ((x86_cw ^ sse2_cw) & (MSVCRT__MCW_EM | MSVCRT__MCW_RC)) x86_cw |= MSVCRT__EM_AMBIGUOUS;
|
|
|
|
return x86_cw;
|
2001-01-11 00:59:25 +01:00
|
|
|
#else
|
2011-01-25 21:01:12 +01:00
|
|
|
FIXME( "not implemented\n" );
|
|
|
|
return 0;
|
2001-01-11 00:59:25 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _controlfp (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2004-06-25 03:19:15 +02:00
|
|
|
return _control87( newval, mask & ~MSVCRT__EM_DENORMAL );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-01-25 22:27:17 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _set_controlfp (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void CDECL _set_controlfp( unsigned int newval, unsigned int mask )
|
|
|
|
{
|
|
|
|
_controlfp( newval, mask );
|
|
|
|
}
|
|
|
|
|
2010-04-01 12:41:06 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _controlfp_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
|
|
|
|
{
|
2010-11-26 14:57:24 +01:00
|
|
|
static const unsigned int all_flags = (MSVCRT__MCW_EM | MSVCRT__MCW_IC | MSVCRT__MCW_RC |
|
|
|
|
MSVCRT__MCW_PC | MSVCRT__MCW_DN);
|
2010-11-27 20:40:14 +01:00
|
|
|
unsigned int val;
|
2010-04-01 12:41:06 +02:00
|
|
|
|
2010-11-27 20:40:14 +01:00
|
|
|
if (!MSVCRT_CHECK_PMT( !(newval & mask & ~all_flags) ))
|
2010-11-26 14:57:24 +01:00
|
|
|
{
|
2010-11-27 20:40:14 +01:00
|
|
|
if (cur) *cur = _controlfp( 0, 0 ); /* retrieve it anyway */
|
2010-11-26 14:57:24 +01:00
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
2010-11-27 20:40:14 +01:00
|
|
|
val = _controlfp( newval, mask );
|
|
|
|
if (cur) *cur = val;
|
2010-04-01 12:41:06 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _copysign (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__copysign(double num, double sign)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2015-03-24 10:51:12 +01:00
|
|
|
if (signbit(sign))
|
|
|
|
return signbit(num) ? num : -num;
|
|
|
|
return signbit(num) ? -num : num;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _finite (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
int CDECL MSVCRT__finite(double num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2013-12-01 16:26:14 +01:00
|
|
|
return isfinite(num) != 0; /* See comment for _isnan() */
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _fpreset (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
void CDECL _fpreset(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2011-01-25 22:12:16 +01:00
|
|
|
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
|
|
|
const unsigned int x86_cw = 0x27f;
|
|
|
|
__asm__ __volatile__( "fninit; fldcw %0" : : "m" (x86_cw) );
|
|
|
|
if (sse2_supported)
|
|
|
|
{
|
|
|
|
const unsigned long sse2_cw = 0x1f80;
|
|
|
|
__asm__ __volatile__( "ldmxcsr %0" : : "m" (sse2_cw) );
|
|
|
|
}
|
2001-01-11 00:59:25 +01:00
|
|
|
#else
|
2011-01-25 22:12:16 +01:00
|
|
|
FIXME( "not implemented\n" );
|
2001-01-11 00:59:25 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _isnan (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
INT CDECL MSVCRT__isnan(double num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
/* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
|
|
|
|
* Do the same, as the result may be used in calculations
|
|
|
|
*/
|
2013-12-01 16:26:14 +01:00
|
|
|
return isnan(num) != 0;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2006-01-14 17:40:29 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _j0 (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__j0(double num)
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
/* FIXME: errno handling */
|
|
|
|
return j0(num);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _j1 (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__j1(double num)
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
/* FIXME: errno handling */
|
|
|
|
return j1(num);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2011-06-03 15:28:32 +02:00
|
|
|
* _jn (MSVCRT.@)
|
2006-01-14 17:40:29 +01:00
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__jn(int n, double num)
|
2006-01-14 17:40:29 +01:00
|
|
|
{
|
|
|
|
/* FIXME: errno handling */
|
|
|
|
return jn(n, num);
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _y0 (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__y0(double num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
double retval;
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2001-01-11 00:59:25 +01:00
|
|
|
retval = y0(num);
|
2011-06-03 15:28:32 +02:00
|
|
|
if (MSVCRT__fpclass(retval) == MSVCRT__FPCLASS_NINF)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-07-19 05:24:50 +02:00
|
|
|
*MSVCRT__errno() = MSVCRT_EDOM;
|
2001-01-11 00:59:25 +01:00
|
|
|
retval = sqrt(-1);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _y1 (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__y1(double num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
double retval;
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2001-01-11 00:59:25 +01:00
|
|
|
retval = y1(num);
|
2011-06-03 15:28:32 +02:00
|
|
|
if (MSVCRT__fpclass(retval) == MSVCRT__FPCLASS_NINF)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-07-19 05:24:50 +02:00
|
|
|
*MSVCRT__errno() = MSVCRT_EDOM;
|
2001-01-11 00:59:25 +01:00
|
|
|
retval = sqrt(-1);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _yn (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__yn(int order, double num)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
double retval;
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2001-01-11 00:59:25 +01:00
|
|
|
retval = yn(order,num);
|
2011-06-03 15:28:32 +02:00
|
|
|
if (MSVCRT__fpclass(retval) == MSVCRT__FPCLASS_NINF)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-07-19 05:24:50 +02:00
|
|
|
*MSVCRT__errno() = MSVCRT_EDOM;
|
2001-01-11 00:59:25 +01:00
|
|
|
retval = sqrt(-1);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _nextafter (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
double CDECL MSVCRT__nextafter(double num, double next)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
double retval;
|
2013-11-29 15:06:33 +01:00
|
|
|
if (!isfinite(num) || !isfinite(next)) *MSVCRT__errno() = MSVCRT_EDOM;
|
2001-01-11 00:59:25 +01:00
|
|
|
retval = nextafter(num,next);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2003-03-21 00:47:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _ecvt (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
char * CDECL MSVCRT__ecvt( double number, int ndigits, int *decpt, int *sign )
|
2003-03-21 00:47:25 +01:00
|
|
|
{
|
2009-11-01 18:59:20 +01:00
|
|
|
int prec, len;
|
2004-06-25 03:19:15 +02:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
2011-08-02 22:20:32 +02:00
|
|
|
/* FIXME: check better for overflow (native supports over 300 chars) */
|
2009-04-13 09:06:41 +02:00
|
|
|
ndigits = min( ndigits, 80 - 7); /* 7 : space for dec point, 1 for "e",
|
|
|
|
* 4 for exponent and one for
|
|
|
|
* terminating '\0' */
|
2003-03-21 00:47:25 +01:00
|
|
|
if (!data->efcvt_buffer)
|
|
|
|
data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
|
|
|
|
|
2009-04-13 09:06:41 +02:00
|
|
|
if( number < 0) {
|
|
|
|
*sign = TRUE;
|
|
|
|
number = -number;
|
|
|
|
} else
|
|
|
|
*sign = FALSE;
|
|
|
|
/* handle cases with zero ndigits or less */
|
|
|
|
prec = ndigits;
|
|
|
|
if( prec < 1) prec = 2;
|
2009-11-01 18:59:20 +01:00
|
|
|
len = snprintf(data->efcvt_buffer, 80, "%.*le", prec - 1, number);
|
2009-04-13 09:06:41 +02:00
|
|
|
/* take the decimal "point away */
|
|
|
|
if( prec != 1)
|
2009-11-01 18:59:20 +01:00
|
|
|
memmove( data->efcvt_buffer + 1, data->efcvt_buffer + 2, len - 1 );
|
2009-04-13 09:06:41 +02:00
|
|
|
/* take the exponential "e" out */
|
|
|
|
data->efcvt_buffer[ prec] = '\0';
|
|
|
|
/* read the exponent */
|
|
|
|
sscanf( data->efcvt_buffer + prec + 1, "%d", decpt);
|
|
|
|
(*decpt)++;
|
|
|
|
/* adjust for some border cases */
|
|
|
|
if( data->efcvt_buffer[0] == '0')/* value is zero */
|
|
|
|
*decpt = 0;
|
|
|
|
/* handle cases with zero ndigits or less */
|
|
|
|
if( ndigits < 1){
|
|
|
|
if( data->efcvt_buffer[ 0] >= '5')
|
|
|
|
(*decpt)++;
|
|
|
|
data->efcvt_buffer[ 0] = '\0';
|
|
|
|
}
|
|
|
|
TRACE("out=\"%s\"\n",data->efcvt_buffer);
|
2003-03-21 00:47:25 +01:00
|
|
|
return data->efcvt_buffer;
|
|
|
|
}
|
|
|
|
|
2010-12-10 14:46:36 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _ecvt_s (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
int CDECL MSVCRT__ecvt_s( char *buffer, MSVCRT_size_t length, double number, int ndigits, int *decpt, int *sign )
|
2010-12-10 14:46:36 +01:00
|
|
|
{
|
|
|
|
int prec, len;
|
|
|
|
char *result;
|
|
|
|
const char infret[] = "1#INF";
|
|
|
|
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return MSVCRT_EINVAL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(decpt != NULL)) return MSVCRT_EINVAL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(sign != NULL)) return MSVCRT_EINVAL;
|
|
|
|
if (!MSVCRT_CHECK_PMT_ERR( length > 2, MSVCRT_ERANGE )) return MSVCRT_ERANGE;
|
|
|
|
if (!MSVCRT_CHECK_PMT_ERR(ndigits < (int)length - 1, MSVCRT_ERANGE )) return MSVCRT_ERANGE;
|
2010-12-10 14:46:36 +01:00
|
|
|
|
|
|
|
/* special case - inf */
|
|
|
|
if(number == HUGE_VAL || number == -HUGE_VAL)
|
|
|
|
{
|
|
|
|
memset(buffer, '0', ndigits);
|
|
|
|
memcpy(buffer, infret, min(ndigits, sizeof(infret) - 1 ) );
|
|
|
|
buffer[ndigits] = '\0';
|
|
|
|
(*decpt) = 1;
|
|
|
|
if(number == -HUGE_VAL)
|
|
|
|
(*sign) = 1;
|
|
|
|
else
|
|
|
|
(*sign) = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-30 20:33:06 +02:00
|
|
|
/* handle cases with zero ndigits or less */
|
|
|
|
prec = ndigits;
|
|
|
|
if( prec < 1) prec = 2;
|
2011-10-21 01:44:45 +02:00
|
|
|
result = MSVCRT_malloc(prec + 7);
|
2010-12-10 14:46:36 +01:00
|
|
|
|
|
|
|
if( number < 0) {
|
|
|
|
*sign = TRUE;
|
|
|
|
number = -number;
|
|
|
|
} else
|
|
|
|
*sign = FALSE;
|
2011-03-30 20:33:06 +02:00
|
|
|
len = snprintf(result, prec + 7, "%.*le", prec - 1, number);
|
2010-12-10 14:46:36 +01:00
|
|
|
/* take the decimal "point away */
|
|
|
|
if( prec != 1)
|
|
|
|
memmove( result + 1, result + 2, len - 1 );
|
|
|
|
/* take the exponential "e" out */
|
|
|
|
result[ prec] = '\0';
|
|
|
|
/* read the exponent */
|
|
|
|
sscanf( result + prec + 1, "%d", decpt);
|
|
|
|
(*decpt)++;
|
|
|
|
/* adjust for some border cases */
|
|
|
|
if( result[0] == '0')/* value is zero */
|
|
|
|
*decpt = 0;
|
|
|
|
/* handle cases with zero ndigits or less */
|
|
|
|
if( ndigits < 1){
|
|
|
|
if( result[ 0] >= '5')
|
|
|
|
(*decpt)++;
|
|
|
|
result[ 0] = '\0';
|
|
|
|
}
|
|
|
|
memcpy( buffer, result, max(ndigits + 1, 1) );
|
|
|
|
MSVCRT_free( result );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-03-21 00:47:25 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* _fcvt (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
char * CDECL MSVCRT__fcvt( double number, int ndigits, int *decpt, int *sign )
|
2003-03-21 00:47:25 +01:00
|
|
|
{
|
2004-06-25 03:19:15 +02:00
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
2007-09-24 21:10:36 +02:00
|
|
|
int stop, dec1, dec2;
|
|
|
|
char *ptr1, *ptr2, *first;
|
|
|
|
char buf[80]; /* ought to be enough */
|
2003-03-21 00:47:25 +01:00
|
|
|
|
|
|
|
if (!data->efcvt_buffer)
|
|
|
|
data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
|
|
|
|
|
2007-09-24 21:10:36 +02:00
|
|
|
if (number < 0)
|
|
|
|
{
|
|
|
|
*sign = 1;
|
|
|
|
number = -number;
|
|
|
|
} else *sign = 0;
|
|
|
|
|
|
|
|
snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
|
|
|
|
ptr1 = buf;
|
|
|
|
ptr2 = data->efcvt_buffer;
|
|
|
|
first = NULL;
|
|
|
|
dec1 = 0;
|
|
|
|
dec2 = 0;
|
|
|
|
|
|
|
|
/* For numbers below the requested resolution, work out where
|
|
|
|
the decimal point will be rather than finding it in the string */
|
|
|
|
if (number < 1.0 && number > 0.0) {
|
|
|
|
dec2 = log10(number + 1e-10);
|
|
|
|
if (-dec2 <= ndigits) dec2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If requested digits is zero or less, we will need to truncate
|
|
|
|
* the returned string */
|
|
|
|
if (ndigits < 1) {
|
|
|
|
stop = strlen(buf) + ndigits;
|
|
|
|
} else {
|
|
|
|
stop = strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
|
|
|
|
while (*ptr1 != '\0' && *ptr1 != '.') {
|
|
|
|
if (!first) first = ptr2;
|
|
|
|
if ((ptr1 - buf) < stop) {
|
|
|
|
*ptr2++ = *ptr1++;
|
|
|
|
} else {
|
|
|
|
ptr1++;
|
|
|
|
}
|
|
|
|
dec1++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ndigits > 0) {
|
|
|
|
ptr1++;
|
|
|
|
if (!first) {
|
|
|
|
while (*ptr1 == '0') { /* Process leading zeroes */
|
|
|
|
*ptr2++ = *ptr1++;
|
|
|
|
dec1--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (*ptr1 != '\0') {
|
|
|
|
if (!first) first = ptr2;
|
|
|
|
*ptr2++ = *ptr1++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*ptr2 = '\0';
|
|
|
|
|
|
|
|
/* We never found a non-zero digit, then our number is either
|
|
|
|
* smaller than the requested precision, or 0.0 */
|
|
|
|
if (!first) {
|
|
|
|
if (number > 0.0) {
|
|
|
|
first = ptr2;
|
|
|
|
} else {
|
|
|
|
first = data->efcvt_buffer;
|
|
|
|
dec1 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*decpt = dec2 ? dec2 : dec1;
|
|
|
|
return first;
|
2003-03-21 00:47:25 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 18:47:34 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* _fcvt_s (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
int CDECL MSVCRT__fcvt_s(char* outbuffer, MSVCRT_size_t size, double number, int ndigits, int *decpt, int *sign)
|
2011-01-29 18:47:34 +01:00
|
|
|
{
|
|
|
|
int stop, dec1, dec2;
|
|
|
|
char *ptr1, *ptr2, *first;
|
|
|
|
char buf[80]; /* ought to be enough */
|
|
|
|
|
|
|
|
if (!outbuffer || !decpt || !sign || size == 0)
|
|
|
|
{
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (number < 0)
|
|
|
|
{
|
|
|
|
*sign = 1;
|
|
|
|
number = -number;
|
|
|
|
} else *sign = 0;
|
|
|
|
|
|
|
|
snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
|
|
|
|
ptr1 = buf;
|
|
|
|
ptr2 = outbuffer;
|
|
|
|
first = NULL;
|
|
|
|
dec1 = 0;
|
|
|
|
dec2 = 0;
|
|
|
|
|
|
|
|
/* For numbers below the requested resolution, work out where
|
|
|
|
the decimal point will be rather than finding it in the string */
|
|
|
|
if (number < 1.0 && number > 0.0) {
|
|
|
|
dec2 = log10(number + 1e-10);
|
|
|
|
if (-dec2 <= ndigits) dec2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If requested digits is zero or less, we will need to truncate
|
|
|
|
* the returned string */
|
|
|
|
if (ndigits < 1) {
|
|
|
|
stop = strlen(buf) + ndigits;
|
|
|
|
} else {
|
|
|
|
stop = strlen(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
|
|
|
|
while (*ptr1 != '\0' && *ptr1 != '.') {
|
|
|
|
if (!first) first = ptr2;
|
|
|
|
if ((ptr1 - buf) < stop) {
|
|
|
|
if (size > 1) {
|
|
|
|
*ptr2++ = *ptr1++;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ptr1++;
|
|
|
|
}
|
|
|
|
dec1++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ndigits > 0) {
|
|
|
|
ptr1++;
|
|
|
|
if (!first) {
|
|
|
|
while (*ptr1 == '0') { /* Process leading zeroes */
|
|
|
|
if (number == 0.0 && size > 1) {
|
|
|
|
*ptr2++ = '0';
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
ptr1++;
|
|
|
|
dec1--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (*ptr1 != '\0') {
|
|
|
|
if (!first) first = ptr2;
|
|
|
|
if (size > 1) {
|
|
|
|
*ptr2++ = *ptr1++;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*ptr2 = '\0';
|
|
|
|
|
|
|
|
/* We never found a non-zero digit, then our number is either
|
|
|
|
* smaller than the requested precision, or 0.0 */
|
|
|
|
if (!first && (number <= 0.0))
|
|
|
|
dec1 = 0;
|
|
|
|
|
|
|
|
*decpt = dec2 ? dec2 : dec1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-03-21 00:47:25 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* _gcvt (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
char * CDECL MSVCRT__gcvt( double number, int ndigit, char *buff )
|
2003-03-21 00:47:25 +01:00
|
|
|
{
|
2010-08-27 01:46:35 +02:00
|
|
|
if(!buff) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ndigit < 0) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSVCRT_sprintf(buff, "%.*g", ndigit, number);
|
2003-03-21 00:47:25 +01:00
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
2010-08-27 01:46:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* _gcvt_s (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
int CDECL MSVCRT__gcvt_s(char *buff, MSVCRT_size_t size, double number, int digits)
|
2010-08-27 01:46:35 +02:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if(!buff) {
|
|
|
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( digits<0 || digits>=size) {
|
|
|
|
if(size)
|
|
|
|
buff[0] = '\0';
|
|
|
|
|
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return MSVCRT_ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = MSVCRT__scprintf("%.*g", digits, number);
|
|
|
|
if(len > size) {
|
|
|
|
buff[0] = '\0';
|
|
|
|
*MSVCRT__errno() = MSVCRT_ERANGE;
|
|
|
|
return MSVCRT_ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSVCRT_sprintf(buff, "%.*g", digits, number);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
#include <stdlib.h> /* div_t, ldiv_t */
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* div (MSVCRT.@)
|
|
|
|
* VERSION
|
|
|
|
* [i386] Windows binary compatible - returns the struct in eax/edx.
|
|
|
|
*/
|
|
|
|
#ifdef __i386__
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned __int64 CDECL MSVCRT_div(int num, int denom)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
div_t dt = div(num,denom);
|
2003-11-29 00:17:28 +01:00
|
|
|
return ((unsigned __int64)dt.rem << 32) | (unsigned int)dt.quot;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
/*********************************************************************
|
|
|
|
* div (MSVCRT.@)
|
|
|
|
* VERSION
|
|
|
|
* [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_div_t CDECL MSVCRT_div(int num, int denom)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-05-17 01:08:01 +02:00
|
|
|
div_t dt = div(num,denom);
|
|
|
|
MSVCRT_div_t ret;
|
|
|
|
ret.quot = dt.quot;
|
|
|
|
ret.rem = dt.rem;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
#endif /* ifdef __i386__ */
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ldiv (MSVCRT.@)
|
|
|
|
* VERSION
|
|
|
|
* [i386] Windows binary compatible - returns the struct in eax/edx.
|
|
|
|
*/
|
|
|
|
#ifdef __i386__
|
2009-05-23 11:49:09 +02:00
|
|
|
unsigned __int64 CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
ldiv_t ldt = ldiv(num,denom);
|
2009-05-23 11:49:09 +02:00
|
|
|
return ((unsigned __int64)ldt.rem << 32) | (MSVCRT_ulong)ldt.quot;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
/*********************************************************************
|
|
|
|
* ldiv (MSVCRT.@)
|
|
|
|
* VERSION
|
|
|
|
* [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
|
|
|
|
*/
|
2009-05-23 11:49:09 +02:00
|
|
|
MSVCRT_ldiv_t CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-05-17 01:08:01 +02:00
|
|
|
ldiv_t result = ldiv(num,denom);
|
|
|
|
|
|
|
|
MSVCRT_ldiv_t ret;
|
|
|
|
ret.quot = result.quot;
|
|
|
|
ret.rem = result.rem;
|
|
|
|
|
|
|
|
return ret;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
#endif /* ifdef __i386__ */
|
|
|
|
|
2009-08-24 12:50:46 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _adjust_fdiv (MSVCRT.@)
|
|
|
|
* Used by the MSVC compiler to work around the Pentium FDIV bug.
|
|
|
|
*/
|
|
|
|
int MSVCRT__adjust_fdiv = 0;
|
|
|
|
|
2001-02-12 04:45:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdiv_m16i (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdiv_m16i( short arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdiv_m32 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdiv_m32( unsigned int arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdiv_m32i (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdiv_m32i( int arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdiv_m64 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdiv_m64( unsigned __int64 arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdiv_r (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _adj_fdiv_r(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdivr_m16i (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdivr_m16i( short arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdivr_m32 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdivr_m32( unsigned int arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdivr_m32i (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdivr_m32i( int arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fdivr_m64 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2004-05-13 01:22:36 +02:00
|
|
|
void __stdcall _adj_fdivr_m64( unsigned __int64 arg )
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fpatan (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _adj_fpatan(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fprem (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _adj_fprem(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fprem1 (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _adj_fprem1(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _adj_fptan (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _adj_fptan(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _safe_fdiv (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _safe_fdiv(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _safe_fdivr (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _safe_fdivr(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _safe_fprem (MSVCRT.@)
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _safe_fprem(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _safe_fprem1 (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* This function is likely to have the wrong number of arguments.
|
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* I _think_ this function is intended to work around the Pentium
|
|
|
|
* fdiv bug.
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void _safe_fprem1(void)
|
2001-02-12 04:45:09 +01:00
|
|
|
{
|
2001-05-09 19:31:31 +02:00
|
|
|
TRACE("(): stub\n");
|
2001-02-12 04:45:09 +01:00
|
|
|
}
|
2009-08-24 12:50:46 +02:00
|
|
|
|
2011-01-26 20:48:44 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_acos (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_acos(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = acos( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_acosf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_acosf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = acosf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_asin (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_asin(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = asin( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_asinf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_asinf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = asinf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_atan (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_atan(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = atan( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_atan2 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_atan2(void)
|
|
|
|
{
|
|
|
|
double d1, d2;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1), "=m" (d2) );
|
|
|
|
d1 = atan2( d1, d2 );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d1) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_atanf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_atanf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = atanf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_cos (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_cos(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = cos( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_cosf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_cosf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = cosf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_exp (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_exp(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = exp( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_expf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_expf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = expf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_log (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_log(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = log( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_log10 (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_log10(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = log10( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_log10f (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_log10f(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = log10f( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_logf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_logf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = logf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_pow (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_pow(void)
|
|
|
|
{
|
|
|
|
double d1, d2;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1), "=m" (d2) );
|
|
|
|
d1 = pow( d1, d2 );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d1) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_powf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_powf(void)
|
|
|
|
{
|
|
|
|
float f1, f2;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0; movd %%xmm1,%1" : "=g" (f1), "=g" (f2) );
|
|
|
|
f1 = powf( f1, f2 );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f1) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_sin (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_sin(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = sin( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_sinf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_sinf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = sinf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_tan (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_tan(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
|
|
|
d = tan( d );
|
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_tanf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
void __cdecl __libm_sse2_tanf(void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
__asm__ __volatile__( "movd %%xmm0,%0" : "=g" (f) );
|
|
|
|
f = tanf( f );
|
|
|
|
__asm__ __volatile__( "movd %0,%%xmm0" : : "g" (f) );
|
|
|
|
}
|
|
|
|
|
2014-04-21 14:32:40 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* __libm_sse2_sqrt_precise (MSVCR110.@)
|
|
|
|
*/
|
2014-01-07 15:47:34 +01:00
|
|
|
void __cdecl __libm_sse2_sqrt_precise(void)
|
|
|
|
{
|
|
|
|
double d;
|
2014-05-19 18:49:02 +02:00
|
|
|
__asm__ __volatile__( "movq %%xmm0,%0" : "=m" (d) );
|
2014-01-07 15:47:34 +01:00
|
|
|
d = sqrt( d );
|
2014-05-19 18:49:02 +02:00
|
|
|
__asm__ __volatile__( "movq %0,%%xmm0" : : "m" (d) );
|
2014-01-07 15:47:34 +01:00
|
|
|
}
|
|
|
|
|
2009-08-24 12:50:46 +02:00
|
|
|
#endif /* __i386__ */
|
2014-12-08 13:35:25 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* cbrt (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_cbrt(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_CBRT
|
|
|
|
return cbrt(x);
|
|
|
|
#else
|
|
|
|
return x < 0 ? -pow(-x, 1.0 / 3.0) : pow(x, 1.0 / 3.0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* cbrtf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_cbrtf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_CBRTF
|
|
|
|
return cbrtf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_cbrt(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* cbrtl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
LDOUBLE CDECL MSVCR120_cbrtl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_cbrt(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* exp2 (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_exp2(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_EXP2
|
|
|
|
return exp2(x);
|
|
|
|
#else
|
|
|
|
return pow(2, x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* exp2f (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_exp2f(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_EXP2F
|
|
|
|
return exp2f(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_exp2(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* exp2l (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
LDOUBLE CDECL MSVCR120_exp2l(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_exp2(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* log2 (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_log2(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LOG2
|
|
|
|
return log2(x);
|
|
|
|
#else
|
|
|
|
return log(x) / log(2);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* log2f (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_log2f(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LOG2F
|
|
|
|
return log2f(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_log2(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* log2l (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
LDOUBLE CDECL MSVCR120_log2l(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_log2(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* rint (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_rint(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_RINT
|
|
|
|
return rint(x);
|
|
|
|
#else
|
|
|
|
return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* rintf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_rintf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_RINTF
|
|
|
|
return rintf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_rint(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* rintl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
LDOUBLE CDECL MSVCR120_rintl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_rint(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* lrint (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_long CDECL MSVCR120_lrint(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LRINT
|
|
|
|
return lrint(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_rint(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* lrintf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_long CDECL MSVCR120_lrintf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LRINTF
|
|
|
|
return lrintf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_lrint(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* lrintl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_long CDECL MSVCR120_lrintl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_lrint(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* llrint (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_longlong CDECL MSVCR120_llrint(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LLRINT
|
|
|
|
return llrint(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_rint(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* llrintf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_longlong CDECL MSVCR120_llrintf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LLRINTF
|
|
|
|
return llrintf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_llrint(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* rintl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_longlong CDECL MSVCR120_llrintl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_llrint(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* round (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_round(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ROUND
|
|
|
|
return round(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_rint(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* roundf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_roundf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ROUNDF
|
|
|
|
return roundf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_round(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* roundl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
LDOUBLE CDECL MSVCR120_roundl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_round(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* lround (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_long CDECL MSVCR120_lround(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LROUND
|
|
|
|
return lround(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_round(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* lroundf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_long CDECL MSVCR120_lroundf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LROUNDF
|
|
|
|
return lroundf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_lround(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* lroundl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_long CDECL MSVCR120_lroundl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_lround(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* llround (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_longlong CDECL MSVCR120_llround(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LLROUND
|
|
|
|
return llround(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_round(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* llroundf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_longlong CDECL MSVCR120_llroundf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LLROUNDF
|
|
|
|
return llroundf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_llround(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* roundl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_longlong CDECL MSVCR120_llroundl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_llround(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* trunc (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_trunc(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_TRUNC
|
|
|
|
return trunc(x);
|
|
|
|
#else
|
|
|
|
return (x > 0) ? floor(x) : ceil(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* truncf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_truncf(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_TRUNCF
|
|
|
|
return truncf(x);
|
|
|
|
#else
|
|
|
|
return MSVCR120_trunc(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* truncl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
LDOUBLE CDECL MSVCR120_truncl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_trunc(x);
|
|
|
|
}
|
2014-12-09 07:43:07 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _dclass (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
short CDECL MSVCR120__dclass(double x)
|
|
|
|
{
|
|
|
|
switch (MSVCRT__fpclass(x)) {
|
|
|
|
case MSVCRT__FPCLASS_QNAN:
|
|
|
|
case MSVCRT__FPCLASS_SNAN:
|
|
|
|
return MSVCRT_FP_NAN;
|
|
|
|
case MSVCRT__FPCLASS_NINF:
|
|
|
|
case MSVCRT__FPCLASS_PINF:
|
|
|
|
return MSVCRT_FP_INFINITE;
|
|
|
|
case MSVCRT__FPCLASS_ND:
|
|
|
|
case MSVCRT__FPCLASS_PD:
|
|
|
|
return MSVCRT_FP_SUBNORMAL;
|
|
|
|
case MSVCRT__FPCLASS_NN:
|
|
|
|
case MSVCRT__FPCLASS_PN:
|
|
|
|
default:
|
|
|
|
return MSVCRT_FP_NORMAL;
|
|
|
|
case MSVCRT__FPCLASS_NZ:
|
|
|
|
case MSVCRT__FPCLASS_PZ:
|
|
|
|
return MSVCRT_FP_ZERO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _fdclass (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
short CDECL MSVCR120__fdclass(float x)
|
|
|
|
{
|
|
|
|
return MSVCR120__dclass(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _ldclass (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
short CDECL MSVCR120__ldclass(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120__dclass(x);
|
|
|
|
}
|
2015-01-07 15:16:23 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _dtest (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
short CDECL MSVCR120__dtest(double *x)
|
|
|
|
{
|
|
|
|
return MSVCR120__dclass(*x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _fdtest (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
short CDECL MSVCR120__fdtest(float *x)
|
|
|
|
{
|
|
|
|
return MSVCR120__dclass(*x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _ldtest (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
short CDECL MSVCR120__ldtest(LDOUBLE *x)
|
|
|
|
{
|
|
|
|
return MSVCR120__dclass(*x);
|
|
|
|
}
|
2015-05-26 14:54:40 +02:00
|
|
|
|
2015-05-21 18:25:48 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* erff (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_erff(float x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ERFF
|
|
|
|
return erff(x);
|
|
|
|
#else
|
|
|
|
FIXME( "not implemented\n" );
|
|
|
|
return 0.0f;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* erf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_erf(double x)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ERF
|
|
|
|
return erf(x);
|
|
|
|
#else
|
|
|
|
FIXME( "not implemented\n" );
|
|
|
|
return 0.0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* erfl (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
LDOUBLE CDECL MSVCR120_erfl(LDOUBLE x)
|
|
|
|
{
|
|
|
|
return MSVCR120_erf(x);
|
|
|
|
}
|
|
|
|
|
2015-05-26 14:54:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* fmaxf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_fmaxf(float x, float y)
|
|
|
|
{
|
|
|
|
if(isnanf(x))
|
|
|
|
return y;
|
|
|
|
if(isnanf(y))
|
|
|
|
return x;
|
|
|
|
if(x==0 && y==0)
|
|
|
|
return signbit(x) ? y : x;
|
|
|
|
return x<y ? y : x;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* fmax (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_fmax(double x, double y)
|
|
|
|
{
|
|
|
|
if(isnan(x))
|
|
|
|
return y;
|
|
|
|
if(isnan(y))
|
|
|
|
return x;
|
|
|
|
if(x==0 && y==0)
|
|
|
|
return signbit(x) ? y : x;
|
|
|
|
return x<y ? y : x;
|
|
|
|
}
|
2015-05-26 14:54:49 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _fdsign (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCR120__fdsign(float x)
|
|
|
|
{
|
|
|
|
return signbit(x) ? 0x8000 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _dsign (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCR120__dsign(double x)
|
|
|
|
{
|
|
|
|
return signbit(x) ? 0x8000 : 0;
|
|
|
|
}
|
2015-09-12 14:29:00 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* fminf (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
float CDECL MSVCR120_fminf(float x, float y)
|
|
|
|
{
|
|
|
|
if(isnanf(x))
|
|
|
|
return y;
|
|
|
|
if(isnanf(y))
|
|
|
|
return x;
|
|
|
|
if(x==0 && y==0)
|
|
|
|
return signbit(x) ? x : y;
|
|
|
|
return x<y ? x : y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* fmin (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
double CDECL MSVCR120_fmin(double x, double y)
|
|
|
|
{
|
|
|
|
if(isnan(x))
|
|
|
|
return y;
|
|
|
|
if(isnan(y))
|
|
|
|
return x;
|
|
|
|
if(x==0 && y==0)
|
|
|
|
return signbit(x) ? x : y;
|
|
|
|
return x<y ? x : y;
|
|
|
|
}
|