Distributor prototypes now appear in header files. (With test case.)
authorJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 9 Sep 2010 00:45:18 +0000 (20:45 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 9 Sep 2010 00:45:18 +0000 (20:45 -0400)
src/aop-header.c
src/aop-weave.c
test/duplicate.xml
test/plugin-duplicate.c

index 48196c40f4677cf163bbc5374539897ffde29ee1..9e31260e6aca77b027225dfd52912875dab37766 100644 (file)
@@ -341,6 +341,7 @@ write_prototype (void **table_entry, void *info)
 {
   int i;
   char *out;
+  const char *return_type;
   size_t size;
   struct aop_prototype *prototype = *table_entry;
   htab_t prototype_strings = (htab_t)info;
@@ -349,7 +350,8 @@ write_prototype (void **table_entry, void *info)
   out = line;
   size = sizeof (line);
 
-  BUF_PRINTF ("void %s(", prototype->name);
+  return_type = prototype->has_return_value ? "int" : "void";
+  BUF_PRINTF ("%s %s(", return_type, prototype->name);
 
   /* Print each of the types. */
   for (i = 0; i < prototype->num_params; i++)
index afca4c26425ec7a93b16e0fc3a7e818674b262d9..348534c452858a5fa6f7062bd772c4321d60766b 100644 (file)
@@ -315,7 +315,6 @@ op_default_insert_before (struct aop_joinpoint *jp, gimple stmt)
   gsi_insert_before (jp->gsi, stmt, GSI_SAME_STMT);
 }
 
-
 /* This is the default insert_after() operation for aop_pointcut
    objects.  It just inserts a gimple statement before the iterator in
    the aop_joinpoint object.  This function holds to the requirement
@@ -434,5 +433,9 @@ aop_duplicate (struct aop_joinpoint *jp, const char *func_name, ...)
                              argp);
   va_end (argp);
 
+  va_start (argp, func_name);
+  insert_prototype (true /* int return type */, func_name,
+                   gimple_call_num_args (func_call), argp);
+
   duplicate_function_body ("ia_body_index", func_call);
 }
index e60fc24667ffb99c4741365cb00c9a1547052970..e5b6b6013f836e0020b947187ea0b556376fba6c 100644 (file)
       In bar: 10!
       In exit advice: One
     </output>
+    <prototypes>
+      int _distrib();
+      void _assign_advice();
+      void _bar_advice();
+      void _entry_advice(signed char *, ALL_SIGNED_T);
+      void _exit_advice(signed char *);
+    </prototypes>
   </run>
 </testcase>
index 53658f9d120fab1010ea677284626c7ab4e131ce..e6ef15f48c76840fd97a12c54b239a07974f59c1 100644 (file)
@@ -69,6 +69,19 @@ static unsigned int plugin_duplicate()
   return 0;
 }
 
+void aop_finish()
+{
+  const char *header;
+  header = aop_get_arg_value("header");
+
+  if (header != NULL) {
+    int res;
+    res = aop_write_c_header(header, "_INT_HEADER_", NULL, NULL);
+    if (res != 0)
+      perror(header);
+  }
+}
+
 AOP_MAIN_PROTO aop_main()
 {
   aop_register_pass("duplicate", plugin_duplicate);