⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cyg_ass.h

📁 该工程是从ecos嵌入式系统下移植过来的一个小型的fat16文件系统
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifdef CYGDBG_INFRA_DEBUG_LOOP_INVARIANTS# define CYG_LOOP_INVARIANT( _bool_ , _msg_ ) CYG_ASSERT( _bool_, _msg_ )# define CYG_LOOP_INVARIANTC( _bool_ ) \    CYG_ASSERT( _bool_, "loop invariant " #_bool_ )#else# define CYG_LOOP_INVARIANT( _bool_ , _msg_ ) CYG_EMPTY_STATEMENT# define CYG_LOOP_INVARIANTC( _bool_ )        CYG_EMPTY_STATEMENT#endif#ifdef __cplusplus// All variants of _CLASS# define CYG_PRECONDITION_CLASS( _pobj_, _msg_ )  \    CYG_PRECONDITION( ((0 != (_pobj_)) &&         \                       (_pobj_)->check_this(CYG_ASSERT_CLASS_ZEAL)), _msg_)# define CYG_PRECONDITION_CLASSC( _pobj_ )        \    CYG_PRECONDITION_CLASS( (_pobj_),             \       "precondition, class pointer (" #_pobj_ ") is valid" )    # define CYG_POSTCONDITION_CLASS( _pobj_, _msg_ ) \    CYG_POSTCONDITION( ((0 != (_pobj_)) &&        \                        (_pobj_)->check_this(CYG_ASSERT_CLASS_ZEAL)), _msg_)# define CYG_POSTCONDITION_CLASSC( _pobj_ )       \    CYG_POSTCONDITION_CLASS( (_pobj_),            \       "postcondition, class pointer (" #_pobj_ ") is valid" )# define CYG_LOOP_INVARIANT_CLASS( _pobj_, _msg_) \    CYG_LOOP_INVARIANT( ((0 != (_pobj_)) &&       \                         (_pobj_)->check_this(CYG_ASSERT_CLASS_ZEAL)), _msg_)        # define CYG_LOOP_INVARIANT_CLASSC( _pobj_ )      \    CYG_LOOP_INVARIANT_CLASS( (_pobj_),           \       "loop invariant, class pointer (" #_pobj_ ") is valid" )// All variants of _CLASSO# define CYG_PRECONDITION_CLASSO( _obj_, _msg_ )  \    CYG_PRECONDITION( (_obj_).check_this(CYG_ASSERT_CLASS_ZEAL), _msg_)    # define CYG_PRECONDITION_CLASSOC( _obj_ )        \    CYG_PRECONDITION_CLASSO( (_obj_),             \        "precondition, object (" #_obj_ ") is valid" )# define CYG_POSTCONDITION_CLASSO( _obj_, _msg_ ) \    CYG_POSTCONDITION( (_obj_).check_this(CYG_ASSERT_CLASS_ZEAL), _msg_)    # define CYG_POSTCONDITION_CLASSOC( _obj_ )       \    CYG_POSTCONDITION_CLASSO( (_obj_),            \       "postcondition, object (" #_obj_ ") is valid" )                             # define CYG_LOOP_INVARIANT_CLASSO( _obj_, _msg_) \    CYG_LOOP_INVARIANT( (_obj_).check_this(CYG_ASSERT_CLASS_ZEAL), _msg_)# define CYG_LOOP_INVARIANT_CLASSOC( _obj_ )      \    CYG_LOOP_INVARIANT_CLASSO( (_obj_),           \       "loop invariant, object (" #_obj_ ") is valid" )// All variants of _ZERO_OR_CLASS# define CYG_PRECONDITION_ZERO_OR_CLASS( _pobj_, _msg_ )  \    CYG_PRECONDITION( ((0 == (_pobj_)) ||                 \                       (_pobj_)->check_this(CYG_ASSERT_CLASS_ZEAL)), _msg_)    # define CYG_PRECONDITION_ZERO_OR_CLASSC( _pobj_ )        \    CYG_PRECONDITION_ZERO_OR_CLASS( (_pobj_),             \       "precondition, class pointer (" #_pobj_ ") is zero or valid" )    # define CYG_POSTCONDITION_ZERO_OR_CLASS( _pobj_, _msg_ ) \    CYG_POSTCONDITION( ((0 == (_pobj_)) ||                \                        (_pobj_)->check_this(CYG_ASSERT_CLASS_ZEAL)), _msg_)# define CYG_POSTCONDITION_ZERO_OR_CLASSC( _pobj_ )       \    CYG_POSTCONDITION_ZERO_OR_CLASS( (_pobj_),            \       "postcondition, class pointer (" #_pobj_ ") is zero or valid" )                             # define CYG_LOOP_INVARIANT_ZERO_OR_CLASS( _pobj_, _msg_) \    CYG_LOOP_INVARIANT( ((0 == (_pobj_)) ||               \                         (_pobj_)->check_this(CYG_ASSERT_CLASS_ZEAL)), _msg_)        # define CYG_LOOP_INVARIANT_ZERO_OR_CLASSC( _pobj_ )      \    CYG_LOOP_INVARIANT_ZERO_OR_CLASS( (_pobj_),           \       "loop invariant, class pointer (" #_pobj_ ") is zero or valid" )// All variants of _THIS# define CYG_PRECONDITION_THIS( _msg_ )  \    CYG_PRECONDITION( this->check_this(CYG_ASSERT_CLASS_ZEAL), _msg_)    # define CYG_PRECONDITION_THISC()        \    CYG_PRECONDITION_THIS( "precondition, \"this\"  is valid" )    # define CYG_POSTCONDITION_THIS( _msg_ ) \    CYG_POSTCONDITION( this->check_this(CYG_ASSERT_CLASS_ZEAL), _msg_)    # define CYG_POSTCONDITION_THISC()       \    CYG_POSTCONDITION_THIS( "postcondition, \"this\" is valid" )                             # define CYG_LOOP_INVARIANT_THIS( _msg_) \    CYG_LOOP_INVARIANT( this->check_this(CYG_ASSERT_CLASS_ZEAL), _msg_)        # define CYG_LOOP_INVARIANT_THISC()      \    CYG_LOOP_INVARIANT_THIS( "loop invariant, \"this\" is valid" )#endif // __cplusplus// -------------------------------------------------------------------------// Invariants. These are a bit more interesting. The ordinary invariants// take an arbitrary boolean expression, and C++ does not provide any way// of evaluating this expression automatically on entry and exit - any// attempt to use local objects leads to trying to evaluate the expression// when it is not in scope. This problem does not arise with objects.//// For C++ objects it is possible to do a bit better. A template can be// used to create a local object whose constructor will validate the// target object and whose destructor will validate the target object// again. Unfortunately it is necessary to pass the type as well as// the object: typeof() is a gcc extension, and RTTI's typeid facility// would provide the derived class and not what we actually want.            #ifdef CYGDBG_INFRA_DEBUG_INVARIANTS    # define CYG_INVARIANT( _bool_, _msg_ ) \        CYG_MACRO_START                 \        if ( ! ( _bool_ ) )             \            CYG_ASSERT_DOCALL( _msg_ ); \        CYG_MACRO_END# define CYG_INVARIANTC( _bool_ )       \        CYG_MACRO_START                 \        if ( ! ( _bool_ ) )             \            CYG_ASSERT_DOCALL( "invariant (" #_bool_ ")" ); \        CYG_MACRO_END# ifdef __cplusplus// NOTE: if the compiler does not manage to inline the appropriate// template functions then the impact on code size and performance becomes// rather large. But there are significant performance overheads anyway// simply because of the call to check_this()...            //template<class X> class __CygInvariantObject {    const X*  rep;  private:    // Prevent access to the default constructors.    __CygInvariantObject() { }    __CygInvariantObject( const __CygInvariantObject&  arg ) { }    __CygInvariantObject & operator=( const __CygInvariantObject & arg) { return *this; }      public:    __CygInvariantObject( X* arg, const char* msg ) : rep(arg) {        if ( !rep->check_this( CYG_ASSERT_CLASS_ZEAL ) )            CYG_ASSERT_DOCALL( msg );    }    __CygInvariantObject( X& arg, const char* msg ) : rep(&arg) {        if ( !rep->check_this( CYG_ASSERT_CLASS_ZEAL ) )            CYG_ASSERT_DOCALL( msg );    }    __CygInvariantObject( const X* arg, const char* msg ) : rep(arg) {        if ( !rep->check_this( CYG_ASSERT_CLASS_ZEAL ) )            CYG_ASSERT_DOCALL( msg );    }    __CygInvariantObject( const X& arg, const char* msg ) : rep(&arg) {        if ( !rep->check_this( CYG_ASSERT_CLASS_ZEAL ) )            CYG_ASSERT_DOCALL( msg );    }    ~__CygInvariantObject( ) {        if ( !rep->check_this( CYG_ASSERT_CLASS_ZEAL ) )            CYG_ASSERT_DOCALL( "invariant, object valid on exit" );        rep = 0;    };};//// These macros provide sensible concatenation facilities at// the C preprocessor level, getting around complications in the// macro expansion rules related to __LINE__ and __FILE__.# define __CYG_INVARIANT_CLASSNAME_AUX( a, b) a ## b# define __CYG_INVARIANT_CLASSNAME( a, b ) \              __CYG_INVARIANT_CLASSNAME_AUX( a, b )// These macro definitions do not use CYG_MACRO_START because// I do not want the scope of the local objects to get confused.//// The first line of the macro expansion specifies the type of// the local object being created. The second line invents a// name for this object. The third line provides command-line// arguments.    # define CYG_INVARIANT_CLASS( _type_, _pobj_, _msg_ )          \     __CygInvariantObject<_type_>                              \     __CYG_INVARIANT_CLASSNAME( __invariant_class_, __LINE__ ) \              ( _pobj_, _msg_ )# define CYG_INVARIANT_CLASSC( _type_, _pobj_ )                \     __CygInvariantObject<_type_>                              \     __CYG_INVARIANT_CLASSNAME( __invariant_class_, __LINE__ ) \              ( _pobj_, "invariant, class pointer (" #_pobj_ ") is valid" )         # define CYG_INVARIANT_CLASSO( _type_, _obj_, _msg_ )          \     __CygInvariantObject<_type_>                              \     __CYG_INVARIANT_CLASSNAME( __invariant_class_, __LINE__ ) \              ( _obj_, _msg_ )# define CYG_INVARIANT_CLASSOC( _type_, _obj_ )                \     __CygInvariantObject<_type_>                              \     __CYG_INVARIANT_CLASSNAME( __invariant_class_, __LINE__ ) \              ( _obj_, "invariant, object (" #_obj_ ") is valid" )# define CYG_INVARIANT_THIS( _type_, _msg_ )                   \     __CygInvariantObject<_type_>                              \     __CYG_INVARIANT_CLASSNAME( __invariant_class_, __LINE__ ) \              ( this, _msg_ )         # define CYG_INVARIANT_THISC( _type_ )                         \     __CygInvariantObject<_type_>                              \     __CYG_INVARIANT_CLASSNAME( __invariant_class_, __LINE__ ) \              ( this, "invariant, \"this\" is valid" )# endif // __cplusplus#else  // !CYGDBG_INFRA_DEBUG_INVARIANTS# define CYG_INVARIANT( _bool_, _msg_ ) CYG_EMPTY_STATEMENT# define CYG_INVARIANTC( _bool_ )       CYG_EMPTY_STATEMENT# ifdef __cplusplus#  define CYG_INVARIANT_CLASS( _type_, _pobj_, _msg_ )#  define CYG_INVARIANT_CLASSC( _type_, _pobj_ )#  define CYG_INVARIANT_CLASSO( _type_, _obj_, _msg_ )#  define CYG_INVARIANT_CLASSOC( _type_, _obj_ )#  define CYG_INVARIANT_THIS( _type_, _msg_ )#  define CYG_INVARIANT_THISC( _type_ )# endif    #endif // CYGDBG_INFRA_DEBUG_INVARIANTS// -------------------------------------------------------------------------// Compile time failure; like #error but in a macro so we can use it in// other definitions.//// Usage:// #define new CYG_COMPILETIMEFAIL( "Do NOT use new!")#define CYG_COMPILETIMEFAIL( _msg_ ) !!!-- _msg_ --!!!// -------------------------------------------------------------------------// The host-side implementation of the infrastructure provides a number// of additional functions that allow applications to provide their own// implementation of cyg_assert_fail(). This is not strictly necessary// since the presence of cyg_assert_fail() in the application would// override the one in the library anyway, but it is useful to make// certain functionality more readily available.//// These declarations are only available if the symbol// CYG_DECLARE_HOST_ASSERTION_SUPPORT is defined.#ifdef CYG_DECLARE_HOST_ASSERTION_SUPPORT// The default assertion handler writes its output to a file and// if possible a suitable message to stdout. It is possible to// install an alternative handler. If this alternative returns false// then the default handler will be invoked instead, otherwise the// application will exit.externC void cyg_assert_install_failure_handler(                bool (*)(const char* /* psz_func */,                         const char* /* psz_file */,                         cyg_uint32  /* linenum */,                         const char* /* psz_msg */) );// Register a callback that should get invoked as part of handling an// assertion failure and that will typically produce some additional// output. For example the trace code will install a callback to output// trace information.//// The first argument is a string identifying the callback. The second// argument is a function pointer for the callback itself, whose// argument is another function that can be invoked for output.externC void cyg_assert_install_failure_callback(                const char* /* name */,                void (*)( void (*)(const char*) ));// This function can be called by assert failure handlers to invoke// the installed callbacks. The three arguments are function pointers// that get invoked prior to callback invocation, by the callback itself,// and after each callback. In the first case the argument will be the// callback name.externC void cyg_assert_failure_invoke_callbacks(                void (*)(const char* /* name */),                void (*)(const char* /* callback data */ ),                void (*)(void) );// This function is intended to be called from inside gdb instead of// cyg_assert_fail(),, without the need to specify a filename or// anything else.externC void cyg_assert_quickfail(void);#endif // CYG_DECLARE_HOST_ASSERTION_SUPPORT    // -------------------------------------------------------------------------#endif // CYGONCE_INFRA_CYG_ASS_H multiple inclusion protection// EOF cyg_ass.h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -