Main Page   File List  

macros.h

Go to the documentation of this file.
00001 /* $Id: macros.h 25954 2006-05-22 11:39:39Z fm3 $ */
00002 /*****************************************************************************/
00025 /*****************************************************************************/
00026 #ifndef _L4UTIL_MACROS_H
00027 #define _L4UTIL_MACROS_H
00028 
00029 /* L4 includes */
00030 #include <l4/sys/types.h>
00031 #include <l4/sys/kdebug.h>
00032 #include <l4/sys/syscalls.h>
00033 #include <l4/log/l4log.h>
00034 #include <l4/util/l4_macros.h>
00035 
00036 /*****************************************************************************
00037  *** generic macros
00038  *****************************************************************************/
00039 
00040 /* print message and enter kernel debugger */
00041 #ifndef Panic
00042 
00043 // Don't include <stdlib.h> here, leads to trouble.
00044 // Don't use exit() here since we want to terminate ASAP.
00045 // We might be executed in context of the region manager.
00046 EXTERN_C_BEGIN
00047 void _exit(int status) __attribute__ ((__noreturn__));
00048 EXTERN_C_END
00049 
00050 # ifdef L4BID_RELEASE_MODE
00051 #  define Panic(args...) do                                      \
00052                            {                                     \
00053                              LOGL(args);                         \
00054                              LOG_flush();                        \
00055                              _exit(-1);                          \
00056                            }                                     \
00057                          while (1)
00058 # else
00059 #  define Panic(args...) do                                      \
00060                            {                                     \
00061                              LOGL(args);                         \
00062                              LOG_flush();                        \
00063                              enter_kdebug("PANIC, 'g' for exit");\
00064                              _exit(-1);                          \
00065                            }                                     \
00066                          while (1)
00067 # endif
00068 #endif
00069 
00070 /* assertion */
00071 #ifndef Assert
00072 #  define Assert(expr) do                                        \
00073                          {                                       \
00074                            if (!(expr))                          \
00075                              {                                   \
00076                                LOG_printf(#expr "\n");           \
00077                                Panic("Assertion failed");        \
00078                              }                                   \
00079                          }                                       \
00080                        while (0)
00081 #endif
00082 
00083 /* enter kernel debugger */
00084 #ifndef Kdebug
00085 #  define Kdebug(args...)  do                                    \
00086                              {                                   \
00087                                LOGL(args);                       \
00088                                LOG_flush();                      \
00089                                enter_kdebug("KD");               \
00090                              }                                   \
00091                            while (0)
00092 #endif
00093 
00094 /*****************************************************************************
00095  *** debug stuff (to be removed, use LOG* macros instead!)
00096  *****************************************************************************/
00097 
00098 /* we use our own debug macros */
00099 #ifdef KDEBUG
00100 #  undef KDEBUG
00101 #endif
00102 #ifdef ASSERT
00103 #  undef ASSERT
00104 #endif
00105 #ifdef PANIC
00106 #  undef PANIC
00107 #endif
00108 
00109 #ifdef DEBUG
00110 
00111 #define KDEBUG(args...) do                                   \
00112                           {                                  \
00113                             LOGL(args);                      \
00114                             LOG_flush();                     \
00115                             enter_kdebug("KD");              \
00116                           }                                  \
00117                         while (0)
00118 
00119 #ifdef DEBUG_ASSERTIONS
00120 #  define ASSERT(expr)    Assert(expr)
00121 #else
00122 #  define ASSERT(expr)    do {} while (0)
00123 #endif
00124 
00125 #ifdef DEBUG_ERRORS
00126 #  define PANIC(format, args...) Panic(format, ## args)
00127 #else
00128 #  define PANIC(args...)  do {} while (0)
00129 #endif
00130 
00131 #else /* !DEBUG */
00132 
00133 #define KDEBUG(args...) do {} while (0)
00134 #define ASSERT(expr)    do {} while (0)
00135 #define PANIC(args...)  do {} while (0)
00136 
00137 #endif /* !DEBUG */
00138 
00139 #endif /* !_L4UTIL_MACROS_H */

L4 Utilities, part of DROPS  © 2000-2003