From 56d36b014ac0ad128268e979e24d449d28330721 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Sun, 18 Feb 2007 08:01:56 +0000 Subject: [PATCH] Build Mercury using MSVC 6. boehm_gc/NT_MAKEFILE: msvc_dbg.c is in the include\private directory. boehm_gc/msvc_dbg.c: Define ULONG_PTR as an int. compiler/prog_event.m: ssize_t isn't defined under windows. library/par_builtin.m: The CL compiler doesn't accept empty structs. robdd/Makefile: -Wall isn't a valid option to CL. runtime/mercury_mm_own_stacks.c: runtime/mercury_term_size.c: Conditionally import unistd.h runtime/mercury_trace_base.c: Use the correct version of snprintf. Fix the MR_FILE_EXISTS macro to work under win32. --- boehm_gc/NT_MAKEFILE | 2 +- boehm_gc/msvc_dbg.c | 2 ++ compiler/prog_event.m | 2 +- library/par_builtin.m | 1 + robdd/Makefile | 4 ++-- runtime/mercury_mm_own_stacks.c | 4 +++- runtime/mercury_term_size.c | 4 +++- runtime/mercury_trace_base.c | 14 +++++++++++++- 8 files changed, 26 insertions(+), 7 deletions(-) diff --git a/boehm_gc/NT_MAKEFILE b/boehm_gc/NT_MAKEFILE index e521bfdc7..297f6a243 100644 --- a/boehm_gc/NT_MAKEFILE +++ b/boehm_gc/NT_MAKEFILE @@ -16,7 +16,7 @@ all: gctest.exe cord\de.exe test_cpp.exe .cpp.obj: $(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DALL_INTERIOR_POINTERS -DGC_NOT_DLL -DGC_BUILD $*.CPP /Fo$*.obj -$(OBJS) tests\test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_pmark.h include\gc_mark.h include\msvc_dbg.h +$(OBJS) tests\test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_pmark.h include\gc_mark.h include\private\msvc_dbg.h gc.lib: $(OBJS) lib /MACHINE:i386 /out:gc.lib $(OBJS) diff --git a/boehm_gc/msvc_dbg.c b/boehm_gc/msvc_dbg.c index 82e0de6e1..adb195aa3 100644 --- a/boehm_gc/msvc_dbg.c +++ b/boehm_gc/msvc_dbg.c @@ -34,6 +34,8 @@ #ifdef _WIN64 typedef ULONG_PTR ULONG_ADDR; #else + /* the following line is needed for MSVC 6 */ + typedef int ULONG_PTR; typedef ULONG ULONG_ADDR; #endif diff --git a/compiler/prog_event.m b/compiler/prog_event.m index 53e890f5b..fb7d119cf 100644 --- a/compiler/prog_event.m +++ b/compiler/prog_event.m @@ -203,7 +203,7 @@ read_event_set(SpecsFileName, EventSetName, EventSpecMap, ErrorSpecs, !IO) :- SpecsFileName); MR_make_aligned_string_copy(Problem, buf); } else { - ssize_t num_bytes_read; + size_t num_bytes_read; num_bytes_read = read(spec_fd, spec_buf, stat_buf.st_size); if (num_bytes_read != stat_buf.st_size) { diff --git a/library/par_builtin.m b/library/par_builtin.m index 20d27de23..129f910a8 100644 --- a/library/par_builtin.m +++ b/library/par_builtin.m @@ -82,6 +82,7 @@ }; #else /* !MR_THREAD_SAFE */ struct MR_Future { + char dummy; /* ANSI C doesn't allow empty structs */ }; #endif /* !MR_THREAD_SAFE */ "). diff --git a/robdd/Makefile b/robdd/Makefile index 1145f7d9c..0235c5e80 100644 --- a/robdd/Makefile +++ b/robdd/Makefile @@ -1,5 +1,5 @@ #-----------------------------------------------------------------------------# -# Copyright (C) 2001-2004 University of Melbourne. +# Copyright (C) 2001-2004,2007 University of Melbourne. # This file may only be copied under the terms of the GNU General # Public Licence - see the file COPYING in the Mercury distribution. #-----------------------------------------------------------------------------# @@ -38,7 +38,7 @@ GENFILES=$(COMMONOS) $(TESTOS) # Unix options LINKSW=-o DEF=-D -MSGS=-Wall +MSGS= RM=rm -f MV=mv MKDIR=mkdir diff --git a/runtime/mercury_mm_own_stacks.c b/runtime/mercury_mm_own_stacks.c index fe7e9ddd9..763a969fb 100644 --- a/runtime/mercury_mm_own_stacks.c +++ b/runtime/mercury_mm_own_stacks.c @@ -19,7 +19,9 @@ #include "mercury_dlist.h" #include -#include /* for sleep() */ +#ifdef MR_HAVE_UNISTD_H + #include /* for sleep() */ +#endif #ifdef MR_MINIMAL_MODEL_DEBUG /* diff --git a/runtime/mercury_term_size.c b/runtime/mercury_term_size.c index 9cdd95907..ad1b89981 100644 --- a/runtime/mercury_term_size.c +++ b/runtime/mercury_term_size.c @@ -18,7 +18,9 @@ #include #include #include -#include +#ifdef MR_HAVE_UNISTD_H + #include +#endif #include #ifdef MR_RECORD_TERM_SIZES diff --git a/runtime/mercury_trace_base.c b/runtime/mercury_trace_base.c index de8f06fd9..c695cbfb4 100644 --- a/runtime/mercury_trace_base.c +++ b/runtime/mercury_trace_base.c @@ -43,6 +43,10 @@ ENDINIT #include /* for the wait system call */ #endif +#if defined(MR_HAVE__SNPRINTF) && ! defined(MR_HAVE_SNPRINTF) + #define snprintf _snprintf +#endif + #define MR_TRACE_COUNT_SUMMARY_MAX_DEFAULT 20 void (*MR_trace_shutdown)(void) = NULL; @@ -274,7 +278,15 @@ MR_PathPort MR_named_count_port[MR_PORT_NONE + 1]; #define MERCURY_TRACE_COUNTS_PREFIX "mercury_trace_counts" #define TEMP_SUFFIX ".tmp" -#define MR_FILE_EXISTS(filename) (access(filename, F_OK) == 0) +#if defined(F_OK) + /* unistd.h version */ + #define MR_PERMISSIONS F_OK +#else + /* win32 version */ + #define MR_PERMISSIONS 0 +#endif + +#define MR_FILE_EXISTS(filename) (access(filename, MR_PERMISSIONS) == 0) void MR_trace_record_label_exec_counts(void *dummy)