=== modified file 'build-aux/move-if-change' (properties changed: +x to -x)
=== modified file 'lib-src/emacsclient.c'
--- lib-src/emacsclient.c	2011-10-27 00:59:21 +0000
+++ lib-src/emacsclient.c	2011-11-10 17:40:29 +0000
@@ -1635,7 +1635,9 @@
   /* Send over our environment and current directory. */
   if (!current_frame)
     {
+#ifndef _MSC_VER
       extern char **environ;
+#endif
       int i;
       for (i = 0; environ[i]; i++)
         {

=== modified file 'lib-src/makefile.w32-in'
--- lib-src/makefile.w32-in	2011-07-07 01:32:56 +0000
+++ lib-src/makefile.w32-in	2011-11-08 18:23:01 +0000
@@ -23,7 +23,7 @@
 
 LOCAL_FLAGS	= -DWINDOWSNT -DDOS_NT -DNO_LDAV=1 \
 		  -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../lib \
-		  -I../nt/inc -I../src
+		  -I../nt/inc -I../src $(EMACS_EXTRA_C_FLAGS)
 
 LIBS 		= $(BASE_LIBS) $(ADVAPI32)
 

=== modified file 'lib/strftime.c'
--- lib/strftime.c	2011-03-31 04:24:03 +0000
+++ lib/strftime.c	2011-11-10 17:39:37 +0000
@@ -36,9 +36,14 @@
 #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/bindings.el'
--- lisp/bindings.el	2011-10-08 16:37:46 +0000
+++ lisp/bindings.el	2011-11-10 17:49:35 +0000
@@ -824,13 +824,13 @@
 ;; Define control-digits.
 (let ((i ?0))
   (while (<= i ?9)
-    (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
+;    (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
     (setq i (1+ i))))
 (define-key global-map [?\C--] 'negative-argument)
 ;; Define control-meta-digits.
 (let ((i ?0))
   (while (<= i ?9)
-    (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
+;    (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
     (setq i (1+ i))))
 (define-key global-map [?\C-\M--] 'negative-argument)
 

=== modified file 'nt/config.nt'
--- nt/config.nt	2011-11-05 17:16:01 +0000
+++ nt/config.nt	2011-11-10 17:42:22 +0000
@@ -303,6 +303,10 @@
 /* Define to 1 if you have the `localtime_r' function. */
 #undef HAVE_LOCALTIME_R
 
+/* Define to 1 if you have the declaration of `strtoll', and to 0 if you
+   don't. */
+#define HAVE_DECL_STRTOLL 1
+
 /* Define to 1 if you have the declaration of `strtoull', and to 0 if you
    don't. */
 #define HAVE_DECL_STRTOULL 1
@@ -353,8 +357,8 @@
 /* A va_copy replacement for MSVC.  */
 #ifdef _MSC_VER
 # ifdef _WIN64
-#  ifndef va_copy
-#   error "va_copy is needed, but not defined!"
+#  ifndef va_copy               /* Need to be checked (?) */
+#   define va_copy(d,s) ((d) = (s))
 #  endif
 # else	/* not _WIN64 */
 #  define va_copy(d,s) ((d) = (s))
@@ -429,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	2011-05-07 04:00:12 +0000
+++ nt/configure.bat	2011-11-09 15:43:42 +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=
@@ -536,7 +536,8 @@
 echo The failed program was: >>config.log
 type junk.c >>config.log
 set HAVE_PNG=
-goto :pngDone
+rem goto :pngDone
+goto :end
 
 :havePng
 echo ...PNG header available, building with PNG support.

=== modified file 'nt/emacs.rc'
--- nt/emacs.rc	2011-10-31 02:25:01 +0000
+++ nt/emacs.rc	2011-11-10 02:47:58 +0000
@@ -1,6 +1,10 @@
 Emacs ICON   icons\emacs.ico
 32649 CURSOR icons\hand.cur
+#ifdef WIN64
+1 24 "emacs-x64.manifest"
+#else
 1 24 "emacs.manifest"
+#endif
 
 #ifndef VS_VERSION_INFO
 #define VS_VERSION_INFO 1

=== modified file 'nt/inc/inttypes.h'
--- nt/inc/inttypes.h	2011-05-06 12:09:08 +0000
+++ nt/inc/inttypes.h	2011-11-08 04:33:57 +0000
@@ -24,7 +24,13 @@
 #include_next <inttypes.h>
 #else  /* !__MINGW32__ */
 #include "stdint.h"
+#ifdef _WIN64
 #define strtoumax _strtoui64
+#define strtoimax _strtoi64
+#else
+#define strtoumax strtoul
+#define strtoimax strtol
+#endif
 #endif	/* !__MINGW32__ */
 
 #endif

=== modified file 'nt/inc/stdint.h'
--- nt/inc/stdint.h	2011-11-05 22:33:44 +0000
+++ nt/inc/stdint.h	2011-11-10 01:36:50 +0000
@@ -29,7 +29,9 @@
 
 #ifdef _WIN64
 typedef __int64 intptr_t;
-#define UINT64_MAX 18446744073709551616
+typedef unsigned int uint32_t;
+typedef unsigned __int64 uint64_t;
+#define UINT64_MAX (18446744073709551615i64)
 #define UINT64_MIN 0
 /* "i64" is the non-standard suffix used by MSVC for 64-bit constants.  */
 #define INT64_MAX 9223372036854775807i64
@@ -39,6 +41,8 @@
 #define UINTMAX_MIN UINT64_MIN
 #define INTMAX_MAX INT64_MAX
 #define INTMAX_MIN INT64_MIN
+#define uintmax_t unsigned __int64
+#define intmax_t __int64
 #else
 typedef int intptr_t;
 typedef unsigned int uint32_t;
@@ -51,10 +55,10 @@
 #define UINTMAX_MIN UINT32_MIN
 #define INTMAX_MAX INT32_MAX
 #define INTMAX_MIN INT32_MIN
+#define uintmax_t unsigned long
+#define intmax_t long
 #endif
 
-#define uintmax_t unsigned __int64
-#define intmax_t __int64
 #define PTRDIFF_MAX INTPTR_MAX
 
 #endif	/* !__GNUC__ */

=== modified file 'nt/nmake.defs'
--- nt/nmake.defs	2011-11-05 11:34:56 +0000
+++ nt/nmake.defs	2011-11-09 16:52:19 +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
@@ -164,7 +168,11 @@
 
 # see comments in allocate_heap in w32heap.c before changing any of the
 # -stack, -heap, or -base settings.
+!if "$(ARCH)" == "AMD64"
+TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -pdb:$(BLD)\temacs.pdb -machine:x64 $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
+!else
 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)
+!endif
 
 !ifdef NOOPT
 OBJDIR          = obj
@@ -234,11 +242,24 @@
 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
+
+!else
 !ERROR Unknown architecture type "$(ARCH)".
 !endif
 !endif
 !endif
 !endif
+!endif
 
 LINK_FLAGS	= $(ARCH_LDFLAGS) $(DEBUG_LINK) $(USER_LDFLAGS)
 

=== modified file 'src/lisp.h'
--- src/lisp.h	2011-11-07 17:04:01 +0000
+++ src/lisp.h	2011-11-10 17:24:14 +0000
@@ -163,14 +163,23 @@
 /* First, try and define DECL_ALIGN(type,var) which declares a static
    variable VAR of type TYPE with the added requirement that it be
    TYPEBITS-aligned.  */
+
+#ifndef GCTYPEBITS
+#define GCTYPEBITS 3
+#endif
+
 #ifndef NO_DECL_ALIGN
 # ifndef DECL_ALIGN
 #  if HAVE_ATTRIBUTE_ALIGNED
 #   define DECL_ALIGN(type, var) \
      type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
 #  elif defined(_MSC_VER)
+#   define ALIGN_GCTYPEBITS 8
+#   if (1 << GCTYPEBITS) != ALIGN_GCTYPEBITS
+#    error ALIGN_GCTYPEBITS is wrong!
+#   endif
 #   define DECL_ALIGN(type, var) \
-     type __declspec(align(1 << GCTYPEBITS)) var
+     type __declspec(align(ALIGN_GCTYPEBITS)) var
 #  else
      /* What directives do other compilers use?  */
 #  endif
@@ -300,10 +309,6 @@
     Lisp_Fwd_Kboard_Obj,	/* Fwd to a Lisp_Object field of kboards.  */
   };
 
-#ifndef GCTYPEBITS
-#define GCTYPEBITS 3
-#endif
-
 /* These values are overridden by the m- file on some machines.  */
 #ifndef VALBITS
 #define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)

=== modified file 'src/m/amdx86-64.h'
--- src/m/amdx86-64.h	2011-04-19 00:34:42 +0000
+++ src/m/amdx86-64.h	2011-11-08 16:00:11 +0000
@@ -27,9 +27,17 @@
 /* __x86_64 defined automatically.  */
 
 /* Define the type to use.  */
+#ifdef _WIN64
+#define EMACS_INT               __int64
+#define pI			"i64"
+#define EMACS_UINT              unsigned __int64
+#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	2011-11-05 22:55:08 +0000
+++ src/makefile.w32-in	2011-11-10 02:16:49 +0000
@@ -177,7 +177,7 @@
 $(TEMACS):      $(TLIB0) $(TLIB1) $(TLIB2) $(TLASTLIB) $(TOBJ) $(TRES) \
 		  ../nt/$(BLD)/addsection.exe $(GNULIB)
 	$(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
-	"$(THISDIR)/../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 21
+	"$(THISDIR)/../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 42
 
 # These omit firstfile.${O}, but there's no documentation in there
 # anyways.

=== modified file 'src/s/ms-w32.h'
--- src/s/ms-w32.h	2011-11-05 16:30:13 +0000
+++ src/s/ms-w32.h	2011-11-10 17:46:07 +0000
@@ -275,11 +275,13 @@
 #define popen     _popen
 #define pclose    _pclose
 #define umask	  _umask
-#define utimbuf	  _utimbuf
+#define snprintf  _snprintf
 #define strdup    _strdup
+#define strtoll   _strtoi64
 #define strupr    _strupr
 #define strnicmp  _strnicmp
 #define stricmp   _stricmp
+/* #define tzname    _tzname */
 #define tzset     _tzset
 
 #if !defined (_MSC_VER) || (_MSC_VER < 1400)
@@ -335,7 +337,7 @@
 #define _WINSOCK_H
 
 /* Defines size_t and alloca ().  */
-#if (defined(_MSC_VER) && defined(emacs)) || defined(USE_CRT_DLL)
+#if (defined(_MSC_VER) && defined(emacs))
 #define malloc e_malloc
 #define free   e_free
 #define realloc e_realloc

=== modified file 'src/w32.c'
--- src/w32.c	2011-11-07 16:42:34 +0000
+++ src/w32.c	2011-11-10 17:46:50 +0000
@@ -1665,10 +1665,10 @@
 
       if (!GetModuleFileName (NULL, modname, MAX_PATH))
 	abort ();
+
       if ((p = strrchr (modname, '\\')) == NULL)
 	abort ();
       *p = 0;
-
       if ((p = strrchr (modname, '\\')) && xstrcasecmp (p, "\\bin") == 0)
 	{
 	  char buf[SET_ENV_BUF_SIZE];
@@ -1685,7 +1685,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, '\\');

=== modified file 'src/xdisp.c'
--- src/xdisp.c	2011-11-08 20:05:27 +0000
+++ src/xdisp.c	2011-11-10 17:20:07 +0000
@@ -1086,7 +1086,11 @@
    area AREA of window W.  AREA < 0 means return the right edge of the
    whole window, to the left of the right fringe of W.  */
 
+#ifdef _MSC_VER
 int
+#else
+inline int
+#endif
 window_box_right_offset (struct window *w, int area)
 {
   return window_box_left_offset (w, area) + window_box_width (w, area);
@@ -1116,7 +1120,11 @@
    area AREA of window W.  AREA < 0 means return the right edge of the
    whole window, to the left of the right fringe of W.  */
 
+#ifdef _MSC_VER
 int
+#else
+inline int
+#endif
 window_box_right (struct window *w, int area)
 {
   return window_box_left (w, area) + window_box_width (w, area);

