=== modified file 'lib-src/etags.c'
--- lib-src/etags.c	2012-01-19 07:21:25 +0000
+++ lib-src/etags.c	2012-02-27 23:33:17 +0000
@@ -140,6 +140,7 @@
 #ifdef WINDOWSNT
 # include <fcntl.h>
 # include <direct.h>
+# define getcwd _getcwd
 # include <io.h>
 # define MAXPATHLEN _MAX_PATH
 # undef HAVE_NTGUI

=== modified file 'lib/strftime.c'
--- lib/strftime.c	2011-03-31 04:24:03 +0000
+++ lib/strftime.c	2011-12-05 13:09:35 +0000
@@ -36,9 +36,13 @@
 #include <ctype.h>
 #include <time.h>
 
+#ifdef _MSC_VER
+#define tzname _tzname
+#else
 #if HAVE_TZNAME && !HAVE_DECL_TZNAME
 extern char *tzname[];
 #endif
+#endif
 
 /* Do multibyte processing if multibytes are supported, unless
    multibyte sequences are safe in formats.  Multibyte sequences are

=== modified file 'lisp/term/w32-win.el'
--- lisp/term/w32-win.el	2012-01-19 07:21:25 +0000
+++ lisp/term/w32-win.el	2012-02-05 20:06:34 +0000
@@ -192,20 +192,20 @@
 ;;; Set default known names for external libraries
 (setq dynamic-library-alist
       (list
-       '(xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
+       '(xpm "xt19xpm.dll" "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
        ;; Versions of libpng 1.4.x and later are incompatible with
        ;; earlier versions.  Set up the list of libraries according to
        ;; the version we were compiled against.  (If we were compiled
        ;; without PNG support, libpng-version's value is -1.)
        (if (>= libpng-version 10400)
 	   ;; libpng14-14.dll is libpng 1.4.3 from GTK+
-	   '(png "libpng14-14.dll" "libpng14.dll")
-	 '(png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll"
+	   '(png "xt19png.dll" "libpng14-14.dll" "libpng14.dll")
+	 '(png "xt19png.dll" "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll"
 	       ;; these are libpng 1.2.8 from GTK+
 	       "libpng13d.dll" "libpng13.dll"))
-       '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
-       '(tiff "libtiff3.dll" "libtiff.dll")
-       '(gif "giflib4.dll" "libungif4.dll" "libungif.dll")
+       '(jpeg "xt19jpeg.dll" "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
+       '(tiff "xt19tiff.dll" "libtiff3.dll" "libtiff.dll")
+       '(gif "xt19gif.dll" "giflib4.dll" "libungif4.dll" "libungif.dll")
        '(svg "librsvg-2-2.dll")
        '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
        '(glib "libglib-2.0-0.dll")

=== modified file 'nt/addsection.c'
--- nt/addsection.c	2012-01-19 07:21:25 +0000
+++ nt/addsection.c	2012-02-05 20:06:34 +0000
@@ -36,9 +36,9 @@
 
 PIMAGE_NT_HEADERS
 (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
-				     DWORD FileLength,
-				     LPDWORD HeaderSum,
-				     LPDWORD CheckSum);
+				     DWORD_PTR FileLength,
+				     PDWORD_PTR HeaderSum,
+				     PDWORD_PTR CheckSum);
 
 #undef min
 #undef max
@@ -164,7 +164,7 @@
 /* Return pointer to section header for section containing the given
    relative virtual address. */
 IMAGE_SECTION_HEADER *
-rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
+rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
 {
   PIMAGE_SECTION_HEADER section;
   int i;
@@ -179,7 +179,7 @@
 	 some very old exes (eg. gzip dated Dec 1993).  Since
 	 w32_executable_type relies on this function to work reliably,
 	 we need to cope with this.  */
-      DWORD real_size = max (section->SizeOfRawData,
+      DWORD_PTR real_size = max (section->SizeOfRawData,
 			     section->Misc.VirtualSize);
       if (rva >= section->VirtualAddress
 	  && rva < section->VirtualAddress + real_size)
@@ -192,7 +192,7 @@
 /* Return pointer to section header for section containing the given
    offset in its raw data area. */
 IMAGE_SECTION_HEADER *
-offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
+offset_to_section (DWORD_PTR offset, IMAGE_NT_HEADERS * nt_header)
 {
   PIMAGE_SECTION_HEADER section;
   int i;
@@ -212,8 +212,8 @@
 /* Return offset to an object in dst, given offset in src.  We assume
    there is at least one section in both src and dst images, and that
    the some sections may have been added to dst (after sections in src).  */
-static DWORD
-relocate_offset (DWORD offset,
+static DWORD_PTR
+relocate_offset (DWORD_PTR offset,
 		 IMAGE_NT_HEADERS * src_nt_header,
 		 IMAGE_NT_HEADERS * dst_nt_header)
 {
@@ -247,32 +247,32 @@
 }
 
 #define OFFSET_TO_RVA(offset, section) \
-	  (section->VirtualAddress + ((DWORD)(offset) - section->PointerToRawData))
+	  (section->VirtualAddress + ((DWORD_PTR)(offset) - section->PointerToRawData))
 
 #define RVA_TO_OFFSET(rva, section) \
-	  (section->PointerToRawData + ((DWORD)(rva) - section->VirtualAddress))
+	  (section->PointerToRawData + ((DWORD_PTR)(rva) - section->VirtualAddress))
 
 #define RVA_TO_SECTION_OFFSET(rva, section) \
-	  ((DWORD)(rva) - section->VirtualAddress)
+	  ((DWORD_PTR)(rva) - section->VirtualAddress)
 
 /* Convert address in executing image to RVA.  */
-#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
+#define PTR_TO_RVA(ptr) ((DWORD_PTR)(ptr) - (DWORD_PTR) GetModuleHandle (NULL))
 
 #define PTR_TO_OFFSET(ptr, pfile_data) \
           ((unsigned const char *)(ptr) - (pfile_data)->file_base)
 
 #define OFFSET_TO_PTR(offset, pfile_data) \
-          ((pfile_data)->file_base + (DWORD)(offset))
+          ((pfile_data)->file_base + (DWORD_PTR)(offset))
 
-#define ROUND_UP(p, align)   (((DWORD)(p) + (align)-1) & ~((align)-1))
-#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))
+#define ROUND_UP(p, align)   (((DWORD_PTR)(p) + (align)-1) & ~((align)-1))
+#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((align)-1))
 
 
 static void
 copy_executable_and_add_section (file_data *p_infile,
 				 file_data *p_outfile,
 				 const char *new_section_name,
-				 DWORD new_section_size)
+				 DWORD_PTR new_section_size)
 {
   unsigned char *dst;
   PIMAGE_DOS_HEADER dos_header;
@@ -280,7 +280,7 @@
   PIMAGE_NT_HEADERS dst_nt_header;
   PIMAGE_SECTION_HEADER section;
   PIMAGE_SECTION_HEADER dst_section;
-  DWORD offset;
+  DWORD_PTR offset;
   int i;
   int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
 
@@ -324,10 +324,10 @@
   dst = (unsigned char *) p_outfile->file_base;
 
   COPY_CHUNK ("Copying DOS header...", dos_header,
-	      (DWORD) nt_header - (DWORD) dos_header, be_verbose);
+	      (DWORD_PTR) nt_header - (DWORD_PTR) dos_header, be_verbose);
   dst_nt_header = (PIMAGE_NT_HEADERS) dst;
   COPY_CHUNK ("Copying NT header...", nt_header,
-	      (DWORD) section - (DWORD) nt_header, be_verbose);
+	      (DWORD_PTR) section - (DWORD_PTR) nt_header, be_verbose);
   dst_section = (PIMAGE_SECTION_HEADER) dst;
   COPY_CHUNK ("Copying section table...", section,
 	      nt_header->FileHeader.NumberOfSections * sizeof (*section),
@@ -509,8 +509,8 @@
   /* Patch up header fields; profiler is picky about this. */
   {
     HANDLE hImagehelp = LoadLibrary ("imagehlp.dll");
-    DWORD  headersum;
-    DWORD  checksum;
+    DWORD_PTR  headersum;
+    DWORD_PTR  checksum;
 
     dos_header = (PIMAGE_DOS_HEADER) out_file.file_base;
     nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew);

=== modified file 'nt/config.nt'
--- nt/config.nt	2012-02-27 03:20:00 +0000
+++ nt/config.nt	2012-02-28 06:40:01 +0000
@@ -433,7 +433,11 @@
 
    See m/template.h for documentation on writing m/MACHINE.h files.  */
 #undef config_machfile
+#ifdef _WIN64
+#include "m/amdx86-64.h"
+#else
 #include "m/intel386.h"
+#endif
 
 /* Define `subprocesses' should be defined if you want to
    have code for asynchronous subprocesses

=== modified file 'nt/configure.bat'
--- nt/configure.bat	2012-01-19 07:21:25 +0000
+++ nt/configure.bat	2012-02-05 20:06:34 +0000
@@ -96,8 +96,8 @@
 set profile=N
 set nocygwin=N
 set COMPILER=
-set usercflags=
-set escusercflags=
+set usercflags=-I../src -I../nt/inc -I../lib -Ic:/source/XEmTeX/source/libs/w32compat -Ic:/source/XEmTeX/source/libs/zlib-1.2.5 -Ic:/source/XEmTeX/source/libs/libpng-1.5.4 -Ic:/source/XEmTeX/source/libs/jpeg-8b -Ic:/source/XEmTeX/source/libs/tiff-3.9.5/libtiff -Ic:/source/XEmTeX/source/libs/giflib-4.1.6/lib -Ic:/source/XEmTeX/source/libs/xpm-3.4k -Ic:/source/XEmTeX/source/libs/xpm-3.4k/lib
+set escusercflags=-I../src -I../nt/inc -I../lib -Ic:/source/XEmTeX/source/libs/w32compat -Ic:/source/XEmTeX/source/libs/zlib-1.2.5 -Ic:/source/XEmTeX/source/libs/libpng-1.5.4 -Ic:/source/XEmTeX/source/libs/jpeg-8b -Ic:/source/XEmTeX/source/libs/tiff-3.9.5/libtiff -Ic:/source/XEmTeX/source/libs/giflib-4.1.6/lib -Ic:/source/XEmTeX/source/libs/xpm-3.4k -Ic:/source/XEmTeX/source/libs/xpm-3.4k/lib
 set docflags=
 set userldflags=
 set escuserldflags=

=== modified file 'nt/emacs.rc'
--- nt/emacs.rc	2012-02-27 03:20:00 +0000
+++ nt/emacs.rc	2012-02-28 06:40:01 +0000
@@ -1,6 +1,10 @@
 Emacs ICON   icons\emacs.ico
 32649 CURSOR icons\hand.cur
-1 24 "emacs.manifest"
+#ifdef WIN64
+1 24 "emacs-x64.manifest"
+#else
+1 24 "emacs-x86.manifest"
+#endif
 
 #ifndef VS_VERSION_INFO
 #define VS_VERSION_INFO 1

=== modified file 'nt/inc/sys/socket.h'
--- nt/inc/sys/socket.h	2012-01-19 07:21:25 +0000
+++ nt/inc/sys/socket.h	2012-02-27 23:33:16 +0000
@@ -126,42 +126,147 @@
 extern int h_errno;
 
 /* map winsock error codes to standard names */
+#if defined(EWOULDBLOCK)
+#undef EWOULDBLOCK
+#endif
 #define EWOULDBLOCK             WSAEWOULDBLOCK
+#if defined(EINPROGRESS)
+#undef EINPROGRESS
+#endif
 #define EINPROGRESS             WSAEINPROGRESS
+#if defined(EALREADY)
+#undef EALREADY
+#endif
 #define EALREADY                WSAEALREADY
+#if defined(ENOTSOCK)
+#undef ENOTSOCK
+#endif
 #define ENOTSOCK                WSAENOTSOCK
+#if defined(EDESTADDRREQ)
+#undef EDESTADDRREQ
+#endif
 #define EDESTADDRREQ            WSAEDESTADDRREQ
+#if defined(EMSGSIZE)
+#undef EMSGSIZE
+#endif
 #define EMSGSIZE                WSAEMSGSIZE
+#if defined(EPROTOTYPE)
+#undef EPROTOTYPE
+#endif
 #define EPROTOTYPE              WSAEPROTOTYPE
+#if defined(ENOPROTOOPT)
+#undef ENOPROTOOPT
+#endif
 #define ENOPROTOOPT             WSAENOPROTOOPT
+#if defined(EPROTONOSUPPORT)
+#undef EPROTONOSUPPORT
+#endif
 #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
+#if defined(ESOCKTNOSUPPORT)
+#undef ESOCKTNOSUPPORT
+#endif
 #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
+#if defined(EOPNOTSUPP)
+#undef EOPNOTSUPP
+#endif
 #define EOPNOTSUPP              WSAEOPNOTSUPP
+#if defined(EPFNOSUPPORT)
+#undef EPFNOSUPPORT
+#endif
 #define EPFNOSUPPORT            WSAEPFNOSUPPORT
+#if defined(EAFNOSUPPORT)
+#undef EAFNOSUPPORT
+#endif
 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
+#if defined(EADDRINUSE)
+#undef EADDRINUSE
+#endif
 #define EADDRINUSE              WSAEADDRINUSE
+#if defined(EADDRNOTAVAIL)
+#undef EADDRNOTAVAIL
+#endif
 #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
+#if defined(ENETDOWN)
+#undef ENETDOWN
+#endif
 #define ENETDOWN                WSAENETDOWN
+#if defined(ENETUNREACH)
+#undef ENETUNREACH
+#endif
 #define ENETUNREACH             WSAENETUNREACH
+#if defined(ENETRESET)
+#undef ENETRESET
+#endif
 #define ENETRESET               WSAENETRESET
+#if defined(ECONNABORTED)
+#undef ECONNABORTED
+#endif
 #define ECONNABORTED            WSAECONNABORTED
+#if defined(ECONNRESET)
+#undef ECONNRESET
+#endif
 #define ECONNRESET              WSAECONNRESET
+#if defined(ENOBUFS)
+#undef ENOBUFS
+#endif
 #define ENOBUFS                 WSAENOBUFS
+#if defined(EISCONN)
+#undef EISCONN
+#endif
 #define EISCONN                 WSAEISCONN
+#if defined(ENOTCONN)
+#undef ENOTCONN
+#endif
 #define ENOTCONN                WSAENOTCONN
+#if defined(ESHUTDOWN)
+#undef ESHUTDOWN
+#endif
 #define ESHUTDOWN               WSAESHUTDOWN
+#if defined(ETOOMANYREFS)
+#undef ETOOMANYREFS
+#endif
 #define ETOOMANYREFS            WSAETOOMANYREFS
+#if defined(ETIMEDOUT)
+#undef ETIMEDOUT
+#endif
 #define ETIMEDOUT               WSAETIMEDOUT
+#if defined(ECONNREFUSED)
+#undef ECONNREFUSED
+#endif
 #define ECONNREFUSED            WSAECONNREFUSED
+#if defined(ELOOP)
+#undef ELOOP
+#endif
 #define ELOOP                   WSAELOOP
 /* #define ENAMETOOLONG            WSAENAMETOOLONG */
+#if defined(EHOSTDOWN)
+#undef EHOSTDOWN
+#endif
 #define EHOSTDOWN               WSAEHOSTDOWN
+#if defined(EHOSTUNREACH)
+#undef EHOSTUNREACH
+#endif
 #define EHOSTUNREACH            WSAEHOSTUNREACH
 /* #define ENOTEMPTY               WSAENOTEMPTY */
+#if defined(EPROCLIM)
+#undef EPROCLIM
+#endif
 #define EPROCLIM                WSAEPROCLIM
+#if defined(EUSERS)
+#undef EUSERS
+#endif
 #define EUSERS                  WSAEUSERS
+#if defined(EDQUOT)
+#undef EDQUOT
+#endif
 #define EDQUOT                  WSAEDQUOT
+#if defined(ESTALE)
+#undef ESTALE
+#endif
 #define ESTALE                  WSAESTALE
+#if defined(EREMOTE)
+#undef EREMOTE
+#endif
 #define EREMOTE                 WSAEREMOTE
 
 #endif /* _SOCKET_H_ */

=== modified file 'nt/nmake.defs'
--- nt/nmake.defs	2012-02-05 20:40:36 +0000
+++ nt/nmake.defs	2012-02-19 21:54:33 +0000
@@ -86,7 +86,11 @@
 !    if "$(PROCESSOR_ARCHITECTURE)" == "PPC"
 ARCH		= ppc
 !    else
-!     error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
+!     if "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
+ARCH		= AMD64
+!     else
+!      error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
+!     endif
 !    endif
 !   endif
 !  endif
@@ -105,11 +109,11 @@
 CC_OUT		= -Fo
 LINK		= link
 LINK_OUT	= -out:
-RC		= rc
+RC		= rc $(ARCH_RCFLAGS)
 RC_OUT		= -Fo
 RC_INCLUDE	= -i
 
-USE_CRT_DLL	= 1
+# USE_CRT_DLL	= 1
 
 !ifdef USE_CRT_DLL
 libc		= msvcrt$(D).lib
@@ -151,20 +155,17 @@
 !endif
 
 CFLAGS          = -I. $(ARCH_CFLAGS) \
+		  -D_CRT_SECURE_NO_WARNINGS \
 		  $(DEBUG_CFLAGS) $(CHECKING_CFLAGS) $(USER_CFLAGS) $(LOCAL_FLAGS)
 ESC_CFLAGS      = -I. $(ARCH_CFLAGS) \
+		  -D_CRT_SECURE_NO_WARNINGS \
 		  $(DEBUG_CFLAGS) $(CHECKING_CFLAGS) $(ESC_USER_CFLAGS) $(LOCAL_FLAGS)
 
 #SYS_LDFLAGS	= -nologo -release -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
-!ifdef NOOPT
-SYS_LDFLAGS	= -nologo -manifest -dynamicbase:no -debug -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
-!else
-SYS_LDFLAGS	= -nologo -manifest -dynamicbase:no -release -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
-!endif
+SYS_LDFLAGS	= -nologo -manifest -dynamicbase:no -incremental:no -version:5.10 -swaprun:cd -swaprun:net setargv.obj
 
 # see comments in allocate_heap in w32heap.c before changing any of the
-# -stack, -heap, or -base settings.
-TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -pdb:$(BLD)\temacs.pdb -machine:$(ARCH) $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
+TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -pdb:$(BLD)\temacs.pdb -machine:$(TARGET_CPU) $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
 
 !ifdef NOOPT
 OBJDIR          = obj
@@ -195,7 +196,7 @@
 
 !ifdef NODEBUG
 DEBUG_FLAG =
-DEBUG_LINK =
+DEBUG_LINK = -release
 D =
 !else
 DEBUG_FLAG = -Zi
@@ -233,15 +234,28 @@
 !else
 !if "$(ARCH)" == "ppc"
 # These flags are a guess...if they don't work, please send me mail.
-ARCH_CFLAGS	= -D_PPC_=1 -c -Ze -Zi -W2 -Od
 ARCH_LDFLAGS	= $(SYS_LDFLAGS)
 
 !else
+!if "$(ARCH)" == "AMD64"
+# These flags are a guess...if they don't work, please send me mail.
+!ifdef NOOPT
+#ARCH_CFLAGS     = -nologo -c -Zel -W2 -H63 -Od -G3d -Zp8 $(DEBUG_FLAG)
+ARCH_CFLAGS     = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -Od -Gd $(DEBUG_FLAG)
+!else
+#ARCH_CFLAGS     = -nologo -c -Zel -W2 -H63 -Oxsb2 -Oy- -G6dF -Zp8 $(DEBUG_FLAG)
+ARCH_CFLAGS     = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -Oi -Ot -Oy- -Ob2 -GF -Gy -Gd $(DEBUG_FLAG)
+!endif
+ARCH_LDFLAGS	= $(SYS_LDFLAGS) -machine:x64
+ARCH_RCFLAGS	= -DWIN64
+
+!else
 !ERROR Unknown architecture type "$(ARCH)".
 !endif
 !endif
 !endif
 !endif
+!endif
 
 LINK_FLAGS	= $(ARCH_LDFLAGS) $(DEBUG_LINK) $(USER_LDFLAGS)
 

=== modified file 'src/alloc.c'
--- src/alloc.c	2012-02-26 01:09:59 +0000
+++ src/alloc.c	2012-02-28 06:40:01 +0000
@@ -64,6 +64,7 @@
 
 #ifdef WINDOWSNT
 #include "w32.h"
+#include "w32heap.h"
 #endif
 
 #ifdef DOUG_LEA_MALLOC
@@ -1150,7 +1151,7 @@
 
   if (2 > (intptr_t) ABLOCKS_BUSY (abase))
     { /* All the blocks are free.  */
-      int i = 0, aligned = (intptr_t) ABLOCKS_BUSY (abase);
+      int i = 0, aligned = (ABLOCKS_BUSY (abase) != NULL);
       struct ablock **tem = &free_ablock;
       struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1];
 
@@ -2982,7 +2983,7 @@
 /* Allocate other vector-like structures.  */
 
 struct Lisp_Vector *
-allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag)
+allocate_pseudovector (size_t memlen, size_t lisplen, EMACS_INT tag)
 {
   struct Lisp_Vector *v = allocate_vectorlike (memlen);
   int i;
@@ -5056,13 +5057,13 @@
 	    /* If a buffer's gap size is more than 10% of the buffer
 	       size, or larger than 2000 bytes, then shrink it
 	       accordingly.  Keep a minimum size of 20 bytes.  */
-	    int size = min (2000, max (20, (nextb->text->z_byte / 10)));
+	    size_t size = min (2000, max (20, (nextb->text->z_byte / 10)));
 
 	    if (nextb->text->gap_size > size)
 	      {
 		struct buffer *save_current = current_buffer;
 		current_buffer = nextb;
-		make_gap (-(nextb->text->gap_size - size));
+		make_gap ((size - nextb->text->gap_size));
 		current_buffer = save_current;
 	      }
 	  }

=== modified file 'src/coding.c'
--- src/coding.c	2012-02-09 07:48:22 +0000
+++ src/coding.c	2012-02-27 23:33:18 +0000
@@ -298,6 +298,10 @@
 #include "frame.h"
 #include "termhooks.h"
 
+#ifdef WINDOWSNT
+#include "w32.h"
+#endif
+
 Lisp_Object Vcoding_system_hash_table;
 
 static Lisp_Object Qcoding_system, Qeol_type;

=== modified file 'src/dispnew.c'
--- src/dispnew.c	2012-02-04 11:29:29 +0000
+++ src/dispnew.c	2012-02-27 23:33:18 +0000
@@ -49,6 +49,7 @@
 #endif /* HAVE_X_WINDOWS */
 
 #ifdef HAVE_NTGUI
+#include "w32.h"
 #include "w32term.h"
 #endif /* HAVE_NTGUI */
 

=== modified file 'src/dosfns.c'
--- src/dosfns.c	2012-01-19 07:21:25 +0000
+++ src/dosfns.c	2012-02-05 20:06:34 +0000
@@ -542,7 +542,7 @@
       double pmem;
       EXFUN (Fget_internal_run_time, 0);
 #ifndef SYSTEM_MALLOC
-      extern unsigned long ret_lim_data ();
+      extern size_t ret_lim_data ();
 #endif
 
       uid = getuid ();
@@ -579,7 +579,7 @@
 #ifndef SYSTEM_MALLOC
       /* ret_lim_data is on vm-limit.c, which is not compiled in under
 	 SYSTEM_MALLOC.  */
-      pmem = (double)((unsigned long) sbrk (0)) / ret_lim_data () * 100.0;
+      pmem = (double)((size_t) sbrk (0)) / ret_lim_data () * 100.0;
       if (pmem > 100)
 #endif
 	pmem = 100;

=== modified file 'src/editfns.c'
--- src/editfns.c	2012-01-19 07:21:25 +0000
+++ src/editfns.c	2012-02-27 23:33:18 +0000
@@ -81,6 +81,7 @@
 #endif
 
 #ifdef WINDOWSNT
+#include "w32.h"
 extern Lisp_Object w32_get_internal_run_time (void);
 #endif
 

=== modified file 'src/fileio.c'
--- src/fileio.c	2012-02-25 09:07:23 +0000
+++ src/fileio.c	2012-02-28 06:40:01 +0000
@@ -52,6 +52,7 @@
 #define NOMINMAX 1
 #include <windows.h>
 #include <fcntl.h>
+#include "w32.h"
 #endif /* not WINDOWSNT */
 
 #ifdef MSDOS

=== modified file 'src/frame.c'
--- src/frame.c	2012-01-19 07:21:25 +0000
+++ src/frame.c	2012-02-05 20:06:34 +0000
@@ -812,6 +812,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
   if (track && FRAME_WINDOW_P (XFRAME (frame)))
     {
+      extern Lisp_Object x_get_focus_frame(struct frame *);
       Lisp_Object focus, xfocus;
 
       xfocus = x_get_focus_frame (XFRAME (frame));

=== modified file 'src/gmalloc.c'
--- src/gmalloc.c	2011-09-09 01:06:52 +0000
+++ src/gmalloc.c	2012-02-27 23:33:18 +0000
@@ -56,6 +56,7 @@
 
 #endif	/* _MALLOC_INTERNAL.  */
 
+#include <w32heap.h>
 
 #ifdef	__cplusplus
 extern "C"
@@ -459,7 +460,7 @@
      __malloc_size_t size;
 {
   __ptr_t result;
-  unsigned long int adj;
+  intptr_t adj;
 
   /* align accepts an unsigned argument, but __morecore accepts a
      signed one.  This could lead to trouble if SIZE overflows a
@@ -469,8 +470,8 @@
     result = 0;
   else
     result = (*__morecore) (size);
-  adj = (unsigned long int) ((unsigned long int) ((char *) result -
-						  (char *) NULL)) % BLOCKSIZE;
+  adj = (intptr_t) (((char *) result -
+                     (char *) NULL)) % BLOCKSIZE;
   if (adj != 0)
     {
       __ptr_t new;
@@ -539,7 +540,7 @@
   _heapinfo[block].busy.info.size = blocks;
   /* Leave back-pointers for malloc_find_address.  */
   while (--blocks > 0)
-    _heapinfo[block + blocks].busy.info.size = -blocks;
+    _heapinfo[block + blocks].busy.info.size = -((__malloc_ptrdiff_t)blocks);
 }
 
 #ifdef USE_PTHREAD
@@ -715,7 +716,7 @@
  	  /* Did it fail?  */
  	  if (newinfo == NULL)
  	    {
- 	      (*__morecore) (-size);
+ 	      (*__morecore) (-((__malloc_ptrdiff_t)size));
  	      return NULL;
  	    }
 
@@ -727,7 +728,7 @@
  	    break;
 
  	  /* Must try again.  First give back most of what we just got.  */
- 	  (*__morecore) (- newsize * sizeof (malloc_info));
+ 	  (*__morecore) (- ((ptrdiff_t)(newsize * sizeof (malloc_info))));
  	  newsize *= 2;
   	}
 
@@ -809,8 +810,8 @@
 	    next->next->prev = next->prev;
 	  block = BLOCK (result);
 	  if (--_heapinfo[block].busy.info.frag.nfree != 0)
-	    _heapinfo[block].busy.info.frag.first = (unsigned long int)
-	      ((unsigned long int) ((char *) next->next - (char *) NULL)
+	    _heapinfo[block].busy.info.frag.first = (intptr_t)
+	      (((char *) next->next - (char *) NULL)
 	       % BLOCKSIZE) >> log;
 
 	  /* Update the statistics.  */
@@ -951,7 +952,7 @@
 	 first with a negative number so you can find the first block by
 	 adding that adjustment.  */
       while (--blocks > 0)
-	_heapinfo[block + blocks].busy.info.size = -blocks;
+	_heapinfo[block + blocks].busy.info.size = -((ptrdiff_t)blocks);
     }
 
   PROTECT_MALLOC_STATE (1);
@@ -1224,7 +1225,7 @@
 	    {
 	      register __malloc_size_t bytes = blocks * BLOCKSIZE;
 	      _heaplimit -= blocks;
-	      (*__morecore) (-bytes);
+	      (*__morecore) (-((__malloc_ptrdiff_t)bytes));
 	      _heapinfo[_heapinfo[block].free.prev].free.next
 		= _heapinfo[block].free.next;
 	      _heapinfo[_heapinfo[block].free.next].free.prev
@@ -1295,8 +1296,8 @@
 	     it is the first free fragment of this block. */
 	  prev = (struct list *) ptr;
 	  _heapinfo[block].busy.info.frag.nfree = 1;
-	  _heapinfo[block].busy.info.frag.first = (unsigned long int)
-	    ((unsigned long int) ((char *) ptr - (char *) NULL)
+	  _heapinfo[block].busy.info.frag.first = (intptr_t)
+	    ((intptr_t) ((char *) ptr - (char *) NULL)
 	     % BLOCKSIZE >> type);
 	  prev->next = _fraghead[type].next;
 	  prev->prev = &_fraghead[type];
@@ -1373,6 +1374,9 @@
 #include <malloc.h>
 #endif
 
+#ifdef min
+#undef min
+#endif
 
 #define min(A, B) ((A) < (B) ? (A) : (B))
 
@@ -1689,7 +1693,7 @@
      __malloc_size_t size;
 {
   __ptr_t result;
-  unsigned long int adj, lastadj;
+  intptr_t adj, lastadj;
   __ptr_t (*hook) (__malloc_size_t, __malloc_size_t) = __memalign_hook;
 
   if (hook)
@@ -1703,7 +1707,7 @@
 
   /* Figure out how much we will need to pad this particular block
      to achieve the required alignment.  */
-  adj = (unsigned long int) ((char *) result - (char *) NULL) % alignment;
+  adj = (intptr_t) ((char *) result - (char *) NULL) % alignment;
 
   do
     {
@@ -1714,7 +1718,7 @@
 	return NULL;
 
       lastadj = adj;
-      adj = (unsigned long int) ((char *) result - (char *) NULL) % alignment;
+      adj = (intptr_t) ((char *) result - (char *) NULL) % alignment;
       /* It's conceivable we might have been so unlucky as to get a
 	 different block with weaker alignment.  If so, this block is too
 	 short to contain SIZE after alignment correction.  So we must
@@ -1904,7 +1908,7 @@
 struct hdr
   {
     __malloc_size_t size;		/* Exact size requested by user.  */
-    unsigned long int magic;	/* Magic number to check header integrity.  */
+    uint64_t magic;	/* Magic number to check header integrity.  */
   };
 
 static enum mcheck_status checkhdr (const struct hdr *);

=== modified file 'src/image.c'
--- src/image.c	2012-02-15 06:40:08 +0000
+++ src/image.c	2012-02-19 21:54:33 +0000
@@ -16,6 +16,10 @@
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#ifdef _MSC_VER
+#define _W32COMPAT_H_ 1
+#endif
+
 #include <config.h>
 #include <stdio.h>
 #include <math.h>

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2012-02-24 08:34:09 +0000
+++ src/keyboard.c	2012-02-28 06:40:01 +0000
@@ -66,6 +66,7 @@
 #endif
 
 #ifdef HAVE_NTGUI
+#include "w32.h"
 #include "w32term.h"
 #endif /* HAVE_NTGUI */
 

=== modified file 'src/lisp.h'
--- src/lisp.h	2012-02-25 19:39:42 +0000
+++ src/lisp.h	2012-02-28 06:40:01 +0000
@@ -489,7 +489,7 @@
 /* For integers known to be positive, XFASTINT provides fast retrieval
    and XSETFASTINT provides fast storage.  This takes advantage of the
    fact that Lisp_Int is 0.  */
-#define XFASTINT(a) ((a) + 0)
+#define XFASTINT(a) (((a) + 0))
 #define XSETFASTINT(a, b) ((a) = (b))
 
 /* Extract the value of a Lisp_Object as a (un)signed integer.  */
@@ -2817,7 +2817,7 @@
 EXFUN (Fmake_bool_vector, 2);
 extern Lisp_Object Qchar_table_extra_slots;
 extern struct Lisp_Vector *allocate_vector (EMACS_INT);
-extern struct Lisp_Vector *allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag);
+extern struct Lisp_Vector *allocate_pseudovector (size_t memlen, size_t lisplen, EMACS_INT tag);
 #define ALLOCATE_PSEUDOVECTOR(typ,field,tag)				\
   ((typ*)								\
    allocate_pseudovector						\

=== modified file 'src/lread.c'
--- src/lread.c	2012-01-26 06:30:49 +0000
+++ src/lread.c	2012-02-27 23:33:18 +0000
@@ -44,6 +44,10 @@
 #include "msdos.h"
 #endif
 
+#ifdef WINDOWSNT
+#include "w32.h"
+#endif
+
 #include <unistd.h>
 #include <math.h>
 

=== modified file 'src/m/amdx86-64.h'
--- src/m/amdx86-64.h	2012-01-19 07:21:25 +0000
+++ src/m/amdx86-64.h	2012-02-28 07:00:30 +0000
@@ -17,7 +17,13 @@
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#define BITS_PER_LONG           64
+#ifdef _WIN64
+# define BITS_PER_LONG           32
+# define BITS_PER_LONG_LONG      64
+#else
+# define BITS_PER_LONG           64
+#endif
+
 #define BITS_PER_EMACS_INT      64
 
 /* Now define a symbol for the cpu type, if your compiler
@@ -27,9 +33,17 @@
 /* __x86_64 defined automatically.  */
 
 /* Define the type to use.  */
-#define EMACS_INT               long
-#define pI			"l"
-#define EMACS_UINT              unsigned long
+#ifdef _WIN64
+# define EMACS_INT               __int64
+# define EMACS_UINT              unsigned __int64
+# define pI			"ll"
+# define VIRT_ADDR_VARIES
+# define DATA_START 	get_data_start ()
+#else
+# define EMACS_INT               long
+# define pI			"l"
+# define EMACS_UINT              unsigned long
+#endif
 
 /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */
 #undef DATA_SEG_BITS

=== modified file 'src/makefile.w32-in'
--- src/makefile.w32-in	2012-01-19 07:21:25 +0000
+++ src/makefile.w32-in	2012-02-05 20:06:34 +0000
@@ -25,7 +25,7 @@
 EMACSLOADPATH=$(CURDIR)/../lisp
 
 # Size in MBs of the static heap in temacs.exe.
-HEAPSIZE = 27
+HEAPSIZE = 42
 
 #
 # HAVE_CONFIG_H is required by some generic gnu sources stuck into

=== modified file 'src/ralloc.c'
--- src/ralloc.c	2012-02-01 16:51:20 +0000
+++ src/ralloc.c	2012-02-27 23:33:18 +0000
@@ -24,6 +24,8 @@
 
 #ifdef emacs
 
+#define SIZE ESIZE
+
 #include <config.h>
 #include <setjmp.h>
 #include "lisp.h"		/* Needed for VALBITS.  */
@@ -76,7 +78,7 @@
 /* Declarations for working with the malloc, ralloc, and system breaks.  */
 
 /* Function to set the real break value.  */
-POINTER (*real_morecore) (long int);
+POINTER (*real_morecore) (intptr_t);
 
 /* The break value, as seen by malloc.  */
 static POINTER virtual_break_value;
@@ -95,20 +97,20 @@
 /* Macros for rounding.  Note that rounding to any value is possible
    by changing the definition of PAGE.  */
 #define PAGE (getpagesize ())
-#define ALIGNED(addr) (((unsigned long int) (addr) & (page_size - 1)) == 0)
-#define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \
+#define ALIGNED(addr) (((intptr_t) (addr) & (page_size - 1)) == 0)
+#define ROUNDUP(size) (((intptr_t) (size) + page_size - 1) \
 		       & ~(page_size - 1))
 #define ROUND_TO_PAGE(addr) (addr & (~(page_size - 1)))
 
 #define MEM_ALIGN sizeof (double)
-#define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \
+#define MEM_ROUNDUP(addr) (((intptr_t)(addr) + MEM_ALIGN - 1) \
 				   & ~(MEM_ALIGN - 1))
 
 /* The hook `malloc' uses for the function which gets more space
    from the system.  */
 
 #ifndef SYSTEM_MALLOC
-extern POINTER (*__morecore) (long int);
+extern POINTER (*__morecore) (intptr_t);
 #endif
 
 
@@ -315,7 +317,7 @@
 relinquish (void)
 {
   register heap_ptr h;
-  long excess = 0;
+  ptrdiff_t excess = 0;
 
   /* Add the amount of space beyond break_value
      in all heaps which have extend beyond break_value at all.  */
@@ -370,7 +372,7 @@
 /* Return the total size in use by relocating allocator,
    above where malloc gets space.  */
 
-long
+intptr_t
 r_alloc_size_in_use (void)
 {
   return (char *) break_value - (char *) virtual_break_value;
@@ -749,7 +751,7 @@
    GNU malloc package.  */
 
 POINTER
-r_alloc_sbrk (long int size)
+r_alloc_sbrk (ptrdiff_t size)
 {
   register bloc_ptr b;
   POINTER address;
@@ -1020,7 +1022,7 @@
    malloc must return a null pointer.  */
 
 void
-r_alloc_freeze (long int size)
+r_alloc_freeze (intptr_t size)
 {
   if (! r_alloc_initialized)
     r_alloc_init ();

=== modified file 'src/regex.c'
--- src/regex.c	2012-01-19 07:21:25 +0000
+++ src/regex.c	2012-02-27 23:33:18 +0000
@@ -161,8 +161,8 @@
   do {									     \
     if (target_multibyte)						     \
       {									     \
-	re_char *dtemp = (p) == (str2) ? (end1) : (p);			     \
-	re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \
+	const re_char *dtemp = (p) == (str2) ? (end1) : (p);			     \
+	const re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \
 	while (dtemp-- > dlimit && !CHAR_HEAD_P (*dtemp));		     \
 	c = STRING_CHAR (dtemp);					     \
       }									     \
@@ -541,8 +541,8 @@
 #define true 1
 
 static regoff_t re_match_2_internal _RE_ARGS ((struct re_pattern_buffer *bufp,
-					       re_char *string1, size_t size1,
-					       re_char *string2, size_t size2,
+					       const re_char *string1, size_t size1,
+					       const re_char *string2, size_t size2,
 					       ssize_t pos,
 					       struct re_registers *regs,
 					       ssize_t stop));
@@ -825,8 +825,8 @@
   do									\
     {									\
       re_wchar_t range_start, range_end;				\
-      re_char *rtp;							\
-      re_char *range_table_end						\
+      const re_char *rtp;							\
+      const re_char *range_table_end						\
 	= CHARSET_RANGE_TABLE_END ((range_table), (count));		\
 									\
       for (rtp = (range_table); rtp < range_table_end; rtp += 2 * 3)	\
@@ -1368,7 +1368,7 @@
 
 union fail_stack_elt
 {
-  re_char *pointer;
+  const re_char *pointer;
   /* This should be the biggest `int' that's no bigger than a pointer.  */
   long integer;
 };
@@ -1659,7 +1659,7 @@
 
 /* Subroutine declarations and macros for regex_compile.  */
 
-static reg_errcode_t regex_compile _RE_ARGS ((re_char *pattern, size_t size,
+static reg_errcode_t regex_compile _RE_ARGS ((const re_char *pattern, size_t size,
 					      reg_syntax_t syntax,
 					      struct re_pattern_buffer *bufp));
 static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg));
@@ -1669,14 +1669,14 @@
 				  int arg, unsigned char *end));
 static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc,
 				  int arg1, int arg2, unsigned char *end));
-static boolean at_begline_loc_p _RE_ARGS ((re_char *pattern,
-					   re_char *p,
-					   reg_syntax_t syntax));
-static boolean at_endline_loc_p _RE_ARGS ((re_char *p,
-					   re_char *pend,
-					   reg_syntax_t syntax));
-static re_char *skip_one_char _RE_ARGS ((re_char *p));
-static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
+static boolean at_begline_loc_p _RE_ARGS ((const re_char *pattern,
+					   const re_char *p,
+					   reg_syntax_t syntax));
+static boolean at_endline_loc_p _RE_ARGS ((const re_char *p,
+					   const re_char *pend,
+					   reg_syntax_t syntax));
+static const re_char *skip_one_char _RE_ARGS ((const re_char *p));
+static int analyse_first _RE_ARGS ((const re_char *p, const re_char *pend,
 				    char *fastmap, const int multibyte));
 
 /* Fetch the next character in the uncompiled pattern, with no
@@ -2484,9 +2484,9 @@
   /* `const' makes AIX compiler fail.  */
   unsigned char *p = pattern;
 #else
-  re_char *p = pattern;
+  const re_char *p = pattern;
 #endif
-  re_char *pend = pattern + size;
+  const re_char *pend = pattern + size;
 
   /* How to translate the characters in the pattern.  */
   RE_TRANSLATE_TYPE translate = bufp->translate;
@@ -2507,7 +2507,7 @@
 
   /* Place in the uncompiled pattern (i.e., the {) to
      which to go back if the interval is invalid.  */
-  re_char *beg_interval;
+  const re_char *beg_interval;
 
   /* Address of the place where a forward jump should go to the end of
      the containing expression.  Each alternative of an `or' -- except the
@@ -2525,9 +2525,9 @@
 
   /* These hold the values of p, pattern, and pend from the main
      pattern when we have pushed into a subpattern.  */
-  re_char *main_p IF_LINT (= NULL);
-  re_char *main_pattern IF_LINT (= NULL);
-  re_char *main_pend IF_LINT (= NULL);
+  const re_char *main_p IF_LINT (= NULL);
+  const re_char *main_pattern IF_LINT (= NULL);
+  const re_char *main_pend IF_LINT (= NULL);
 
 #ifdef DEBUG
   debug++;
@@ -2616,7 +2616,7 @@
 	{
 	case ' ':
 	  {
-	    re_char *p1 = p;
+	    const re_char *p1 = p;
 
 	    /* If there's no special whitespace regexp, treat
 	       spaces normally.  And don't try to do this recursively.  */
@@ -2837,7 +2837,7 @@
 
 	case '[':
 	  {
-	    re_char *p1;
+	    const re_char *p1;
 
 	    CLEAR_RANGE_TABLE_WORK_USED (range_table_work);
 
@@ -3215,7 +3215,7 @@
 		  }
 		else
 		  /* It's really shy.  */
-		  regnum = - bufp->re_nsub;
+		  regnum = - ((int)bufp->re_nsub);
 
 		if (COMPILE_STACK_FULL)
 		  {
@@ -3831,7 +3831,7 @@
 static boolean
 at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax)
 {
-  re_char *prev = p - 2;
+  const re_char *prev = p - 2;
   boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
 
   return
@@ -3853,9 +3853,9 @@
 static boolean
 at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax)
 {
-  re_char *next = p;
+  const re_char *next = p;
   boolean next_backslash = *next == '\\';
-  re_char *next_next = p + 1 < pend ? p + 1 : 0;
+  const re_char *next_next = p + 1 < pend ? p + 1 : 0;
 
   return
        /* Before a subexpression?  */
@@ -3931,7 +3931,7 @@
 	    3..9: <body>
 	    10: on_failure_jump 3
 	 as used for the *? operator.  */
-      re_char *p1 = p;
+      const re_char *p1 = p;
 
       switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
 	{
@@ -4521,9 +4521,9 @@
 	  /* Update STARTPOS to the previous character boundary.  */
 	  if (multibyte)
 	    {
-	      re_char *p = POS_ADDR_VSTRING (startpos) + 1;
-	      re_char *p0 = p;
-	      re_char *phead = HEAD_ADDR_VSTRING (startpos);
+	      const re_char *p = POS_ADDR_VSTRING (startpos) + 1;
+	      const re_char *p0 = p;
+	      const re_char *phead = HEAD_ADDR_VSTRING (startpos);
 
 	      /* Find the head of multibyte form.  */
 	      PREV_CHAR_BOUNDARY (p, phead);
@@ -4541,7 +4541,7 @@
 
 /* Declarations and macros for re_match_2.  */
 
-static int bcmp_translate _RE_ARGS ((re_char *s1, re_char *s2,
+static int bcmp_translate _RE_ARGS ((const re_char *s1, const re_char *s2,
                                      register ssize_t len,
                                      RE_TRANSLATE_TYPE translate,
                                      const int multibyte));
@@ -4638,7 +4638,7 @@
 
 /* If the operation is a match against one or more chars,
    return a pointer to the next operation, else return NULL.  */
-static re_char *
+static const re_char *
 skip_one_char (const re_char *p)
 {
   switch (SWITCH_ENUM_CAST (*p++))
@@ -4680,7 +4680,7 @@
 
 
 /* Jump over non-matching operations.  */
-static re_char *
+static const re_char *
 skip_noops (const re_char *p, const re_char *pend)
 {
   int mcnt;
@@ -4976,24 +4976,24 @@
   size_t reg;
 
   /* Just past the end of the corresponding string.  */
-  re_char *end1, *end2;
+  const re_char *end1, *end2;
 
   /* Pointers into string1 and string2, just past the last characters in
      each to consider matching.  */
-  re_char *end_match_1, *end_match_2;
+  const re_char *end_match_1, *end_match_2;
 
   /* Where we are in the data, and the end of the current string.  */
-  re_char *d, *dend;
+  const re_char *d, *dend;
 
   /* Used sometimes to remember where we were before starting matching
      an operator so that we can go back in case of failure.  This "atomic"
      behavior of matching opcodes is indispensable to the correctness
      of the on_failure_keep_string_jump optimization.  */
-  re_char *dfail;
+  const re_char *dfail;
 
   /* Where we are in the pattern, and the end of the pattern.  */
-  re_char *p = bufp->buffer;
-  re_char *pend = p + bufp->used;
+  const re_char *p = bufp->buffer;
+  const re_char *pend = p + bufp->used;
 
   /* We use this to map every character in the string.	*/
   RE_TRANSLATE_TYPE translate = bufp->translate;
@@ -5037,7 +5037,7 @@
      stopped matching the regnum-th subexpression.  (The zeroth register
      keeps track of what the whole pattern matches.)  */
 #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
-  re_char **regstart, **regend;
+  const re_char **regstart, **regend;
 #endif
 
   /* The following record the register info as found in the above
@@ -5046,7 +5046,7 @@
      turn happens only if we have not yet matched the entire string. */
   unsigned best_regs_set = false;
 #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
-  re_char **best_regstart, **best_regend;
+  const re_char **best_regstart, **best_regend;
 #endif
 
   /* Logically, this is `best_regend[0]'.  But we don't want to have to
@@ -5057,7 +5057,7 @@
      the end of the best match so far in a separate variable.  We
      initialize this to NULL so that when we backtrack the first time
      and need to test it, it's not garbage.  */
-  re_char *match_end = NULL;
+  const re_char *match_end = NULL;
 
 #ifdef DEBUG
   /* Counts the total number of registers pushed.  */
@@ -5484,7 +5484,7 @@
 
 	    /* Start of actual range_table, or end of bitmap if there is no
 	       range table.  */
-	    re_char *range_table IF_LINT (= NULL);
+	    const re_char *range_table IF_LINT (= NULL);
 
 	    /* Nonzero if there is a range table.  */
 	    int range_table_exists;
@@ -5626,7 +5626,7 @@
 	   followed by the numeric value of <digit> as the register number.  */
 	case duplicate:
 	  {
-	    register re_char *d2, *dend2;
+	    const register re_char *d2, *dend2;
 	    int regno = *p++;	/* Get which register to match against.  */
 	    DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno);
 
@@ -5854,7 +5854,7 @@
 	  DEBUG_PRINT3 ("EXECUTING on_failure_jump_smart %d (to %p).\n",
 			mcnt, p + mcnt);
 	  {
-	    re_char *p1 = p; /* Next operation.  */
+	    const re_char *p1 = p; /* Next operation.  */
 	    /* Here, we discard `const', making re_match non-reentrant.  */
 	    unsigned char *p2 = (unsigned char*) p + mcnt; /* Jump dest.  */
 	    unsigned char *p3 = (unsigned char*) p - 3; /* opcode location.  */
@@ -6251,7 +6251,7 @@
       IMMEDIATE_QUIT_CHECK;
       if (!FAIL_STACK_EMPTY ())
 	{
-	  re_char *str, *pat;
+	  const re_char *str, *pat;
 	  /* A restart point is known.  Restore to that state.  */
 	  DEBUG_PRINT1 ("\nFAIL:\n");
 	  POP_FAILURE_POINT (str, pat);
@@ -6309,9 +6309,9 @@
 bcmp_translate (const re_char *s1, const re_char *s2, register ssize_t len,
 		RE_TRANSLATE_TYPE translate, const int target_multibyte)
 {
-  register re_char *p1 = s1, *p2 = s2;
-  re_char *p1_end = s1 + len;
-  re_char *p2_end = s2 + len;
+  const register re_char *p1 = s1, *p2 = s2;
+  const re_char *p1_end = s1 + len;
+  const re_char *p2_end = s2 + len;
 
   /* FIXME: Checking both p1 and p2 presumes that the two strings might have
      different lengths, but relying on a single `len' would break this. -sm  */

=== modified file 'src/s/ms-w32.h'
--- src/s/ms-w32.h	2012-01-19 07:21:25 +0000
+++ src/s/ms-w32.h	2012-02-28 14:08:20 +0000
@@ -191,6 +191,14 @@
 #include <sys/timeb.h>
 #include <sys/stat.h>
 #include <signal.h>
+#include <string.h>
+#include <stdio.h>
+extern void *e_malloc(size_t);
+extern void e_free(void *);
+extern void *e_realloc(void *, size_t);
+#ifndef _CRT_ALLOCATION_DEFINED
+#define _CRT_ALLOCATION_DEFINED
+#endif
 
 /* MSVC gets link-time errors without these redirections.  */
 #define fstat(a, b) sys_fstat(a, b)
@@ -281,13 +289,14 @@
 #define utimbuf	  _utimbuf
 #endif
 #define strdup    _strdup
+#define strtoll   _strtoi64
 #define strupr    _strupr
 #define strnicmp  _strnicmp
 #define stricmp   _stricmp
 #define tzset     _tzset
 
+#if !defined (_MSC_VER) /* || (_MSC_VER < 1400) */
 #define tzname    _tzname
-#if !defined (_MSC_VER) || (_MSC_VER < 1400)
 #undef  utime
 #define utime	  _utime
 #endif
@@ -406,5 +415,12 @@
 #define DebPrint(stuff)
 #endif
 
+#ifdef _MSC_VER
+#if _MSC_VER >= 800 && !defined(__cplusplus)
+#pragma warning(disable:4116)
+#pragma warning(disable:4715)
+#pragma warning(disable:4244)
+#endif
+#endif
 
 /* ============================================================ */

=== modified file 'src/unexw32.c'
--- src/unexw32.c	2012-01-19 07:21:25 +0000
+++ src/unexw32.c	2012-02-05 20:06:34 +0000
@@ -67,18 +67,18 @@
 /* Cached info about the .data section in the executable.  */
 PIMAGE_SECTION_HEADER data_section;
 PCHAR  data_start = 0;
-DWORD  data_size = 0;
+DWORD_PTR  data_size = 0;
 
 /* Cached info about the .bss section in the executable.  */
 PIMAGE_SECTION_HEADER bss_section;
 PCHAR  bss_start = 0;
-DWORD  bss_size = 0;
-DWORD  extra_bss_size = 0;
+DWORD_PTR  bss_size = 0;
+DWORD_PTR  extra_bss_size = 0;
 /* bss data that is static might be discontiguous from non-static.  */
 PIMAGE_SECTION_HEADER bss_section_static;
 PCHAR  bss_start_static = 0;
-DWORD  bss_size_static = 0;
-DWORD  extra_bss_size_static = 0;
+DWORD_PTR  bss_size_static = 0;
+DWORD_PTR  extra_bss_size_static = 0;
 
 PIMAGE_SECTION_HEADER heap_section;
 
@@ -231,7 +231,7 @@
 /* Return pointer to section header for section containing the given
    relative virtual address. */
 IMAGE_SECTION_HEADER *
-rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
+rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
 {
   PIMAGE_SECTION_HEADER section;
   int i;
@@ -246,7 +246,7 @@
 	 some very old exes (eg. gzip dated Dec 1993).  Since
 	 w32_executable_type relies on this function to work reliably,
 	 we need to cope with this.  */
-      DWORD real_size = max (section->SizeOfRawData,
+      DWORD_PTR real_size = max (section->SizeOfRawData,
 			     section->Misc.VirtualSize);
       if (rva >= section->VirtualAddress
 	  && rva < section->VirtualAddress + real_size)
@@ -259,7 +259,7 @@
 /* Return pointer to section header for section containing the given
    offset in its raw data area. */
 IMAGE_SECTION_HEADER *
-offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
+offset_to_section (DWORD_PTR offset, IMAGE_NT_HEADERS * nt_header)
 {
   PIMAGE_SECTION_HEADER section;
   int i;
@@ -279,8 +279,8 @@
 /* Return offset to an object in dst, given offset in src.  We assume
    there is at least one section in both src and dst images, and that
    the some sections may have been added to dst (after sections in src).  */
-DWORD
-relocate_offset (DWORD offset,
+DWORD_PTR
+relocate_offset (DWORD_PTR offset,
 		 IMAGE_NT_HEADERS * src_nt_header,
 		 IMAGE_NT_HEADERS * dst_nt_header)
 {
@@ -314,16 +314,16 @@
 }
 
 #define OFFSET_TO_RVA(offset, section) \
-	  (section->VirtualAddress + ((DWORD)(offset) - section->PointerToRawData))
+	  (section->VirtualAddress + ((DWORD_PTR)(offset) - section->PointerToRawData))
 
 #define RVA_TO_OFFSET(rva, section) \
-	  (section->PointerToRawData + ((DWORD)(rva) - section->VirtualAddress))
+	  (section->PointerToRawData + ((DWORD_PTR)(rva) - section->VirtualAddress))
 
 #define RVA_TO_SECTION_OFFSET(rva, section) \
-	  ((DWORD)(rva) - section->VirtualAddress)
+	  ((DWORD_PTR)(rva) - section->VirtualAddress)
 
 /* Convert address in executing image to RVA.  */
-#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
+#define PTR_TO_RVA(ptr) ((DWORD_PTR)(ptr) - (DWORD_PTR) GetModuleHandle (NULL))
 
 #define RVA_TO_PTR(var,section,filedata) \
 	  ((void *)(RVA_TO_OFFSET (var,section) + (filedata).file_base))
@@ -332,7 +332,7 @@
           ((unsigned char *)(ptr) - (pfile_data)->file_base)
 
 #define OFFSET_TO_PTR(offset, pfile_data) \
-          ((pfile_data)->file_base + (DWORD)(offset))
+          ((pfile_data)->file_base + (DWORD_PTR)(offset))
 
 
 /* Flip through the executable and cache the info necessary for dumping.  */
@@ -349,7 +349,7 @@
       printf ("Unknown EXE header in %s...bailing.\n", p_infile->name);
       exit (1);
     }
-  nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
+  nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
 				   dos_header->e_lfanew);
   if (nt_header == NULL)
     {
@@ -488,7 +488,7 @@
   PIMAGE_NT_HEADERS dst_nt_header;
   PIMAGE_SECTION_HEADER section;
   PIMAGE_SECTION_HEADER dst_section;
-  DWORD offset;
+  DWORD_PTR offset;
   int i;
   int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
 
@@ -541,17 +541,17 @@
      Note that dst is updated implicitly by each COPY_CHUNK.  */
 
   dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
-  nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
+  nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
 				   dos_header->e_lfanew);
   section = IMAGE_FIRST_SECTION (nt_header);
 
   dst = (unsigned char *) p_outfile->file_base;
 
   COPY_CHUNK ("Copying DOS header...", dos_header,
-	      (DWORD) nt_header - (DWORD) dos_header, be_verbose);
+	      (DWORD_PTR) nt_header - (DWORD_PTR) dos_header, be_verbose);
   dst_nt_header = (PIMAGE_NT_HEADERS) dst;
   COPY_CHUNK ("Copying NT header...", nt_header,
-	      (DWORD) section - (DWORD) nt_header, be_verbose);
+	      (DWORD_PTR) section - (DWORD_PTR) nt_header, be_verbose);
   dst_section = (PIMAGE_SECTION_HEADER) dst;
   COPY_CHUNK ("Copying section table...", section,
 	      nt_header->FileHeader.NumberOfSections * sizeof (*section),
@@ -627,8 +627,8 @@
 	}
       if (section == heap_section)
 	{
-	  DWORD heap_start = (DWORD) get_heap_start ();
-	  DWORD heap_size = get_committed_heap_size ();
+	  DWORD_PTR heap_start = (DWORD_PTR) get_heap_start ();
+	  DWORD_PTR heap_size = get_committed_heap_size ();
 
 	  /* Dump the used portion of the predump heap, adjusting the
              section's size to the appropriate size.  */

=== modified file 'src/vm-limit.c'
--- src/vm-limit.c	2012-01-19 07:21:25 +0000
+++ src/vm-limit.c	2012-02-05 20:06:34 +0000
@@ -20,7 +20,7 @@
 #include <setjmp.h>
 #include "lisp.h"
 #include "mem-limits.h"
-
+#include "w32heap.h"
 /*
   Level number of warnings already issued.
   0 -- no warnings issued.
@@ -41,7 +41,7 @@
 static POINTER data_space_start;
 
 /* Number of bytes of writable memory we can expect to be able to get.  */
-static unsigned long lim_data;
+static size_t lim_data;
 
 
 #if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS)
@@ -79,7 +79,7 @@
     lim_data = ULIMIT_BREAK_VALUE;
 #endif
 
-  lim_data -= (long) data_space_start;
+  lim_data -= (intptr_t) data_space_start;
 }
 
 #else /* not USG */
@@ -88,7 +88,7 @@
 static void
 get_lim_data (void)
 {
-  extern unsigned long reserved_heap_size;
+  extern size_t reserved_heap_size;
   lim_data = reserved_heap_size;
 }
 
@@ -127,7 +127,7 @@
     lim_data = 512U * 1024U * 1024U;
 }
 
-unsigned long
+size_t
 ret_lim_data (void)
 {
   get_lim_data ();
@@ -166,13 +166,13 @@
 check_memory_limits (void)
 {
 #ifdef REL_ALLOC
-  extern POINTER (*real_morecore) (long);
+  extern POINTER (*real_morecore) (__malloc_ptrdiff_t);
 #endif
-  extern POINTER (*__morecore) (long);
+  extern POINTER (*__morecore) (__malloc_ptrdiff_t);
 
   register POINTER cp;
-  unsigned long five_percent;
-  unsigned long data_size;
+  size_t five_percent;
+  size_t data_size;
   enum warnlevel new_warnlevel;
 
   if (lim_data == 0)

=== modified file 'src/w32.c'
--- src/w32.c	2012-02-04 13:48:38 +0000
+++ src/w32.c	2012-02-27 23:33:18 +0000
@@ -19,6 +19,9 @@
 /*
    Geoff Voelker (voelker@cs.washington.edu)                         7-29-94
 */
+
+#define _CRT_ALLOCATION_DEFINED
+
 #include <stddef.h> /* for offsetof */
 #include <stdlib.h>
 #include <stdio.h>
@@ -1703,7 +1706,8 @@
       /* FIXME: should use substring of get_emacs_configuration ().
 	 But I don't think the Windows build supports alpha, mips etc
          anymore, so have taken the easy option for now.  */
-      else if (p && xstrcasecmp (p, "\\i386") == 0)
+      else if (p && (xstrcasecmp (p, "\\i386") == 0
+                     || xstrcasecmp (p, "\\AMD64") == 0))
 	{
 	  *p = 0;
 	  p = strrchr (modname, '\\');
@@ -1861,7 +1865,12 @@
     case PROCESSOR_INTEL_386:
     case PROCESSOR_INTEL_486:
     case PROCESSOR_INTEL_PENTIUM:
+    case PROCESSOR_AMD_X8664:
+#ifdef _WIN64
+      arch = "amd64";
+#else
       arch = "i386";
+#endif
       break;
 #endif
 
@@ -2400,7 +2409,7 @@
 	return NULL;
     }
 
-  if (!(dirp = (DIR *) malloc (sizeof (DIR))))
+  if (!(dirp = (DIR *) xmalloc (sizeof (DIR))))
     return NULL;
 
   dirp->dd_fd = 0;

=== modified file 'src/w32.h'
--- src/w32.h	2012-01-19 07:21:25 +0000
+++ src/w32.h	2012-02-27 23:33:18 +0000
@@ -159,5 +159,9 @@
                                   const void* buf, size_t sz);
 #endif /* HAVE_GNUTLS */
 
+extern struct tm *sys_localtime (const time_t *t);
+extern char *sys_strerror(int error_no);
+extern FILE *sys_fopen (const char * path, const char * mode);
+
 #endif /* EMACS_W32_H */
 

=== modified file 'src/w32fns.c'
--- src/w32fns.c	2012-01-19 07:21:25 +0000
+++ src/w32fns.c	2012-02-27 23:33:18 +0000
@@ -74,7 +74,6 @@
 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);

=== modified file 'src/w32heap.c'
--- src/w32heap.c	2012-01-19 07:21:25 +0000
+++ src/w32heap.c	2012-02-28 14:03:03 +0000
@@ -27,7 +27,7 @@
 #include "w32heap.h"
 #include "lisp.h"  /* for VALMASK */
 
-#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD)(rva) + (DWORD)GetModuleHandle (NULL)))
+#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL)))
 
 /* This gives us the page size and the size of the allocation unit on NT.  */
 SYSTEM_INFO sysinfo_cache;
@@ -98,7 +98,7 @@
 unsigned char *data_region_base = NULL;
 unsigned char *data_region_end = NULL;
 unsigned char *real_data_region_end = NULL;
-unsigned long  reserved_heap_size = 0;
+size_t  reserved_heap_size = 0;
 
 /* The start of the data segment.  */
 unsigned char *
@@ -122,16 +122,20 @@
      the preload heap section up to the usable address limit.  Since GNU
      malloc can handle gaps in the memory it gets from sbrk, we can
      simply set the sbrk pointer to the base of the new heap region.  */
-  unsigned long base =
+  DWORD_PTR base =
     ROUND_UP ((RVA_TO_PTR (preload_heap_section->VirtualAddress)
 	       + preload_heap_section->Misc.VirtualSize),
 	      get_allocation_unit ());
-  unsigned long end  = 1 << VALBITS; /* 256MB */
+  DWORD_PTR end  = ((unsigned __int64)1) << VALBITS; /* 256MB */
   void *ptr = NULL;
 
   while (!ptr && (base < end))
     {
+#ifdef _WIN64
+      reserved_heap_size = min(end - base, 0x800000000i64); /* Limit to 32Gb */
+#else
       reserved_heap_size = end - base;
+#endif
       ptr = VirtualAlloc ((void *) base,
 			  get_reserved_heap_size (),
 			  MEM_RESERVE,
@@ -145,7 +149,11 @@
 static char *
 allocate_heap (void)
 {
-  unsigned long size = 0x80000000; /* start by asking for 2GB */
+#ifdef _WIN64
+  size_t size = 0x800000000i64; /* start by asking for 32GB */
+#else
+  size_t size = 0x80000000; /* start by asking for 2GB */
+#endif
   void *ptr = NULL;
 
   while (!ptr && size > 0x00100000)
@@ -167,17 +175,17 @@
    be the address of the _start_ (not end) of the new block in case of
    success, and zero (not -1) in case of failure.  */
 void *
-sbrk (unsigned long increment)
+sbrk (size_t increment)
 {
   void *result;
-  long size = (long) increment;
+  ptrdiff_t size = (ptrdiff_t)increment;
 
   result = data_region_end;
 
   /* If size is negative, shrink the heap by decommitting pages.  */
   if (size < 0)
     {
-      int new_size;
+      ptrdiff_t new_size;
       unsigned char *new_data_region_end;
 
       size = -size;
@@ -190,7 +198,7 @@
 	 partial deallocation [cga].  */
       new_data_region_end = (data_region_end - size);
       new_data_region_end = (unsigned char *)
-	((long) (new_data_region_end + syspage_mask) & ~syspage_mask);
+	((DWORD_PTR) (new_data_region_end + syspage_mask) & ~syspage_mask);
       new_size = real_data_region_end - new_data_region_end;
       real_data_region_end = new_data_region_end;
       if (new_size > 0)
@@ -221,7 +229,7 @@
       /* We really only commit full pages, so record where
 	 the real end of committed memory is [cga].  */
       real_data_region_end = (unsigned char *)
-	  ((long) (data_region_end + syspage_mask) & ~syspage_mask);
+	  ((DWORD_PTR) (data_region_end + syspage_mask) & ~syspage_mask);
     }
 
   return result;
@@ -246,7 +254,7 @@
   PIMAGE_NT_HEADERS nt_header;
 
   dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);
-  nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
+  nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
 				   dos_header->e_lfanew);
   preload_heap_section = find_section ("EMHEAP", nt_header);
 
@@ -262,7 +270,7 @@
 #if !defined (USE_LISP_UNION_TYPE) && !defined (USE_LSB_TAG)
       /* Ensure that the addresses don't use the upper tag bits since
 	 the Lisp type goes there.  */
-      if (((unsigned long) data_region_base & ~VALMASK) != 0)
+      if (((DWORD_PTR) data_region_base & ~VALMASK) != 0)
 	{
 	  printf ("Error: The heap was allocated in upper memory.\n");
 	  exit (1);
@@ -285,13 +293,13 @@
 
 /* Round the heap up to the given alignment.  */
 void
-round_heap (unsigned long align)
+round_heap (DWORD_PTR align)
 {
-  unsigned long needs_to_be;
-  unsigned long need_to_alloc;
+  DWORD_PTR needs_to_be;
+  DWORD_PTR need_to_alloc;
 
-  needs_to_be = (unsigned long) ROUND_UP (get_heap_end (), align);
-  need_to_alloc = needs_to_be - (unsigned long) get_heap_end ();
+  needs_to_be = (DWORD_PTR) ROUND_UP (get_heap_end (), align);
+  need_to_alloc = needs_to_be - (DWORD_PTR) get_heap_end ();
 
   if (need_to_alloc)
     sbrk (need_to_alloc);

=== modified file 'src/w32heap.h'
--- src/w32heap.h	2012-01-19 07:21:25 +0000
+++ src/w32heap.h	2012-02-05 20:06:34 +0000
@@ -24,8 +24,8 @@
 
 #include <windows.h>
 
-#define ROUND_UP(p, align)   (((DWORD)(p) + (align)-1) & ~((align)-1))
-#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))
+#define ROUND_UP(p, align)   (((DWORD_PTR)(p) + (align)-1) & ~((align)-1))
+#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((align)-1))
 
 /*
  * Heap related stuff.
@@ -42,7 +42,7 @@
 
 extern unsigned char *get_data_start (void);
 extern unsigned char *get_data_end (void);
-extern unsigned long  reserved_heap_size;
+extern size_t         reserved_heap_size;
 extern SYSTEM_INFO    sysinfo_cache;
 extern OSVERSIONINFO  osinfo_cache;
 extern BOOL   	      using_dynamic_heap;
@@ -58,13 +58,13 @@
 extern int os_subtype;
 
 /* Emulation of Unix sbrk().  */
-extern void *sbrk (unsigned long size);
+extern void *sbrk (size_t size);
 
 /* Initialize heap structures for sbrk on startup.  */
 extern void init_heap (void);
 
 /* Round the heap to this size.  */
-extern void round_heap (unsigned long size);
+extern void round_heap (size_t size);
 
 /* Cache system info, e.g., the NT page size.  */
 extern void cache_system_info (void);
@@ -89,7 +89,7 @@
 
 /* Return pointer to section header for section containing the given
    relative virtual address. */
-IMAGE_SECTION_HEADER * rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header);
+IMAGE_SECTION_HEADER * rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header);
 
 #endif /* NTHEAP_H_ */
 

=== modified file 'src/w32proc.c'
--- src/w32proc.c	2012-01-19 07:21:25 +0000
+++ src/w32proc.c	2012-02-27 23:33:15 +0000
@@ -21,6 +21,8 @@
      Adapted from alarm.c by Tim Fleehart
 */
 
+#define _CRT_ALLOCATION_DEFINED
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -63,7 +65,7 @@
 
 #define RVA_TO_PTR(var,section,filedata) \
   ((void *)((section)->PointerToRawData					\
-	    + ((DWORD)(var) - (section)->VirtualAddress)		\
+	    + ((DWORD_PTR)(var) - (section)->VirtualAddress)		\
 	    + (filedata).file_base))
 
 Lisp_Object Qhigh, Qlow;

=== modified file 'src/xfaces.c'
--- src/xfaces.c	2012-02-06 08:19:09 +0000
+++ src/xfaces.c	2012-02-27 23:33:18 +0000
@@ -226,6 +226,7 @@
 #endif
 
 #ifdef WINDOWSNT
+#include "w32.h"
 #include "w32term.h"
 #include "fontset.h"
 /* Redefine X specifics to W32 equivalents to avoid cluttering the

