- configure tests for finite()/fpclass(), fixes BSD compile
- winapi_check updates, fix errno in more math calls

diff --git a/configure b/configure
index a6ad753..ff94c2c 100755
--- a/configure
+++ b/configure
@@ -5369,6 +5369,8 @@
 	__libc_fork \
 	_lwp_create \
 	clone \
+	finite \
+	fpclass \
 	getnetbyaddr \
 	getnetbyname \
 	getpagesize \
@@ -5397,12 +5399,12 @@
 
 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 <<EOF
-#line 5406 "configure"
+#line 5408 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5425,7 +5427,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5429: \"$ac_link\") 1>&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 @@
 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
-#line 5512 "configure"
+#line 5514 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 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 @@
 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 <<EOF
-#line 5549 "configure"
+#line 5551 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -5598,12 +5600,12 @@
 
 
 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 <<EOF
-#line 5607 "configure"
+#line 5609 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -5652,7 +5654,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5656: \"$ac_compile\") 1>&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 @@
 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 <<EOF
-#line 5684 "configure"
+#line 5686 "configure"
 #include "confdefs.h"
 
 int main() {
 } int $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:5691: \"$ac_compile\") 1>&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 @@
 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 <<EOF
-#line 5722 "configure"
+#line 5724 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -5726,7 +5728,7 @@
 #include <float.h>
 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 @@
 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
-#line 5747 "configure"
+#line 5749 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -5761,7 +5763,7 @@
 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
-#line 5765 "configure"
+#line 5767 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -5782,7 +5784,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 5786 "configure"
+#line 5788 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -5793,7 +5795,7 @@
 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 @@
 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 <<EOF
-#line 5826 "configure"
+#line 5828 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -5850,7 +5852,7 @@
 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 @@
   ac_cv_sizeof_long_long=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 5862 "configure"
+#line 5864 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -5869,7 +5871,7 @@
   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 @@
 
    
 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 <<EOF
-#line 5900 "configure"
+#line 5902 "configure"
 #include "confdefs.h"
 
 #include <netdb.h>
@@ -5917,7 +5919,7 @@
     
 ; 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 @@
 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 <<EOF
-#line 5952 "configure"
+#line 5954 "configure"
 #include "confdefs.h"
 
 	#include <sys/ioctl.h>
@@ -5963,7 +5965,7 @@
 /*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 @@
 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 <<EOF
-#line 5999 "configure"
+#line 6001 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6012,7 +6014,7 @@
 	
 ; 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 @@
 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 <<EOF
-#line 6048 "configure"
+#line 6050 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6059,7 +6061,7 @@
 	
 ; 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 @@
 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 <<EOF
-#line 6095 "configure"
+#line 6097 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6106,7 +6108,7 @@
 	
 ; 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 @@
 
 
 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 @@
         wine_cv_statfs_bfree=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 6145 "configure"
+#line 6147 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6168,7 +6170,7 @@
 	
 ; 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 @@
 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 @@
         wine_cv_statfs_bavail=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 6205 "configure"
+#line 6207 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6228,7 +6230,7 @@
 	
 ; 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 @@
 
 
 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 <<EOF
-#line 6262 "configure"
+#line 6264 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -6266,7 +6268,7 @@
 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 @@
 
 
 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 <<EOF
-#line 6298 "configure"
+#line 6300 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -6303,7 +6305,7 @@
 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 @@
 
 
 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 <<EOF
-#line 6335 "configure"
+#line 6337 "configure"
 #include "confdefs.h"
 #if (defined(i386) || defined(__i386)) && !defined(__i386__)
 yes
diff --git a/configure.in b/configure.in
index ed13321..1cd455c 100644
--- a/configure.in
+++ b/configure.in
@@ -710,6 +710,8 @@
 	__libc_fork \
 	_lwp_create \
 	clone \
+	finite \
+	fpclass \
 	getnetbyaddr \
 	getnetbyname \
 	getpagesize \
diff --git a/dlls/crtdll/crtdll.h b/dlls/crtdll/crtdll.h
index 1cb5ea2..e18af22 100644
--- a/dlls/crtdll/crtdll.h
+++ b/dlls/crtdll/crtdll.h
@@ -344,6 +344,7 @@
 VOID   __cdecl CRTDLL__beep( UINT freq, UINT duration );
 INT    __cdecl CRTDLL_rand( VOID );
 UINT   __cdecl CRTDLL__rotl( UINT x,INT shift );
+double __cdecl CRTDLL__logb( double x );
 DWORD  __cdecl CRTDLL__lrotl( DWORD x,INT shift );
 DWORD  __cdecl CRTDLL__lrotr( DWORD x,INT shift );
 DWORD  __cdecl CRTDLL__rotr( UINT x,INT shift );
@@ -412,6 +413,9 @@
 LPVOID __cdecl CRTDLL__lsearch( LPVOID match, LPVOID start, LPUINT array_size,
                                 UINT elem_size, comp_func cf );
 VOID   __cdecl CRTDLL__purecall( VOID );
+double __cdecl CRTDLL__y0( double x );
+double __cdecl CRTDLL__y1( double x );
+double __cdecl CRTDLL__yn( INT x, double y );
 
 /* CRTDLL_mem.c */
 LPVOID  __cdecl CRTDLL_new( DWORD size );
diff --git a/dlls/crtdll/crtdll.spec b/dlls/crtdll/crtdll.spec
index 4c22aa8..35d69a1 100644
--- a/dlls/crtdll/crtdll.spec
+++ b/dlls/crtdll/crtdll.spec
@@ -182,7 +182,7 @@
 @ cdecl _loaddll(str) CRTDLL__loaddll
 @ cdecl _local_unwind2(ptr long) CRTDLL__local_unwind2
 @ stub _locking
-@ cdecl _logb(double) logb
+@ cdecl _logb(double) CRTDLL__logb
 @ cdecl _lrotl (long long) CRTDLL__lrotl
 @ cdecl _lrotr (long long) CRTDLL__lrotr
 @ cdecl _lsearch(ptr ptr long long ptr) CRTDLL__lsearch
@@ -342,9 +342,9 @@
 @ cdecl _write(long ptr long) CRTDLL__write
 @ stub _wtoi
 @ stub _wtol
-@ cdecl _y0(double) y0
-@ cdecl _y1(double) y1
-@ cdecl _yn(long double) yn
+@ cdecl _y0(double) CRTDLL__y0
+@ cdecl _y1(double) CRTDLL__y1
+@ cdecl _yn(long double) CRTDLL__yn
 @ cdecl abort() CRTDLL_abort
 @ cdecl abs(long) abs
 @ cdecl acos(double) acos
diff --git a/dlls/crtdll/crtdll_main.c b/dlls/crtdll/crtdll_main.c
index 0f4e5b4..5bb34f6 100644
--- a/dlls/crtdll/crtdll_main.c
+++ b/dlls/crtdll/crtdll_main.c
@@ -24,8 +24,8 @@
 
 #include "crtdll.h"
 #include <ctype.h>
-#define __USE_ISOC9X 1 /* for isfinite */
-#define __USE_ISOC99 1 /* for isfinite */
+#define __USE_ISOC9X 1
+#define __USE_ISOC99 1
 #include <math.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -33,10 +33,22 @@
 #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 @@
   __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 @@
 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__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__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__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__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__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__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__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__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__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 @@
   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__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__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__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__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__CItanh(void)
 {
   FPU_DOUBLE(x);
-  if (!isfinite(x)) CRTDLL_errno = EDOM;
+  if (!finite(x)) CRTDLL_errno = EDOM;
   return tanh(x);
 }
 
@@ -446,27 +458,34 @@
  */
 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
 }
 
 
@@ -555,6 +574,16 @@
 
 
 /*********************************************************************
+ *                  _logb           (CRTDLL.174)
+ */
+double __cdecl CRTDLL__logb(double x)
+{
+  if (!finite(x)) CRTDLL_errno = EDOM;
+  return logb(x);
+}
+
+
+/*********************************************************************
  *                  _lrotl          (CRTDLL.175)
  */
 DWORD __cdecl CRTDLL__lrotl(DWORD x,INT shift)
@@ -593,6 +622,7 @@
 {
   /* 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_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 @@
  */
 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 @@
  */
 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 @@
 
 
 /*********************************************************************
- *                  _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 @@
 }
 #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 @@
  */
 #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 @@
 }
 #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 46e694d..2a5ac4a 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 8cbe7b8..0e30121 100644
--- a/tools/winapi_check/win32/crtdll.api
+++ b/tools/winapi_check/win32/crtdll.api
@@ -13,6 +13,7 @@
 ULONG
 UINT
 WCHAR
+UCHAR
 clock_t
 size_t
 time_t
@@ -23,6 +24,11 @@
 unsigned int
 unsigned long
 
+%longlong
+ 
+LONGLONG
+ULONGLONG
+
 %ptr
 
 CHAR *
@@ -50,6 +56,7 @@
 time_t *
 struct _heapinfo *
 struct _utimbuf *
+struct _exception *
 fpos_t *
 diskfree_t *
 unsigned char *
@@ -78,4 +85,6 @@
 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 8320fc5..1947432 100644
--- a/tools/winapi_check/win32/ntdll.api
+++ b/tools/winapi_check/win32/ntdll.api
@@ -1,3 +1,7 @@
+%double
+
+double
+
 %long
 
 ACCESS_MASK