[m-dev.] for review: ANSI C fixes for none.x grades
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Nov 28 19:12:12 AEDT 1999
On 25-Nov-1999, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Peter Ross wrote:
> > is it possible for something to be Declare_static and for this
> > to be the only declaration?
>
> No -- in llds_out.m, in output_single_c_file, the first thing it does
> is to calls gather_c_labels and then output_c_label_decl_list
> to output declarations of all the labels defined in that C file.
Oops, I misread the code: it just outputs declarations of all the
labels *referenced* in that C file, not the labels defined in that C file.
So the declaration is *not* unnecessary. Sorry about the incorrect
advice.
Anyway, because of this, the change that you committed broke --split-c-files.
So I've just committed the following change to fix it.
The solution is rather obvious in retrospect: put the declaration
at file scope rather than using a nested declaration.
(The reasons that the current code uses a nested declaration
are entirely hysterical raisins.)
----------
Estimated hours taken: 0.75
compiler/export.m:
Fix a bug in petdr's recent change to export.m: it turns out
that the Declare_static() declarations that I had said were not
needed are indeed needed. To make it valid ANSI C, I changed the
code to put the declaration at file scope rather than using a nested
declaration.
Workspace: /home/mercury0/fjh/mercury
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.30
diff -u -d -r1.30 export.m
--- export.m 1999/11/25 09:09:31 1.30
+++ export.m 1999/11/28 07:54:13
@@ -104,6 +104,8 @@
% For each exported procedure, produce a C function.
% The code we generate is in the form
%
+ % Declare_entry(<label of called proc>); /* or Declare_static */
+ %
% #if SEMIDET
% bool
% #elif FUNCTION
@@ -133,11 +135,9 @@
% /* save the registers which may be clobbered */
% /* by the C function call MR_call_engine(). */
% save_transient_registers();
- % {
- % /* The Declare_entry may not be necessary */
- % Declare_entry(<label of called proc>);
+ %
% (void) MR_call_engine(ENTRY(<label of called proc>), FALSE);
- % }
+ %
% /* restore the registers which may have been */
% /* clobbered by the return from the C function */
% /* MR_call_engine() */
@@ -179,13 +179,14 @@
llds_out__get_proc_label(ProcLabel, yes, ProcLabelString),
( Exported = yes ->
- string__append_list(["Declare_entry", "(",
- ProcLabelString, ");\n"], DeclareString)
+ DeclareString = "Declare_entry"
;
- DeclareString = ""
+ DeclareString = "Declare_static"
),
string__append_list([ "\n",
+ DeclareString, "(", ProcLabelString, ");\n",
+ "\n",
C_RetType, "\n",
C_Function, "(", ArgDecls, ")\n{\n",
"#if NUM_REAL_REGS > 0\n",
@@ -197,11 +198,8 @@
"\trestore_registers();\n",
InputArgs,
"\tsave_transient_registers();\n",
- "\t{\n\t",
- DeclareString,
"\t(void) MR_call_engine(ENTRY(",
- ProcLabelString,
- "), FALSE);\n\t}\n",
+ ProcLabelString, "), FALSE);\n",
"\trestore_transient_registers();\n",
MaybeFail,
OutputArgs,
--
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