[m-rev.] for review: bootstrap with MSVC as C compiler.

Peter Ross pro at missioncriticalit.com
Fri Oct 25 02:26:48 AEST 2002


Hi,


===================================================================


Estimated hours taken: 5
Branches: main

Bootstrap the main branch using the MS Visual C compiler.

README.MS-VisualC:
	Document that TMPDIR environment variable needs to be set.

configure.in:
boehm_gc/Mmakefile:
runtime/mercury_conf.h.in:
runtime/mercury_stack_trace.c:
trace/mercury_trace.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_source.c:
trace/mercury_trace_spy.c:

configure.in:
	Check for the _snprintf, sleep and Sleep functions and the
	windows.h header.

runtime/mercury_conf.h.in:
	Add #defines for the _snprintf, sleep and Sleep functions and
	windows.h header.

boehm_gc/Mmakefile:
	Compile the collector with debugging turned off so that when linking
	the debugger with the compiler you don't get duplicate definitions
	for the C std lib symbols (the debug versions and the release
	versions).

runtime/mercury_stack_trace.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.c:
	Use _snprintf if snprintf doesn't exist.

trace/mercury_trace.c:
	Report an error if we attempt to use the external debugger when it's
	not enabled.

trace/mercury_trace_source.c:
	Use the correct version of sleep for the environment that we are
	compiling in and if it doesn't exist busy wait for hopefully
	long enough.

*** INTERDIFF ***

diff -u configure.in configure.in
--- configure.in
+++ configure.in
@@ -500,7 +500,7 @@
 		unistd.h sys/wait.h sys/siginfo.h sys/signal.h ucontext.h \
 		asm/sigcontext.h sys/param.h sys/time.h sys/times.h \
 		sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h \
-		sys/stropts.h)
+		sys/stropts.h windows.h)
 
 if test "$MR_HAVE_UCONTEXT_H" != 1; then
 	MERCURY_CHECK_FOR_HEADERS(sys/ucontext.h)
@@ -2782,3 +2782,22 @@
 else
 	AC_MSG_RESULT(no)
 fi
+
+#-----------------------------------------------------------------------------#
+#
+# Check for the WIN32 Sleep function
+#
+AC_MSG_CHECKING(for Sleep function)
+AC_CACHE_VAL(mercury_cv_have_capital_s_sleep,
+AC_TRY_LINK([
+	#include <windows.h>
+],[
+	Sleep(1);
+],[mercury_cv_have_capital_s_sleep=yes],[mercury_cv_have_capital_s_sleep=no]))
+
+if test "$mercury_cv_have_capital_s_sleep" = yes; then
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(MR_HAVE_CAPITAL_S_SLEEP)
+else
+	AC_MSG_RESULT(no)
+fi
diff -u runtime/mercury_conf.h.in runtime/mercury_conf.h.in
--- runtime/mercury_conf.h.in
+++ runtime/mercury_conf.h.in
@@ -125,6 +125,7 @@
 **	MR_HAVE_TERMIOS_H	we have <termios.h>
 **	MR_HAVE_SYS_IOCTL_H	we have <sys/ioctl.h>
 **	MR_HAVE_SYS_STROPTS_H	we have <sys/stropts.h>
+**	MR_HAVE_WINDOWS_H	we have <windows.h>
 */
 #undef	MR_HAVE_SYS_SIGINFO_H
 #undef	MR_HAVE_SYS_SIGNAL_H
@@ -143,6 +144,7 @@
 #undef	MR_HAVE_TERMIOS_H
 #undef	MR_HAVE_SYS_IOCTL_H
 #undef	MR_HAVE_SYS_STROPTS_H
+#undef	MR_HAVE_WINDOWS_H
 
 /*
 ** MR_HAVE_POSIX_TIMES is defined if we have the POSIX
@@ -213,6 +215,7 @@
 **	MR_HAVE_IOCTL		we have the ioctl() function.
 **	MR_HAVE_ACCESS		we have the access() function.
 **	MR_HAVE_SLEEP		we have the sleep() function.
+**	MR_HAVE_CAPITAL_S_SLEEP	we have the Sleep() function.
 */
 #undef	MR_HAVE_GETPID
 #undef	MR_HAVE_SETPGID
@@ -255,6 +258,7 @@
 #undef	MR_HAVE_IOCTL
 #undef	MR_HAVE_ACCESS
 #undef	MR_HAVE_SLEEP
+#undef	MR_HAVE_CAPITAL_S_SLEEP
 
 /*
 ** We use mprotect() and signals to catch stack and heap overflows.
diff -u trace/mercury_trace.c trace/mercury_trace.c
--- trace/mercury_trace.c
+++ trace/mercury_trace.c
@@ -174,7 +174,8 @@
 	switch (MR_trace_ctrl.MR_trace_cmd) {
 		case MR_CMD_COLLECT:
 		  {
-		        MR_Event_Info	event_info;
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+			MR_Event_Info	event_info;
 			MR_Word		*saved_regs = event_info.MR_saved_regs;
 			int		max_r_num;
 			const char	*path;
diff -u trace/mercury_trace_source.c trace/mercury_trace_source.c
--- trace/mercury_trace_source.c
+++ trace/mercury_trace_source.c
@@ -30,7 +30,7 @@
   #include <sys/types.h>	/* for getpid() */
 #endif
 
-#ifndef MR_HAVE_SLEEP
+#ifdef MR_HAVE_WINDOWS_H
 #include <windows.h>
 #endif
 
@@ -344,10 +344,17 @@
 		*/
 #ifdef MR_HAVE_SLEEP
 		sleep(1);
-#else
+#elif MR_HAVE_CAPITAL_S_SLEEP
 		Sleep(1000);
+#else
+        /*
+        ** busy-wait for a few billion cycles, which should hopefully
+        ** take a second or more.
+        */
+        volatile int i;
+        for (i = 0; i < 100000000; i++)
+        {}
 #endif
-
 		msg = MR_trace_source_check_server(real_server_cmd,
 				server->server_name, verbose);
 		if (msg == NULL) {
only in patch2:
--- README.MS-VisualC	30 May 2001 13:51:26 -0000	1.2
+++ README.MS-VisualC	24 Oct 2002 14:50:03 -0000
@@ -18,6 +18,8 @@
 configure defaults to using the hlc.gc grade as this is the only grade
 currently supported.
 
+Also ensure that the environment variable TMPDIR points to a valid directory.
+
 -----------------------------------------------------------------------------
 
 SOURCE INSTALLATION

Index: README.MS-VisualC
===================================================================
RCS file: /home/mercury1/repository/mercury/README.MS-VisualC,v
retrieving revision 1.2
diff -u -r1.2 README.MS-VisualC
--- README.MS-VisualC	30 May 2001 13:51:26 -0000	1.2
+++ README.MS-VisualC	24 Oct 2002 16:11:38 -0000
@@ -18,6 +18,8 @@
 configure defaults to using the hlc.gc grade as this is the only grade
 currently supported.
 
+Also ensure that the environment variable TMPDIR points to a valid directory.
+
 -----------------------------------------------------------------------------
 
 SOURCE INSTALLATION
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.334
diff -u -r1.334 configure.in
--- configure.in	24 Oct 2002 09:16:09 -0000	1.334
+++ configure.in	24 Oct 2002 16:11:43 -0000
@@ -489,18 +489,18 @@
 		sysconf getpagesize gethostname \
 		mprotect memalign memmove \
 		sigaction siginterrupt setitimer \
-		snprintf vsnprintf _vsnprintf strerror \
+		snprintf _snprintf vsnprintf _vsnprintf strerror \
 		open close dup dup2 fdopen fileno fstat stat isatty \
 		getpid setpgid fork execlp wait kill \
 		grantpt unlockpt ptsname tcgetattr tcsetattr ioctl \
-		access
+		access sleep
 
 #-----------------------------------------------------------------------------#
 MERCURY_CHECK_FOR_HEADERS( \
 		unistd.h sys/wait.h sys/siginfo.h sys/signal.h ucontext.h \
 		asm/sigcontext.h sys/param.h sys/time.h sys/times.h \
 		sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h \
-		sys/stropts.h)
+		sys/stropts.h windows.h)
 
 if test "$MR_HAVE_UCONTEXT_H" != 1; then
 	MERCURY_CHECK_FOR_HEADERS(sys/ucontext.h)
@@ -2779,6 +2779,25 @@
 if test "$mercury_cv_have_posix_times" = yes; then
 	AC_MSG_RESULT(yes)
 	AC_DEFINE(MR_HAVE_POSIX_TIMES)
+else
+	AC_MSG_RESULT(no)
+fi
+
+#-----------------------------------------------------------------------------#
+#
+# Check for the WIN32 Sleep function
+#
+AC_MSG_CHECKING(for Sleep function)
+AC_CACHE_VAL(mercury_cv_have_capital_s_sleep,
+AC_TRY_LINK([
+	#include <windows.h>
+],[
+	Sleep(1);
+],[mercury_cv_have_capital_s_sleep=yes],[mercury_cv_have_capital_s_sleep=no]))
+
+if test "$mercury_cv_have_capital_s_sleep" = yes; then
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(MR_HAVE_CAPITAL_S_SLEEP)
 else
 	AC_MSG_RESULT(no)
 fi
Index: boehm_gc/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/Mmakefile,v
retrieving revision 1.22
diff -u -r1.22 Mmakefile
--- boehm_gc/Mmakefile	22 Oct 2002 14:55:17 -0000	1.22
+++ boehm_gc/Mmakefile	24 Oct 2002 16:11:43 -0000
@@ -42,7 +42,7 @@
 
 submake: force
 	MAKEFLAGS=""; export MAKEFLAGS; \
-	nmake -f NT_MAKEFILE gc.lib; \
+	nmake -f NT_MAKEFILE nodebug=1 gc.lib; \
 	cp gc.lib libgc.lib 
 
 clean_local:
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.45
diff -u -r1.45 mercury_conf.h.in
--- runtime/mercury_conf.h.in	16 Oct 2002 05:45:24 -0000	1.45
+++ runtime/mercury_conf.h.in	24 Oct 2002 16:11:48 -0000
@@ -125,6 +125,7 @@
 **	MR_HAVE_TERMIOS_H	we have <termios.h>
 **	MR_HAVE_SYS_IOCTL_H	we have <sys/ioctl.h>
 **	MR_HAVE_SYS_STROPTS_H	we have <sys/stropts.h>
+**	MR_HAVE_WINDOWS_H	we have <windows.h>
 */
 #undef	MR_HAVE_SYS_SIGINFO_H
 #undef	MR_HAVE_SYS_SIGNAL_H
@@ -143,6 +144,7 @@
 #undef	MR_HAVE_TERMIOS_H
 #undef	MR_HAVE_SYS_IOCTL_H
 #undef	MR_HAVE_SYS_STROPTS_H
+#undef	MR_HAVE_WINDOWS_H
 
 /*
 ** MR_HAVE_POSIX_TIMES is defined if we have the POSIX
@@ -177,6 +179,7 @@
 **	MR_HAVE_KILL		we have the kill() function.
 ** 	MR_HAVE_GETHOSTNAME	we have the gethostname() function.
 **	MR_HAVE_SNPRINTF 	we have the snprintf() function.
+**	MR_HAVE__SNPRINTF 	we have the _snprintf() function.
 **	MR_HAVE_VSNPRINTF 	we have the vsnprintf() function.
 **	MR_HAVE__VSNPRINTF 	we have the _vsnprintf() function.
 **	MR_HAVE_SYSCONF     	we have the sysconf() system call.
@@ -211,6 +214,8 @@
 **	MR_HAVE_TCSETATTR	we have the tcsetattr() function.
 **	MR_HAVE_IOCTL		we have the ioctl() function.
 **	MR_HAVE_ACCESS		we have the access() function.
+**	MR_HAVE_SLEEP		we have the sleep() function.
+**	MR_HAVE_CAPITAL_S_SLEEP	we have the Sleep() function.
 */
 #undef	MR_HAVE_GETPID
 #undef	MR_HAVE_SETPGID
@@ -220,6 +225,7 @@
 #undef	MR_HAVE_KILL
 #undef	MR_HAVE_GETHOSTNAME
 #undef	MR_HAVE_SNPRINTF
+#undef	MR_HAVE__SNPRINTF
 #undef	MR_HAVE_VSNPRINTF
 #undef	MR_HAVE__VSNPRINTF
 #undef	MR_HAVE_SYSCONF
@@ -251,6 +257,8 @@
 #undef	MR_HAVE_TCSETATTR
 #undef	MR_HAVE_IOCTL
 #undef	MR_HAVE_ACCESS
+#undef	MR_HAVE_SLEEP
+#undef	MR_HAVE_CAPITAL_S_SLEEP
 
 /*
 ** We use mprotect() and signals to catch stack and heap overflows.
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.49
diff -u -r1.49 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c	11 Sep 2002 07:20:27 -0000	1.49
+++ runtime/mercury_stack_trace.c	24 Oct 2002 16:11:48 -0000
@@ -21,6 +21,10 @@
 #include "mercury_trace_base.h"
 #include <stdio.h>
 
+#if defined(MR_HAVE__SNPRINTF) && ! defined(MR_HAVE_SNPRINTF)
+  #define snprintf	_snprintf
+#endif
+
 #ifndef MR_HIGHLEVEL_CODE
 
 static  const char  *MR_step_over_nondet_frame(FILE *fp,
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.56
diff -u -r1.56 mercury_trace.c
--- trace/mercury_trace.c	22 Oct 2002 12:50:30 -0000	1.56
+++ trace/mercury_trace.c	24 Oct 2002 16:11:49 -0000
@@ -174,7 +174,8 @@
 	switch (MR_trace_ctrl.MR_trace_cmd) {
 		case MR_CMD_COLLECT:
 		  {
-		        MR_Event_Info	event_info;
+#ifdef MR_USE_EXTERNAL_DEBUGGER
+			MR_Event_Info	event_info;
 			MR_Word		*saved_regs = event_info.MR_saved_regs;
 			int		max_r_num;
 			const char	*path;
@@ -211,6 +212,9 @@
 				return MR_trace_event(&MR_trace_ctrl, MR_TRUE,
                                                layout, port, seqno, depth);
 			}
+#else
+			MR_fatal_error("attempt to use external debugger");
+#endif
 
 			goto check_stop_print;
 		  }	
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.144
diff -u -r1.144 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	22 Oct 2002 04:36:26 -0000	1.144
+++ trace/mercury_trace_internal.c	24 Oct 2002 16:11:50 -0000
@@ -85,6 +85,10 @@
 #define	MDBRC_FILENAME		".mdbrc"
 #define	DEFAULT_MDBRC_FILENAME	"mdbrc"
 
+#if defined(MR_HAVE__SNPRINTF) && ! defined(MR_HAVE_SNPRINTF)
+  #define snprintf	_snprintf
+#endif
+
 /*
 ** XXX We should consider whether all the static variables in this module
 ** should be thread local.
Index: trace/mercury_trace_source.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_source.c,v
retrieving revision 1.6
diff -u -r1.6 mercury_trace_source.c
--- trace/mercury_trace_source.c	18 Feb 2002 07:01:31 -0000	1.6
+++ trace/mercury_trace_source.c	24 Oct 2002 16:11:50 -0000
@@ -30,6 +30,10 @@
   #include <sys/types.h>	/* for getpid() */
 #endif
 
+#ifdef MR_HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
 #define MR_DEFAULT_SOURCE_WINDOW_COMMAND	"xterm -e"
 #define MR_DEFAULT_SOURCE_SERVER_COMMAND	"vim"
 
@@ -338,8 +342,19 @@
 		/*
 		** XXX This is an inaccurate way of keeping time.
 		*/
+#ifdef MR_HAVE_SLEEP
 		sleep(1);
-
+#elif MR_HAVE_CAPITAL_S_SLEEP
+		Sleep(1000);
+#else
+        /*
+        ** busy-wait for a few billion cycles, which should hopefully
+        ** take a second or more.
+        */
+        volatile int i;
+        for (i = 0; i < 100000000; i++)
+        {}
+#endif
 		msg = MR_trace_source_check_server(real_server_cmd,
 				server->server_name, verbose);
 		if (msg == NULL) {
Index: trace/mercury_trace_spy.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_spy.c,v
retrieving revision 1.20
diff -u -r1.20 mercury_trace_spy.c
--- trace/mercury_trace_spy.c	18 Feb 2002 07:01:31 -0000	1.20
+++ trace/mercury_trace_spy.c	24 Oct 2002 16:11:50 -0000
@@ -21,6 +21,13 @@
 
 #include <stdlib.h>
 
+#if defined(MR_HAVE__SNPRINTF) && ! defined(MR_HAVE_SNPRINTF)
+  #define snprintf	_snprintf
+#endif
+
+#if defined(MR_HAVE_SNPRINTF) || defined(MR_HAVE__SNPRINTF)
+  #define MR_HAVE_A_SNPRINTF
+#endif
 const char		*MR_spy_when_names[] =
 {
 	"all",
@@ -409,7 +416,7 @@
 
 	if (new_size == old_size) {
 		/* there were no matching labels */
-#ifdef	MR_HAVE_SNPRINTF
+#ifdef	MR_HAVE_A_SNPRINTF
 		snprintf(MR_error_msg_buf, MR_ERROR_MSG_BUF_SIZE,
 			"there is no event at %s:%d",
 			filename, linenumber);

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list