From: Justin Seyster Date: Thu, 9 Sep 2010 00:45:18 +0000 (-0400) Subject: Distributor prototypes now appear in header files. (With test case.) X-Git-Tag: release-v1.0~41 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=cc8ddb76e277a30abb3152dab1b1ca0b291fa540;p=interaspect.git Distributor prototypes now appear in header files. (With test case.) --- diff --git a/src/aop-header.c b/src/aop-header.c index 48196c4..9e31260 100644 --- a/src/aop-header.c +++ b/src/aop-header.c @@ -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++) diff --git a/src/aop-weave.c b/src/aop-weave.c index afca4c2..348534c 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -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); } diff --git a/test/duplicate.xml b/test/duplicate.xml index e60fc24..e5b6b60 100644 --- a/test/duplicate.xml +++ b/test/duplicate.xml @@ -17,5 +17,12 @@ In bar: 10! In exit advice: One + + int _distrib(); + void _assign_advice(); + void _bar_advice(); + void _entry_advice(signed char *, ALL_SIGNED_T); + void _exit_advice(signed char *); + diff --git a/test/plugin-duplicate.c b/test/plugin-duplicate.c index 53658f9..e6ef15f 100644 --- a/test/plugin-duplicate.c +++ b/test/plugin-duplicate.c @@ -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);