X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fdebug.h;fp=src%2Flib%2Fdebug.h;h=4f3cb5b662dd07d54adcba4debccc7017e70e897;hb=c956c0c2175fc09a8e8d6d3f8effd49abcf7aae1;hp=138247339fcb72357b2ccf69bf88873ccb7b0e79;hpb=244113935a061b272a408db62f3106deadcd1061;p=pintos-anon diff --git a/src/lib/debug.h b/src/lib/debug.h index 1382473..4f3cb5b 100644 --- a/src/lib/debug.h +++ b/src/lib/debug.h @@ -1,6 +1,28 @@ #ifndef HEADER_DEBUG_H #define HEADER_DEBUG_H 1 +#if __GNUC__ > 1 +#define ATTRIBUTE(X) __attribute__ (X) +#else +#define ATTRIBUTE(X) +#endif + +#define UNUSED ATTRIBUTE ((unused)) +#define NO_RETURN ATTRIBUTE ((noreturn)) +#define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (printf, FMT, FIRST))) +#define SCANF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (scanf, FMT, FIRST))) + +void panic (const char *, ...) + __attribute__ ((format (printf, 1, 2), noreturn)); +void backtrace (void); + +#endif /* debug.h */ + +/* This is outside the header guard so that debug.h may be + included multiple times with different settings of NDEBUG. */ +#undef ASSERT +#undef NOT_REACHED + #ifndef NDEBUG #define ASSERT(CONDITION) \ if (CONDITION) { \ @@ -14,19 +36,3 @@ #define ASSERT(CONDITION) ((void) 0) #define NOT_REACHED() for (;;) #endif - -void panic (const char *, ...) - __attribute__ ((format (printf, 1, 2), noreturn)); - -#if __GNUC__ > 1 -#define ATTRIBUTE(X) __attribute__ (X) -#else -#define ATTRIBUTE(X) -#endif - -#define UNUSED ATTRIBUTE ((unused)) -#define NO_RETURN ATTRIBUTE ((noreturn)) -#define PRINTF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (printf, FMT, FIRST))) -#define SCANF_FORMAT(FMT, FIRST) ATTRIBUTE ((format (scanf, FMT, FIRST))) - -#endif /* debug.h */