tac0S
Template Affectional Command Operating System
utility.h
Go to the documentation of this file.
1 
25 #ifndef UTILITY_H
26 #define UTILITY_H
27 
28 #include "copyright.h"
29 
30 // Miscellaneous useful routines
31 
32 #include <bool.h>
33  // Boolean values.
34  // This is the same definition
35  // as in the g++ library.
36 
38 #define divRoundDown(n,s) ((n) / (s))
39 #define divRoundUp(n,s) (((n) / (s)) + ((((n) % (s)) > 0) ? 1 : 0))
40 
41 // This declares the type "VoidFunctionPtr" to be a "pointer to a
42 // function taking an integer argument and returning nothing". With
43 // such a function pointer (say it is "func"), we can call it like this:
44 //
45 // (*func) (17);
46 //
47 // This is used by Thread::Fork and for interrupt handlers, as well
48 // as a couple of other places.
49 
50 typedef void (*VoidFunctionPtr) (int arg);
51 typedef void (*VoidNoArgFunctionPtr) ();
52 
53 
56 #include "sysdep.h"
57 
58 // Interface to debugging routines.
59 
61 extern void DebugInit (const char *flags);
62 
64 extern bool DebugIsEnabled (char flag);
65 
67 extern void DEBUG (char flag, const char *format, ...);
68  // if flag is enabled
69 
78 #define ASSERT(condition) \
79  if (!(condition)) { \
80  fprintf(stderr, "Assertion failed: line %d, file \"%s\"\n", \
81  __LINE__, __FILE__); \
82  fflush(stderr); \
83  Abort(); \
84  }
85 
86 
87 #endif /* UTILITY_H */
System-dependent interface.
void DEBUG(char flag, const char *format,...)
Print debug message.
Definition: utility.cc:65
void DebugInit(const char *flags)
Include interface that isolates us from the host machine system library. Requires definition of bool...
Definition: utility.cc:38
bool DebugIsEnabled(char flag)
Is this debug flag enabled?
Definition: utility.cc:49