From c7b36b9550a66a033d42152741bf7e3f4927cb39 Mon Sep 17 00:00:00 2001
From: Fabrice Popineau <fabrice.popineau@gmail.com>
Date: Fri, 30 Nov 2012 17:14:22 +0200
Subject: [PATCH] Fix compilation problems with 64-bit MSVC compiler.

 src/w32fns.c: Remove prototype of atof.
 (syspage_mask): Declared DWORD_PTR, for compatibility with 64-bit
 builds.
 (file_dialog_callback): Declared UINT_PTR.
 src/w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility
 with 64-bit builds.
 src/w32.c (FILE_DEVICE_FILE_SYSTEM, METHOD_BUFFERED)
 (FILE_ANY_ACCESS, CTL_CODE) [_MSC_VER]: Define only if not already
 defined.
---
 src/ChangeLog   | 14 ++++++++++++++
 src/w32.c       |  8 ++++++++
 src/w32common.h |  2 +-
 src/w32fns.c    |  5 ++---
 4 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index a1d09e683c3..48776fcbdc7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
+2012-11-30  Fabrice Popineau  <fabrice.popineau@gmail.com>
+
+	* w32fns.c: Remove prototype of atof.
+	(syspage_mask): Declared DWORD_PTR, for compatibility with 64-bit
+	builds.
+	(file_dialog_callback): Declared UINT_PTR.
+
+	* w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility
+	with 64-bit builds.
+
+	* w32.c (FILE_DEVICE_FILE_SYSTEM, METHOD_BUFFERED)
+	(FILE_ANY_ACCESS, CTL_CODE) [_MSC_VER]: Define only if not already
+	defined.
+
 2012-11-27  Glenn Morris  <rgm@gnu.org>
 
 	* data.c (Fboundp, Fsymbol_value): Doc fix re lexical-binding.
diff --git a/src/w32.c b/src/w32.c
index 1c3331516d4..f5630993d43 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -150,10 +150,18 @@ typedef struct _REPARSE_DATA_BUFFER {
     } DUMMYUNIONNAME;
 } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
 
+#ifndef FILE_DEVICE_FILE_SYSTEM
 #define FILE_DEVICE_FILE_SYSTEM	9
+#endif
+#ifndef METHOD_BUFFERED
 #define METHOD_BUFFERED	        0
+#endif
+#ifndef FILE_ANY_ACCESS
 #define FILE_ANY_ACCESS	        0x00000000
+#endif
+#ifndef CTL_CODE
 #define CTL_CODE(t,f,m,a)       (((t)<<16)|((a)<<14)|((f)<<2)|(m))
+#endif
 #define FSCTL_GET_REPARSE_POINT \
   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
 #endif
diff --git a/src/w32common.h b/src/w32common.h
index 50724e5553c..5e9b61824ae 100644
--- a/src/w32common.h
+++ b/src/w32common.h
@@ -34,7 +34,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 extern SYSTEM_INFO    sysinfo_cache;
 extern OSVERSIONINFO  osinfo_cache;
-extern unsigned long  syspage_mask;
+extern DWORD_PTR      syspage_mask;
 
 extern int    	      w32_major_version;
 extern int    	      w32_minor_version;
diff --git a/src/w32fns.c b/src/w32fns.c
index d598d66b3a5..8e1ecc1cb00 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -80,7 +80,6 @@ void syms_of_w32fns (void);
 void globals_of_w32fns (void);
 
 extern void free_frame_menubar (struct frame *);
-extern double atof (const char *);
 extern int w32_console_toggle_lock_key (int, Lisp_Object);
 extern void w32_menu_display_help (HWND, HMENU, UINT, UINT);
 extern void w32_free_menu_strings (HWND);
@@ -221,7 +220,7 @@ SYSTEM_INFO sysinfo_cache;
 /* This gives us version, build, and platform identification.  */
 OSVERSIONINFO osinfo_cache;
 
-unsigned long syspage_mask = 0;
+DWORD_PTR syspage_mask = 0;
 
 /* The major and minor versions of NT.  */
 int w32_major_version;
@@ -6019,7 +6018,7 @@ typedef char guichar_t;
    read-only when "Directories" is selected in the filter.  This
    allows us to work around the fact that the standard Open File
    dialog does not support directories.  */
-static UINT CALLBACK
+static UINT_PTR CALLBACK
 file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   if (msg == WM_NOTIFY)
-- 
2.39.5