msvcrt: Set errno in the standard math functions too, not only in the

_CI* variants.
This commit is contained in:
Alexandre Julliard 2006-01-14 17:36:23 +01:00
parent ee603ce6dd
commit 78412005e1
2 changed files with 181 additions and 53 deletions

View File

@ -51,6 +51,155 @@ typedef int (*MSVCRT_matherr_func)(struct MSVCRT__exception *);
static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL; static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
/*********************************************************************
* MSVCRT_acos (MSVCRT.@)
*/
double MSVCRT_acos( double x )
{
if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return acos(x);
}
/*********************************************************************
* MSVCRT_asin (MSVCRT.@)
*/
double MSVCRT_asin( double x )
{
if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return asin(x);
}
/*********************************************************************
* MSVCRT_atan (MSVCRT.@)
*/
double MSVCRT_atan( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return atan(x);
}
/*********************************************************************
* MSVCRT_atan2 (MSVCRT.@)
*/
double MSVCRT_atan2( double x, double y )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return atan2(x,y);
}
/*********************************************************************
* MSVCRT_cos (MSVCRT.@)
*/
double MSVCRT_cos( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return cos(x);
}
/*********************************************************************
* MSVCRT_cosh (MSVCRT.@)
*/
double MSVCRT_cosh( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return cosh(x);
}
/*********************************************************************
* MSVCRT_exp (MSVCRT.@)
*/
double MSVCRT_exp( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return exp(x);
}
/*********************************************************************
* MSVCRT_fmod (MSVCRT.@)
*/
double MSVCRT_fmod( double x, double y )
{
if (!finite(x) || !finite(y)) *MSVCRT__errno() = MSVCRT_EDOM;
return fmod(x,y);
}
/*********************************************************************
* MSVCRT_log (MSVCRT.@)
*/
double MSVCRT_log( double x)
{
if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
return log(x);
}
/*********************************************************************
* MSVCRT_log10 (MSVCRT.@)
*/
double MSVCRT_log10( double x )
{
if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
return log10(x);
}
/*********************************************************************
* MSVCRT_pow (MSVCRT.@)
*/
double MSVCRT_pow( double x, double y )
{
/* FIXME: If x < 0 and y is not integral, set EDOM */
double z = pow(x,y);
if (!finite(z)) *MSVCRT__errno() = MSVCRT_EDOM;
return z;
}
/*********************************************************************
* MSVCRT_sin (MSVCRT.@)
*/
double MSVCRT_sin( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return sin(x);
}
/*********************************************************************
* MSVCRT_sinh (MSVCRT.@)
*/
double MSVCRT_sinh( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return sinh(x);
}
/*********************************************************************
* MSVCRT_sqrt (MSVCRT.@)
*/
double MSVCRT_sqrt( double x )
{
if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return sqrt(x);
}
/*********************************************************************
* MSVCRT_tan (MSVCRT.@)
*/
double MSVCRT_tan( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return tan(x);
}
/*********************************************************************
* MSVCRT_tanh (MSVCRT.@)
*/
double MSVCRT_tanh( double x )
{
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
return tanh(x);
}
#if defined(__GNUC__) && defined(__i386__) #if defined(__GNUC__) && defined(__i386__)
#define FPU_DOUBLE(var) double var; \ #define FPU_DOUBLE(var) double var; \
@ -65,8 +214,7 @@ static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
double _CIacos(void) double _CIacos(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_acos(x);
return acos(x);
} }
/********************************************************************* /*********************************************************************
@ -75,8 +223,7 @@ double _CIacos(void)
double _CIasin(void) double _CIasin(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_asin(x);
return asin(x);
} }
/********************************************************************* /*********************************************************************
@ -85,8 +232,7 @@ double _CIasin(void)
double _CIatan(void) double _CIatan(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_atan(x);
return atan(x);
} }
/********************************************************************* /*********************************************************************
@ -95,8 +241,7 @@ double _CIatan(void)
double _CIatan2(void) double _CIatan2(void)
{ {
FPU_DOUBLES(x,y); FPU_DOUBLES(x,y);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_atan2(x,y);
return atan2(x,y);
} }
/********************************************************************* /*********************************************************************
@ -105,8 +250,7 @@ double _CIatan2(void)
double _CIcos(void) double _CIcos(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_cos(x);
return cos(x);
} }
/********************************************************************* /*********************************************************************
@ -115,8 +259,7 @@ double _CIcos(void)
double _CIcosh(void) double _CIcosh(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_cosh(x);
return cosh(x);
} }
/********************************************************************* /*********************************************************************
@ -125,8 +268,7 @@ double _CIcosh(void)
double _CIexp(void) double _CIexp(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_exp(x);
return exp(x);
} }
/********************************************************************* /*********************************************************************
@ -135,8 +277,7 @@ double _CIexp(void)
double _CIfmod(void) double _CIfmod(void)
{ {
FPU_DOUBLES(x,y); FPU_DOUBLES(x,y);
if (!finite(x) || !finite(y)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_fmod(x,y);
return fmod(x,y);
} }
/********************************************************************* /*********************************************************************
@ -145,9 +286,7 @@ double _CIfmod(void)
double _CIlog(void) double _CIlog(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_log(x);
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
return log(x);
} }
/********************************************************************* /*********************************************************************
@ -156,9 +295,7 @@ double _CIlog(void)
double _CIlog10(void) double _CIlog10(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_log10(x);
if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
return log10(x);
} }
/********************************************************************* /*********************************************************************
@ -166,12 +303,8 @@ double _CIlog10(void)
*/ */
double _CIpow(void) double _CIpow(void)
{ {
double z;
FPU_DOUBLES(x,y); FPU_DOUBLES(x,y);
/* FIXME: If x < 0 and y is not integral, set EDOM */ return MSVCRT_pow(x,y);
z = pow(x,y);
if (!finite(z)) *MSVCRT__errno() = MSVCRT_EDOM;
return z;
} }
/********************************************************************* /*********************************************************************
@ -180,8 +313,7 @@ double _CIpow(void)
double _CIsin(void) double _CIsin(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_sin(x);
return sin(x);
} }
/********************************************************************* /*********************************************************************
@ -190,8 +322,7 @@ double _CIsin(void)
double _CIsinh(void) double _CIsinh(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_sinh(x);
return sinh(x);
} }
/********************************************************************* /*********************************************************************
@ -200,8 +331,7 @@ double _CIsinh(void)
double _CIsqrt(void) double _CIsqrt(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_sqrt(x);
return sqrt(x);
} }
/********************************************************************* /*********************************************************************
@ -210,8 +340,7 @@ double _CIsqrt(void)
double _CItan(void) double _CItan(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_tan(x);
return tan(x);
} }
/********************************************************************* /*********************************************************************
@ -220,8 +349,7 @@ double _CItan(void)
double _CItanh(void) double _CItanh(void)
{ {
FPU_DOUBLE(x); FPU_DOUBLE(x);
if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM; return MSVCRT_tanh(x);
return tanh(x);
} }
#else /* defined(__GNUC__) && defined(__i386__) */ #else /* defined(__GNUC__) && defined(__i386__) */

View File

@ -569,11 +569,11 @@
@ cdecl _yn(long double ) @ cdecl _yn(long double )
@ cdecl abort() MSVCRT_abort @ cdecl abort() MSVCRT_abort
@ cdecl abs(long) @ cdecl abs(long)
@ cdecl acos(double) @ cdecl acos(double) MSVCRT_acos
@ cdecl asctime(ptr) MSVCRT_asctime @ cdecl asctime(ptr) MSVCRT_asctime
@ cdecl asin(double) @ cdecl asin(double) MSVCRT_asin
@ cdecl atan(double) @ cdecl atan(double) MSVCRT_atan
@ cdecl atan2(double double) @ cdecl atan2(double double) MSVCRT_atan2
@ cdecl atexit(ptr) MSVCRT_atexit @ cdecl atexit(ptr) MSVCRT_atexit
@ cdecl atof(str) @ cdecl atof(str)
@ cdecl atoi(str) @ cdecl atoi(str)
@ -583,13 +583,13 @@
@ cdecl ceil(double) @ cdecl ceil(double)
@ cdecl clearerr(ptr) MSVCRT_clearerr @ cdecl clearerr(ptr) MSVCRT_clearerr
@ cdecl clock() MSVCRT_clock @ cdecl clock() MSVCRT_clock
@ cdecl cos(double) @ cdecl cos(double) MSVCRT_cos
@ cdecl cosh(double) @ cdecl cosh(double) MSVCRT_cosh
@ cdecl ctime(ptr) MSVCRT_ctime @ cdecl ctime(ptr) MSVCRT_ctime
@ cdecl difftime(long long) MSVCRT_difftime @ cdecl difftime(long long) MSVCRT_difftime
@ cdecl div(long long) MSVCRT_div @ cdecl div(long long) MSVCRT_div
@ cdecl exit(long) MSVCRT_exit @ cdecl exit(long) MSVCRT_exit
@ cdecl exp(double) @ cdecl exp(double) MSVCRT_exp
@ cdecl fabs(double) @ cdecl fabs(double)
@ cdecl fclose(ptr) MSVCRT_fclose @ cdecl fclose(ptr) MSVCRT_fclose
@ cdecl feof(ptr) MSVCRT_feof @ cdecl feof(ptr) MSVCRT_feof
@ -601,7 +601,7 @@
@ cdecl fgetwc(ptr) MSVCRT_fgetwc @ cdecl fgetwc(ptr) MSVCRT_fgetwc
@ cdecl fgetws(ptr long ptr) MSVCRT_fgetws @ cdecl fgetws(ptr long ptr) MSVCRT_fgetws
@ cdecl floor(double) @ cdecl floor(double)
@ cdecl fmod(double double) @ cdecl fmod(double double) MSVCRT_fmod
@ cdecl fopen(str str) MSVCRT_fopen @ cdecl fopen(str str) MSVCRT_fopen
@ varargs fprintf(ptr str) MSVCRT_fprintf @ varargs fprintf(ptr str) MSVCRT_fprintf
@ cdecl fputc(long ptr) MSVCRT_fputc @ cdecl fputc(long ptr) MSVCRT_fputc
@ -657,8 +657,8 @@
@ cdecl ldiv(long long) MSVCRT_ldiv @ cdecl ldiv(long long) MSVCRT_ldiv
@ cdecl localeconv() MSVCRT_localeconv @ cdecl localeconv() MSVCRT_localeconv
@ cdecl localtime(ptr) MSVCRT_localtime @ cdecl localtime(ptr) MSVCRT_localtime
@ cdecl log(double) @ cdecl log(double) MSVCRT_log
@ cdecl log10(double) @ cdecl log10(double) MSVCRT_log10
@ cdecl -i386 longjmp(ptr long) MSVCRT_longjmp @ cdecl -i386 longjmp(ptr long) MSVCRT_longjmp
@ cdecl malloc(long) MSVCRT_malloc @ cdecl malloc(long) MSVCRT_malloc
@ cdecl mblen(ptr long) MSVCRT_mblen @ cdecl mblen(ptr long) MSVCRT_mblen
@ -672,7 +672,7 @@
@ cdecl mktime(ptr) MSVCRT_mktime @ cdecl mktime(ptr) MSVCRT_mktime
@ cdecl modf(double ptr) @ cdecl modf(double ptr)
@ cdecl perror(str) MSVCRT_perror @ cdecl perror(str) MSVCRT_perror
@ cdecl pow(double double) @ cdecl pow(double double) MSVCRT_pow
@ varargs printf(str) MSVCRT_printf @ varargs printf(str) MSVCRT_printf
@ cdecl putc(long ptr) MSVCRT_putc @ cdecl putc(long ptr) MSVCRT_putc
@ cdecl putchar(long) MSVCRT_putchar @ cdecl putchar(long) MSVCRT_putchar
@ -691,10 +691,10 @@
@ cdecl setlocale(long str) MSVCRT_setlocale @ cdecl setlocale(long str) MSVCRT_setlocale
@ cdecl setvbuf(ptr str long long) MSVCRT_setvbuf @ cdecl setvbuf(ptr str long long) MSVCRT_setvbuf
@ cdecl signal(long long) MSVCRT_signal @ cdecl signal(long long) MSVCRT_signal
@ cdecl sin(double) @ cdecl sin(double) MSVCRT_sin
@ cdecl sinh(double) @ cdecl sinh(double) MSVCRT_sinh
@ varargs sprintf(ptr str) MSVCRT_sprintf @ varargs sprintf(ptr str) MSVCRT_sprintf
@ cdecl sqrt(double) @ cdecl sqrt(double) MSVCRT_sqrt
@ cdecl srand(long) MSVCRT_srand @ cdecl srand(long) MSVCRT_srand
@ varargs sscanf(str str) MSVCRT_sscanf @ varargs sscanf(str str) MSVCRT_sscanf
@ cdecl strcat(str str) @ cdecl strcat(str str)
@ -721,8 +721,8 @@
@ varargs swprintf(wstr wstr) MSVCRT_swprintf @ varargs swprintf(wstr wstr) MSVCRT_swprintf
@ varargs swscanf(wstr wstr) MSVCRT_swscanf @ varargs swscanf(wstr wstr) MSVCRT_swscanf
@ cdecl system(str) MSVCRT_system @ cdecl system(str) MSVCRT_system
@ cdecl tan(double) @ cdecl tan(double) MSVCRT_tan
@ cdecl tanh(double) @ cdecl tanh(double) MSVCRT_tanh
@ cdecl time(ptr) MSVCRT_time @ cdecl time(ptr) MSVCRT_time
@ cdecl tmpfile() MSVCRT_tmpfile @ cdecl tmpfile() MSVCRT_tmpfile
@ cdecl tmpnam(ptr) MSVCRT_tmpnam @ cdecl tmpnam(ptr) MSVCRT_tmpnam