Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

fast_assert.h File Reference


Detailed Description

Fast assertions.

The following variant should be faster than the usual g_assert() because the generated code is smaller which allows better optimization and is more cache-friendly.

Look at the generated code for functions which use assertion checks to see the difference.

Taking advantage of it may require using -momit-leaf-frame-pointer or -fomit-frame-pointer for GCC and an appropriate -march option is also recommended.

Note:
This file should be included by override.h and assumes that common.h has been included.
Author:
Christian Biere
Date:
2006

Go to the source code of this file.

Data Structures

struct  assertion_data

Defines

#define RUNTIME_ASSERT(expr)   fast_assert(expr, #expr)
#define RUNTIME_UNREACHABLE()   fast_assert_not_reached()
#define fast_assert(expr, expr_string)
#define fast_assert_not_reached()
#define return_unless(expr)   return_unless_intern((expr), #expr)
#define return_unless_intern(expr, expr_string)
#define return_value_unless(expr, val)   return_value_unless_intern((expr), #expr, val)
#define return_value_unless_intern(expr, expr_string, val)

Typedefs

typedef assertion_data assertion_data

Functions

void G_GNUC_NORETURN REGPARM (1) assertion_failure(const assertion_data *const data)


Define Documentation

#define fast_assert expr,
expr_string   ) 
 

Value:

G_STMT_START { \
    if (G_UNLIKELY(!(expr))) { \
        static const struct assertion_data assertion_data_ = { \
            __FILE__, expr_string, __LINE__ \
        }; \
        assertion_failure(&assertion_data_); \
    } \
} G_STMT_END

 
#define fast_assert_not_reached  ) 
 

Value:

G_STMT_START { \
    static const struct assertion_data assertion_data_ = { \
        __FILE__, NULL, __LINE__ \
    }; \
    assertion_failure(&assertion_data_); \
} G_STMT_END

#define return_unless expr   )     return_unless_intern((expr), #expr)
 

#define return_unless_intern expr,
expr_string   ) 
 

Value:

G_STMT_START { \
    if (G_UNLIKELY(!(expr))) { \
        static const struct assertion_data assertion_data_ = { \
            __FILE__, expr_string, __LINE__ \
        }; \
        assertion_warning(&assertion_data_); \
        return; \
    } \
} G_STMT_END

#define return_value_unless expr,
val   )     return_value_unless_intern((expr), #expr, val)
 

#define return_value_unless_intern expr,
expr_string,
val   ) 
 

Value:

G_STMT_START { \
    if (G_UNLIKELY(!(expr))) { \
        static const struct assertion_data assertion_data_ = { \
            __FILE__, expr_string, __LINE__ \
        }; \
        assertion_warning(&assertion_data_); \
        return (val); \
    } \
} G_STMT_END

#define RUNTIME_ASSERT expr   )     fast_assert(expr, #expr)
 

 
#define RUNTIME_UNREACHABLE  )     fast_assert_not_reached()
 


Typedef Documentation

typedef struct assertion_data assertion_data
 


Function Documentation

void G_GNUC_NORETURN REGPARM  )  const
 


Generated on Sat Jun 30 17:53:26 2007 for gtk-gnutella by  doxygen 1.3.9.1