[m-rev.] for review: fix link errors in profiling grades

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Aug 15 15:26:13 AEST 2002


tools/make_port_code:
	Generate bodies for the profiling builtin predicates for all grades,
	in order to avoid link errors when using the profiling grades.
	For non-deep-profiling grades, the bodies just abort.

Zoltan.

cvs diff: Diffing .
Index: make_port_code
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/make_port_code,v
retrieving revision 1.1
diff -u -b -r1.1 make_port_code
--- make_port_code	2002/08/09 05:26:52	1.1
+++ make_port_code	2002/08/15 05:20:45
@@ -20,11 +20,13 @@
 tmp_declare_entry="/tmp/make_port_code_decl_$$"
 tmp_define_entry="/tmp/make_port_code_defn_$$"
 tmp_init_entry="/tmp/make_port_code_init_$$"
-trap "/bin/rm $tmp_code $tmp_prolog $tmp_declare_entry $tmp_define_entry $tmp_init_entry" 0 1 2 3 15
+tmp_hlc="/tmp/make_port_code_hlc_$$"
+trap "/bin/rm $tmp_code $tmp_prolog $tmp_declare_entry $tmp_define_entry $tmp_init_entry $tmp_hlc" 0 1 2 3 15
 > ${tmp_code}
 > ${tmp_declare_entry}
 > ${tmp_define_entry}
 > ${tmp_init_entry}
+> ${tmp_hlc}
 
 cat > ${tmp_prolog} << END
 /*
@@ -37,7 +39,7 @@
 ** The contents of this file were generated by the make_port_code script
 ** in the tools directory. Do not edit.
 **
-** The function of the code in this file is described in the paper on deep
+** The function of the code in this module is described in the paper on deep
 ** profiling by Thomas Conway and Zoltan Somogyi.
 */
 
@@ -179,7 +181,40 @@
 
             init="MR_init_entry_an(${prefix}${name});"
             echo ${init} >> ${tmp_init_entry}
+
+            (
+                echo
+                echo "extern void MR_CALL"
+                echo -n "${prefix}${name}_p_0("
+                n=1
+                for arg in ${inputs} ${outputs}
+                do
+                    if test $n -gt 1
+                    then
+                        echo -n ", void *arg${n}"
+                    else
+                        echo -n "void *arg${n}"
+                    fi
+                    n=`expr $n + 1`
         done
+                echo ");"
+                echo "void MR_CALL"
+                echo -n "${prefix}${name}_p_0("
+                n=1
+                for arg in ${inputs} ${outputs}
+                do
+                    if test $n -gt 1
+                    then
+                        echo -n ", void *arg${n}"
+                    else
+                        echo -n "void *arg${n}"
+                    fi
+                    n=`expr $n + 1`
+                done
+                echo ")"
+                echo "{ MR_fatal_error(\"call to \" ${prefix}{name}_p_0); }"
+            ) >> ${tmp_hlc}
+        done
     done
 done
 
@@ -193,12 +228,11 @@
 
 #include "mercury_goto.h"
 
-#ifdef MR_DEEP_PROFILING
-
+#ifndef  MR_HIGH_LEVEL_CODE
 END
 cat ${tmp_declare_entry} >> ${header}
 cat >> ${header} << END
-#endif /* MR_DEEP_PROFILING */
+#endif  /* MR_HIGH_LEVEL_CODE */
 #endif /* ${protect} */
 END
 
@@ -209,7 +243,7 @@
 cat >> ${source} << END
 #include "mercury_imp.h"
 
-#ifdef MR_DEEP_PROFILING
+#ifndef MR_HIGH_LEVEL_CODE
 #include "mercury_deep_profiling_hand.h"
 #include "${header}"
 
@@ -221,8 +255,15 @@
 cat ${tmp_code} >> ${source}
 cat >> ${source} << END
 MR_END_MODULE
-#endif /* MR_DEEP_PROFILING */
  
+#else   /* MR_HIGH_LEVEL_CODE */
+
+END
+cat ${tmp_hlc} >> ${source}
+cat >> ${source} << END
+
+#endif  /* MR_HIGH_LEVEL_CODE */
+ 
 /* Ensure that the initialization code for the above module gets to run. */
 /*
 INIT mercury_sys_init_${module}
@@ -237,7 +278,7 @@
 
 void mercury_sys_init_${module}_init(void)
 {
-#ifdef  MR_DEEP_PROFILING
+#ifdef  MR_HIGH_LEVEL_CODE
         ${module}();
 #endif
 }
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list