From 8c9afb46949ddd9853f38eb8c1a865cb13522d92 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 27 Nov 2011 20:52:53 +0200 Subject: [PATCH] Fix MS-Windows build with MSVC compiler. Parts of the changes by Fabrice Popineau . lib-src/makefile.w32-in (LOCAL_FLAGS): Add $(EMACS_EXTRA_C_FLAGS). lib-src/emacsclient.c (main) : 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 | 7 +++++++ lib-src/emacsclient.c | 1 - lib-src/makefile.w32-in | 2 +- nt/ChangeLog | 12 ++++++++++++ nt/config.nt | 8 ++++++-- nt/inc/inttypes.h | 6 ++++++ nt/inc/stdint.h | 10 +++++++--- src/ChangeLog | 16 ++++++++++++++++ src/lisp.h | 15 ++++++++++----- src/s/ms-w32.h | 8 ++++++-- 10 files changed, 71 insertions(+), 14 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 0832f8932ee..db1464f65d8 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,10 @@ +2011-11-27 Eli Zaretskii + + * makefile.w32-in (LOCAL_FLAGS): Add $(EMACS_EXTRA_C_FLAGS). + + * emacsclient.c (main) : Remove declaration, already + pulled in by unistd.h on Posix hosts and stdlib.h on MS-Windows. + 2011-11-24 Glenn Morris * make-docfile.c (scan_lisp_file): Treat defcustom like defvar. diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 56e17c100be..b46700ba660 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -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++) { diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in index 28f913a4df6..be7f4d0b6db 100644 --- a/lib-src/makefile.w32-in +++ b/lib-src/makefile.w32-in @@ -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) diff --git a/nt/ChangeLog b/nt/ChangeLog index 2ae44150685..859123c1a86 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,15 @@ +2011-11-27 Fabrice Popineau (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 * configure.bat: Fix typos. diff --git a/nt/config.nt b/nt/config.nt index 3a06a9f5b7a..77297e3db25 100644 --- a/nt/config.nt +++ b/nt/config.nt @@ -303,6 +303,10 @@ along with GNU Emacs. If not, see . */ /* 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)) diff --git a/nt/inc/inttypes.h b/nt/inc/inttypes.h index 3e8b55ab98e..ba26cc1115d 100644 --- a/nt/inc/inttypes.h +++ b/nt/inc/inttypes.h @@ -24,7 +24,13 @@ along with GNU Emacs. If not, see . */ #include_next #else /* !__MINGW32__ */ #include "stdint.h" +#ifdef _WIN64 #define strtoumax _strtoui64 +#define strtoimax _strtoi64 +#else +#define strtoumax strtoul +#define strtoimax strtol +#endif #endif /* !__MINGW32__ */ #endif diff --git a/nt/inc/stdint.h b/nt/inc/stdint.h index fa2e06f3da9..4eda1c5a688 100644 --- a/nt/inc/stdint.h +++ b/nt/inc/stdint.h @@ -29,7 +29,9 @@ along with GNU Emacs. If not, see . */ #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__ */ diff --git a/src/ChangeLog b/src/ChangeLog index 5b1d5aa2f24..a2d84d901b5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2011-11-27 Eli Zaretskii + + * 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 * gtkutil.c (xg_create_frame_widgets): Call diff --git a/src/lisp.h b/src/lisp.h index fa41239a1c8..5735c207241 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -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) diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h index fb0882860d1..cc19765aba6 100644 --- a/src/s/ms-w32.h +++ b/src/s/ms-w32.h @@ -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 -- 2.39.5