Support MSVC build with newer versions of Visual Studio.
[bpt/emacs.git] / src / s / ms-w32.h
index 8b189ba..519f6e7 100644 (file)
@@ -86,6 +86,12 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
 
 #include <sys/types.h>
+
+#ifdef _MSC_VER
+typedef unsigned long sigset_t;
+typedef int ssize_t;
+#endif
+
 struct sigaction {
   int sa_flags;
   void (*sa_handler)(int);
@@ -111,11 +117,7 @@ struct sigaction {
 #undef  HAVE_UTIME_H
 #undef  HAVE_LINUX_VERSION_H
 #undef  HAVE_SYS_SYSTEMINFO_H
-#define HAVE_LIMITS_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STDLIB_H 1
 #define HAVE_PWD_H 1
-#define STDC_HEADERS 1
 #define TIME_WITH_SYS_TIME 1
 
 #define HAVE_GETTIMEOFDAY 1
@@ -185,6 +187,12 @@ struct sigaction {
 
 #ifdef emacs
 
+#ifdef _MSC_VER
+#include <sys/timeb.h>
+#include <sys/stat.h>
+#include <signal.h>
+#endif
+
 /* Calls that are emulated or shadowed.  */
 #undef access
 #define access  sys_access
@@ -204,6 +212,7 @@ struct sigaction {
 #define dup2    sys_dup2
 #define fopen   sys_fopen
 #define link    sys_link
+#define localtime sys_localtime
 #define mkdir   sys_mkdir
 #undef mktemp
 #define mktemp  sys_mktemp
@@ -273,6 +282,15 @@ typedef int pid_t;
 #define utime    _utime
 #endif
 
+#ifdef _MSC_VER
+/* MSVC gets link-time errors without these redirections.  */
+#define fstat(a, b) sys_fstat(a, b)
+#define stat(a, b)  sys_stat(a, b)
+#if _MSC_VER >= 1400
+#define utime       sys_utime
+#endif
+#endif
+
 /* This is hacky, but is necessary to avoid warnings about macro
    redefinitions using the SDK compilers.  */
 #ifndef __STDC__
@@ -320,13 +338,17 @@ extern char *get_emacs_configuration_options (void);
 #define _WINSOCK_H
 
 /* Defines size_t and alloca ().  */
-#ifdef USE_CRT_DLL
+#if (defined(_MSC_VER) && defined(emacs)) || defined(USE_CRT_DLL)
 #define malloc e_malloc
 #define free   e_free
 #define realloc e_realloc
 #define calloc e_calloc
 #endif
+#ifdef _MSC_VER
+#define alloca _alloca
+#else
 #include <malloc.h>
+#endif
 
 #include <sys/stat.h>
 
@@ -385,4 +407,3 @@ extern void _DebPrint (const char *fmt, ...);
 
 
 /* ============================================================ */
-