Fix MS-Windows build with MSVC compiler.
authorEli Zaretskii <eliz@gnu.org>
Sun, 27 Nov 2011 18:52:53 +0000 (20:52 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sun, 27 Nov 2011 18:52:53 +0000 (20:52 +0200)
Parts of the changes by Fabrice Popineau  <fabrice.popineau@supelec.fr>.

 lib-src/makefile.w32-in (LOCAL_FLAGS): Add $(EMACS_EXTRA_C_FLAGS).
 lib-src/emacsclient.c (main) <environ>: Remove declaration, already
 pulled in by unistd.h on Posix hosts and stdlib.h on MS-Windows.
 nt/inc/stdint.h (uint32_t, uint64_t) [_WIN64]: New typedefs.
 (UINT64_MAX) [_WIN64]: Fix definition.
 (uintmax_t, intmax_t): Fix definitions.
 nt/inc/inttypes.h (strtoumax, strtoimax) [!__MINGW32__]: Provide
 correct definitions.
 nt/config.nt (HAVE_DECL_STRTOLL): Define.
 (va_copy) [_WIN64]: Provide a better definition.
 src/s/ms-w32.h (utimbuf) [_MSC_VER]: Don't define.
 (snprintf) [_MSC_VER]: Redirect to _snprintf.
 (strtoll) [_MSC_VER]: Redirect to _strtoi64.
 (malloc, free, realloc, calloc): Redirect to e_* only when
 compiling Emacs.
 src/lisp.h (GCTYPEBITS): Move before first use.
 (ALIGN_GCTYPEBITS) [_MSC_VER]: Define.
 (DECL_ALIGN) [_MSC_VER]: Use it, as MSVC doesn't like bit ops in
 this macro definition.
 (tzname): Redirect to _tzname for all values of _MSC_VER.

Fixes: debbugs:9960

lib-src/ChangeLog
lib-src/emacsclient.c
lib-src/makefile.w32-in
nt/ChangeLog
nt/config.nt
nt/inc/inttypes.h
nt/inc/stdint.h
src/ChangeLog
src/lisp.h
src/s/ms-w32.h

index 0832f89..db1464f 100644 (file)
@@ -1,3 +1,10 @@
+2011-11-27  Eli Zaretskii  <eliz@gnu.org>
+
+       * makefile.w32-in (LOCAL_FLAGS): Add $(EMACS_EXTRA_C_FLAGS).
+
+       * emacsclient.c (main) <environ>: Remove declaration, already
+       pulled in by unistd.h on Posix hosts and stdlib.h on MS-Windows.
+
 2011-11-24  Glenn Morris  <rgm@gnu.org>
 
        * make-docfile.c (scan_lisp_file): Treat defcustom like defvar.
index 56e17c1..b46700b 100644 (file)
@@ -1635,7 +1635,6 @@ main (int argc, char **argv)
   /* Send over our environment and current directory. */
   if (!current_frame)
     {
-      extern char **environ;
       int i;
       for (i = 0; environ[i]; i++)
         {
index 28f913a..be7f4d0 100644 (file)
@@ -23,7 +23,7 @@ ALL = make-docfile hexl ctags etags movemail ebrowse emacsclient
 
 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)
 
index 2ae4415..859123c 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-27  Fabrice Popineau  <fabrice.popineau@supelec.fr>  (tiny change)
+
+       * inc/stdint.h (uint32_t, uint64_t) [_WIN64]: New typedefs.
+       (UINT64_MAX) [_WIN64]: Fix definition.
+       (uintmax_t, intmax_t): Fix definitions.
+
+       * inc/inttypes.h (strtoumax, strtoimax) [!__MINGW32__]: Provide
+       correct definitions.
+
+       * config.nt (HAVE_DECL_STRTOLL): Define.
+       (va_copy) [_WIN64]: Provide a better definition.
+
 2011-11-25  Juanma Barranquero  <lekktu@gmail.com>
 
        * configure.bat: Fix typos.
index 3a06a9f..77297e3 100644 (file)
@@ -303,6 +303,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 /* 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 @@ typedef unsigned short mode_t;
 /* 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))
index 3e8b55a..ba26cc1 100644 (file)
@@ -24,7 +24,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #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
index fa2e06f..4eda1c5 100644 (file)
@@ -29,7 +29,9 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifdef _WIN64
 typedef __int64 intptr_t;
-#define UINT64_MAX 18446744073709551615
+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 @@ typedef __int64 intptr_t;
 #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 @@ typedef unsigned int uint32_t;
 #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__ */
index 5b1d5aa..a2d84d9 100644 (file)
@@ -1,3 +1,19 @@
+2011-11-27  Eli Zaretskii  <eliz@gnu.org>
+
+       * s/ms-w32.h (utimbuf) [_MSC_VER]: Don't define.
+       (snprintf) [_MSC_VER]: Redirect to _snprintf.
+       (strtoll) [_MSC_VER]: Redirect to _strtoi64.
+       (malloc, free, realloc, calloc): Redirect to e_* only when
+       compiling Emacs.
+
+       * lisp.h (GCTYPEBITS): Move before first use.
+       (ALIGN_GCTYPEBITS) [_MSC_VER]: Define.
+       (DECL_ALIGN) [_MSC_VER]: Use it, as MSVC doesn't like bit ops in
+       this macro definition.
+
+       * s/ms-w32.h (tzname): Redirect to _tzname for all values of
+       _MSC_VER.
+
 2011-11-27  Jan Djärv  <jan.h.d@swipnet.se>
 
        * gtkutil.c (xg_create_frame_widgets): Call
index fa41239..5735c20 100644 (file)
@@ -163,14 +163,23 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
 /* 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 @@ enum Lisp_Fwd_Type
     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)
index fb08828..cc19765 100644 (file)
@@ -267,6 +267,8 @@ struct sigaction {
 #define getpid    _getpid
 #ifdef _MSC_VER
 typedef int pid_t;
+#define snprintf  _snprintf
+#define strtoll   _strtoi64
 #endif
 #define isatty    _isatty
 #define logb      _logb
@@ -275,15 +277,17 @@ typedef int pid_t;
 #define popen     _popen
 #define pclose    _pclose
 #define umask    _umask
+#ifndef _MSC_VER
 #define utimbuf          _utimbuf
+#endif
 #define strdup    _strdup
 #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
@@ -335,7 +339,7 @@ extern char *get_emacs_configuration_options (void);
 #define _WINSOCK_H
 
 /* Defines size_t and alloca ().  */
-#if (defined(_MSC_VER) && defined(emacs)) || defined(USE_CRT_DLL)
+#ifdef emacs
 #define malloc e_malloc
 #define free   e_free
 #define realloc e_realloc