Commit efda3807 by Brian Hackett Committed by Richard Biener

plugin.h (invoke_plugin_callbacks): New inline function.

2010-04-29  Brian Hackett   <bhackett1024@gmail.com>

	* plugin.h (invoke_plugin_callbacks): New inline function.
	* plugin.c (flag_plugin_added): New global flag.
	(add_new_plugin): Initialize above flag.
	(invoke_plugin_callbacks): Rename to ...
	(invoke_plugin_callbacks_full): ... this.

From-SVN: r158896
parent 2942c502
2010-04-29 Brian Hackett <bhackett1024@gmail.com>
* plugin.h (invoke_plugin_callbacks): New inline function.
* plugin.c (flag_plugin_added): New global flag.
(add_new_plugin): Initialize above flag.
(invoke_plugin_callbacks): Rename to ...
(invoke_plugin_callbacks_full): ... this.
2010-04-28 Jan Hubicka <jh@suse.cz> 2010-04-28 Jan Hubicka <jh@suse.cz>
* lto-symtab.c (lto_symtab_entry_def) Add vnode. * lto-symtab.c (lto_symtab_entry_def) Add vnode.
......
...@@ -86,6 +86,8 @@ struct callback_info ...@@ -86,6 +86,8 @@ struct callback_info
static struct callback_info *plugin_callbacks_init[PLUGIN_EVENT_FIRST_DYNAMIC]; static struct callback_info *plugin_callbacks_init[PLUGIN_EVENT_FIRST_DYNAMIC];
static struct callback_info **plugin_callbacks = plugin_callbacks_init; static struct callback_info **plugin_callbacks = plugin_callbacks_init;
/* For invoke_plugin_callbacks(), see plugin.h. */
bool flag_plugin_added = false;
#ifdef ENABLE_PLUGIN #ifdef ENABLE_PLUGIN
/* Each plugin should define an initialization function with exactly /* Each plugin should define an initialization function with exactly
...@@ -137,6 +139,8 @@ add_new_plugin (const char* plugin_name) ...@@ -137,6 +139,8 @@ add_new_plugin (const char* plugin_name)
bool name_is_short; bool name_is_short;
const char *pc; const char *pc;
flag_plugin_added = true;
/* Replace short names by their full path when relevant. */ /* Replace short names by their full path when relevant. */
name_is_short = !IS_ABSOLUTE_PATH (plugin_name); name_is_short = !IS_ABSOLUTE_PATH (plugin_name);
for (pc = plugin_name; name_is_short && *pc; pc++) for (pc = plugin_name; name_is_short && *pc; pc++)
...@@ -483,16 +487,11 @@ unregister_callback (const char *plugin_name, int event) ...@@ -483,16 +487,11 @@ unregister_callback (const char *plugin_name, int event)
return PLUGEVT_NO_CALLBACK; return PLUGEVT_NO_CALLBACK;
} }
/* Called from inside GCC. Invoke all plug-in callbacks registered with /* Invoke all plugin callbacks registered with the specified event,
the specified event. called from invoke_plugin_callbacks(). */
Return PLUGEVT_SUCCESS if at least one callback was called,
PLUGEVT_NO_CALLBACK if there was no callback.
EVENT - the event identifier
GCC_DATA - event-specific data provided by the compiler */
int int
invoke_plugin_callbacks (int event, void *gcc_data) invoke_plugin_callbacks_full (int event, void *gcc_data)
{ {
int retval = PLUGEVT_SUCCESS; int retval = PLUGEVT_SUCCESS;
......
/* Header file for internal GCC plugin mechanism. /* Header file for internal GCC plugin mechanism.
Copyright (C) 2009 Free Software Foundation, Inc. Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -26,7 +26,7 @@ struct attribute_spec; ...@@ -26,7 +26,7 @@ struct attribute_spec;
extern void add_new_plugin (const char *); extern void add_new_plugin (const char *);
extern void parse_plugin_arg_opt (const char *); extern void parse_plugin_arg_opt (const char *);
extern int invoke_plugin_callbacks (int, void *); extern int invoke_plugin_callbacks_full (int, void *);
extern void initialize_plugins (void); extern void initialize_plugins (void);
extern bool plugins_active_p (void); extern bool plugins_active_p (void);
extern void dump_active_plugins (FILE *); extern void dump_active_plugins (FILE *);
...@@ -35,6 +35,28 @@ extern void print_plugins_versions (FILE *file, const char *indent); ...@@ -35,6 +35,28 @@ extern void print_plugins_versions (FILE *file, const char *indent);
extern void print_plugins_help (FILE *file, const char *indent); extern void print_plugins_help (FILE *file, const char *indent);
extern void finalize_plugins (void); extern void finalize_plugins (void);
/* Called from inside GCC. Invoke all plugin callbacks registered with
the specified event.
Return PLUGEVT_SUCCESS if at least one callback was called,
PLUGEVT_NO_CALLBACK if there was no callback.
EVENT - the event identifier
GCC_DATA - event-specific data provided by the compiler */
static inline int
invoke_plugin_callbacks (int event, void *gcc_data)
{
#ifdef ENABLE_PLUGIN
/* True iff at least one plugin has been added. */
extern bool flag_plugin_added;
if (flag_plugin_added)
return invoke_plugin_callbacks_full (event, gcc_data);
#endif
return PLUGEVT_NO_CALLBACK;
}
/* In attribs.c. */ /* In attribs.c. */
extern void register_attribute (const struct attribute_spec *attr); extern void register_attribute (const struct attribute_spec *attr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment