source: SH_SHM/trunk/source/sysbase.h @ 358

Revision 358, 8.2 KB checked in by marcus, 8 years ago (diff)

r192 | walther | 2011-03-31 17:30:28 +0200 (Do, 31 Mär 2011) | 4 lines

  • locsat and fk source may be defined at command line
  • replacing makedepend by gccmakedep (bug not fixed for 5 years in Xorg)
  • added include to sysbase.h for proper macro definition
Line 
1
2/* file SYSBASE.H
3 *      =========
4 *
5 * version 24, 22-May-2006
6 *
7 * v 21: 28-Nov-94, K. Stammler: new naming conventions on sun
8 *
9 * machine dependent definitions
10 * this file conatins all available implementations
11 * K. Stammler, 2-MAY-90
12 */
13
14
15/*
16 *
17 *  SeismicHandler, seismic analysis software
18 *  Copyright (C) 1996,  Klaus Stammler, Federal Institute for Geosciences
19 *                                       and Natural Resources (BGR), Germany
20 *
21 *  This program is free software; you can redistribute it and/or modify
22 *  it under the terms of the GNU General Public License as published by
23 *  the Free Software Foundation; either version 2 of the License, or
24 *  (at your option) any later version.
25 *
26 *  This program is distributed in the hope that it will be useful,
27 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29 *  GNU General Public License for more details.
30 *
31 *  You should have received a copy of the GNU General Public License
32 *  along with this program; if not, write to the Free Software
33 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
34 *
35 */
36
37#include <stdlib.h>
38
39#ifndef __SYSBASE
40#define __SYSBASE
41
42#ifndef __BASECNST
43#include "basecnst.h"
44#endif
45
46/* short integer */
47#define BYTE unsigned char
48#define TSyByte BYTE
49#define TSyWord short int
50#define TSyUword unsigned short int
51
52/* boolean type */
53#define BOOLEAN int
54#define TSyBoolean BOOLEAN
55
56/* boolean values TRUE & FALSE */
57#ifdef BC_DEFINE_TRUE_FALSE
58#define TRUE (1)
59#define FALSE (0)
60#endif
61#define cSyTrue (1)
62#define cSyFalse (0)
63
64/* infinite loop declaration */
65#define FOREVER for(;;)
66#define TSyForever FOREVER
67
68/* status type */
69#ifndef STATUS
70#define STATUS int
71#define Severe(s) (*(s) != 0)
72#define TSyStatus STATUS
73#define SySevere(s) (*(s) != 0)
74#endif /* TSyStatus */
75
76/* nearest integer number to floating number */
77#define Nint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
78#define Nint32(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
79#define SyNint(x) ((x)>0 ? (int)((x)+0.5) : (int)((x)-0.5))
80
81/* nearest long number to floating number */
82#define Nlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
83#define SyNlong(x) ((x)>0 ? (long)((x)+0.5) : (long)((x)-0.5))
84
85/* capitalize character */
86#define Cap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
87#define SyCap(c) (((c)>='a' && (c)<='z') ? ((c)-32) : (c))
88#define Uncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
89#define SyUncap(c) (((c)>='A' && (c)<='Z') ? ((c)+32) : (c))
90
91/* absolute value of number */
92#define Abs(x) ((x)<0?-(x):(x))
93#define SyAbs(x) ((x)<0?-(x):(x))
94
95/* binary file type, here the same as text file */
96typedef FILE *BFILE;
97#define TSyBfile BFILE
98
99/* sy_findfile parameter */
100#define SYC_FF_NAME 1
101#define SYC_FF_DIR 2
102#define SYC_FF_EXT 4
103#define cSyFfName 1
104#define cSyFfDir 2
105#define cSyFfExt 4
106
107/* deallocate memory */
108#define sy_deallocmem(p) free(p)
109#define SyDeallocMem(p) free(p)
110
111/* read logical name table */
112#define sy_lognames(f,s) fo_readtable(f,s)
113#define SyLogNames(f,s) fo_readtable(f,s)
114
115/* open text file */
116/* #define sy_fopen(f,a) fo_fopen(f,a) */
117/* routine implemented for it */
118
119/* close text file */
120#define sy_fclose(f) fclose(f)
121#define SyFclose(f) fclose(f)
122
123/* read from text file */
124#define sy_fread(b,s,n,f) fread(b,s,n,f)
125#define SyFread(b,s,n,f) fread(b,s,n,f)
126
127/* write to text file */
128#define sy_fwrite(b,s,n,f) fwrite(b,s,n,f)
129#define SyFwrite(b,s,n,f) fwrite(b,s,n,f)
130
131/* read from binary file */
132#define sy_fbread(b,s,n,f) fread(b,s,n,f)
133#define SyFbread(b,s,n,f) fread(b,s,n,f)
134
135/* write to binary file */
136#define sy_fbwrite(b,s,n,f) fwrite(b,s,n,f)
137#define SyFbwrite(b,s,n,f) fwrite(b,s,n,f)
138
139/* seek on binary file */
140#define sy_fbseek(f,p,m) fseek(f,p,m)
141#define SyFbseek(f,p,m) fseek(f,p,m)
142
143/* open binary file */
144#define sy_fbopen(f,a) sy_fopen(f,a)
145#define SyFbopen(f,a) sy_fopen(f,a)
146
147/* close binary file */
148#define sy_fbclose(f) fclose(f)
149#define SyFbclose(f) fclose(f)
150
151/* binary file operation failed */
152#define sy_fbfailed(f) ((f)==NULL)
153#define SyFbfailed(f) ((f)==NULL)
154
155/* call to operating system */
156#define sy_system(c,s) system(c)
157#define SySystem(c,s) system(c)
158
159/* delete file */
160#define sy_fdelete(f) unlink(f)
161#define SyFdelete(f) unlink(f)
162
163/* rename file */
164#define sy_frename(f,t) rename(f,t)
165#define SyFrename(f,t) rename(f,t)
166
167/* difference time, not implemented */
168#define sy_difftime() 1.0
169#define SyDifftime() 1.0
170
171
172/* system constants */
173/* ---------------- */
174
175/* maximum unsigned */
176#define SYC_MAXUNSG 0xffffffffL
177#define cSyMaxUnsg SYC_MAXUNSG
178
179/* maximum integer */
180#define SYC_MAXINT 0x7fffffffL
181#define cSyMaxInt SYC_MAXINT
182
183/* minimum integer */
184#define SYC_MININT 0x80000000L
185#define cSyMinInt SYC_MININT
186
187/* maximum long */
188#define SYC_MAXLONG 0x7fffffffL
189#define cSyMaxLong SYC_MAXLONG
190
191/* minimum long */
192#define SYC_MINLONG 0x80000000L
193#define cSyMinLong SYC_MINLONG
194
195/* open existing file to overwrite */
196#define SYC_OPEN_OVWR "r+"
197#define cSyOpenOvwr SYC_OPEN_OVWR
198
199
200/* system specific types */
201/* --------------------- */
202
203/* difference time */
204typedef float DIFFTIME;
205typedef float TSyDifftime;
206
207
208/* not implemented routines */
209#define sy_gettime(s) strcpy(s,SHC_TIMEDEFAULT)
210#define SyGetTime(s) strcpy(s,SHC_TIMEDEFAULT)
211#define sy_sharecpu()
212#define SyShareCpu()
213#define sy_alert(t) printf("%s",t)
214#define SyAlert(t) printf("%s",t)
215#define sy_initprocess()
216#define SyInitProcess()
217
218
219/* include fileopen */
220#ifndef __FOUSRDEF
221#include BC_FOUSRDEF
222#endif
223
224
225/*------------------------------------------------------------------------*/
226/*    prototypes of routines of module SYSCALL.C                          */
227/*------------------------------------------------------------------------*/
228
229
230#define SyAllocMem sy_allocmem
231
232void *sy_allocmem( long cnt, int size, STATUS *status );
233
234/* allocates memory ("cnt" objects of size "size)
235 *
236 * parameters of routine
237 * long     cnt;            input; number of objects
238 * int      size;           input; size of each object
239 * STATUS   *status;        output; return status
240 */
241
242
243/*------------------------------------------------------------------------*/
244
245
246#define SyFindFile sy_findfile
247
248void sy_findfile( int request, char wild[], char filename[] );
249
250/* looks for files matching wild card string "wild". Returns filename of
251 * file found or "\0" if not found.  "request" controls the returned
252 * elements.  For example the value (SYC_FF_DIR|SYC_FF_NAME|SYC_FF_EXT)
253 * means, that the returned string contains directory, file name and
254 * extension.
255 *
256 * parameters of routine
257 * int      request;        input; what elements (name,dir,extension)
258 * char     *wild;          input; wild card string
259 * char     *filename;      output; next file found
260 */
261
262
263/*------------------------------------------------------------------------*/
264
265
266#define SyFopen sy_fopen
267
268FILE *sy_fopen( char file[], char access[] );
269
270/* opens file.  Backslashes "\" in the filename are converted to slashes "/"
271 *
272 * parameters of routine
273 * char       file[];        input; filename of file to be opened
274 * char       access[];      input; access string
275 *                           returns pointer to file or NULL
276 */
277
278
279/*------------------------------------------------------------------------*/
280
281
282#define SyRandom sy_random
283
284double sy_random( double ampl );
285
286/* creates random number with absolute value less than (or equal to)
287 * "amp"
288 *
289 * parameters of routine
290 * double               ampl;           input; max. amplitude; if zero, a new random
291 *                                                                       series is started
292 */
293
294
295/*------------------------------------------------------------------------*/
296
297
298#define SyRandomStr sy_randomstr
299
300void sy_randomstr( int lth, char str[] );
301
302/* creates random string of length "lth"
303 *
304 * parameters of routine
305 * int        lth;      input; length of output string
306 * char       str[];    output; random string
307 */
308
309
310/*------------------------------------------------------------------------*/
311
312
313#define SyLocalInf sy_localinf
314
315void sy_localinf( char item[], char value[], STATUS *status );
316
317/* returns local info in "value"
318 *
319 * parameters of routine
320 * char       item[];     input; info item
321 * char       value[];    output; return value
322 * STATUS     *status;    output; return status
323 */
324
325
326/*------------------------------------------------------------------------*/
327
328
329#endif /* __SYSBASE */
330
Note: See TracBrowser for help on using the repository browser.