Kernel/logdebug - Cast values in relation assert print (Avoids 64-bit values confusin...
[tpg/acess2.git] / KernelLand / Kernel / include / logdebug.h
1 /*
2  * Acess2 Kernel
3  * - By John Hodge (thePowersGang)
4  *
5  * logdebug.h
6  * - Logging / Debug printing functions
7  */
8 #ifndef _KERNEL__LOGDEBUG_H_
9 #define _KERNEL__LOGDEBUG_H_
10
11 #include <stdarg.h>
12
13 #ifndef NORETURN
14 #define NORETURN        __attribute__((noreturn))
15 #endif
16
17 // --- Logging ---
18 /**
19  * \name Logging to kernel ring buffer
20  * \{
21  */
22 extern void     Log_KernelPanic(const char *Ident, const char *Message, ...);
23 extern void     Log_Panic(const char *Ident, const char *Message, ...);
24 extern void     Log_Error(const char *Ident, const char *Message, ...);
25 extern void     Log_Warning(const char *Ident, const char *Message, ...);
26 extern void     Log_Notice(const char *Ident, const char *Message, ...);
27 extern void     Log_Log(const char *Ident, const char *Message, ...);
28 extern void     Log_Debug(const char *Ident, const char *Message, ...);
29 /**
30  * \}
31  */
32
33 // --- Debug ---
34 /**
35  * \name Debugging and Errors
36  * \{
37  */
38 extern void     Debug_KernelPanic(void);        //!< Initiate a kernel panic
39 extern void     Panic(const char *Msg, ...) NORETURN;   //!< Print a panic message (initiates a kernel panic)
40 extern void     Warning(const char *Msg, ...);  //!< Print a warning message
41 extern bool     LogF(const char *Fmt, ...);     //!< Print a log message without a trailing newline
42 extern void     LogFV(const char *Fmt, va_list Args);   //!< va_list non-newline log message
43 extern void     Log(const char *Fmt, ...);      //!< Print a log message
44 extern void     Debug(const char *Fmt, ...);    //!< Print a debug message (doesn't go to KTerm)
45 extern void     LogV(const char *Fmt, va_list Args);    //!< va_list Log message
46 extern void     Debug_Enter(const char *FuncName, const char *ArgTypes, ...);
47 extern void     Debug_Log(const char *FuncName, const char *Fmt, ...);
48 extern void     Debug_Leave(const char *FuncName, char RetType, ...);
49 extern void     Debug_HexDump(const char *Header, const void *Data, size_t Length);
50
51 #define UNIMPLEMENTED() Warning("'%s' unimplemented", __func__)
52 #define TODO(fmt, ...)  Panic("TODO: ", fmt ,## __VA_ARGS__)
53 #if DEBUG
54 # define ENTER(_types...)       Debug_Enter((char*)__func__, _types)
55 # define LOG(_fmt...)   Debug_Log((char*)__func__, _fmt)
56 # define LEAVE(_t...)   Debug_Leave((char*)__func__, _t)
57 # define LEAVE_RET(_t,_v...)    do{LEAVE(_t,_v);return _v;}while(0)
58 # define LEAVE_RET0()   do{LEAVE('-');return;}while(0)
59 #else
60 # define ENTER(...)
61 # define LOG(...)
62 # define LEAVE(...)
63 # define LEAVE_RET(_t,_v...)    return (_v)
64 # define LEAVE_RET0()   return
65 #endif
66 #if !DISABLE_ASSERTS
67 # define ASSERTV(expr,msg,args...) do{if(!(expr))Panic("%s:%i - %s: Assertion '"#expr"' failed"msg,__FILE__,__LINE__,(char*)__func__,##args);}while(0)
68 # define ASSERTRV(expr,rv,msg,args...)  do{if(!(expr)){Warning("%s:%i - %s: Assertion '"#expr"' failed"msg,__FILE__,__LINE__,(char*)__func__ , ##args);return rv;}}while(0)
69 #else
70 # define ASSERTV(expr)
71 # define ASSERTRV(expr)
72 #endif
73 #define assert(expr)    ASSERTV(expr, "")
74 #define ASSERT(expr)    ASSERTV(expr, "")
75 #define ASSERTR(expr,rv)        ASSERTRV(expr, rv, "")
76 #define ASSERTC(l,rel,r)        ASSERTV ((l) rel (r), ": 0x%x"#rel"0x%x", (Uint)l, (Uint)r)
77 #define ASSERTCR(l,rel,r,rv)    ASSERTRV((l) rel (r), rv, ": 0x%x"#rel"0x%x", (Uint)l, (Uint)r)
78 /**
79  * \}
80  */
81
82 #endif
83

UCC git Repository :: git.ucc.asn.au