aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2011-11-05 13:34:56 +0200
committerEli Zaretskii2011-11-05 13:34:56 +0200
commita6fc3b5c539c0a35e4447a12cc395294952d7561 (patch)
tree1e04d32fc9bdb6972987c95b0f8bb96e050846a8 /src
parent27f5a13648b2f5b2873803c9338e77e61acfd1a5 (diff)
downloademacs-a6fc3b5c539c0a35e4447a12cc395294952d7561.tar.gz
emacs-a6fc3b5c539c0a35e4447a12cc395294952d7561.zip
Support MSVC build with newer versions of Visual Studio.
Small portions of the changes by Fabrice Popineau <fabrice.popineau@supelec.fr>. src/makefile.w32-in (TAGS-gmake): Don't use $(patsubst ...), as Nmake barfs on that. Use $(OBJ*_c) variables instead, defined on nt/gmake.defs. src/lisp.h (ENUM_BF): New macro, for enumerated types in bitfields, which are not supported by MSVC. (Lisp_Symbol, Lisp_Misc_Any, Lisp_Marker, Lisp_Misc_Overlay) (Lisp_Save_Value, Lisp_Free): Use ENUM_BF for enumerated types in bitfields. (Lisp_Object) [USE_LISP_UNION_TYPE]: Use ENUM_BF for enumerated types in bitfields. (DEFUN) [_MSC_VER]: Define in a different way for MSVC. src/w32fns.c [_MSC_VER]: DECLARE_HANDLE for any MSVC version. src/w32.c: Don't include w32api.h for MSVC. (init_environment) [_MSC_VER]: Call sys_access, not _access. src/s/ms-w32.h <sigset_t, ssize_t> [_MSC_VER]: Typedefs for MSVC. [_MSC_VER]: Include sys/timeb.h, sys/stat.h, and signal.h. (fstat, stat, utime) [_MSC_VER]: Redirect to their sys_* cousins. (malloc, free, realloc, calloc) [_MSC_VER]: Always redirect to the e_* cousins. (alloca) [_MSC_VER]: Define to _alloca. src/lisp.h (DECL_ALIGN) [_MSC_VER]: Define for MSVC. src/regex.c <re_char> [_MSC_VER]: A separate definition for MSVC. nt/makefile.w32-in (clean-other-dirs-nmake) (distclean-other-dirs-nmake, maintainer-clean-other-dirs-nmake): Update for current structure of doc/ subdirectories. nt/gmake.defs (OBJ0_c, OBJ1_c, OBJ2_c): New variables. nt/INSTALL: Update for newer versions of MSVC. lib/makefile.w32-in (FRC): New dummy target. (TAGS): Depend on FRC. Fixes: debbugs:9960
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog35
-rw-r--r--src/lisp.h56
-rw-r--r--src/makefile.w32-in6
-rw-r--r--src/regex.c4
-rw-r--r--src/s/ms-w32.h27
-rw-r--r--src/w32.c7
-rw-r--r--src/w32fns.c4
7 files changed, 116 insertions, 23 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 624ad71379d..83e6154fb5f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,38 @@
12011-11-05 Eli Zaretskii <eliz@gnu.org>
2
3 Support MSVC build with newer versions of Visual Studio.
4 * makefile.w32-in (TAGS-gmake): Don't use $(patsubst ...), as
5 Nmake barfs on that. Use $(OBJ*_c) variables instead, defined on
6 nt/gmake.defs.
7
8 * lisp.h (ENUM_BF): New macro, for enumerated types in bitfields,
9 which are not supported by MSVC.
10 (Lisp_Symbol, Lisp_Misc_Any, Lisp_Marker, Lisp_Misc_Overlay)
11 (Lisp_Save_Value, Lisp_Free): Use ENUM_BF for enumerated types in
12 bitfields.
13 (Lisp_Object) [USE_LISP_UNION_TYPE]: Use ENUM_BF for enumerated
14 types in bitfields.
15 (DEFUN) [_MSC_VER]: Define in a different way for MSVC.
16
17 * w32fns.c [_MSC_VER]: DECLARE_HANDLE for any MSVC version.
18
192011-11-05 Fabrice Popineau <fabrice.popineau@supelec.fr> (tiny change)
20
21 Support MSVC build with newer versions of Visual Studio.
22 * w32.c: Don't include w32api.h for MSVC.
23 (init_environment) [_MSC_VER]: Call sys_access, not _access.
24
25 * s/ms-w32.h <sigset_t, ssize_t> [_MSC_VER]: Typedefs for MSVC.
26 [_MSC_VER]: Include sys/timeb.h, sys/stat.h, and signal.h.
27 (fstat, stat, utime) [_MSC_VER]: Redirect to their sys_* cousins.
28 (malloc, free, realloc, calloc) [_MSC_VER]: Always redirect to the
29 e_* cousins.
30 (alloca) [_MSC_VER]: Define to _alloca.
31
32 * lisp.h (DECL_ALIGN) [_MSC_VER]: Define for MSVC.
33
34 * regex.c <re_char> [_MSC_VER]: A separate definition for MSVC.
35
12011-11-04 Eli Zaretskii <eliz@gnu.org> 362011-11-04 Eli Zaretskii <eliz@gnu.org>
2 37
3 * xdisp.c (note_mouse_highlight): If either of 38 * xdisp.c (note_mouse_highlight): If either of
diff --git a/src/lisp.h b/src/lisp.h
index df8812f73b7..f3c704bc763 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -168,6 +168,9 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
168# if HAVE_ATTRIBUTE_ALIGNED 168# if HAVE_ATTRIBUTE_ALIGNED
169# define DECL_ALIGN(type, var) \ 169# define DECL_ALIGN(type, var) \
170 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var 170 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
171# elif defined(_MSC_VER)
172# define DECL_ALIGN(type, var) \
173 type __declspec(align(1 << GCTYPEBITS)) var
171# else 174# else
172 /* What directives do other compilers use? */ 175 /* What directives do other compilers use? */
173# endif 176# endif
@@ -225,6 +228,15 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
225# endif 228# endif
226#endif 229#endif
227 230
231/* Stolen from GDB. The only known compiler that doesn't support
232 enums in bitfields is MSVC. */
233#ifdef _MSC_VER
234#define ENUM_BF(TYPE) unsigned int
235#else
236#define ENUM_BF(TYPE) enum TYPE
237#endif
238
239
228enum Lisp_Type 240enum Lisp_Type
229 { 241 {
230 /* Integer. XINT (obj) is the integer value. */ 242 /* Integer. XINT (obj) is the integer value. */
@@ -315,12 +327,12 @@ union Lisp_Object
315 /* Use explict signed, the signedness of a bit-field of type 327 /* Use explict signed, the signedness of a bit-field of type
316 int is implementation defined. */ 328 int is implementation defined. */
317 signed EMACS_INT val : VALBITS; 329 signed EMACS_INT val : VALBITS;
318 enum Lisp_Type type : GCTYPEBITS; 330 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
319 } s; 331 } s;
320 struct 332 struct
321 { 333 {
322 EMACS_UINT val : VALBITS; 334 EMACS_UINT val : VALBITS;
323 enum Lisp_Type type : GCTYPEBITS; 335 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
324 } u; 336 } u;
325 } 337 }
326Lisp_Object; 338Lisp_Object;
@@ -336,14 +348,14 @@ union Lisp_Object
336 348
337 struct 349 struct
338 { 350 {
339 enum Lisp_Type type : GCTYPEBITS; 351 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
340 /* Use explict signed, the signedness of a bit-field of type 352 /* Use explict signed, the signedness of a bit-field of type
341 int is implementation defined. */ 353 int is implementation defined. */
342 signed EMACS_INT val : VALBITS; 354 signed EMACS_INT val : VALBITS;
343 } s; 355 } s;
344 struct 356 struct
345 { 357 {
346 enum Lisp_Type type : GCTYPEBITS; 358 ENUM_BF (Lisp_Type) type : GCTYPEBITS;
347 EMACS_UINT val : VALBITS; 359 EMACS_UINT val : VALBITS;
348 } u; 360 } u;
349 } 361 }
@@ -1096,7 +1108,7 @@ struct Lisp_Symbol
1096 1 : it's a varalias, the value is really in the `alias' symbol. 1108 1 : it's a varalias, the value is really in the `alias' symbol.
1097 2 : it's a localized var, the value is in the `blv' object. 1109 2 : it's a localized var, the value is in the `blv' object.
1098 3 : it's a forwarding variable, the value is in `forward'. */ 1110 3 : it's a forwarding variable, the value is in `forward'. */
1099 enum symbol_redirect redirect : 3; 1111 ENUM_BF (symbol_redirect) redirect : 3;
1100 1112
1101 /* Non-zero means symbol is constant, i.e. changing its value 1113 /* Non-zero means symbol is constant, i.e. changing its value
1102 should signal an error. If the value is 3, then the var 1114 should signal an error. If the value is 3, then the var
@@ -1309,7 +1321,7 @@ struct Lisp_Hash_Table
1309 1321
1310struct Lisp_Misc_Any /* Supertype of all Misc types. */ 1322struct Lisp_Misc_Any /* Supertype of all Misc types. */
1311{ 1323{
1312 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_??? */ 1324 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_??? */
1313 unsigned gcmarkbit : 1; 1325 unsigned gcmarkbit : 1;
1314 int spacer : 15; 1326 int spacer : 15;
1315 /* Make it as long as "Lisp_Free without padding". */ 1327 /* Make it as long as "Lisp_Free without padding". */
@@ -1318,7 +1330,7 @@ struct Lisp_Misc_Any /* Supertype of all Misc types. */
1318 1330
1319struct Lisp_Marker 1331struct Lisp_Marker
1320{ 1332{
1321 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Marker */ 1333 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Marker */
1322 unsigned gcmarkbit : 1; 1334 unsigned gcmarkbit : 1;
1323 int spacer : 13; 1335 int spacer : 13;
1324 /* This flag is temporarily used in the functions 1336 /* This flag is temporarily used in the functions
@@ -1468,7 +1480,7 @@ struct Lisp_Overlay
1468 I.e. 9words plus 2 bits, 3words of which are for external linked lists. 1480 I.e. 9words plus 2 bits, 3words of which are for external linked lists.
1469*/ 1481*/
1470 { 1482 {
1471 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Overlay */ 1483 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */
1472 unsigned gcmarkbit : 1; 1484 unsigned gcmarkbit : 1;
1473 int spacer : 15; 1485 int spacer : 15;
1474 struct Lisp_Overlay *next; 1486 struct Lisp_Overlay *next;
@@ -1487,7 +1499,7 @@ struct Lisp_Kboard_Objfwd
1487 This type of object is used in the arg to record_unwind_protect. */ 1499 This type of object is used in the arg to record_unwind_protect. */
1488struct Lisp_Save_Value 1500struct Lisp_Save_Value
1489 { 1501 {
1490 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Save_Value */ 1502 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */
1491 unsigned gcmarkbit : 1; 1503 unsigned gcmarkbit : 1;
1492 int spacer : 14; 1504 int spacer : 14;
1493 /* If DOGC is set, POINTER is the address of a memory 1505 /* If DOGC is set, POINTER is the address of a memory
@@ -1501,7 +1513,7 @@ struct Lisp_Save_Value
1501/* A miscellaneous object, when it's on the free list. */ 1513/* A miscellaneous object, when it's on the free list. */
1502struct Lisp_Free 1514struct Lisp_Free
1503 { 1515 {
1504 enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_Free */ 1516 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Free */
1505 unsigned gcmarkbit : 1; 1517 unsigned gcmarkbit : 1;
1506 int spacer : 15; 1518 int spacer : 15;
1507 union Lisp_Misc *chain; 1519 union Lisp_Misc *chain;
@@ -1896,13 +1908,23 @@ typedef struct {
1896 1908
1897/* This version of DEFUN declares a function prototype with the right 1909/* This version of DEFUN declares a function prototype with the right
1898 arguments, so we can catch errors with maxargs at compile-time. */ 1910 arguments, so we can catch errors with maxargs at compile-time. */
1899#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ 1911#ifdef _MSC_VER
1900 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ 1912#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1901 static DECL_ALIGN (struct Lisp_Subr, sname) = \ 1913 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1902 { PVEC_SUBR, \ 1914 static DECL_ALIGN (struct Lisp_Subr, sname) = \
1903 { .a ## maxargs = fnname }, \ 1915 { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
1904 minargs, maxargs, lname, intspec, 0}; \ 1916 { (Lisp_Object (__cdecl *)(void))fnname }, \
1905 Lisp_Object fnname 1917 minargs, maxargs, lname, intspec, 0}; \
1918 Lisp_Object fnname
1919#else /* not _MSC_VER */
1920#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
1921 Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
1922 static DECL_ALIGN (struct Lisp_Subr, sname) = \
1923 { PVEC_SUBR, \
1924 { .a ## maxargs = fnname }, \
1925 minargs, maxargs, lname, intspec, 0}; \
1926 Lisp_Object fnname
1927#endif
1906 1928
1907/* Note that the weird token-substitution semantics of ANSI C makes 1929/* Note that the weird token-substitution semantics of ANSI C makes
1908 this work for MANY and UNEVALLED. */ 1930 this work for MANY and UNEVALLED. */
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 53cb5f857ab..bee857694e2 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -348,11 +348,11 @@ TAGS-LISP: $(OBJ0) $(OBJ1) $(OBJ2)
348TAGS-gmake: 348TAGS-gmake:
349 ../lib-src/$(BLD)/etags.exe --include=TAGS-LISP --include=../nt/TAGS \ 349 ../lib-src/$(BLD)/etags.exe --include=TAGS-LISP --include=../nt/TAGS \
350 --regex=@../nt/emacs-src.tags \ 350 --regex=@../nt/emacs-src.tags \
351 $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ0)) 351 $(OBJ0_c)
352 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ 352 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \
353 $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ1)) 353 $(OBJ1_c)
354 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ 354 ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \
355 $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ2)) \ 355 $(OBJ2_c) \
356 $(CURDIR)/*.h $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h 356 $(CURDIR)/*.h $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h
357 357
358TAGS-nmake: 358TAGS-nmake:
diff --git a/src/regex.c b/src/regex.c
index 8033ab9edaa..ccbad58abb3 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -530,7 +530,11 @@ init_syntax_once (void)
530#define MIN(a, b) ((a) < (b) ? (a) : (b)) 530#define MIN(a, b) ((a) < (b) ? (a) : (b))
531 531
532/* Type of source-pattern and string chars. */ 532/* Type of source-pattern and string chars. */
533#ifdef _MSC_VER
534typedef unsigned char re_char;
535#else
533typedef const unsigned char re_char; 536typedef const unsigned char re_char;
537#endif
534 538
535typedef char boolean; 539typedef char boolean;
536#define false 0 540#define false 0
diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h
index 813c3cef115..519f6e7bc63 100644
--- a/src/s/ms-w32.h
+++ b/src/s/ms-w32.h
@@ -86,6 +86,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
86#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_)) 86#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
87 87
88#include <sys/types.h> 88#include <sys/types.h>
89
90#ifdef _MSC_VER
91typedef unsigned long sigset_t;
92typedef int ssize_t;
93#endif
94
89struct sigaction { 95struct sigaction {
90 int sa_flags; 96 int sa_flags;
91 void (*sa_handler)(int); 97 void (*sa_handler)(int);
@@ -181,6 +187,12 @@ struct sigaction {
181 187
182#ifdef emacs 188#ifdef emacs
183 189
190#ifdef _MSC_VER
191#include <sys/timeb.h>
192#include <sys/stat.h>
193#include <signal.h>
194#endif
195
184/* Calls that are emulated or shadowed. */ 196/* Calls that are emulated or shadowed. */
185#undef access 197#undef access
186#define access sys_access 198#define access sys_access
@@ -270,6 +282,15 @@ typedef int pid_t;
270#define utime _utime 282#define utime _utime
271#endif 283#endif
272 284
285#ifdef _MSC_VER
286/* MSVC gets link-time errors without these redirections. */
287#define fstat(a, b) sys_fstat(a, b)
288#define stat(a, b) sys_stat(a, b)
289#if _MSC_VER >= 1400
290#define utime sys_utime
291#endif
292#endif
293
273/* This is hacky, but is necessary to avoid warnings about macro 294/* This is hacky, but is necessary to avoid warnings about macro
274 redefinitions using the SDK compilers. */ 295 redefinitions using the SDK compilers. */
275#ifndef __STDC__ 296#ifndef __STDC__
@@ -317,13 +338,17 @@ extern char *get_emacs_configuration_options (void);
317#define _WINSOCK_H 338#define _WINSOCK_H
318 339
319/* Defines size_t and alloca (). */ 340/* Defines size_t and alloca (). */
320#ifdef USE_CRT_DLL 341#if (defined(_MSC_VER) && defined(emacs)) || defined(USE_CRT_DLL)
321#define malloc e_malloc 342#define malloc e_malloc
322#define free e_free 343#define free e_free
323#define realloc e_realloc 344#define realloc e_realloc
324#define calloc e_calloc 345#define calloc e_calloc
325#endif 346#endif
347#ifdef _MSC_VER
348#define alloca _alloca
349#else
326#include <malloc.h> 350#include <malloc.h>
351#endif
327 352
328#include <sys/stat.h> 353#include <sys/stat.h>
329 354
diff --git a/src/w32.c b/src/w32.c
index 42546fc8d49..f17e987f437 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -94,7 +94,9 @@ typedef struct _MEMORY_STATUS_EX {
94 94
95#include <tlhelp32.h> 95#include <tlhelp32.h>
96#include <psapi.h> 96#include <psapi.h>
97#ifndef _MSC_VER
97#include <w32api.h> 98#include <w32api.h>
99#endif
98#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15) 100#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
99/* This either is not in psapi.h or guarded by higher value of 101/* This either is not in psapi.h or guarded by higher value of
100 _WIN32_WINNT than what we use. w32api supplied with MinGW 3.15 102 _WIN32_WINNT than what we use. w32api supplied with MinGW 3.15
@@ -1547,7 +1549,12 @@ init_environment (char ** argv)
1547 read-only filesystem, like CD-ROM or a write-protected floppy. 1549 read-only filesystem, like CD-ROM or a write-protected floppy.
1548 The only way to be really sure is to actually create a file and 1550 The only way to be really sure is to actually create a file and
1549 see if it succeeds. But I think that's too much to ask. */ 1551 see if it succeeds. But I think that's too much to ask. */
1552#ifdef _MSC_VER
1553 /* MSVC's _access crashes with D_OK. */
1554 if (tmp && sys_access (tmp, D_OK) == 0)
1555#else
1550 if (tmp && _access (tmp, D_OK) == 0) 1556 if (tmp && _access (tmp, D_OK) == 0)
1557#endif
1551 { 1558 {
1552 char * var = alloca (strlen (tmp) + 8); 1559 char * var = alloca (strlen (tmp) + 8);
1553 sprintf (var, "TMPDIR=%s", tmp); 1560 sprintf (var, "TMPDIR=%s", tmp);
diff --git a/src/w32fns.c b/src/w32fns.c
index f7ba1c59e7b..6380a87098a 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -140,8 +140,8 @@ struct MONITOR_INFO
140 DWORD dwFlags; 140 DWORD dwFlags;
141}; 141};
142 142
143/* Reportedly, VS 6 does not have this in its headers. */ 143/* Reportedly, MSVC does not have this in its headers. */
144#if defined (_MSC_VER) && _MSC_VER < 1300 144#ifdef _MSC_VER
145DECLARE_HANDLE(HMONITOR); 145DECLARE_HANDLE(HMONITOR);
146#endif 146#endif
147 147