OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
usrmac.h
Go to the documentation of this file.
1 /*
2 
3 $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
4 $Log: usrmac.h,v $
5 Revision 4.14 1996/01/17 16:48:10 seawifsd
6 added TIME_REPORT feature that when macro ON_TIME() and
7 OFF_TIME() are used in the code, unix time will be printed
8 and difference will be printed also.
9 
10 
11 Revision 4.13 1995/08/03 20:15:51 seawifsd
12 added macros MSEC2SEC and SEC2MSEC.
13 
14 Revision 4.12 1995/04/03 14:21:04 seawifsd
15 added support to find out duplicate memory free.
16 
17 Revision 4.11 1995/02/15 20:34:30 seawifsd
18 defined AX_PLUS_B(X,A,B), R_AX_PLUS_B(Y,A,B) and INRANGE(v,lo,hi)
19 
20 Revision 4.10 1995/01/17 19:59:06 seawifsd
21 Jan. 17, 1994, V4.10
22 
23 Revision 4.1 1995/01/17 14:15:20 seawifsd
24 Jan. 9, 1994, 4.0
25 
26 Revision 3.7 1995/01/06 18:52:10 seawifsd
27 re-defined CHKPRT1/CHKPRT2 macros for ANSI/non-ANSI situation.
28 
29 Revision 3.6 1994/12/15 16:50:45 seawifsd
30 added macro definitions for MALLOCFAILEXIT,CHKMALLOC,and CHKCALLOC.
31 
32 Revision 3.5 1994/11/28 18:23:11 seawifsd
33 fixed macro NOPRINT definition caused by changing the default from PRINT to
34 NOPRINT.
35 
36 Revision 3.4 1994/11/09 18:36:08 seawifsd
37 changed default from 'debuging if NOPRINT is not defined' to
38 'debuging only if PRINT is defined'.
39 
40 Revision 3.3 1994/11/08 18:47:21 seawifsd
41 Nov. 8, 1994, 3.3a3
42 
43 Revision 3.3 1994/11/08 15:05:18 seawifsd
44 Nov. 8, 1994, 3.3a2
45 
46 Revision 1.1.1.4 1994/11/03 20:16:46 frank
47 To prevent conflicts in the definition of MIN/MAX/MOD macros, those
48 macros are renamed to MINV,MAXV and MODV respectively.
49 
50 Revision 1.1.1.3 1994/10/04 15:38:39 frank
51 made sure macros TRUE and FALSE are properly defined.
52 added '#include "wifs_conf.h"' to deal with application specific features.
53 
54 Revision 1.1.1.2 1994/05/23 14:08:20 frank
55 include the platform/compiler dependent include file config.h.
56 
57 Revision 1.2 1994/05/11 15:54:39 seawifst
58 May 6, 1994, version 1.2
59  Summary 1.1.1.1 to 1.1.1.1(total 1 revisions):
60  * Make sure PROTOTYPE is set when __STDC__ is defined.
61 
62 Revision 1.1.1.1 1994/05/06 14:23:11 frank
63 Make sure PROTOTYPE is set when __STDC__ is defined.
64 
65 Revision 1.1 1994/04/19 13:52:17 seawifst
66 Initial revision
67 
68 
69  */
70 
71 
72 #ifndef USRMAC_H_
73 #define USRMAC_H_
74 
75 /*
76 #define FAKETILT
77  */
78 /*
79 #define FAKEGAIN
80  */
81 /*
82 #define FIXSETDIMS
83  */
84 #ifndef PRIVATE
85 #define PRIVATE static
86 #endif
87 #ifndef bool
88 #define bool int
89 #endif
90 #if !defined(TRUE) || ((TRUE) != 1)
91 #define TRUE (1)
92 #endif
93 #if !defined(FALSE) || ((FALSE) != 0)
94 #define FALSE (0)
95 #endif
96 
97 #define S_FILE_FOUND -3
98 #define S_FILE_NOT_FOUND -2
99 #define S_ERROR -1
100 #define S_SUCCESS 0
101 #define S_END_OF_FILE 1
102 
103 
104 #ifdef PRINT
105 #undef NOPRINT
106 #define PRINTF printf("(%s,%d) ",__FILE__,__LINE__); printf
107 #define FPRINTF fprintf(stderr,"(%s,%d) ",__FILE__,__LINE__); fprintf
108 #else
109 #define NOPRINT 1
110 #define PRINTF if (!NOPRINT) printf
111 #define FPRINTF if (!NOPRINT) fprintf
112 #endif /* PRINT */
113 
114 /*
115  Example:
116  CHKPRT1("%d",SDS->rank) -> PRINTF("%s=""%d","SDS->rank",SDS->rank)
117  CHKPRT2("%d,%d",SDS->rec,i) -> PRINTF("%s=""%d,%d","SDS->rec,i",SDS->rec,i)
118  */
119 #ifdef __STDC__
120 #define CHKPRT1(FMT,ARG) PRINTF("%s="# FMT,# ARG,ARG)
121 #define CHKPRT2(FMT,ARG1,ARG2) PRINTF("%s="# FMT,# ARG1 #ARG2,ARG1,ARG2)
122 #define CHKIPRT(EX) PRINTF("%s=%d\n", # EX ,EX)
123 #define CHKFPRT(EX) PRINTF("%s=%f\n", # EX ,EX)
124 #define CHKSPRT(EX) PRINTF("%s=%s\n", # EX ,EX)
125 #else
126 #define CHKPRT1(FMT,ARG) PRINTF("%s="FMT,"ARG",ARG)
127 #define CHKPRT2(FMT,ARG1,ARG2) PRINTF("%s="FMT,"ARG1,ARG2",ARG1,ARG2)
128 #define CHKIPRT(EX) PRINTF("%s=%d\n","EX",EX)
129 #define CHKFPRT(EX) PRINTF("%s=%f\n","EX",EX)
130 #define CHKSPRT(EX) PRINTF("%s=%s\n","EX",EX)
131 #endif /* ANSI */
132 
133 #define MAXV(a,b) (((a) > (b)) ? (a) : (b))
134 #define MINV(a,b) (((a) > (b)) ? (b) : (a))
135 #define MODV(a,b) ((a) - ((a)/(b))*(b))
136 
137 #define AX_PLUS_B(X,A,B) (A) * (X) + (B)
138 #define R_AX_PLUS_B(Y,A,B) ((Y) - (B)) / (A)
139 #define INRANGE(v,lo,hi) (((v - lo) >= 0) && ((hi - v) >= 0))
140 
141 #ifdef CHECK_DUPLICATE_FREE
142 #ifndef MM_PTR
143 #define MM_PTR
144 static void *mm_ptr = (void *) 0x01;
145 #endif /* !MM_PTR */
146 #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);}
147 #endif /* CHECK_DUPLICATE_FREE */
148 
149 #ifdef TIME_REPORT
150 #include <stdio.h>
151 #include <time.h>
152 #include <sys/time.h>
153 
154 static struct timeval stime_struct;
155 static struct timeval etime_struct;
156 static clock_t sclock;
157 static clock_t eclock;
158 
159 #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)
160 #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))
161 #else
162 #define ON_TIME()
163 #define OFF_TIME()
164 #endif /* TIME_REPORT */
165 
166 #define TRACE trace
167 
168 #ifdef __STDC__
169 #ifndef PROTOTYPE
170 #define PROTOTYPE
171 #endif /* PROTOTYPE */
172 #endif /* __STDC__ */
173 
174 #ifdef PROTO
175 #undef PROTO
176 #endif /* PROTO */
177 #ifdef PROTOTYPE
178 #define PROTO(x) x
179 #else
180 #define PROTO(x) ()
181 #endif
182 
183 #ifndef byte
184 #define byte unsigned char
185 #endif
186 
187 /*
188  define size of different data type
189  */
190 #define SC sizeof(char)
191 #define SB sizeof(byte)
192 #define SS sizeof(short int)
193 #define SI sizeof(int)
194 #define SL sizeof(int32_t int)
195 #define SF sizeof(float)
196 #define SD sizeof(double)
197 
198 /*
199  Following macros are used to indicate where in the program, we use
200  fake routines to supply data or we don't process the data yet, or
201  the definition of some constants is not confirmed, if
202  you see compiler complaining about 'NODATA','FAKEDATA', or 'FAKEDEF'
203  are been redefined.
204  */
205 #define NODATA
206 #define FAKEDATA
207 #define FAKEDEF
208 
209 /*
210  for code need to be resolve
211  */
212 #define ISSUE
213 
214 
215 /*
216  Following macros are used to turn on/off addition information, or do
217  some additional operations.
218  NOTE: you must use OPTIONS_START and OPTIONS_STOP in pairs.
219  default is turn off the OPTIONS if not defined. i.e. all the codes
220  in between OPTIONS_START and OPTIONS_STOP will not be executed.
221  You can specify it in the compile time also by
222  cc -DOPTIONS=OPTIONS_OFF ; turn off
223  cc -DOPTIONS=OPTIONS_ON ; turn on
224  */
225 #define OPTIONS_ON 1
226 #define OPTIONS_OFF 0
227 #ifndef OPTIONS
228 #define OPTIONS OPTIONS_OFF
229 #endif
230 #define OPTIONS_START(); if (OPTIONS) {
231 #define OPTIONS_STOP(); }
232 
233 #define MSEC2SEC(x) ((x + 500)/1000)
234 #define SEC2MSEC(x) (x * 1000)
235 
236 #include "config.h"
237 #include "wifs_conf.h"
238 #endif /* USRMAC_H_ */