Skip to content

Commit

Permalink
allow registration of callbacks on gcc.PLUGIN_GGC_{START,MARKING,FINISH}
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmalcolm committed Jan 14, 2012
1 parent 6133f8c commit e75f80d
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions gcc-python-callbacks.c
Expand Up @@ -253,6 +253,41 @@ gcc_python_callback_for_FINISH_UNIT(void *gcc_data, void *user_data)
user_data);
}

static void
gcc_python_callback_for_GGC_START(void *gcc_data, void *user_data)
{
PyGILState_STATE gstate;

gstate = PyGILState_Ensure();

gcc_python_finish_invoking_callback(gstate,
0, NULL,
user_data);
}

static void
gcc_python_callback_for_GGC_MARKING(void *gcc_data, void *user_data)
{
PyGILState_STATE gstate;

gstate = PyGILState_Ensure();

gcc_python_finish_invoking_callback(gstate,
0, NULL,
user_data);
}

static void
gcc_python_callback_for_GGC_END(void *gcc_data, void *user_data)
{
PyGILState_STATE gstate;

gstate = PyGILState_Ensure();

gcc_python_finish_invoking_callback(gstate,
0, NULL,
user_data);
}


PyObject*
Expand Down Expand Up @@ -318,6 +353,25 @@ gcc_python_register_callback(PyObject *self, PyObject *args, PyObject *kwargs)
closure);
break;

case PLUGIN_GGC_START:
register_callback("python", // FIXME
(enum plugin_event)event,
gcc_python_callback_for_GGC_START,
closure);
break;
case PLUGIN_GGC_MARKING:
register_callback("python", // FIXME
(enum plugin_event)event,
gcc_python_callback_for_GGC_MARKING,
closure);
break;
case PLUGIN_GGC_END:
register_callback("python", // FIXME
(enum plugin_event)event,
gcc_python_callback_for_GGC_END,
closure);
break;

default:
PyErr_Format(PyExc_ValueError, "event type %i invalid (or not wired up yet)", event);
return NULL;
Expand Down

0 comments on commit e75f80d

Please sign in to comment.