X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firhooks.c;h=52b8422b94789873909956684dd081eda46d20b4;hb=945c6c2ceebef5e41c0486c31f49d2319cacb3da;hp=db98c0ca3b534489759a5aba272d42644afcbc97;hpb=3a87a0c2dba077ff709f7bd55d6a986fb75ad66d;p=libfirm diff --git a/ir/ir/irhooks.c b/ir/ir/irhooks.c index db98c0ca3..52b8422b9 100644 --- a/ir/ir/irhooks.c +++ b/ir/ir/irhooks.c @@ -1,44 +1,36 @@ /* - * Project: libFIRM - * File name: ir/ir/irhooks.c - * Purpose: Generic hooks for various libFirm functions. - * Author: Michael Beck - * Created: - * CVS-ID: $Id$ - * Copyright: (C) 1998-2005 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * This file is part of libFirm. + * Copyright (C) 2012 University of Karlsruhe. */ /** - * @file irhooks.c - * - * Generic hooks for various libFirm functions. - * - * @author Michael Beck + * @file + * @brief Generic hooks for various libFirm functions. + * @author Michael Beck */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif -#include "irhooks.h" +#include -#ifdef FIRM_ENABLE_HOOKS +#include "irhooks.h" -/* the hooks */ hook_entry_t *hooks[hook_last]; -/* register a hook */ -void register_hook(hook_type_t hook, hook_entry_t *entry) { - /* check if a hook function is specifyed. It's a union, so no matter which one */ +void register_hook(hook_type_t hook, hook_entry_t *entry) +{ + /* check if a hook function is specified. It's a union, so no matter which one */ if (! entry->hook._hook_turn_into_id) return; + /* hook should not be registered yet */ + assert(entry->next == NULL && hooks[hook] != entry); + entry->next = hooks[hook]; hooks[hook] = entry; } -/* unregister a hook */ -void unregister_hook(hook_type_t hook, hook_entry_t *entry) { +void unregister_hook(hook_type_t hook, hook_entry_t *entry) +{ hook_entry_t *p; if (hooks[hook] == entry) { @@ -47,22 +39,11 @@ void unregister_hook(hook_type_t hook, hook_entry_t *entry) { return; } - for (p = hooks[hook]; p && p->next != entry; p = p->next); + for (p = hooks[hook]; p && p->next != entry; p = p->next) { + } if (p) { p->next = entry->next; entry->next = NULL; } } - - -#else - -void register_hook(hook_type_t hook, hook_entry_t *entry) {} -void unregister_hook(hook_type_t hook, hook_entry_t *entry) {} - -#endif /* FIRM_ENABLE_HOOKS */ - -int init_hooks(void) { - return (int)register_hook + (int)unregister_hook; -}