Main Page   Compound List   File List   Compound Members   File Members  

utility.h File Reference

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

Go to the source code of this file.

Defines

#define min(a, b)   (((a) < (b)) ? (a) : (b))
#define max(a, b)   (((a) > (b)) ? (a) : (b))
#define divRoundDown(n, s)   ((n) / (s))
#define divRoundUp(n, s)   (((n) / (s)) + ((((n) % (s)) > 0) ? 1 : 0))
#define ASSERT(condition)

Typedefs

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

Functions

void DebugInit (char *flags)
bool DebugIsEnabled (char flag)
void DEBUG (char flag, char *format,...)


Define Documentation

#define ASSERT condition   
 

Value:

if (!(condition)) {                                                       \
        fprintf(stderr, "Assertion failed: line %d, file \"%s\"\n",           \
                __LINE__, __FILE__);                                          \
        fflush(stderr);                                                       \
        Abort();                                                              \
    }

Definition at line 76 of file utility.h.

Referenced by AddrSpace::AddrSpace, AssignNameToSocket, CheckEndian, Interrupt::CheckIfDue, Thread::CheckOverflow, Network::CheckPktAvail, BitMap::Clear, Close, Copy, FileHeader::Deallocate, Disk::Disk, ExceptionHandler, FileSystem::FileSystem, Thread::Finish, Initialize, Lseek, Mail::Mail, main, BitMap::Mark, Machine::OneInstruction, OpenForReadWrite, OpenForWrite, OpenSocket, PollFile, PostOffice::PostalDelivery, Console::PutChar, Read, ReadFromSocket, Machine::ReadMem, Machine::ReadRegister, Disk::ReadRequest, PostOffice::Receive, SynchList::Remove, Interrupt::Schedule, PostOffice::Send, Network::Send, SendToSocket, Interrupt::SetLevel, Thread::Sleep, StartProcess, SynchConsole::SynchConsole, BitMap::Test, Machine::Translate, Condition::Wait, WriteFile, Machine::WriteMem, Machine::WriteRegister, Disk::WriteRequest, Thread::Yield, Interrupt::YieldOnReturn, and Thread::~Thread.

#define divRoundDown n,
     ((n) / (s))
 

Definition at line 39 of file utility.h.

Referenced by OpenFile::ReadAt, and OpenFile::WriteAt.

#define divRoundUp n,
     (((n) / (s)) + ((((n) % (s)) > 0) ? 1 : 0))
 

Definition at line 40 of file utility.h.

Referenced by AddrSpace::AddrSpace, FileHeader::Allocate, and BitMap::BitMap.

#define max a,
     (((a) > (b)) ? (a) : (b))
 

Definition at line 36 of file utility.h.

#define min a,
     (((a) < (b)) ? (a) : (b))
 

Definition at line 35 of file utility.h.


Typedef Documentation

typedef void(* VoidFunctionPtr)(int arg)
 

Definition at line 51 of file utility.h.

Referenced by CallOnUserAbort, Console::Console, Disk::Disk, Thread::Fork, SynchList::Mapcar, List::Mapcar, Network::Network, PendingInterrupt::PendingInterrupt, Scheduler::Print, Interrupt::Schedule, Thread::StackAllocate, SynchConsole::SynchConsole, and Timer::Timer.

typedef void(* VoidNoArgFunctionPtr)()
 

Definition at line 52 of file utility.h.

Referenced by CallOnUserAbort.


Function Documentation

void DEBUG char    flag,
char *    format,
...   
 

Definition at line 65 of file utility.cc.

Referenced by AddrSpace::AddrSpace, AssignNameToSocket, Interrupt::ChangeLevel, Interrupt::CheckIfDue, Network::CheckPktAvail, Disk::ComputeLatency, Copy, FileSystem::Create, Disk::Disk, ExceptionHandler, FileSystem::FileSystem, Thread::Finish, Thread::Fork, MailBox::Get, Interrupt::Idle, AddrSpace::InitRegisters, main, List::Mapcar, Machine::OneInstruction, Interrupt::OneTick, FileSystem::Open, Machine::RaiseException, OpenFile::ReadAt, SynchConsole::ReadLine, Machine::ReadMem, Disk::ReadRequest, Scheduler::ReadyToRun, Scheduler::Run, Interrupt::Schedule, Network::Send, Thread::Sleep, ThreadTest, Machine::Translate, Disk::UpdateLast, OpenFile::WriteAt, Machine::WriteMem, Disk::WriteRequest, Thread::Yield, and Thread::~Thread.

00066 {
00067     if (DebugIsEnabled(flag)) {
00068         va_list ap;
00069         // You will get an unused variable message here -- ignore it.
00070         va_start(ap, format);
00071         vfprintf(stdout, format, ap);
00072         va_end(ap);
00073         fflush(stdout);
00074     }
00075 }

void DebugInit char *    flags
 

Definition at line 38 of file utility.cc.

Referenced by Initialize.

00039 {
00040     enableFlags = flagList;
00041 }

bool DebugIsEnabled char    flag
 

Definition at line 49 of file utility.cc.

Referenced by Interrupt::CheckIfDue, DEBUG, FileSystem::FileSystem, MailBox::Get, Machine::OneInstruction, PostOffice::PostalDelivery, Disk::ReadRequest, Machine::Run, PostOffice::Send, and Disk::WriteRequest.

00050 {
00051     if (enableFlags != NULL)
00052        return (strchr(enableFlags, flag) != 0) 
00053                 || (strchr(enableFlags, '+') != 0);
00054     else
00055       return FALSE;
00056 }


Generated on Mon Feb 10 09:54:53 2003 for nachos by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees