|
ocssw
1.0
|
00001 /* 00002 00003 $Header: /app/shared/RCS/irix-5.2/seawifsd/src/hdfio/Shared.V4.5/L012_Util/util/usr/usrmac.h,v 4.13 1995/08/03 20:15:51 00004 $Log: usrmac.h,v $ 00005 Revision 4.14 1996/01/17 16:48:10 seawifsd 00006 added TIME_REPORT feature that when macro ON_TIME() and 00007 OFF_TIME() are used in the code, unix time will be printed 00008 and difference will be printed also. 00009 00010 00011 Revision 4.13 1995/08/03 20:15:51 seawifsd 00012 added macros MSEC2SEC and SEC2MSEC. 00013 00014 Revision 4.12 1995/04/03 14:21:04 seawifsd 00015 added support to find out duplicate memory free. 00016 00017 Revision 4.11 1995/02/15 20:34:30 seawifsd 00018 defined AX_PLUS_B(X,A,B), R_AX_PLUS_B(Y,A,B) and INRANGE(v,lo,hi) 00019 00020 Revision 4.10 1995/01/17 19:59:06 seawifsd 00021 Jan. 17, 1994, V4.10 00022 00023 Revision 4.1 1995/01/17 14:15:20 seawifsd 00024 Jan. 9, 1994, 4.0 00025 00026 Revision 3.7 1995/01/06 18:52:10 seawifsd 00027 re-defined CHKPRT1/CHKPRT2 macros for ANSI/non-ANSI situation. 00028 00029 Revision 3.6 1994/12/15 16:50:45 seawifsd 00030 added macro definitions for MALLOCFAILEXIT,CHKMALLOC,and CHKCALLOC. 00031 00032 Revision 3.5 1994/11/28 18:23:11 seawifsd 00033 fixed macro NOPRINT definition caused by changing the default from PRINT to 00034 NOPRINT. 00035 00036 Revision 3.4 1994/11/09 18:36:08 seawifsd 00037 changed default from 'debuging if NOPRINT is not defined' to 00038 'debuging only if PRINT is defined'. 00039 00040 Revision 3.3 1994/11/08 18:47:21 seawifsd 00041 Nov. 8, 1994, 3.3a3 00042 00043 Revision 3.3 1994/11/08 15:05:18 seawifsd 00044 Nov. 8, 1994, 3.3a2 00045 00046 Revision 1.1.1.4 1994/11/03 20:16:46 frank 00047 To prevent conflicts in the definition of MIN/MAX/MOD macros, those 00048 macros are renamed to MINV,MAXV and MODV respectively. 00049 00050 Revision 1.1.1.3 1994/10/04 15:38:39 frank 00051 made sure macros TRUE and FALSE are properly defined. 00052 added '#include "wifs_conf.h"' to deal with application specific features. 00053 00054 Revision 1.1.1.2 1994/05/23 14:08:20 frank 00055 include the platform/compiler dependent include file config.h. 00056 00057 Revision 1.2 1994/05/11 15:54:39 seawifst 00058 May 6, 1994, version 1.2 00059 Summary 1.1.1.1 to 1.1.1.1(total 1 revisions): 00060 * Make sure PROTOTYPE is set when __STDC__ is defined. 00061 00062 Revision 1.1.1.1 1994/05/06 14:23:11 frank 00063 Make sure PROTOTYPE is set when __STDC__ is defined. 00064 00065 Revision 1.1 1994/04/19 13:52:17 seawifst 00066 Initial revision 00067 00068 00069 */ 00070 00071 00072 #ifndef USRMAC_H_ 00073 #define USRMAC_H_ 00074 00075 /* 00076 #define FAKETILT 00077 */ 00078 /* 00079 #define FAKEGAIN 00080 */ 00081 /* 00082 #define FIXSETDIMS 00083 */ 00084 #ifndef PRIVATE 00085 # define PRIVATE static 00086 #endif 00087 #ifndef bool 00088 #define bool int 00089 #endif 00090 #if !defined(TRUE) || ((TRUE) != 1) 00091 #define TRUE (1) 00092 #endif 00093 #if !defined(FALSE) || ((FALSE) != 0) 00094 #define FALSE (0) 00095 #endif 00096 00097 #define S_FILE_FOUND -3 00098 #define S_FILE_NOT_FOUND -2 00099 #define S_ERROR -1 00100 #define S_SUCCESS 0 00101 #define S_END_OF_FILE 1 00102 00103 00104 #ifdef PRINT 00105 #undef NOPRINT 00106 #define PRINTF printf("(%s,%d) ",__FILE__,__LINE__); printf 00107 #define FPRINTF fprintf(stderr,"(%s,%d) ",__FILE__,__LINE__); fprintf 00108 #else 00109 #define NOPRINT 1 00110 #define PRINTF if (!NOPRINT) printf 00111 #define FPRINTF if (!NOPRINT) fprintf 00112 #endif /* PRINT */ 00113 00114 /* 00115 Example: 00116 CHKPRT1("%d",SDS->rank) -> PRINTF("%s=""%d","SDS->rank",SDS->rank) 00117 CHKPRT2("%d,%d",SDS->rec,i) -> PRINTF("%s=""%d,%d","SDS->rec,i",SDS->rec,i) 00118 */ 00119 #ifdef __STDC__ 00120 #define CHKPRT1(FMT,ARG) PRINTF("%s="# FMT,# ARG,ARG) 00121 #define CHKPRT2(FMT,ARG1,ARG2) PRINTF("%s="# FMT,# ARG1 #ARG2,ARG1,ARG2) 00122 #define CHKIPRT(EX) PRINTF("%s=%d\n", # EX ,EX) 00123 #define CHKFPRT(EX) PRINTF("%s=%f\n", # EX ,EX) 00124 #define CHKSPRT(EX) PRINTF("%s=%s\n", # EX ,EX) 00125 #else 00126 #define CHKPRT1(FMT,ARG) PRINTF("%s="FMT,"ARG",ARG) 00127 #define CHKPRT2(FMT,ARG1,ARG2) PRINTF("%s="FMT,"ARG1,ARG2",ARG1,ARG2) 00128 #define CHKIPRT(EX) PRINTF("%s=%d\n","EX",EX) 00129 #define CHKFPRT(EX) PRINTF("%s=%f\n","EX",EX) 00130 #define CHKSPRT(EX) PRINTF("%s=%s\n","EX",EX) 00131 #endif /* ANSI */ 00132 00133 #define MAXV(a,b) (((a) > (b)) ? (a) : (b)) 00134 #define MINV(a,b) (((a) > (b)) ? (b) : (a)) 00135 #define MODV(a,b) ((a) - ((a)/(b))*(b)) 00136 00137 #define AX_PLUS_B(X,A,B) (A) * (X) + (B) 00138 #define R_AX_PLUS_B(Y,A,B) ((Y) - (B)) / (A) 00139 #define INRANGE(v,lo,hi) (((v - lo) >= 0) && ((hi - v) >= 0)) 00140 00141 static void *chk_rtn_ptr; 00142 00143 #define MALLOCFAILEXIT() fprintf(stderr,"malloc failed at %s line %d\n",__FILE__,__LINE__);exit(-1); 00144 #define CHKMALLOC(type,size) chk_rtn_ptr = (type)malloc(size); if (chk_rtn_ptr == NULL) {MALLOCFAILEXIT()} 00145 #define CHKCALLOC(type,nelm,size) chk_rtn_ptr = (type)calloc(nelm,size); if (chk_rtn_ptr == NULL) {MALLOCFAILEXIT()} 00146 00147 #ifdef CHECK_DUPLICATE_FREE 00148 #ifndef MM_PTR 00149 #define MM_PTR 00150 static void *mm_ptr = (void *)0x01; 00151 #endif /* !MM_PTR */ 00152 #define free(x) if ((x != NULL) && (x != mm_ptr)) { free(x) ; x = mm_ptr;} else {fprintf(stderr,"%s %d: '%s' already free'd\n",__FILE__,__LINE__,#x);} 00153 #endif /* CHECK_DUPLICATE_FREE */ 00154 00155 #ifdef TIME_REPORT 00156 #include <stdio.h> 00157 #include <time.h> 00158 #include <sys/time.h> 00159 00160 static struct timeval stime_struct; 00161 static struct timeval etime_struct; 00162 static clock_t sclock; 00163 static clock_t eclock; 00164 00165 #define ON_TIME() gettimeofday(&stime_struct);sclock=clock();fprintf(stderr,"%s : ON : %ld.%ld %ld\n",FUNC,stime_struct.tv_sec,stime_struct.tv_usec,sclock) 00166 #define OFF_TIME() gettimeofday(&etime_struct);eclock=clock();fprintf(stderr,"%s : OFF : %ld.%ld %f %ld %ld\n",FUNC,etime_struct.tv_sec,etime_struct.tv_usec,(etime_struct.tv_sec - stime_struct.tv_sec)+(etime_struct.tv_usec - stime_struct.tv_usec)/1.0E6,eclock,(eclock - sclock)) 00167 #else 00168 #define ON_TIME() 00169 #define OFF_TIME() 00170 #endif /* TIME_REPORT */ 00171 00172 #define TRACE trace 00173 00174 #ifdef __STDC__ 00175 #ifndef PROTOTYPE 00176 #define PROTOTYPE 00177 #endif /* PROTOTYPE */ 00178 #endif /* __STDC__ */ 00179 00180 #ifdef PROTO 00181 #undef PROTO 00182 #endif /* PROTO */ 00183 #ifdef PROTOTYPE 00184 #define PROTO(x) x 00185 #else 00186 #define PROTO(x) () 00187 #endif 00188 00189 #ifndef byte 00190 #define byte unsigned char 00191 #endif 00192 00193 /* 00194 define size of different data type 00195 */ 00196 #define SC sizeof(char) 00197 #define SB sizeof(byte) 00198 #define SS sizeof(short int) 00199 #define SI sizeof(int) 00200 #define SL sizeof(int32_t int) 00201 #define SF sizeof(float) 00202 #define SD sizeof(double) 00203 00204 /* 00205 Following macros are used to indicate where in the program, we use 00206 fake routines to supply data or we don't process the data yet, or 00207 the definition of some constants is not confirmed, if 00208 you see compiler complaining about 'NODATA','FAKEDATA', or 'FAKEDEF' 00209 are been redefined. 00210 */ 00211 #define NODATA 00212 #define FAKEDATA 00213 #define FAKEDEF 00214 00215 /* 00216 for code need to be resolve 00217 */ 00218 #define ISSUE 00219 00220 00221 /* 00222 Following macros are used to turn on/off addition information, or do 00223 some additional operations. 00224 NOTE: you must use OPTIONS_START and OPTIONS_STOP in pairs. 00225 default is turn off the OPTIONS if not defined. i.e. all the codes 00226 in between OPTIONS_START and OPTIONS_STOP will not be executed. 00227 You can specify it in the compile time also by 00228 cc -DOPTIONS=OPTIONS_OFF ; turn off 00229 cc -DOPTIONS=OPTIONS_ON ; turn on 00230 */ 00231 #define OPTIONS_ON 1 00232 #define OPTIONS_OFF 0 00233 #ifndef OPTIONS 00234 #define OPTIONS OPTIONS_OFF 00235 #endif 00236 #define OPTIONS_START(); if (OPTIONS) { 00237 #define OPTIONS_STOP(); } 00238 00239 #define MSEC2SEC(x) ((x + 500)/1000) 00240 #define SEC2MSEC(x) (x * 1000) 00241 00242 #include "config.h" 00243 #include "wifs_conf.h" 00244 #endif /* USRMAC_H_ */
1.7.6.1