MISR Toolkit  1.5.1
dfi.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF. The full HDF copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* $Id$ */
15 
16 /*-----------------------------------------------------------------------------
17  * File: dfi.h
18  * Purpose: HDF internal header file
19  * Invokes: stdio.h, sys/file.h
20  * Contents:
21  * Compilation parameters
22  * Machine-dependent definitions
23  * Flexibility definitions: i/o buffering, dynamic memory, structure i/o
24  * Size parameters
25  * Remarks: To port to a new system, only dfi.h and Makefile need be modified.
26  * This file is included with user programs, but users do not see it.
27  *---------------------------------------------------------------------------*/
28 
29 #ifndef DFI_H
30 #define DFI_H
31 
32 /*--------------------------------------------------------------------------*/
33 /* Compilation Parameters for Flexibility and Portability */
34 
35 /* modify this line for buffered/unbuffered i/o */
36 #define DF_BUFFIO
37 
38 /* modify this line for dynamic/static memory allocation */
39 #define DF_DYNAMIC
40 
41 /* modify this line if structures cannot be read/written as is */
42 #undef DF_STRUCTOK /* leave it this way - hdfsh expects it */
43 
44 /*--------------------------------------------------------------------------*/
45 /* Machine dependencies */
46 /*--------------------------------------------------------------------------*/
47 
48 #ifdef IRIX
49 #undef DF_STRUCTOK
50 #include <sys/types.h>
51 #include <sys/file.h> /* for unbuffered i/o stuff */
52 #ifndef DFmovmem
53 #define DFmovmem(from, to, len) bcopy(from, to, len)
54 #endif /* DFmovmem */
55 #ifndef DF_STRUCTOK
56 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
57 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
58 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
59  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
60 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
61 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
62 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
63  *p++ = (x>>8) & 255; *p++ = x & 255; }
64 #endif /*DF_STRUCTOK */
65 #define DF_CREAT(name, prot) creat(name, prot)
66 #ifndef DF_MT
67 #define DF_MT DFMT_IRIX
68 #endif /* DF_MT */
69 #endif /*IRIX */
70 
71 #ifdef IBM6000 /* NOTE: IBM6000 defines are same as for SUN */
72 #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
73 #undef DF_STRUCTOK
74 #endif
75 #include <sys/file.h> /* for unbuffered i/o stuff */
76 #define DFmovmem(from, to, len) memcpy(to, from, len)
77 #ifndef DF_STRUCTOK
78 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
79 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
80 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
81  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
82 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
83 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
84 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
85  *p++ = (x>>8) & 255; *p++ = x & 255; }
86 #endif /*DF_STRUCTOK */
87 #define DF_CREAT(name, prot) creat(name, prot)
88 #define DF_MT DFMT_IBM6000
89 #endif /*IBM6000 */
90 
91 #ifdef APOLLO
92 #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
93 #undef DF_STRUCTOK
94 #endif
95 #include <sys/file.h> /* for unbuffered i/o stuff */
96 #define int8 char
97 #define uint8 unsigned char
98 #define int16 short int
99 #define uint16 unsigned short int
100 #define int32 long int
101 #define uint32 unsigned long int
102 #define float32 float
103 #define DFmovmem(from, to, len) memcpy(to, from, len)
104 #ifndef DF_STRUCTOK
105 #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
106 #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
107 #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16; \
108  x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
109 #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
110 #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
111 #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255; \
112  *p++ = (x>>8) & 255; *p++ = x & 255; }
113 #endif /*DF_STRUCTOK */
114 #define DF_CREAT(name, prot) creat(name, prot)
115 #define DF_MT DFMT_APOLLO
116 #endif /*APOLLO */
117 
118 /*--------------------------------------------------------------------------*/
119 /* Flexibility parameters */
120 #ifdef DF_BUFFIO /* set all calls to do buffered I/O */
121 #define DF_OPEN(x,y) fopen(x,y)
122 #define DF_CLOSE(x) fclose(x)
123 #define DF_SEEK(x,y,z) fseek(x,y,z)
124 #define DF_SKEND(x,y,z) fseek(x,y,z)
125 #define DF_TELL(x) ftell(x)
126 #define DF_READ(a,b,c,d) fread(a,b,c,d)
127 #define DF_WRITE(a,b,c,d) fwrite(a,b,c,d)
128 #define DF_FLUSH(a) fflush(a)
129 #define DF_OPENERR(f) (!(f))
130 #define DF_RDACCESS "rb"
131 #define DF_WRACCESS "rb+"
132 
133 #else /*DF_BUFFIO unbuffered i/o */
134 #define DF_OPEN(x,y) open(x,y)
135 #define DF_CLOSE(x) close(x)
136 #define DF_SEEK(x,y,z) lseek(x,y,z)
137 #define DF_SKEND(x,y,z) lseek(x,-1*y,z)
138 #define DF_TELL(x) lseek(x,0L,1)
139 #define DF_READ(a,b,c,d) read(d,a,b*c)
140 #define DF_WRITE(a,b,c,d) write(d,a,b*c)
141 #define DF_OPENERR(f) ((f) == -1)
142 #define DF_FLUSH(a) /* no need to flush */
143 #define DF_RDACCESS O_RDONLY
144 #define DF_WRACCESS O_RDWR
145 #endif /* DF_BUFFIO */
146 
147 #ifndef FILE
148 #include <stdio.h>
149 #endif /*FILE */
150 
151 #endif /* DFI_H */

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52