From d6deb6db917e6194249cf6894b0ba7ecc4f75608 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Mon, 27 Nov 2000 01:37:28 +0000 Subject: [PATCH] - configure tests for finite()/fpclass(), fixes BSD compile - winapi_check updates, fix errno in more math calls --- configure | 112 ++++++++--------- configure.in | 2 + dlls/crtdll/crtdll.h | 4 + dlls/crtdll/crtdll.spec | 8 +- dlls/crtdll/crtdll_main.c | 184 ++++++++++++++++++++-------- include/config.h.in | 6 + tools/winapi_check/win32/crtdll.api | 9 ++ tools/winapi_check/win32/ntdll.api | 4 + 8 files changed, 221 insertions(+), 108 deletions(-) diff --git a/configure b/configure index a6ad753135f..ff94c2ce60c 100755 --- a/configure +++ b/configure @@ -5369,6 +5369,8 @@ for ac_func in \ __libc_fork \ _lwp_create \ clone \ + finite \ + fpclass \ getnetbyaddr \ getnetbyname \ getpagesize \ @@ -5397,12 +5399,12 @@ for ac_func in \ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5401: checking for $ac_func" >&5 +echo "configure:5403: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5503,17 +5505,17 @@ for ac_hdr in \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5507: checking for $ac_hdr" >&5 +echo "configure:5509: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5517: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5519: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5540,12 +5542,12 @@ fi done echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6 -echo "configure:5544: checking whether stat file-mode macros are broken" >&5 +echo "configure:5546: checking whether stat file-mode macros are broken" >&5 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5598,12 +5600,12 @@ fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:5602: checking for working const" >&5 +echo "configure:5604: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5658: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -5673,21 +5675,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:5677: checking for inline" >&5 +echo "configure:5679: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5693: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -5713,12 +5715,12 @@ EOF esac echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:5717: checking for ANSI C header files" >&5 +echo "configure:5719: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5726,7 +5728,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5730: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5743,7 +5745,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -5761,7 +5763,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -5782,7 +5784,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -5793,7 +5795,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:5797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -5817,12 +5819,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:5821: checking for size_t" >&5 +echo "configure:5823: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -5850,7 +5852,7 @@ EOF fi echo $ac_n "checking size of long long""... $ac_c" 1>&6 -echo "configure:5854: checking size of long long" >&5 +echo "configure:5856: checking size of long long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5858,7 +5860,7 @@ else ac_cv_sizeof_long_long=0 else cat > conftest.$ac_ext < main() @@ -5869,7 +5871,7 @@ main() exit(0); } EOF -if { (eval echo configure:5873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long_long=`cat conftestval` else @@ -5891,12 +5893,12 @@ EOF echo $ac_n "checking "whether we can use re-entrant gethostbyname_r Linux style"""... $ac_c" 1>&6 -echo "configure:5895: checking "whether we can use re-entrant gethostbyname_r Linux style"" >&5 +echo "configure:5897: checking "whether we can use re-entrant gethostbyname_r Linux style"" >&5 if eval "test \"`echo '$''{'wine_cv_linux_gethostbyname_r_6'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -5917,7 +5919,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:5921: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5923: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wine_cv_linux_gethostbyname_r_6=yes else @@ -5943,12 +5945,12 @@ EOF if test "$ac_cv_header_linux_joystick_h" = "yes" then echo $ac_n "checking "whether linux/joystick.h uses the Linux 2.2+ API"""... $ac_c" 1>&6 -echo "configure:5947: checking "whether linux/joystick.h uses the Linux 2.2+ API"" >&5 +echo "configure:5949: checking "whether linux/joystick.h uses the Linux 2.2+ API"" >&5 if eval "test \"`echo '$''{'wine_cv_linux_joystick_22_api'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -5963,7 +5965,7 @@ int main() { /*empty*/ ; return 0; } EOF -if { (eval echo configure:5967: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wine_cv_linux_joystick_22_api=yes else @@ -5990,12 +5992,12 @@ fi if test "$ac_cv_header_sys_vfs_h" = "yes" then echo $ac_n "checking "whether sys/vfs.h defines statfs"""... $ac_c" 1>&6 -echo "configure:5994: checking "whether sys/vfs.h defines statfs"" >&5 +echo "configure:5996: checking "whether sys/vfs.h defines statfs"" >&5 if eval "test \"`echo '$''{'wine_cv_sys_vfs_has_statfs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -6012,7 +6014,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6018: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wine_cv_sys_vfs_has_statfs=yes else @@ -6039,12 +6041,12 @@ fi if test "$ac_cv_header_sys_statfs_h" = "yes" then echo $ac_n "checking "whether sys/statfs.h defines statfs"""... $ac_c" 1>&6 -echo "configure:6043: checking "whether sys/statfs.h defines statfs"" >&5 +echo "configure:6045: checking "whether sys/statfs.h defines statfs"" >&5 if eval "test \"`echo '$''{'wine_cv_sys_statfs_has_statfs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -6059,7 +6061,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6065: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wine_cv_sys_statfs_has_statfs=yes else @@ -6086,12 +6088,12 @@ fi if test "$ac_cv_header_sys_mount_h" = "yes" then echo $ac_n "checking "whether sys/mount.h defines statfs"""... $ac_c" 1>&6 -echo "configure:6090: checking "whether sys/mount.h defines statfs"" >&5 +echo "configure:6092: checking "whether sys/mount.h defines statfs"" >&5 if eval "test \"`echo '$''{'wine_cv_sys_mount_has_statfs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -6106,7 +6108,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6110: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wine_cv_sys_mount_has_statfs=yes else @@ -6132,7 +6134,7 @@ fi echo $ac_n "checking "for statfs.f_bfree"""... $ac_c" 1>&6 -echo "configure:6136: checking "for statfs.f_bfree"" >&5 +echo "configure:6138: checking "for statfs.f_bfree"" >&5 if eval "test \"`echo '$''{'wine_cv_statfs_bfree'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6141,7 +6143,7 @@ else wine_cv_statfs_bfree=no else cat > conftest.$ac_ext < @@ -6168,7 +6170,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6172: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6174: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wine_cv_statfs_bfree=yes else @@ -6192,7 +6194,7 @@ EOF fi echo $ac_n "checking "for statfs.f_bavail"""... $ac_c" 1>&6 -echo "configure:6196: checking "for statfs.f_bavail"" >&5 +echo "configure:6198: checking "for statfs.f_bavail"" >&5 if eval "test \"`echo '$''{'wine_cv_statfs_bavail'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6201,7 +6203,7 @@ else wine_cv_statfs_bavail=no else cat > conftest.$ac_ext < @@ -6228,7 +6230,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6234: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wine_cv_statfs_bavail=yes else @@ -6253,12 +6255,12 @@ fi echo $ac_n "checking "for msg_accrights in struct msghdr"""... $ac_c" 1>&6 -echo "configure:6257: checking "for msg_accrights in struct msghdr"" >&5 +echo "configure:6259: checking "for msg_accrights in struct msghdr"" >&5 if eval "test \"`echo '$''{'ac_cv_c_msg_accrights'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -6266,7 +6268,7 @@ int main() { struct msghdr hdr; hdr.msg_accrights=0 ; return 0; } EOF -if { (eval echo configure:6270: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_msg_accrights="yes" else @@ -6289,12 +6291,12 @@ fi echo $ac_n "checking "for sun_len in struct sockaddr_un"""... $ac_c" 1>&6 -echo "configure:6293: checking "for sun_len in struct sockaddr_un"" >&5 +echo "configure:6295: checking "for sun_len in struct sockaddr_un"" >&5 if eval "test \"`echo '$''{'ac_cv_c_sun_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -6303,7 +6305,7 @@ int main() { static struct sockaddr_un addr; addr.sun_len = 1 ; return 0; } EOF -if { (eval echo configure:6307: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6309: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_sun_len="yes" else @@ -6326,12 +6328,12 @@ fi echo $ac_n "checking "whether we need to define __i386__"""... $ac_c" 1>&6 -echo "configure:6330: checking "whether we need to define __i386__"" >&5 +echo "configure:6332: checking "whether we need to define __i386__"" >&5 if eval "test \"`echo '$''{'ac_cv_cpp_def_i386'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < -#define __USE_ISOC9X 1 /* for isfinite */ -#define __USE_ISOC99 1 /* for isfinite */ +#define __USE_ISOC9X 1 +#define __USE_ISOC99 1 #include #include #include @@ -33,10 +33,22 @@ UB 000416: #include "wingdi.h" #include "winuser.h" +#ifndef HAVE_FINITE +#ifndef finite /* Could be macro */ +#ifdef isfinite +#define finite(x) isfinite(x) +#else +#define finite(x) (!isnan(x)) /* At least catch some cases */ +#endif +#endif +#endif + +#ifndef signbit +#define signbit(x) 0 +#endif DEFAULT_DEBUG_CHANNEL(crtdll); - double CRTDLL_HUGE_dll; /* CRTDLL.20 */ UINT CRTDLL_argc_dll; /* CRTDLL.23 */ LPSTR *CRTDLL_argv_dll; /* CRTDLL.24 */ @@ -168,10 +180,10 @@ void __CRTDLL__set_errno(ULONG err) __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \ __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : ) #else -#define FPU_DOUBLE(var) double var = quiet_nan(0); \ +#define FPU_DOUBLE(var) double var = sqrt(-1); \ FIXME(":not implemented\n"); #define FPU_DOUBLES(var1,var2) double var1,var2; \ - var1=var2=quiet_nan(0); FIXME(":not implemented\n") + var1=var2=sqrt(-1); FIXME(":not implemented\n") #endif /********************************************************************* @@ -180,7 +192,7 @@ void __CRTDLL__set_errno(ULONG err) double __cdecl CRTDLL__CIacos(void) { FPU_DOUBLE(x); - if (x < -1.0 || x > 1.0) CRTDLL_errno = EDOM; + if (x < -1.0 || x > 1.0 || !finite(x)) CRTDLL_errno = EDOM; return acos(x); } @@ -191,7 +203,7 @@ double __cdecl CRTDLL__CIacos(void) double __cdecl CRTDLL__CIasin(void) { FPU_DOUBLE(x); - if (x < -1.0 || x > 1.0) CRTDLL_errno = EDOM; + if (x < -1.0 || x > 1.0 || !finite(x)) CRTDLL_errno = EDOM; return asin(x); } @@ -202,7 +214,7 @@ double __cdecl CRTDLL__CIasin(void) double __cdecl CRTDLL__CIatan(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return atan(x); } @@ -212,7 +224,7 @@ double __cdecl CRTDLL__CIatan(void) double __cdecl CRTDLL__CIatan2(void) { FPU_DOUBLES(x,y); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return atan2(x,y); } @@ -223,7 +235,7 @@ double __cdecl CRTDLL__CIatan2(void) double __cdecl CRTDLL__CIcos(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return cos(x); } @@ -233,7 +245,7 @@ double __cdecl CRTDLL__CIcos(void) double __cdecl CRTDLL__CIcosh(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return cosh(x); } @@ -243,7 +255,7 @@ double __cdecl CRTDLL__CIcosh(void) double __cdecl CRTDLL__CIexp(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return exp(x); } @@ -253,7 +265,7 @@ double __cdecl CRTDLL__CIexp(void) double __cdecl CRTDLL__CIfmod(void) { FPU_DOUBLES(x,y); - if (!isfinite(x) | !isfinite(y)) CRTDLL_errno = EDOM; + if (!finite(x) || !finite(y)) CRTDLL_errno = EDOM; return fmod(x,y); } @@ -263,7 +275,7 @@ double __cdecl CRTDLL__CIfmod(void) double __cdecl CRTDLL__CIlog(void) { FPU_DOUBLE(x); - if (x < 0.0 || !isfinite(x)) CRTDLL_errno = EDOM; + if (x < 0.0 || !finite(x)) CRTDLL_errno = EDOM; if (x == 0.0) CRTDLL_errno = ERANGE; return log(x); } @@ -274,7 +286,7 @@ double __cdecl CRTDLL__CIlog(void) double __cdecl CRTDLL__CIlog10(void) { FPU_DOUBLE(x); - if (x < 0.0 || !isfinite(x)) CRTDLL_errno = EDOM; + if (x < 0.0 || !finite(x)) CRTDLL_errno = EDOM; if (x == 0.0) CRTDLL_errno = ERANGE; return log10(x); } @@ -288,7 +300,7 @@ double __cdecl CRTDLL__CIpow(void) FPU_DOUBLES(x,y); /* FIXME: If x < 0 and y is not integral, set EDOM */ z = pow(x,y); - if (!isfinite(z)) CRTDLL_errno = EDOM; + if (!finite(z)) CRTDLL_errno = EDOM; return z; } @@ -298,7 +310,7 @@ double __cdecl CRTDLL__CIpow(void) double __cdecl CRTDLL__CIsin(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return sin(x); } @@ -308,7 +320,7 @@ double __cdecl CRTDLL__CIsin(void) double __cdecl CRTDLL__CIsinh(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return sinh(x); } @@ -318,7 +330,7 @@ double __cdecl CRTDLL__CIsinh(void) double __cdecl CRTDLL__CIsqrt(void) { FPU_DOUBLE(x); - if (x < 0.0) CRTDLL_errno = EDOM; + if (x < 0.0 || !finite(x)) CRTDLL_errno = EDOM; return sqrt(x); } @@ -328,7 +340,7 @@ double __cdecl CRTDLL__CIsqrt(void) double __cdecl CRTDLL__CItan(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return tan(x); } @@ -338,7 +350,7 @@ double __cdecl CRTDLL__CItan(void) double __cdecl CRTDLL__CItanh(void) { FPU_DOUBLE(x); - if (!isfinite(x)) CRTDLL_errno = EDOM; + if (!finite(x)) CRTDLL_errno = EDOM; return tanh(x); } @@ -446,27 +458,34 @@ UINT __cdecl CRTDLL__clearfp( VOID ) */ INT __cdecl CRTDLL__fpclass(double d) { +#if defined(HAVE_FPCLASS) || defined(fpclass) + switch (fpclass( d )) + { + case FP_SNAN: return _FPCLASS_SNAN; + case FP_QNAN: return _FPCLASS_QNAN; + case FP_NINF: return _FPCLASS_NINF; + case FP_PINF: return _FPCLASS_PINF; + case FP_NDENORM: return _FPCLASS_ND; + case FP_PDENORM: return _FPCLASS_PD; + case FP_NZERO: return _FPCLASS_NZ; + case FP_PZERO: return _FPCLASS_PZ; + case FP_NNORM: return _FPCLASS_NN; + } + return _FPCLASS_PN; +#elif defined (fpclassify) switch (fpclassify( d )) { case FP_NAN: return _FPCLASS_QNAN; - case FP_INFINITE: - if (signbit(d)) - return _FPCLASS_NINF; - return _FPCLASS_PINF; - case FP_SUBNORMAL: - if (signbit(d)) - return _FPCLASS_ND; - return _FPCLASS_PD; - case FP_ZERO: - if (signbit(d)) - return _FPCLASS_NZ; - return _FPCLASS_PZ; - case FP_NORMAL: - default: - if (signbit(d)) - return _FPCLASS_NN; - return _FPCLASS_PN; + case FP_INFINITE: return signbit(d) ? _FPCLASS_NINF : _FPCLASS_PINF; + case FP_SUBNORMAL: return signbit(d) ?_FPCLASS_ND : _FPCLASS_PD; + case FP_ZERO: return signbit(d) ? _FPCLASS_NZ : _FPCLASS_PZ; } + return signbit(d) ? _FPCLASS_NN : _FPCLASS_PN; +#else + if (!finite(d)) + return _FPCLASS_QNAN; + return d == 0.0 ? _FPCLASS_PZ : (d < 0 ? _FPCLASS_NN : _FPCLASS_PN); +#endif } @@ -554,6 +573,16 @@ UINT __cdecl CRTDLL__rotl(UINT x,INT shift) } +/********************************************************************* + * _logb (CRTDLL.174) + */ +double __cdecl CRTDLL__logb(double x) +{ + if (!finite(x)) CRTDLL_errno = EDOM; + return logb(x); +} + + /********************************************************************* * _lrotl (CRTDLL.175) */ @@ -593,6 +622,7 @@ double __cdecl CRTDLL__scalb(double x, LONG y) { /* Note - Can't forward directly as libc expects y as double */ double y2 = (double)y; + if (!finite(x)) CRTDLL_errno = EDOM; return scalb( x, y2 ); } @@ -959,7 +989,7 @@ INT __cdecl CRTDLL_isdigit(INT c) */ INT __cdecl CRTDLL_isgraph(INT c) { - return CRTDLL__isctype( c, CRTDLL_ALPHA | CRTDLL_DIGIT | CRTDLL_PUNCT ); + return CRTDLL__isctype( c, CRTDLL_ALPHA | CRTDLL_DIGIT | CRTDLL_PUNCT ); } @@ -1023,10 +1053,12 @@ INT __cdecl CRTDLL_isxdigit(INT c) */ double __cdecl CRTDLL_ldexp(double x, LONG y) { - double z; - z = ldexp(x,y); - /* FIXME: MS doesn't return -0 or very large/small (e=298+) numbers */ - if (!isfinite(z)) CRTDLL_errno = ERANGE; + double z = ldexp(x,y); + + if (!finite(z)) + CRTDLL_errno = ERANGE; + else if (z == 0 && signbit(z)) + z = 0.0; /* Convert -0 -> +0 */ return z; } @@ -1423,7 +1455,7 @@ double __cdecl CRTDLL__copysign(double x, double y) */ INT __cdecl CRTDLL__finite(double d) { - return (isfinite(d)?1:0); /* See comment for CRTDLL__isnan() */ + return (finite(d)?1:0); /* See comment for CRTDLL__isnan() */ } @@ -1474,13 +1506,13 @@ VOID __cdecl CRTDLL__purecall(VOID) /********************************************************************* - * _div (CRTDLL.@) + * _div (CRTDLL.358) * * Return the quotient and remainder of long integer division. */ #ifdef __i386__ /* Windows binary compatible - returns the struct in eax/edx. */ -LONGLONG __cdecl CRTDLL_div(int x, int y) +LONGLONG __cdecl CRTDLL_div(INT x, INT y) { LONGLONG retVal; div_t dt = div(x,y); @@ -1489,7 +1521,7 @@ LONGLONG __cdecl CRTDLL_div(int x, int y) } #else /* Non-x86 cant run win32 apps so dont need binary compatibility */ -div_t __cdecl CRTDLL_div(int x, int y) +div_t __cdecl CRTDLL_div(INT x, INT y) { return div(x,y); } @@ -1503,7 +1535,7 @@ div_t __cdecl CRTDLL_div(int x, int y) */ #ifdef __i386__ /* Windows binary compatible - returns the struct in eax/edx. */ -LONGLONG __cdecl CRTDLL_ldiv(long x, long y) +LONGLONG __cdecl CRTDLL_ldiv(LONG x, LONG y) { LONGLONG retVal; ldiv_t ldt = ldiv(x,y); @@ -1512,9 +1544,63 @@ LONGLONG __cdecl CRTDLL_ldiv(long x, long y) } #else /* Non-x86 cant run win32 apps so dont need binary compatibility */ -ldiv_t __cdecl CRTDLL_ldiv(long x, long y) +ldiv_t __cdecl CRTDLL_ldiv(LONG x, LONG y) { return ldiv(x,y); } #endif /* __i386__ */ + +/********************************************************************* + * _y0 (CRTDLL.332) + * + */ +double __cdecl CRTDLL__y0(double x) +{ + double retVal; + + if (!finite(x)) CRTDLL_errno = EDOM; + retVal = y0(x); + if (CRTDLL__fpclass(retVal) == _FPCLASS_NINF) + { + CRTDLL_errno = EDOM; + retVal = sqrt(-1); + } + return retVal; +} + +/********************************************************************* + * _y1 (CRTDLL.333) + * + */ +double __cdecl CRTDLL__y1(double x) +{ + double retVal; + + if (!finite(x)) CRTDLL_errno = EDOM; + retVal = y1(x); + if (CRTDLL__fpclass(retVal) == _FPCLASS_NINF) + { + CRTDLL_errno = EDOM; + retVal = sqrt(-1); + } + return retVal; +} + +/********************************************************************* + * _yn (CRTDLL.334) + * + */ +double __cdecl CRTDLL__yn(INT x, double y) +{ + double retVal; + + if (!finite(y)) CRTDLL_errno = EDOM; + retVal = yn(x,y); + if (CRTDLL__fpclass(retVal) == _FPCLASS_NINF) + { + CRTDLL_errno = EDOM; + retVal = sqrt(-1); + } + return retVal; +} diff --git a/include/config.h.in b/include/config.h.in index 46e694d76fb..2a5ac4a849a 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -173,6 +173,12 @@ /* Define if you have the dlopen function. */ #undef HAVE_DLOPEN +/* Define if you have the finite function. */ +#undef HAVE_FINITE + +/* Define if you have the fpclass function. */ +#undef HAVE_FPCLASS + /* Define if you have the gethostbyname function. */ #undef HAVE_GETHOSTBYNAME diff --git a/tools/winapi_check/win32/crtdll.api b/tools/winapi_check/win32/crtdll.api index 8cbe7b8d75b..0e3012134a0 100644 --- a/tools/winapi_check/win32/crtdll.api +++ b/tools/winapi_check/win32/crtdll.api @@ -13,6 +13,7 @@ LONG ULONG UINT WCHAR +UCHAR clock_t size_t time_t @@ -23,6 +24,11 @@ int unsigned int unsigned long +%longlong + +LONGLONG +ULONGLONG + %ptr CHAR * @@ -50,6 +56,7 @@ struct _timeb * time_t * struct _heapinfo * struct _utimbuf * +struct _exception * fpos_t * diskfree_t * unsigned char * @@ -78,4 +85,6 @@ sig_handler_type comp_func struct complex atexit_function +div_t +ldiv_t diff --git a/tools/winapi_check/win32/ntdll.api b/tools/winapi_check/win32/ntdll.api index 8320fc5171c..19474327119 100644 --- a/tools/winapi_check/win32/ntdll.api +++ b/tools/winapi_check/win32/ntdll.api @@ -1,3 +1,7 @@ +%double + +double + %long ACCESS_MASK