00001 // utility.h 00002 // Miscellaneous useful definitions. 00003 // 00004 // Copyright (c) 1992-1996 The Regents of the University of California. 00005 // All rights reserved. See copyright.h for copyright notice and limitation 00006 // of liability and disclaimer of warranty provisions. 00007 00008 #ifndef UTILITY_H 00009 #define UTILITY_H 00010 00011 #include "copyright.h" 00012 00013 // Miscellaneous useful routines 00014 00015 #define NULL 0 00016 #define TRUE true 00017 #define FALSE false 00018 // #define bool int // necessary on the Mac? 00019 00020 #define min(a,b) (((a) < (b)) ? (a) : (b)) 00021 #define max(a,b) (((a) > (b)) ? (a) : (b)) 00022 00023 // Divide and either round up or down 00024 #define divRoundDown(n,s) ((n) / (s)) 00025 #define divRoundUp(n,s) (((n) / (s)) + ((((n) % (s)) > 0) ? 1 : 0)) 00026 00027 // This declares the type "VoidFunctionPtr" to be a "pointer to a 00028 // function taking an arbitrary pointer argument and returning nothing". With 00029 // such a function pointer (say it is "func"), we can call it like this: 00030 // 00031 // (*func) ("help!"); 00032 // 00033 // This is used by Thread::Fork as well as a couple of other places. 00034 00035 typedef void (*VoidFunctionPtr)(void *arg); 00036 typedef void (*VoidNoArgFunctionPtr)(); 00037 00038 #endif // UTILITY_H