tac0S
Template Affectional Command Operating System
Macros | Typedefs | Functions
utility.h File Reference

Miscellaneous useful definitions, including debugging routines. More...

#include "copyright.h"
#include <bool.h>
#include "sysdep.h"

Go to the source code of this file.

Macros

#define divRoundDown(n, s)   ((n) / (s))
 Divide and either round up or down.
 
#define divRoundUp(n, s)   (((n) / (s)) + ((((n) % (s)) > 0) ? 1 : 0))
 
#define ASSERT(condition)
 

ASSERT More...

 

Typedefs

typedef void(* VoidFunctionPtr) (int arg)
 
typedef void(* VoidNoArgFunctionPtr) ()
 

Functions

void DebugInit (const char *flags)
 Include interface that isolates us from the host machine system library. Requires definition of bool, and VoidFunctionPtr. More...
 
bool DebugIsEnabled (char flag)
 Is this debug flag enabled? More...
 
void DEBUG (char flag, const char *format,...)
 Print debug message. More...
 

Detailed Description

Miscellaneous useful definitions, including debugging routines.

Author
Olivier Hureau, Hugo Feydel , Julien ALaimo
 The debugging routines allow the user to turn on selected
 debugging messages, controllable from the command line arguments
 passed to Nachos (-d).  You are encouraged to add your own
 debugging flags.  The pre-defined debugging flags are:

 '+' -- turn on all debug messages
 't' -- thread system
 's' -- semaphores, locks, and conditions
 'i' -- interrupt emulation
 'm' -- machine emulation (USER_PROGRAM)
 'd' -- disk emulation (FILESYS)
 'f' -- file system (FILESYS)
 'a' -- address spaces (USER_PROGRAM)
 'n' -- network emulation (NETWORK)

Copyright (c) 1992-1993 The Regents of the University of California. All rights reserved. See copyright.h for copyright notice and limitation of liability and disclaimer of warranty provisions.

Macro Definition Documentation

#define ASSERT (   condition)
Value:
if (!(condition)) { \
fprintf(stderr, "Assertion failed: line %d, file \"%s\"\n", \
__LINE__, __FILE__); \
fflush(stderr); \
Abort(); \
}
void Abort()
Abort Quit and drop core.
Definition: sysdep.cc:428


ASSERT

Parameters
[in]Ifcondition is false, print a message and dump core. Useful for documenting assumptions in the code.

NOTE: needs to be a #define, to be able to print the location

where the error occurred.

Function Documentation

void DEBUG ( char  flag,
const char *  format,
  ... 
)

Print debug message.

Print debug message.

void DebugInit ( const char *  flagList)

Include interface that isolates us from the host machine system library. Requires definition of bool, and VoidFunctionPtr.

enable printing debug messages

Include interface that isolates us from the host machine system library. Requires definition of bool, and VoidFunctionPtr.

If the flag is "+", we enable all DEBUG messages.

Parameters
[in]
bool DebugIsEnabled ( char  flag)

Is this debug flag enabled?

Is this debug flag enabled?

Returns
TRUE if DEBUG messages with "flag" are to be printed.