3 * File name: ir/ir/irhooks.c
4 * Purpose: Generic hooks for various libFirm functions.
8 * Copyright: (C) 1998-2005 Universität Karlsruhe
9 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
15 * Generic hooks for various libFirm functions.
17 * @author Michael Beck
25 #ifdef FIRM_ENABLE_HOOKS
28 hook_entry_t *hooks[hook_last];
31 void register_hook(hook_type_t hook, hook_entry_t *entry) {
32 /* check if a hook function is specified. It's a union, so no matter which one */
33 if (! entry->hook._hook_turn_into_id)
36 entry->next = hooks[hook];
40 /* unregister a hook */
41 void unregister_hook(hook_type_t hook, hook_entry_t *entry) {
44 if (hooks[hook] == entry) {
45 hooks[hook] = entry->next;
50 for (p = hooks[hook]; p && p->next != entry; p = p->next);
53 p->next = entry->next;
61 void register_hook(hook_type_t hook, hook_entry_t *entry) {}
62 void unregister_hook(hook_type_t hook, hook_entry_t *entry) {}
64 #endif /* FIRM_ENABLE_HOOKS */
66 int firm_init_hooks(void) {
67 /* this strange code assures that both functions are available
68 in a shared library even if none of them is called.
69 Meanwhile not needed anymore but ... */
70 return (int)register_hook + (int)unregister_hook;