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

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Oct 23 23:01:34 AEST 2002


On 23-Oct-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> Bootstrap the main branch using the MS Visual C compiler.
> 
> configure.in:
> 	Check for the _snprintf and sleep functions.
>
> runtime/mercury_conf.h.in:
> 	Add #defines for the _snprintf and sleep functions.

Fine.

Technically, this patch breaks C++-compatibility of the header files,
since C++ reserves all names containing `__' for use by the implementation,
so using `MR_HAVE__SNPRINTF' causes undefined behaviour in C++.
However, in practice this is not likely to cause problems.

> trace/mercury_trace_source.c:
> 	Use the correct version of sleep for the environment that we are
> 	compiling in.

> 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	23 Oct 2002 09:42:07 -0000
> @@ -30,6 +30,10 @@
>    #include <sys/types.h>	/* for getpid() */
>  #endif
>  
> +#ifndef MR_HAVE_SLEEP
> +#include <windows.h>
> +#endif

The #include of <windows.h> needs to be wrapped
inside #ifdef MR_HAVE_WINDOWS_H.

>  #define MR_DEFAULT_SOURCE_WINDOW_COMMAND	"xterm -e"
>  #define MR_DEFAULT_SOURCE_SERVER_COMMAND	"vim"
>  
> @@ -338,7 +342,11 @@
>  		/*
>  		** XXX This is an inaccurate way of keeping time.
>  		*/
> +#ifdef MR_HAVE_SLEEP
>  		sleep(1);
> +#else
> +		Sleep(1000);
> +#endif

Likewise here, the call to Sleep(1000) should be wrapped
inside #ifdef MR_HAVE_CAPITAL_S_SLEEP.

You can use AC_TRY_LINK to compute MR_HAVE_CAPITAL_S_SLEEP.

If neither MR_HAVE_SLEEP nor MR_HAVE_CAPITAL_S_SLEEP are defined,
then the code should do something reasonable.  For example,
it could busy-wait

	/* busy-wait for a few billion cycles, which should hopefully
	   take a second or more. */
	volatile int i;
	for (i = 0; i < 100000000; i++)
		{}

or return an error message.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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