Files
mercury/runtime/mercury_proc_id.h
Mark Brown 67791773af Fix some warnings and type errors that show up on the x86_64 architecture.
Estimated hours taken: 3
Branches: main

Fix some warnings and type errors that show up on the x86_64 architecture.

browser/io_action.m:
	Declare is_func in the C code for pickup_io_action to be MR_Bool
	rather than MR_bool, since it is a (word sized) Mercury bool, not
	a C boolean.

library/construct.m:
runtime/mercury_unify_compare_body.h:
	Provide values for variables even when MR_fatal_error is called,
	to avoid warnings about uninitialized variables.  Add default
	switch cases which call MR_fatal_error.

mdbcomp/rtti_access.m:
	Pass an int* to MR_find_context, and cast the result to an MR_Integer
	afterwards.

robdd/bryant.h:
	This code incorrectly assumes that unsigned long will have 32 bits.
	Flag the error with an XXX.

runtime/mercury_deconstruct.c:
trace/mercury_trace_internal.c:
	Cast arity values to int before printing.  We don't support
	arity > 1024 anyway.

runtime/mercury_proc_id.h:
runtime/mercury_types.h:
	Add an extra branch to the MR_Proc_Id union for the case when no
	proc id is present, and add a macro to test for this case.  We can't
	test the enum directly as we did before, because C compilers may
	report a warning that the test will never succeed (since -1 is not
	one of the values in the enum).

	Clarify the comment about the requirement of MR_PredFunc to match
	prim_data.pred_or_func.

	Define a macro for the value that indicates there is no proc id.

	Fix a couple of out-of-date comments.

trace/mercury_trace_browse.h:
	Clarify the comments about the requirement of MR_Browse_Caller_Type,
	MR_Browse_Format and MR_Query_Type to match their corresponding
	Mercury types.

runtime/mercury_tags.h:
	Add a comment to point out that enums don't necessarily have the
	same size as MR_words.

runtime/mercury_stack_layout.h:
	Use the new macro instead of testing directly whether the proc id
	exists.

runtime/mercury_stack_trace.c:
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
trace/mercury_trace_internal.c:
	Use MR_INTEGER_LENGTH_MODIFIER, which is set by `configure', to
	get the right format specifier when printing integers with the same
	size as MR_Word.

runtime/mercury_type_info.c:
	Compare pseudo-typeinfos as MR_Integers rather than ints.

trace/mercury_trace.c:
trace/mercury_trace_tables.c:
	Provide a dummy value for variables to avoid uninitialized variable
	warnings.

trace/mercury_trace_completion.c:
	Cast a void* to MR_Integer before casting it to int.  It would be
	nicer to avoid the second cast altogether, but the readline interface
	requires it.

trace/mercury_trace_internal.c:
	Use MR_trace_is_unsigned when working with MR_Unsigned values.

	Cast pseudo-typeinfos which are variables to MR_Integer rather than
	int, to avoid compiler warnings about pointer casts.  We cast them
	to int before printing them, but that is because we know they won't
	be that big.

	Parse the argument to the goto command as type MR_Unsigned instead
	of int, to make it possible to goto an event with a number bigger
	than 2^31, on 64-bit machines at least.  (We already get 200M+
	events when the compiler is in a debug grade.)

trace/mercury_trace_util.c:
trace/mercury_trace_util.h:
	Provide MR_trace_is_unsigned, which is like MR_trace_is_natural_number
	except that it works with MR_Unsigned values.

trace/mercury_trace_vars.c:
	Cast void* to MR_Integer rather than int.
2005-09-01 07:37:26 +00:00

97 lines
3.3 KiB
C

/*
** Copyright (C) 2003-2005 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
*/
/* mercury_proc_id.h - definitions for recording procedure ids */
#ifndef MERCURY_PROC_ID_H
#define MERCURY_PROC_ID_H
#include "mercury_types.h" /* for MR_ConstString etc */
#include "mercury_tags.h" /* for MR_DEFINE_BUILTIN_ENUM_CONST */
/*
** The MR_PredFunc type indicates whether a procedure came from a predicate
** or a function. The constants defined by this enum should have values
** that correspond directly to the values in the representation of the
** `pred_or_func' type in mdbcomp/prim_data.m, so that it is possible to
** cast to/from MR_Word in order to interface with Mercury code.
*/
typedef enum {
MR_DEFINE_BUILTIN_ENUM_CONST(MR_PREDICATE),
MR_DEFINE_BUILTIN_ENUM_CONST(MR_FUNCTION)
} MR_PredFunc;
/*
** This value should be distinct from any of the values in MR_PredFuncEnum.
** It is used in MR_Proc_Id in the place where an MR_PredFunc field would be,
** and indicates that no proc id exists.
*/
#define MR_NO_PROC_ID -1
/*
** MR_Proc_Id is a union. The first alternative identifies ordinary
** procedures, while the second alternative identifies automatically generated
** unification, comparison, index and initialisation procedures. The third
** alternative indicates that no proc id exists. The meanings of the fields
** in the first two forms are the same as in procedure labels. The runtime
** system can figure out if a proc id exists by using the macro
** MR_PROC_ID_EXISTS, and it can figure out which form is present by using
** the macro MR_PROC_ID_IS_UCI, which will return true only if the proc id
** exists and the procedure is of the second type.
**
** The compiler generates MR_User_Proc_Id and MR_UCI_Proc_Id structures
** in order to avoid having to initialize the MR_Proc_Id union through the
** inapplicable alternative, since the C standard in widespread use now
** doesn't support that.
**
** The places that know about the structure of procedure ids include
** browser/dl.m and besides all the places that refer to the C types below.
*/
struct MR_User_Proc_Id_Struct {
MR_PredFunc MR_user_pred_or_func;
MR_ConstString MR_user_decl_module;
MR_ConstString MR_user_def_module;
MR_ConstString MR_user_name;
MR_int_least16_t MR_user_arity;
MR_int_least16_t MR_user_mode;
};
struct MR_UCI_Proc_Id_Struct {
MR_ConstString MR_uci_type_name;
MR_ConstString MR_uci_type_module;
MR_ConstString MR_uci_def_module;
MR_ConstString MR_uci_pred_name;
MR_int_least16_t MR_uci_type_arity;
MR_int_least16_t MR_uci_mode;
};
struct MR_No_Proc_Id_Struct {
/*
** This field should align with the first field of
** MR_User_Proc_Id_Struct, which means that it should have the same
** size as MR_PredFunc. Its value should always be equal to
** MR_NO_PROC_ID.
*/
int MR_no_proc_id_flag;
};
union MR_Proc_Id_Union {
MR_User_Proc_Id MR_proc_user;
MR_UCI_Proc_Id MR_proc_uci;
MR_No_Proc_Id MR_proc_none;
};
#define MR_PROC_ID_EXISTS(proc_id) \
((proc_id).MR_proc_none.MR_no_proc_id_flag != MR_NO_PROC_ID)
#define MR_PROC_ID_IS_UCI(proc_id) \
((MR_Unsigned) (proc_id).MR_proc_user.MR_user_pred_or_func \
> MR_FUNCTION)
#endif /* not MERCURY_PROC_ID_H */