From 0fce04a5a65f684daf25d485f063b7ab8e086865 Mon Sep 17 00:00:00 2001 From: Justin Seyster Date: Tue, 7 Sep 2010 18:19:54 -0400 Subject: [PATCH] Added aop_finish(). --- src/aop-main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/aop-main.c b/src/aop-main.c index 49c1f7e..35833fa 100644 --- a/src/aop-main.c +++ b/src/aop-main.c @@ -154,6 +154,28 @@ aop_join_on_copy (struct aop_pointcut *pc, int copy, join_callback callback, } } +/** + * InterAspect calls this function after all compilation is finished + * and before GCC and InterAspect data structures are destroyed. It + * is provided so that InterAspect plug-ins can override it (by + * providing their own version), giving them a last chance to clean up + * data structures or free up other resources. + * + * The best place to output an automatic header (using + * aop_write_c_header()) is in aop_finish(). + */ +__attribute__((weak)) __attribute__((noinline)) void +aop_finish () +{ + /* This function exists only to be overridden. */ + + /* Weird bug: if this function is empty, GCC inlines the call to it + in aop_cleanup() making it impossible to override (even if we + explicitly specify noinline). We can trick GCC into emitting the + calls with this empty assembly block. */ + __asm__ volatile (""); +} + /** * Find the value for a command-line argument passed to the plug-in. * You can pass a key/value argument to your plug-in on the GCC @@ -258,6 +280,8 @@ cleanup_passes () static void aop_cleanup (void *event_date, void *data) { + aop_finish (); + free_type_table (); free_prototype_table (); cleanup_passes (); -- 2.43.0