+++ /dev/null
-/*
- * Author: Matthias Braun
- * Date: 29.09.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-
-#include "bemodules.h"
-#include "xmalloc.h"
-
-typedef struct _constructor_list_entry_t {
- struct _constructor_list_entry_t *next;
- be_module_constructor_func func;
-} constructor_list_entry_t;
-
-static constructor_list_entry_t *constructors = NULL;
-
-static void free_constructor_list(void)
-{
- constructor_list_entry_t *entry = constructors;
-
- while(entry != NULL) {
- constructor_list_entry_t *next = entry->next;
- free(entry);
- entry = next;
- }
-}
-
-void be_module_add_constructor(be_module_constructor_func func)
-{
- static int initialized = 0;
- constructor_list_entry_t *entry;
-
- if(!initialized) {
- atexit(free_constructor_list);
- initialized = 1;
- }
-
- entry = xmalloc(sizeof(entry[0]));
- entry->next = constructors;
- entry->func = func;
-
- constructors = entry;
-}
-
-void be_module_call_constructors()
-{
- constructor_list_entry_t *entry;
-
- for(entry = constructors; entry != NULL; entry = entry->next) {
- entry->func();
- }
-}
+++ /dev/null
-/*
- * Author: Matthias Braun
- * Date: 11.12.2006
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- */
-#ifndef BEMODULES_H_
-#define BEMODULES_H_
-
-typedef void (*be_module_constructor_func)(void);
-
-/**
- * Use this macro to register a module constructor. You should put this macro in
- * a .c file of your module. Compiler magic will make sure that your constructor
- * function gets called after the main backend structures are initialized.
- *
- * The module constructor is a convenient place to register commandline options,
- * or add the module to extension lists.
- */
-#define BE_REGISTER_MODULE_CONSTRUCTOR(func) \
- static void __attribute__((constructor)) _be_constructor(void) \
- { \
- be_module_add_constructor(func); \
- }
-
-// TODO msvc version
-
-/**
- * Warning: internal function, use BE_REGISTER_MODULE_CONSTRUCTOR instead.
- *
- * This function registers the constructor function of a backend module
- */
-void be_module_add_constructor(be_module_constructor_func func);
-
-/**
- * Call all registered constructor functions
- */
-void be_module_call_constructors(void);
-
-#endif