Fixed some issues found by winapi_check.

diff --git a/configure b/configure
index 29739ff..435ca53 100755
--- a/configure
+++ b/configure
@@ -5513,6 +5513,8 @@
 	net/if.h \
 	netdb.h \
 	netinet/in.h \
+	netinet/in_systm.h \
+	netinet/ip.h \
 	netinet/tcp.h \
 	pty.h \
 	resolv.h \
@@ -5546,22 +5548,22 @@
 	sys/vfs.h \
 	sys/vm86.h \
 	syscall.h \
-	ucontext.h
+	ucontext.h \
 
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5555: checking for $ac_hdr" >&5
+echo "configure:5557: 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 5560 "configure"
+#line 5562 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5565: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5567: \"$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*
@@ -5588,12 +5590,12 @@
 done
 
 echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:5592: checking whether stat file-mode macros are broken" >&5
+echo "configure:5594: 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 5597 "configure"
+#line 5599 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -5646,12 +5648,12 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:5650: checking for working const" >&5
+echo "configure:5652: 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 5655 "configure"
+#line 5657 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -5700,7 +5702,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5704: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5706: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -5721,21 +5723,21 @@
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:5725: checking for inline" >&5
+echo "configure:5727: 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 5732 "configure"
+#line 5734 "configure"
 #include "confdefs.h"
 
 int main() {
 } int $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:5739: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5741: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -5761,12 +5763,12 @@
 esac
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:5765: checking for ANSI C header files" >&5
+echo "configure:5767: 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 5770 "configure"
+#line 5772 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -5774,7 +5776,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5780: \"$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*
@@ -5791,7 +5793,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 5795 "configure"
+#line 5797 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -5809,7 +5811,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 5813 "configure"
+#line 5815 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -5830,7 +5832,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 5834 "configure"
+#line 5836 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -5841,7 +5843,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:5845: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -5865,12 +5867,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:5869: checking for size_t" >&5
+echo "configure:5871: 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 5874 "configure"
+#line 5876 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -5898,7 +5900,7 @@
 fi
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:5902: checking size of long long" >&5
+echo "configure:5904: 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
@@ -5906,7 +5908,7 @@
   ac_cv_sizeof_long_long=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 5910 "configure"
+#line 5912 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -5917,7 +5919,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:5921: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5923: \"$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
@@ -5939,12 +5941,12 @@
 
    
 echo $ac_n "checking "whether we can use re-entrant gethostbyname_r Linux style"""... $ac_c" 1>&6
-echo "configure:5943: checking "whether we can use re-entrant gethostbyname_r Linux style"" >&5
+echo "configure:5945: 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 5948 "configure"
+#line 5950 "configure"
 #include "confdefs.h"
 
 #include <netdb.h>
@@ -5965,7 +5967,7 @@
     
 ; return 0; }
 EOF
-if { (eval echo configure:5969: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5971: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_linux_gethostbyname_r_6=yes
 else
@@ -5991,12 +5993,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:5995: checking "whether linux/joystick.h uses the Linux 2.2+ API"" >&5
+echo "configure:5997: 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 6000 "configure"
+#line 6002 "configure"
 #include "confdefs.h"
 
 	#include <sys/ioctl.h>
@@ -6011,7 +6013,7 @@
 /*empty*/
 ; return 0; }
 EOF
-if { (eval echo configure:6015: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6017: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_linux_joystick_22_api=yes
 else
@@ -6038,12 +6040,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:6042: checking "whether sys/vfs.h defines statfs"" >&5
+echo "configure:6044: 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 6047 "configure"
+#line 6049 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6060,7 +6062,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6064: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_vfs_has_statfs=yes
 else
@@ -6087,12 +6089,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:6091: checking "whether sys/statfs.h defines statfs"" >&5
+echo "configure:6093: 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 6096 "configure"
+#line 6098 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6107,7 +6109,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6111: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6113: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_statfs_has_statfs=yes
 else
@@ -6134,12 +6136,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:6138: checking "whether sys/mount.h defines statfs"" >&5
+echo "configure:6140: 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 6143 "configure"
+#line 6145 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6154,7 +6156,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6158: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6160: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_mount_has_statfs=yes
 else
@@ -6180,7 +6182,7 @@
 
 
 echo $ac_n "checking "for statfs.f_bfree"""... $ac_c" 1>&6
-echo "configure:6184: checking "for statfs.f_bfree"" >&5
+echo "configure:6186: 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
@@ -6189,7 +6191,7 @@
         wine_cv_statfs_bfree=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 6193 "configure"
+#line 6195 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6216,7 +6218,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6220: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6222: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bfree=yes
 else
@@ -6240,7 +6242,7 @@
 fi
 
 echo $ac_n "checking "for statfs.f_bavail"""... $ac_c" 1>&6
-echo "configure:6244: checking "for statfs.f_bavail"" >&5
+echo "configure:6246: 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
@@ -6249,7 +6251,7 @@
         wine_cv_statfs_bavail=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 6253 "configure"
+#line 6255 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6276,7 +6278,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6280: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6282: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bavail=yes
 else
@@ -6301,12 +6303,12 @@
 
 
 echo $ac_n "checking "for msg_accrights in struct msghdr"""... $ac_c" 1>&6
-echo "configure:6305: checking "for msg_accrights in struct msghdr"" >&5
+echo "configure:6307: 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 6310 "configure"
+#line 6312 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -6314,7 +6316,7 @@
 struct msghdr hdr; hdr.msg_accrights=0
 ; return 0; }
 EOF
-if { (eval echo configure:6318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6320: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_msg_accrights="yes"
 else
@@ -6337,12 +6339,12 @@
 
 
 echo $ac_n "checking "for sun_len in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:6341: checking "for sun_len in struct sockaddr_un"" >&5
+echo "configure:6343: 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 6346 "configure"
+#line 6348 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -6351,7 +6353,7 @@
 static struct sockaddr_un addr; addr.sun_len = 1
 ; return 0; }
 EOF
-if { (eval echo configure:6355: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6357: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_sun_len="yes"
 else
@@ -6374,12 +6376,12 @@
 
 
 echo $ac_n "checking "whether we need to define __i386__"""... $ac_c" 1>&6
-echo "configure:6378: checking "whether we need to define __i386__"" >&5
+echo "configure:6380: 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 6383 "configure"
+#line 6385 "configure"
 #include "confdefs.h"
 #if (defined(i386) || defined(__i386)) && !defined(__i386__)
 yes
diff --git a/configure.in b/configure.in
index 049e890..65537a2 100644
--- a/configure.in
+++ b/configure.in
@@ -776,6 +776,8 @@
 	net/if.h \
 	netdb.h \
 	netinet/in.h \
+	netinet/in_systm.h \
+	netinet/ip.h \
 	netinet/tcp.h \
 	pty.h \
 	resolv.h \
@@ -809,7 +811,7 @@
 	sys/vfs.h \
 	sys/vm86.h \
 	syscall.h \
-	ucontext.h
+	ucontext.h \
 )
 AC_HEADER_STAT()
 
diff --git a/dlls/crtdll/crtdll.spec b/dlls/crtdll/crtdll.spec
index 35d69a1..9d78ae8 100644
--- a/dlls/crtdll/crtdll.spec
+++ b/dlls/crtdll/crtdll.spec
@@ -73,7 +73,7 @@
 @ stub _cprintf
 @ stub _cpumode_dll
 @ stub _cputs
-@ cdecl _creat(str long) CTRDLL__creat
+@ cdecl _creat(str long) CRTDLL__creat
 @ stub _cscanf
 @ extern _ctype CRTDLL_ctype
 @ stub _cwait
@@ -465,7 +465,7 @@
 @ cdecl signal(long ptr) CRTDLL_signal
 @ cdecl sin(double) sin
 @ cdecl sinh(double) sinh
-@ varargs sprintf() sprintf
+@ varargs sprintf(ptr ptr) sprintf
 @ cdecl sqrt(double) sqrt
 @ cdecl srand(long) srand
 @ varargs sscanf() sscanf
diff --git a/dlls/crtdll/crtdll_main.c b/dlls/crtdll/crtdll_main.c
index 5bb34f6..888c6a8 100644
--- a/dlls/crtdll/crtdll_main.c
+++ b/dlls/crtdll/crtdll_main.c
@@ -22,7 +22,10 @@
  * since we need 2 byte wide characters. - Marcus Meissner, 981031
  */
 
+#include "config.h"
+
 #include "crtdll.h"
+
 #include <ctype.h>
 #define __USE_ISOC9X 1
 #define __USE_ISOC99 1
@@ -1506,7 +1509,7 @@
 
 
 /*********************************************************************
- *                  _div               (CRTDLL.358)
+ *                  div               (CRTDLL.358)
  *
  * Return the quotient and remainder of long integer division.
  */
@@ -1529,7 +1532,7 @@
 
 
 /*********************************************************************
- *                  _ldiv               (CRTDLL.249)
+ *                  ldiv               (CRTDLL.249)
  *
  * Return the quotient and remainder of long integer division.
  */
diff --git a/dlls/crtdll/file.c b/dlls/crtdll/file.c
index 8f1b877..f52f819 100644
--- a/dlls/crtdll/file.c
+++ b/dlls/crtdll/file.c
@@ -302,7 +302,7 @@
  *
  * Open a file, creating it if it is not present.
  */
-INT __cdecl CTRDLL__creat(LPCSTR path, INT flags)
+INT __cdecl CRTDLL__creat(LPCSTR path, INT flags)
 {
   INT usedFlags = (flags & _O_TEXT)| _O_CREAT| _O_WRONLY| _O_TRUNC;
   return CRTDLL__open(path, usedFlags);
diff --git a/dlls/icmp/icmp_main.c b/dlls/icmp/icmp_main.c
index d34188a..a92247b 100644
--- a/dlls/icmp/icmp_main.c
+++ b/dlls/icmp/icmp_main.c
@@ -26,9 +26,11 @@
 # include <sys/socket.h>
 #endif
 #ifdef HAVE_NETDB_H
-#include <netdb.h>
+# include <netdb.h>
 #endif
-#include <netinet/in_systm.h>
+#ifdef HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
 #ifdef HAVE_NETINET_IN_H
 # include <netinet/in.h>
 #endif
diff --git a/dlls/kernel/kernel.spec b/dlls/kernel/kernel.spec
index feb965d..e118985 100644
--- a/dlls/kernel/kernel.spec
+++ b/dlls/kernel/kernel.spec
@@ -238,7 +238,7 @@
 224 pascal RegQueryValue(long str ptr ptr) RegQueryValue16
 225 pascal RegQueryValueEx(long str ptr ptr ptr ptr) RegQueryValueEx16
 226 pascal RegSetValueEx(long str long long ptr long) RegSetValueEx16
-227 pascal RegFlushKey(long) RegFlushKey
+227 pascal RegFlushKey(long) RegFlushKey16
 228 pascal16 K228(word) GetExePtr
 229 pascal16 K229(long) Local32GetSegment16
 230 pascal GlobalSmartPageLock(word) GlobalPageLock16 #?
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 2963a0a..66acc14 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -22,12 +22,15 @@
 #endif
 #include <sys/stat.h>
 #include <unistd.h>
-#include <netinet/in_systm.h>
-#ifdef HAVE_NETINET_IH_H
+#ifdef HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
 # include <netinet/in.h>
 #endif
-#include <netinet/in.h>
-#include <netinet/ip.h>
+#ifdef HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
 
 #include "winbase.h"
 #include "wingdi.h"
diff --git a/include/config.h.in b/include/config.h.in
index 53a1a8f..5d01154 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -350,6 +350,12 @@
 /* Define if you have the <netinet/in.h> header file.  */
 #undef HAVE_NETINET_IN_H
 
+/* Define if you have the <netinet/in_systm.h> header file.  */
+#undef HAVE_NETINET_IN_SYSTM_H
+
+/* Define if you have the <netinet/ip.h> header file.  */
+#undef HAVE_NETINET_IP_H
+
 /* Define if you have the <netinet/tcp.h> header file.  */
 #undef HAVE_NETINET_TCP_H
 
diff --git a/loader/dos/dosmod.c b/loader/dos/dosmod.c
index fb7da7f..8aea170 100644
--- a/loader/dos/dosmod.c
+++ b/loader/dos/dosmod.c
@@ -30,7 +30,9 @@
 #endif
 #include <sys/time.h>
 #include <sys/types.h>
-#include <sys/ptrace.h>
+#ifdef HAVE_SYS_PTRACE_H
+# include <sys/ptrace.h>
+#endif
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
 #endif
diff --git a/misc/registry.c b/misc/registry.c
index 438963a..9306d0b 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -1861,3 +1861,12 @@
     if (!count && (type==REG_SZ)) count = strlen(data);
     return RegSetValueExA( hkey, name, reserved, type, data, count );
 }
+
+/******************************************************************************
+ *           RegFlushKey16   [KERNEL.227]
+ */
+DWORD WINAPI RegFlushKey16( HKEY hkey )
+{
+    fix_win16_hkey( &hkey );
+    return RegFlushKey( hkey );
+}
diff --git a/server/context_sparc.c b/server/context_sparc.c
index 0a63c12..bd30922 100644
--- a/server/context_sparc.c
+++ b/server/context_sparc.c
@@ -12,11 +12,15 @@
 #include <errno.h>
 #include <sys/types.h>
 #ifdef HAVE_SYS_REG_H
-#include <sys/reg.h>
+# include <sys/reg.h>
 #endif
 #include <unistd.h>
-#include <sys/ptrace.h>
-#include <sys/user.h>
+#ifdef HAVE_SYS_PTRACE_H
+# include <sys/ptrace.h>
+#endif
+#ifdef HAVE_SYS_USER_H
+# include <sys/user.h>
+#endif
 
 #include "winbase.h"