Protect sys/stat.h and memory.h #includes

Francois Gouget fgouget at free.fr
Thu May 5 12:20:39 CDT 2005


Changelog:

  * tools/winapi/nativeapi.pm
    tools/winapi/winapi_check
    dlls/crtdll/crtdll_main.c
    dlls/dbghelp/elf_module.c
    dlls/dbghelp/stabs.c
    dlls/gdi/freetype.c
    dlls/kernel/comm.c
    dlls/kernel/kernel_main.c
    dlls/kernel/oldconfig.c
    dlls/kernel/vxd.c
    dlls/msacm/winemp3/common.c
    dlls/ntdll/cdrom.c
    dlls/ntdll/directory.c
    dlls/ntdll/path.c
    dlls/ntdll/server.c
    dlls/shell32/shfldr_unixfs.c
    dlls/winaspi/winaspi16.c
    dlls/winaspi/winaspi32.c
    dlls/winedos/int21.c
    dlls/winedos/module.c
    dlls/winedos/ppdev.c
    dlls/winedos/vxd.c
    dlls/winsock/socket.c
    loader/preloader.c

    Francois Gouget <fgouget at free.fr>
    Fix nativeapi.pm so it knows about AC_HEADER_STAT().
    Make the error message about unexpected '#ifdef HAVE_XXX' clearer.
    Protect sys/stat.h and memory.h #includes with the corresponding 
'#ifdef HAVE_XXX' check.

-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
  The greatest programming project of all took six days; on the seventh day the
   programmer rested. We've been trying to debug the *&^%$#@ thing ever since.
                       Moral: design before you implement.
-------------- next part --------------
Index: tools/winapi/nativeapi.pm
===================================================================
RCS file: /var/cvs/wine/tools/winapi/nativeapi.pm,v
retrieving revision 1.2
diff -u -p -r1.2 nativeapi.pm
--- tools/winapi/nativeapi.pm	4 May 2005 10:43:00 -0000	1.2
+++ tools/winapi/nativeapi.pm	5 May 2005 16:12:43 -0000
@@ -110,6 +110,14 @@ sub new($) {
 	    foreach my $name (split(/\s+/, $headers)) {
 		$$conditional_headers{$name}++;
 	    }
+	} elsif(/AC_HEADER_STAT\(\)/) {
+            # This checks for a bunch of standard headers
+            # There's stdlib.h, string.h and sys/types.h too but we don't
+            # want to force ifdefs for those at this point.
+	    foreach my $name ("sys/stat.h", "memory.h", "strings.h",
+                              "inttypes.h", "stdint.h", "unistd.h") {
+		$$conditional_headers{$name}++;
+	    }
 	} elsif(/AC_CHECK_FUNCS\(\s*([^,\)]*)(?:,|\))?/) {
 	    my $funcs = $1;
 	    $funcs =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
Index: tools/winapi/winapi_check
===================================================================
RCS file: /var/cvs/wine/tools/winapi/winapi_check,v
retrieving revision 1.3
diff -u -p -r1.3 winapi_check
--- tools/winapi/winapi_check	4 May 2005 09:55:18 -0000	1.3
+++ tools/winapi/winapi_check	5 May 2005 15:12:47 -0000
@@ -583,8 +583,7 @@ foreach my $file (@c_files) {
 			    }
 			}
 		    } elsif($preprocessor->is_def($macro)) {
-			$output->write("$file: #$directive $argument: is protected, " .
-				       "but is not a conditional include\n");
+			$output->write("$file: #$directive $argument: is protected, but there is no check for it in configure.ac\n");
 		    }
 		}
 
Index: dlls/crtdll/crtdll_main.c
===================================================================
RCS file: /var/cvs/wine/dlls/crtdll/crtdll_main.c,v
retrieving revision 1.52
diff -u -p -r1.52 crtdll_main.c
--- dlls/crtdll/crtdll_main.c	22 Aug 2003 05:05:57 -0000	1.52
+++ dlls/crtdll/crtdll_main.c	5 May 2005 16:22:01 -0000
@@ -21,7 +21,9 @@
 #include "config.h"
 
 #include <stdarg.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 
 #include "windef.h"
 #include "winbase.h"
Index: dlls/dbghelp/elf_module.c
===================================================================
RCS file: /var/cvs/wine/dlls/dbghelp/elf_module.c,v
retrieving revision 1.19
diff -u -p -r1.19 elf_module.c
--- dlls/dbghelp/elf_module.c	5 May 2005 09:50:13 -0000	1.19
+++ dlls/dbghelp/elf_module.c	5 May 2005 16:22:26 -0000
@@ -24,7 +24,9 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <fcntl.h>
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
Index: dlls/dbghelp/stabs.c
===================================================================
RCS file: /var/cvs/wine/dlls/dbghelp/stabs.c,v
retrieving revision 1.15
diff -u -p -r1.15 stabs.c
--- dlls/dbghelp/stabs.c	1 Mar 2005 10:39:49 -0000	1.15
+++ dlls/dbghelp/stabs.c	5 May 2005 16:23:12 -0000
@@ -33,7 +33,9 @@
 
 #include <sys/types.h>
 #include <fcntl.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
Index: dlls/gdi/freetype.c
===================================================================
RCS file: /var/cvs/wine/dlls/gdi/freetype.c,v
retrieving revision 1.84
diff -u -p -r1.84 freetype.c
--- dlls/gdi/freetype.c	18 Apr 2005 10:30:56 -0000	1.84
+++ dlls/gdi/freetype.c	5 May 2005 16:23:28 -0000
@@ -25,7 +25,9 @@
 
 #include <stdarg.h>
 #include <stdlib.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <string.h>
 #include <dirent.h>
 #include <stdio.h>
Index: dlls/kernel/comm.c
===================================================================
RCS file: /var/cvs/wine/dlls/kernel/comm.c,v
retrieving revision 1.91
diff -u -p -r1.91 comm.c
--- dlls/kernel/comm.c	30 Mar 2005 17:08:34 -0000	1.91
+++ dlls/kernel/comm.c	5 May 2005 16:23:45 -0000
@@ -65,7 +65,9 @@
 #endif
 #include <errno.h>
 #include <ctype.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_SYS_FILIO_H
 # include <sys/filio.h>
 #endif
Index: dlls/kernel/kernel_main.c
===================================================================
RCS file: /var/cvs/wine/dlls/kernel/kernel_main.c,v
retrieving revision 1.67
diff -u -p -r1.67 kernel_main.c
--- dlls/kernel/kernel_main.c	27 Apr 2005 11:08:47 -0000	1.67
+++ dlls/kernel/kernel_main.c	5 May 2005 16:24:08 -0000
@@ -25,7 +25,9 @@
 #include <ctype.h>
 #include <stdarg.h>
 #include <string.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <signal.h>
 
 #include "windef.h"
Index: dlls/kernel/oldconfig.c
===================================================================
RCS file: /var/cvs/wine/dlls/kernel/oldconfig.c,v
retrieving revision 1.1
diff -u -p -r1.1 oldconfig.c
--- dlls/kernel/oldconfig.c	20 Apr 2005 15:43:36 -0000	1.1
+++ dlls/kernel/oldconfig.c	5 May 2005 16:24:40 -0000
@@ -27,7 +27,9 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <fcntl.h>
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
Index: dlls/kernel/vxd.c
===================================================================
RCS file: /var/cvs/wine/dlls/kernel/vxd.c,v
retrieving revision 1.15
diff -u -p -r1.15 vxd.c
--- dlls/kernel/vxd.c	18 Aug 2004 00:04:58 -0000	1.15
+++ dlls/kernel/vxd.c	5 May 2005 16:24:48 -0000
@@ -28,7 +28,9 @@
 # include <unistd.h>
 #endif
 #include <sys/types.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <string.h>
 #include <stdarg.h>
 
Index: dlls/msacm/winemp3/common.c
===================================================================
RCS file: /var/cvs/wine/dlls/msacm/winemp3/common.c,v
retrieving revision 1.2
diff -u -p -r1.2 common.c
--- dlls/msacm/winemp3/common.c	8 Dec 2003 21:47:50 -0000	1.2
+++ dlls/msacm/winemp3/common.c	5 May 2005 16:25:12 -0000
@@ -16,12 +16,15 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "config.h"
 #include <ctype.h>
 #include <stdlib.h>
 #include <signal.h>
 
 #include <sys/types.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <fcntl.h>
 
 #include "mpg123.h"
Index: dlls/ntdll/cdrom.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/cdrom.c,v
retrieving revision 1.51
diff -u -p -r1.51 cdrom.c
--- dlls/ntdll/cdrom.c	2 Mar 2005 12:23:22 -0000	1.51
+++ dlls/ntdll/cdrom.c	5 May 2005 16:25:31 -0000
@@ -34,7 +34,9 @@
 # include <unistd.h>
 #endif
 #include <fcntl.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <sys/types.h>
 
 #ifdef HAVE_SYS_IOCTL_H
Index: dlls/ntdll/directory.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/directory.c,v
retrieving revision 1.24
diff -u -p -r1.24 directory.c
--- dlls/ntdll/directory.c	16 Mar 2005 19:48:42 -0000	1.24
+++ dlls/ntdll/directory.c	5 May 2005 16:25:41 -0000
@@ -34,7 +34,9 @@
 #ifdef HAVE_MNTENT_H
 #include <mntent.h>
 #endif
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
Index: dlls/ntdll/path.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/path.c,v
retrieving revision 1.28
diff -u -p -r1.28 path.c
--- dlls/ntdll/path.c	13 Aug 2004 23:53:44 -0000	1.28
+++ dlls/ntdll/path.c	5 May 2005 16:25:49 -0000
@@ -23,7 +23,9 @@
 
 #include <stdarg.h>
 #include <sys/types.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 
 #include "windef.h"
 #include "winbase.h"
Index: dlls/ntdll/server.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/server.c,v
retrieving revision 1.20
diff -u -p -r1.20 server.c
--- dlls/ntdll/server.c	20 Apr 2005 13:12:14 -0000	1.20
+++ dlls/ntdll/server.c	5 May 2005 16:26:01 -0000
@@ -43,7 +43,9 @@
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_SYS_UIO_H
 #include <sys/uio.h>
 #endif
Index: dlls/shell32/shfldr_unixfs.c
===================================================================
RCS file: /var/cvs/wine/dlls/shell32/shfldr_unixfs.c,v
retrieving revision 1.7
diff -u -p -r1.7 shfldr_unixfs.c
--- dlls/shell32/shfldr_unixfs.c	27 Apr 2005 08:12:08 -0000	1.7
+++ dlls/shell32/shfldr_unixfs.c	5 May 2005 16:26:36 -0000
@@ -18,12 +18,17 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <stdarg.h>
 #include <limits.h>
 #include <dirent.h>
-#include <sys/stat.h>
-#include <pwd.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_PWD_H
+# include <pwd.h>
+#endif
 #include <grp.h>
 
 #define COBJMACROS
Index: dlls/winaspi/winaspi16.c
===================================================================
RCS file: /var/cvs/wine/dlls/winaspi/winaspi16.c,v
retrieving revision 1.39
diff -u -p -r1.39 winaspi16.c
--- dlls/winaspi/winaspi16.c	9 Jan 2005 16:52:50 -0000	1.39
+++ dlls/winaspi/winaspi16.c	5 May 2005 16:28:32 -0000
@@ -23,7 +23,9 @@
 #include <sys/types.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <memory.h>
+#ifdef HAVE_MEMORY_H
+# include <memory.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
Index: dlls/winaspi/winaspi32.c
===================================================================
RCS file: /var/cvs/wine/dlls/winaspi/winaspi32.c,v
retrieving revision 1.31
diff -u -p -r1.31 winaspi32.c
--- dlls/winaspi/winaspi32.c	24 Mar 2005 21:01:36 -0000	1.31
+++ dlls/winaspi/winaspi32.c	5 May 2005 16:28:42 -0000
@@ -26,7 +26,9 @@
 #include <sys/types.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <memory.h>
+#ifdef HAVE_MEMORY_H
+# include <memory.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
Index: dlls/winedos/int21.c
===================================================================
RCS file: /var/cvs/wine/dlls/winedos/int21.c,v
retrieving revision 1.77
diff -u -p -r1.77 int21.c
--- dlls/winedos/int21.c	18 Apr 2005 10:30:55 -0000	1.77
+++ dlls/winedos/int21.c	5 May 2005 16:26:59 -0000
@@ -28,7 +28,9 @@
 
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
Index: dlls/winedos/module.c
===================================================================
RCS file: /var/cvs/wine/dlls/winedos/module.c,v
retrieving revision 1.48
diff -u -p -r1.48 module.c
--- dlls/winedos/module.c	5 May 2005 10:32:54 -0000	1.48
+++ dlls/winedos/module.c	5 May 2005 16:27:09 -0000
@@ -33,7 +33,9 @@
 # include <unistd.h>
 #endif
 #include <sys/types.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
 #endif
Index: dlls/winedos/ppdev.c
===================================================================
RCS file: /var/cvs/wine/dlls/winedos/ppdev.c,v
retrieving revision 1.5
diff -u -p -r1.5 ppdev.c
--- dlls/winedos/ppdev.c	10 Feb 2005 19:19:35 -0000	1.5
+++ dlls/winedos/ppdev.c	5 May 2005 16:27:22 -0000
@@ -27,7 +27,9 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 #ifdef HAVE_SYS_IOCTL_H
Index: dlls/winedos/vxd.c
===================================================================
RCS file: /var/cvs/wine/dlls/winedos/vxd.c,v
retrieving revision 1.9
diff -u -p -r1.9 vxd.c
--- dlls/winedos/vxd.c	2 Mar 2005 13:53:51 -0000	1.9
+++ dlls/winedos/vxd.c	5 May 2005 16:28:57 -0000
@@ -22,7 +22,9 @@
 #include "wine/port.h"
 
 #include <fcntl.h>
-#include <memory.h>
+#ifdef HAVE_MEMORY_H
+# include <memory.h>
+#endif
 #include <stdarg.h>
 #include <stdio.h>
 #include <sys/types.h>
Index: dlls/winsock/socket.c
===================================================================
RCS file: /var/cvs/wine/dlls/winsock/socket.c,v
retrieving revision 1.178
diff -u -p -r1.178 socket.c
--- dlls/winsock/socket.c	5 May 2005 09:49:43 -0000	1.178
+++ dlls/winsock/socket.c	5 May 2005 14:43:31 -0000
@@ -99,7 +99,9 @@
 # define HAVE_IPX
 #endif
 #ifdef HAVE_IPX_LINUX
-# include <asm/types.h>
+# ifdef HAVE_ASM_TYPES_H
+#  include <asm/types.h>
+# endif
 # include <linux/ipx.h>
 # define HAVE_IPX
 #endif
Index: loader/preloader.c
===================================================================
RCS file: /var/cvs/wine/loader/preloader.c,v
retrieving revision 1.14
diff -u -p -r1.14 preloader.c
--- loader/preloader.c	15 Apr 2005 16:13:49 -0000	1.14
+++ loader/preloader.c	5 May 2005 16:27:46 -0000
@@ -68,7 +68,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
-#include <sys/stat.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
 #include <fcntl.h>
 #ifdef HAVE_SYS_MMAN_H
 # include <sys/mman.h>


More information about the wine-patches mailing list