From: Justin Seyster Date: Sat, 6 Feb 2010 02:49:17 +0000 (-0500) Subject: Added aop_pointcut and aop_type types. Added a match function and the X-Git-Tag: release-v1.0~125 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=623d7e4e87b54ceb39465f89f9eba6799d4cd32a;p=interaspect.git Added aop_pointcut and aop_type types. Added a match function and the join_on () function. --- diff --git a/src/Makefile.am b/src/Makefile.am index 57fb874..cb075f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ lib_LTLIBRARIES = libinteraspect.la -libinteraspect_la_SOURCES = aop-main.c +libinteraspect_la_SOURCES = aop-pc-assign.c aop-main.c aop-type.c libinteraspect_la_CFLAGS = -Wall -Werror -fvisibility=hidden -prefer-pic libinteraspect_la_LDFLAGS = -static -prefer-pic -version-info 1:0:0 libinteraspect_la_CPPFLAGS = -DHAVE_CONFIG_H -DIN_GCC -I$(gcc_includes) diff --git a/src/aop-main.c b/src/aop-main.c index c7d3bd7..eb79f19 100644 --- a/src/aop-main.c +++ b/src/aop-main.c @@ -49,9 +49,18 @@ #include #include "aop.h" +#include "aop-pointcut.h" static const char *aop_plugin_name; +void +aop_join_on (struct aop_pointcut *pc, join_callback callback) +{ + aop_assert (pc != NULL && pc->join_on != NULL); + + pc->join_on (pc, callback); +} + /* Store a list of all struct opt_pass objects we create so that we can free them at cleanup time. */ typedef struct opt_pass *aop_pass; @@ -150,3 +159,10 @@ plugin_init (struct plugin_name_args *plugin_info, return 0; } + +void +aop_abort (const char *filename, int lineno, const char *function) +{ + fprintf (stderr, "Assertion failure within InterAspect plug-in:\n"); + fancy_abort(filename, lineno, function); +} diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c new file mode 100644 index 0000000..048599c --- /dev/null +++ b/src/aop-pc-assign.c @@ -0,0 +1,47 @@ +/* This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* Whether we want them or not (we don't), Autoconf _insists_ on + defining these. Since GCC's config.h (which we must include) also + defines them, we have to undef them here. */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include +#include +#include + +#include "aop.h" +#include "aop-pointcut.h" + +static void +op_join_on_assign (struct aop_pointcut *pc, join_callback cb) +{ + aop_assert(pc->kind == ATP_ASSIGN); +} + +struct aop_pointcut * +aop_match_assignment_by_type (struct aop_type *type) +{ + struct aop_pointcut *pc; + + pc = ggc_alloc (sizeof (struct aop_pointcut *)); + pc->kind = ATP_ASSIGN; + pc->join_on = op_join_on_assign; + + return pc; +} diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h new file mode 100644 index 0000000..82beda8 --- /dev/null +++ b/src/aop-pointcut.h @@ -0,0 +1,41 @@ +#ifndef __AOP_POINTCUT_H__ +#define __AOP_POINTCUT_H__ + +/* This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* This is a private header. Do not include it in source file for + client plug-ins. */ + +struct aop_type; + +enum aop_pckind { + ATP_ASSIGN, +}; + +struct aop_pc_assign { + struct aop_type *type; +}; + +struct aop_pointcut { + enum aop_pckind kind; + + void (*join_on) (struct aop_pointcut *, join_callback); + + union { + struct aop_pc_assign pc_assign; + }; +}; + +#endif diff --git a/src/aop-type.c b/src/aop-type.c new file mode 100644 index 0000000..a7e6587 --- /dev/null +++ b/src/aop-type.c @@ -0,0 +1,65 @@ +/* This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include + +#include "aop-type.h" + +static struct aop_type _aop_t_all_signed = { + .kind = ATK_ALL_SIGNED, + .pointer_levels = 0, + .tag = NULL, +}; + +static struct aop_type _aop_t_all_unsigned = { + .kind = ATK_ALL_UNSIGNED, + .pointer_levels = 0, + .tag = NULL, +}; + +static struct aop_type _aop_t_all_fp = { + .kind = ATK_ALL_FP, + .pointer_levels = 0, + .tag = NULL, +}; + +static struct aop_type _aop_t_all_pointer = { + .kind = ATK_ALL_POINTER, + .pointer_levels = 0, + .tag = NULL, +}; + +const struct aop_type * +aop_t_all_signed () +{ + return &_aop_t_all_signed; +} + +const struct aop_type * +aop_t_all_unsigned () +{ + return &_aop_t_all_unsigned; +} + +const struct aop_type * +aop_t_all_fp () +{ + return &_aop_t_all_fp; +} + +const struct aop_type * +aop_t_all_pointer () +{ + return &_aop_t_all_pointer; +} diff --git a/src/aop-type.h b/src/aop-type.h new file mode 100644 index 0000000..d4c6c86 --- /dev/null +++ b/src/aop-type.h @@ -0,0 +1,38 @@ +#ifndef __AOP_TYPE_H__ +#define __AOP_TYPE_H__ + +/* This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* This is a private header. Do not include it in source file for + client plug-ins. */ + +enum aop_tykind { + ATK_ALL_SIGNED, + ATK_ALL_UNSIGNED, + ATK_ALL_FP, + ATK_ALL_POINTER, + + ATK_STRUCT, + ATK_UNION, +}; + +struct aop_type { + enum aop_tykind kind; + + int pointer_levels; + const char *tag; +}; + +#endif diff --git a/src/aop.h b/src/aop.h index bc7857b..134c4f8 100644 --- a/src/aop.h +++ b/src/aop.h @@ -1,5 +1,5 @@ -#ifndef __AOP_H_ -#define __AOP_H_ +#ifndef __AOP_H__ +#define __AOP_H__ /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -38,9 +38,28 @@ just declare it as a void function! */ #define AOP_MAIN_PROTO __attribute__((visibility("hidden"))) void -typedef unsigned int (*pass_callback)(); +/* This assertion routine is mostly copied from gcc/system.h */ +#ifndef AOP_NO_ASSERT_CHECK +#define aop_assert(EXPR) \ + ((void)(!(EXPR) ? aop_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0)) +#else /* AOP_NO_ASSERT_CHECK */ +/* Include EXPR, so that unused variable warnings do not occur. */ +#define aop_assert(EXPR) ((void)(0 && (EXPR))) +#endif + +struct aop_pointcut; +struct aop_type; + +typedef unsigned int (*pass_callback) (); +typedef void (*join_callback) (); + +extern struct aop_pointcut *aop_match_assignment_by_type (struct aop_type *type); + +extern void aop_register_pass (const char *pass_name, pass_callback callback); +extern void aop_join_on (struct aop_pointcut *pc, join_callback callback); +extern void aop_main (); -void aop_register_pass(const char *pass_name, pass_callback callback); -void aop_main(); +extern void aop_abort (const char *filename, int lineno, const char *function) + __attribute__((noreturn)); #endif