[m-dev.] diff/for review: changes to runtime for non-gcc C compilers
Tyson Dowd
trd at stimpy.cs.mu.oz.au
Wed Jul 15 16:16:01 AEST 1998
On 14-Jul-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> I'll commit this now, since the changes are all pretty trivial
> (there's just a lot of them), and since I want to be able to include
> them in our beta distribution as soon as possible, since
> Chris Higgins <c.higgins at ndirect.co.uk>, who is trying to port Mercury
> to the Mac, needs them.
>
> But I'd appreciate it if someone could review this for me anyway.
> Tyson?
>
> --------------------
>
> Fix some problems that caused compilation errors when compiling with
> C compilers other than gcc.
>
> runtime/mercury_engine.c:
> runtime/mercury_ho_call.c:
> runtime/mercury_memory_handlers.c:
> runtime/mercury_signal.c:
> runtime/mercury_table_builtins.c:
> Add casts to fix various type errors.
>
> runtime/mercury_heap.h:
> Add LVALUE_CAST()s in hp_alloc() and hp_alloc_atomic()
> to cast MR_hp to Word when calling incr_hp() and incr_hp_atomic().
>
> runtime/mercury_ho_call.c:
> runtime/mercury_wrapper.c:
> runtime/mercury_engine.c:
> runtime/mercury_type_info.c:
> runtime/mercury_wrapper.c:
> Delete extraneous semicolons after occurrences
> of the MR_MAKE_STACK_LAYOUT_* macros.
>
> runtime/mercury_tabling.h:
> Delete extraneous semicolons in the definitions of the
> table_allocate(), table_reallocate(), and table_free() macros.
> Use <stdarg.h> instead of <varargs.h> and add missing call
> to va_end().
>
> runtime/mercury_goto.h:
> Change the ANSI C versions of the ENTRY(), STATIC(), LOCAL(),
> and LABEL() macros to cast their results to type `Code *'.
> The reason is that although the `Code *' type is actually `void *',
> there is no implicit conversion from pointer to function
> to pointer to void in ANSI C.
>
> runtime/mercury_tabling.h:
>
> runtime/mercury_context.h:
> runtime/mercury_context.c:
> `free_context_list' was declared extern in the header file
> but also declared static in the `.c' file, so I deleted
> the declaration in the header file, and moved the comment
> there into the `.c' file.
>
> runtime/mercury_deep_copy.c:
> Add a missing `static' on the declaration of deep_copy_type_info().
>
> runtime/mercury_trace_external.c:
> Avoid unterminated string literals even inside `#if 0 ... #endif'.
>
> runtime/mercury_types.h:
> Minor changes to a couple of comments.
>
> Index: runtime/mercury_deep_copy.c
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy.c,v
> retrieving revision 1.9
> diff -u -r1.9 mercury_deep_copy.c
> --- mercury_deep_copy.c 1998/06/18 04:30:40 1.9
> +++ mercury_deep_copy.c 1998/07/13 18:01:01
> @@ -319,7 +319,7 @@
> }
>
>
> -Word *
> +static Word *
> deep_copy_type_info(Word *type_info, Word *lower_limit, Word *upper_limit)
> {
> if (in_range(type_info)) {
XXX check this in my change.
> Index: runtime/mercury_engine.c
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
> retrieving revision 1.9
> diff -u -r1.9 mercury_engine.c
> --- mercury_engine.c 1998/06/18 04:30:42 1.9
> +++ mercury_engine.c 1998/07/13 17:59:29
> @@ -33,7 +33,7 @@
> #ifndef USE_GCC_NONLOCAL_GOTOS
> static Code *engine_done(void);
> static Code *engine_init_registers(void);
> - MR_MAKE_STACK_LAYOUT_ENTRY(engine_done);
> + MR_MAKE_STACK_LAYOUT_ENTRY(engine_done)
> #endif
Wouldn't it be easier to leave the semicolon off the macro definition
than all the uses? Otherwise people are just going to add new ones
with semicolons anyway.
> Index: runtime/mercury_heap.h
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_heap.h,v
> retrieving revision 1.5
> diff -u -r1.5 mercury_heap.h
> --- mercury_heap.h 1998/06/09 02:08:00 1.5
> +++ mercury_heap.h 1998/07/13 18:56:58
> @@ -76,11 +76,17 @@
> #define mark_hp(dest) ((void)0)
> #define restore_hp(src) ((void)0)
>
> - /* we use `hp' as a convenient temporary here */
> - #define hp_alloc(count) \
> - (incr_hp(MR_hp, (count)), MR_hp += (count), (void)0)
> - #define hp_alloc_atomic(count) \
> - (incr_hp_atomic(MR_hp, (count)), MR_hp += (count), (void)0)
> + /* we use `MR_hp' as a convenient temporary here */
> + #define hp_alloc(count) ( \
> + incr_hp(LVALUE_CAST(Word, MR_hp), (count)), \
> + MR_hp += (count), \
> + (void)0 \
> + )
> + #define hp_alloc_atomic(count) \
> + incr_hp_atomic(LVALUE_CAST(Word, MR_hp), (count)), \
> + MR_hp += (count), \
> + (void)0 \
> + )
The parentheses don't match in hp_alloc_atomic. Should there be a '('
after hp_alloc_atomic(count)?
> #define table_copy_mem(Dest, Source, Size) \
> - memcpy(Dest, Source, Size);
> + memcpy(Dest, Source, Size)
>
> #ifdef MR_TABLE_DEBUG
>
> #include <stdio.h>
> -#include <varargs.h>
> +#include <stdarg.h>
> +
> +/* XXX should move this to mercury_tabling.c */
Were you intending to do this in this diff?
Otherwise the diff seems fine.
--
Tyson Dowd # "Bill Gates is a white persian cat and a monocle
# away from becoming another James Bond villan."
trd at cs.mu.oz.au # "No Mr Bond, I expect you to upgrade."
http://www.cs.mu.oz.au/~trd # -- Dennis Miller and Terri Branch
More information about the developers
mailing list