[m-dev.] for review: add Mission Critical extensions

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Jul 28 01:25:16 AEST 2000


On 20-Jul-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> runtime/mercury_library_types.h:
>     If MISCRIT_STREAMS is defined use the Mission Critical version of
>     the type MercuryFile.  The new definition of MercuryFile makes it
>     possible for Mercury to handle streams connected to sockets and
>     pipes under WinNT.

I think you should explain here why that wasn't possible previously.

> runtime/mercury_miscrit_stream.c:
> runtime/mercury_miscrit_stream.h:
>     Define the basic functions which operate on a MercuryFile structure
>     when it is a real file.
> 
> Index: configure.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/configure.in,v
> retrieving revision 1.212
> diff -u -r1.212 configure.in
> --- configure.in	2000/06/29 09:55:33	1.212
> +++ configure.in	2000/07/20 17:03:07
> @@ -2378,6 +2378,17 @@
>  LIBS="$save_LIBS"
>  
>  #-----------------------------------------------------------------------------#
> +
> +AC_ARG_ENABLE(mc,
> +[  --enable-miscrit-exts   enable the Mission Critical extensions],
> +ac_miscrit=yes,ac_miscrit=no)
> +
> +if test "$ac_miscrit" = "yes"; then
> +	MERCURY_MSG("Enabling the Mission Critical extensions.")
> +	AC_DEFINE(MR_MISCRIT_EXTS)
> +fi

I suggest putting a pointer here to the place where you
document what the Mission Critical extensions are,
i.e. runtime/mercury_conf.h.in.

> --- runtime/mercury_conf.h.in	2000/06/29 09:55:35	1.27
> +++ runtime/mercury_conf.h.in	2000/07/20 17:03:41
> @@ -346,6 +346,18 @@
>  #undef  HAVE_READLINE_READLINE
>  #undef  HAVE_READLINE_HISTORY
>  
> +
> +/*
> +** MR_MISCRIT_EXTS
> +**	Set this if you want to use the Mission Critical version of the
> +**	compiler.
> +**  The Mission Critical version of the compiler includes
> +**      -- changes to the MercuryFile Structure to allow it to be used
> +**         with sockets and pipes under WinNT.  Note that enabling this
> +**         feature only puts the background machinery in place.
> +*/
> +#undef	MR_MISCRIT_EXTS

I think here you should have a lot more documentation, explaining why
the changes to the MercuryFile structure are needed, and why they
aren't incorporated in the mainstream compiler.

> +++ runtime/mercury_conf_param.h	2000/07/20 17:03:43
> @@ -392,4 +392,17 @@
>  
>  /*---------------------------------------------------------------------------*/
>  
> +/*
> +** Mission Critical specific.
> +*/
> +
> +/*
> +** MISCRIT_STREAMS -- Use Mission Critical streams for I/O.
> +*/
> +#ifdef MR_MISCRIT_EXTS
> +  #define MISCRIT_STREAMS
> +#endif

I think here you should a pointer to the documentation
in runtime/mercury_conf.h.in.

> +++ runtime/mercury_library_types.h	2000/07/20 17:03:44
> @@ -23,10 +23,103 @@
>  ** because we keep track of a little bit more information.
>  */
>  
> -typedef struct mercury_file {
> -	FILE *file;
> -	int line_number;
> -} MercuryFile;
> +#ifndef MISCRIT_STREAMS
> +  typedef struct mercury_file {
> +	FILE *file1;
> +	int line_number1;
> +  } MercuryFile;
> +
> +  #define MR_file(mf)		(mf).file1
> +  #define MR_line_number(mf)	(mf).line_number1
> +
> +  #define MR_IS_FILE_STREAM(mf)	( TRUE )
> +
> +  #define MR_MERCURYFILE_INIT(file, line_number)		\
> +  		{ (file), (line_number) }
> +
> +  #define MR_CLOSE(mf)		fclose(MR_file(mf))
> +  #define MR_FLUSH(mf)		fflush(MR_file(mf))
> +
> +  #define MR_READ(mf, ptr, size)	\
> +  		fread((ptr), sizeof(unsigned char), (size), MR_file(mf))
> +  #define MR_WRITE(mf, ptr, size)	\
> +  		fwrite((ptr), sizeof(unsigned char), (size), MR_file(mf))
> +
> +  #define MR_UNGETCH(mf, ch)	ungetc((int) (ch), MR_file(mf))
> +  #define MR_GETCH(mf)		getc(MR_file(mf))
> +
> +  #define MR_VFPRINTF(mf, fmt, args)	\
> +  		vfprintf(MR_file(mf), (fmt), (args))
> +
> +  #define MR_PUTCH(mf, ch)	putc((ch), MR_file(mf))
> +#else
> +  #include "mercury_miscrit_stream.h"
> +
> +  typedef enum {
> +	MR_FILE_STREAM		= 1,
> +	MR_SOCKET_STREAM	= 2,
> +	MR_PIPE_STREAM		= 3,
> +	MR_USER_STREAM		= 4
> +  } MR_StreamType;
> +
> +  typedef int (MR_Stream_close)(MR_StreamInfo *);
> +  typedef int (MR_Stream_flush)(MR_StreamInfo *);
> +  typedef int (MR_Stream_read)(MR_StreamInfo *, void *, size_t);
> +  typedef int (MR_Stream_write)(MR_StreamInfo *, const void *, size_t);
> +  typedef int (MR_Stream_ungetch)(MR_StreamInfo *, int);
> +  typedef int (MR_Stream_getch)(MR_StreamInfo *);
> +  typedef int (MR_Stream_printf)(MR_StreamInfo *, const char *, va_list);
> +  typedef int (MR_Stream_putch)(MR_StreamInfo *, int);
> +
> +  typedef struct mercury_file {
> +	MR_StreamType	stream_type;
> +	MR_StreamInfo	stream_info;
> +	int		line_number;
> +
> +	MR_Stream_close	*close;    
> +	MR_Stream_flush	*flush;
> +	MR_Stream_read	*read;
> +	MR_Stream_write	*write;
> +
> +		/* BUFFERED FUNCTIONS */
> +	MR_Stream_ungetch	*ungetch;
> +	MR_Stream_getch		*getch;
> +	MR_Stream_printf	*printf;
> +	MR_Stream_putch		*putch;
> +  } MercuryFile;
> +
> +  #define MR_file(mf)		(mf).stream_info.file
> +  #define MR_line_number(mf)	(mf).line_number
> +
> +  #define MR_IS_FILE_STREAM(mf)	( (mf).stream_type == MR_FILE_STREAM )
> +
> +  #define MR_MERCURYFILE_INIT(file, line_number)		\
> +  		{ MR_FILE_STREAM, (file), (line_number),	\
> +		  MR_mc_close, MR_mc_flush, MR_mc_read,		\
> +		  MR_mc_write, MR_mc_ungetch, MR_mc_getch,	\
> +		  MR_mc_vfprintf, MR_mc_putch			\
> +		}
> +
> +  #define MR_CLOSE(mf)	((mf).close)(&((mf).stream_info))
> +  #define MR_FLUSH(mf)	((mf).flush)(&((mf).stream_info))
> +
> +  #define MR_READ(mf, ptr, size)	\
> +  		((mf).read)(&((mf).stream_info), (ptr), (size))
> +  #define MR_WRITE(mf, ptr, size)	\
> +  		((mf).write)(&((mf).stream_info), (ptr), (size))
> +
> +  #define MR_UNGETCH(mf, ch)	\
> +  		((mf).ungetch)(&((mf).stream_info), (ch))
> +
> +  #define MR_GETCH(mf)	((mf).getch)(&((mf).stream_info))
> +
> +  #define MR_VFPRINTF(mf, fmt, args)	\
> +  		((mf).printf)(&((mf).stream_info), (fmt), (args))
> +
> +  #define MR_PUTCH(mf, ch)	\
> +  		((mf).putch)(&((mf).stream_info), (ch))
> +
> +#endif

There should be more documentation here, and a pointer to
the documentation in runtime/mercury_conf.h.in.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list