X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=cfg%2Fmodule.h;h=0de48f85614c8c1b9a6997d7ca767552b57f89e1;hb=HEAD;hp=750368aac4c63cabb42dba741eb8b459b617c6f1;hpb=bcf38f772b397e7a8ba781a69aacb9380e54b32a;p=bertos.git diff --git a/cfg/module.h b/cfg/module.h deleted file mode 100755 index 750368aa..00000000 --- a/cfg/module.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * \file - * - * - * \brief Debug macros for inter-module dependency checking. - * - * These macros expand to nothing in release builds. In debug - * builds, they perform run-time dependency checks for modules. - * - * The usage pattern looks like this: - * - * \code - * MOD_DEFINE(phaser) - * - * void phaser_init(void) - * { - * MOD_CHECK(computer); - * MOD_CHECK(warp_core); - * - * [...charge weapons...] - * - * MOD_INIT(phaser); - * } - * - * void phaser_cleanup(void) - * { - * MOD_CLEANUP(phaser); - * - * [...disarm phaser...] - * } - * \endcode - * - * \version $Id$ - * \author Bernardo Innocenti - */ -#ifndef CFG_MODULE_H -#define CFG_MODULE_H - -#include - -/** - * Declare a global variable for module dependency check. - * - * \see MOD_INIT(), MOD_CHECK() - */ -#define MOD_DEFINE(module) DB(bool module ## _initialized;) - -/** - * Check that \a module was already initialized. - * - * Put this check just before accessing any facility - * provided by a module that requires prior initialization. - * - * \see MOD_INIT() - */ - -#define MOD_CHECK(module) \ -do { \ - DB(extern bool module ## _initialized;) \ - ASSERT(module ## _initialized); \ -} while (0) - -/** - * Mark module as initialized. - * - * Marking initialization requires the global data - * previously defined by MOD_DEFINE(). - * - * To prevent double initialization bugs, an initialized - * module must first be cleaned up with MOD_CLEANUP() before - * calling MOD_INIT() another time. - * - * \see MOD_CLEANUP(), MOD_CHECK(), MOD_DEFINE() - */ -#define MOD_INIT(module) \ -do { \ - ASSERT(!module ## _initialized); \ - DB(module ## _initialized = true;) \ -} while (0) - -/** - * Mark module as being no longer initialized. - * - * Marking initialization requires the global data - * previously defined by MOD_DEFINE(). - * - * \see MOD_INIT(), MOD_CHECK(), MOD_DEFINE() - */ -#define MOD_CLEANUP(module) \ -do { \ - ASSERT(module ## _initialized); \ - DB(module ## _initialized = false;) \ -} while (0) - -#endif /* CFG_MODULE_H */ -