[m-rev.] for review: function trailing and aligned addresses

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Jan 18 16:13:44 AEDT 2008


On Fri, 18 Jan 2008, Julien Fischer wrote:

>> I think it would be good to add something similar to the value trailing
>> section too.  Namely, that the MR_Word * addresses must be word aligned.
>
> How's this?
>
> Index: reference_manual.texi
> ===================================================================
> RCS file: 
> /home/mercury/mercury1/repository/mercury/doc/reference_manual.texi,v
> retrieving revision 1.415
> diff -u -r1.415 reference_manual.texi
> --- reference_manual.texi	14 Jan 2008 00:08:02 -0000	1.415
> +++ reference_manual.texi	18 Jan 2008 05:00:28 -0000
> @@ -8851,6 +8851,9 @@
>
> @end table
>
> +Note that @var{address} must be word aligned for both
> +both @code{MR_trail_current_value()} and @code{MR_trail_value()}.
> +
> @node Function trailing
> @subsection Function trailing
>
> @@ -8922,6 +8925,9 @@
> If it is called with anything else (such as @samp{MR_gc}),
> then it should probably abort execution with an error message.
>
> +Note that the address of the C function passed as the first argument of
> + at code{MR_trail_function()} must be word aligned.
> +
> @node Delayed goals and floundering
> @subsection Delayed goals and floundering

Actually, it's probably also worth pointing out that Mercury data
structures will already be appropriately aligned, so:

Index: reference_manual.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.415
diff -u -r1.415 reference_manual.texi
--- reference_manual.texi	14 Jan 2008 00:08:02 -0000	1.415
+++ reference_manual.texi	18 Jan 2008 05:11:19 -0000
@@ -8851,6 +8851,12 @@

  @end table

+Note that @var{address} must be word aligned for both
+both @code{MR_trail_current_value()} and @code{MR_trail_value()}.
+(The address of Mercury data structures that have been passed to
+C via the foreign language interface are guaranteed to be appropriately
+aligned.)
+
  @node Function trailing
  @subsection Function trailing

@@ -8922,6 +8928,9 @@
  If it is called with anything else (such as @samp{MR_gc}),
  then it should probably abort execution with an error message.

+Note that the address of the C function passed as the first argument of
+ at code{MR_trail_function()} must be word aligned.
+
  @node Delayed goals and floundering
  @subsection Delayed goals and floundering

We can make similar gurantees about C functions defined in foreign_code
pragmas after the build system has been changed to always enable
-falign-functions.

Julien.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list