#ifndef __KERNEL_DEBUG_H #define __KERNEL_DEBUG_H void panic_spin(char *filename, int line, const char *func, const char *condition); /** * @brief panic 是一个宏,__VA_ARGS__ 表示可变参数,即 ...,用于传递参数 * __VA_ARGS__ 是预处理器所支持的专用标识符。代表所有与省略号相对应的参数 * “...” 表示定义的宏其参数可变 */ #define PANIC(...) panic_spin(__FILE__, __LINE__, __func__, __VA_ARGS__) #ifdef NDEBUG #define ASSERT(CONDITION) ((void)0) #else #define ASSERT(CONDITION) \ if (CONDITION) \ { \ } \ else \ { \ PANIC(#CONDITION); \ } #endif // NDEBUG #ifdef UNUSED #elif defined(__GNUC__) #define UNUSED(x) UNUSED_##x __attribute__((unused)) #elif defined(__clang__) #define UNUSED(x) _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \ x _Pragma("clang diagnostic pop") #elif defined(__LCLINT__) #define UNUSED(x) /*@unused@*/ x #elif defined(_MSC_VER) #define UNUSED(x) __pragma(warning(push)) __pragma(warning(disable : 4101)) x __pragma(warning(pop)) // warning C4101: unreferenced local variable #elif defined(__ICC) #define UNUSED(x) x __attribute__((unused)) #else #warning "Platform doesn't support attribute 'unused'" #define UNUSED(x) (void)x #endif // UNUSED #endif // __KERNEL_DEBUG_H