1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 // vi: set et ts=4 sw=2 sts=2: 3 /****************************************************************************/ 4 /* */ 5 /* File: misc.h */ 6 /* */ 7 /* Purpose: header for misc.c */ 8 /* */ 9 /* Author: Henrik Rentz-Reichert */ 10 /* Institut fuer Computeranwendungen */ 11 /* Universitaet Stuttgart */ 12 /* Pfaffenwaldring 27 */ 13 /* 70569 Stuttgart */ 14 /* internet: ug@ica3.uni-stuttgart.de */ 15 /* */ 16 /* History: 23.02.95 ug3-version */ 17 /* */ 18 /* Revision: 07.09.95 */ 19 /* */ 20 /****************************************************************************/ 21 22 23 24 /****************************************************************************/ 25 /* */ 26 /* auto include mechanism and other include files */ 27 /* */ 28 /****************************************************************************/ 29 30 #ifndef __MISC__ 31 #define __MISC__ 32 33 34 #include "ugtypes.h" 35 #include <cstring> 36 #include "heaps.h" 37 38 #include "namespace.h" 39 40 START_UG_NAMESPACE 41 42 /****************************************************************************/ 43 /* */ 44 /* defines in the following order */ 45 /* */ 46 /* compile time constants defining static data size (i.e. arrays) */ 47 /* other constants */ 48 /* macros */ 49 /* */ 50 /****************************************************************************/ 51 52 #ifndef PI 53 #define PI 3.141592653589793238462643383279 54 #endif 55 56 #define KBYTE 1024 57 #define MBYTE (KBYTE*KBYTE) 58 #define GBYTE (KBYTE*KBYTE*KBYTE) 59 60 61 /* cleanup old definitions of macros */ 62 #ifdef MIN 63 #undef MIN 64 #endif 65 #ifdef MAX 66 #undef MAX 67 #endif 68 69 #define MIN(x,y) (((x)<(y)) ? (x) : (y)) 70 #define MAX(x,y) (((x)>(y)) ? (x) : (y)) 71 #define POW2(i) (1<<(i)) 72 73 #define SET_FLAG(flag,bitpattern) (flag |= (bitpattern)) 74 #define CLEAR_FLAG(flag,bitpattern) (flag &= ~(bitpattern)) 75 #define READ_FLAG(flag,bitpattern) ((flag & (bitpattern))>0) 76 77 #define HiWrd(aLong) (((aLong) >> 16) & 0xFFFF) 78 #define LoWrd(aLong) ((aLong) & 0xFFFF) 79 80 #define SetHiWrd(aLong,n) aLong = (((n)&0xFFFF)<<16)|((aLong)&0xFFFF) 81 #define SetLoWrd(aLong,n) aLong = ((n)&0xFFFF)|((aLong)&0xFFFF0000) 82 83 /* concatenation macros for preprocessor */ 84 #define XCAT(a,b) a ## b 85 #define XCAT3(a,b,c) a ## b ## c 86 #define CAT(a,b) XCAT(a,b) 87 #define CAT3(a,b,c) XCAT3(a,b,c) 88 89 /* expand macro and transfer expanded to string */ 90 #define XSTR(s) # s 91 #define STR(s) XSTR(s) 92 93 #ifndef YES 94 #define YES 1 95 #endif 96 #define ON 1 97 98 #ifndef NO 99 #define NO 0 100 #endif 101 #define OFF 0 102 103 /****************************************************************************/ 104 /* */ 105 /* definition of exported global variables */ 106 /* */ 107 /****************************************************************************/ 108 109 #ifndef ModelP 110 111 END_UG_NAMESPACE 112 namespace PPIF { 113 114 extern int me; /* to have in the serial case this variable as a dummy */ 115 extern int master; /* to have in the serial case this variable as a dummy */ 116 extern int procs; /* to have in the serial case this variable as a dummy */ 117 } /* end namespace PPIF */ 118 START_UG_NAMESPACE 119 120 extern int _proclist_; /* to have in the serial case this variable as a dummy*/ 121 extern int _partition_; /* to have in the serial case this variable as a dummy*/ 122 #endif 123 124 /****************************************************************************/ 125 /* */ 126 /* function declarations */ 127 /* */ 128 /****************************************************************************/ 129 130 /* general routines */ 131 void INT_2_bitpattern (INT n, char text[33]); 132 INT CenterInPattern (char *str, INT PatLen, const char *text, char p, const char *end); 133 char *expandfmt (const char *fmt); 134 char *ExpandCShellVars (char *string); 135 const char *strntok (const char *str, const char *sep, int n, char *token); 136 137 INT ReadMemSizeFromString (const char *s, MEM *mem_size); 138 INT WriteMemSizeToString (MEM mem_size, char *s); 139 140 END_UG_NAMESPACE 141 142 #endif 143