das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
das3
defs.h
Go to the documentation of this file.
1
/* Copyright (C) 2020 Chris Piker <chris-piker@uiowa.edu>
2
*
3
* This file is part of das2C, the Core Das2 C Library.
4
*
5
* das2C is free software; you can redistribute it and/or modify it under
6
* the terms of the GNU Lesser General Public License version 2.1 as published
7
* by the Free Software Foundation.
8
*
9
* das2C is distributed in the hope that it will be useful, but WITHOUT ANY
10
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public License
15
* version 2.1 along with das2C; if not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
25
#include <limits.h>
26
#include <stdbool.h>
27
#include <stdint.h>
28
#include <stddef.h>
29
30
31
#ifndef _das_defs_h_
32
#define _das_defs_h_
33
34
/* Get compile time byte order, results in faster code that avoids
35
* runtime checks. For some newer chips this may not work as the
36
* processor can be switched from big endian to little endian at runtime.
37
*
38
* At the end of the day either HOST_IS_LSB_FIRST will be defined, or it won't.
39
* If this macro is defined then the host computer stores the least significant
40
* byte of a word in the lowest address, i.e. it's a little endian machine. If
41
* this macro is not defined then the host computer stores the list significant
42
* byte of a word in the highest address, i.e. it a big endian machine.
43
*/
44
#if defined __linux || defined __APPLE__
45
46
#if defined __linux
47
#include <endian.h>
48
#elif defined __APPLE__
49
#include <machine/endian.h>
50
#endif
51
52
#if __BYTE_ORDER == __LITTLE_ENDIAN
53
#define HOST_IS_LSB_FIRST
54
#else
55
#undef HOST_IS_LSB_FIRST
56
#endif
57
58
#if defined __LP64__
59
#define HOST_IS_64_BIT
60
#endif
61
62
#else
/* End Linux Section */
63
64
#ifdef __sun
65
66
#include <sys/isa_defs.h>
67
#ifdef _LITTLE_ENDIAN
68
#define HOST_IS_LSB_FIRST
69
#else
70
#undef HOST_IS_LSB_FIRST
71
#endif
72
73
#else
74
75
#ifdef _WIN32
76
80
#define HOST_IS_LSB_FIRST
81
82
#ifdef _WIN64
83
#define HOST_IS_64_BIT
84
#endif
85
86
#else
87
88
89
#ifdef __EMSCRIPTEN__
90
/* Web assembly environment is defined as little endian */
91
#define HOST_IS_LSB_FIRST
92
#include <emscripten.h>
93
#else
94
95
#error "unknown byte order!"
96
97
#endif
/* webassembly */
98
#endif
/* _WIN32 */
99
#endif
/* __sun */
100
#endif
/* __linux */
101
102
/* Setup the DLL macros for windows */
103
#if defined(_WIN32) && defined(DAS_USE_DLL)
104
# ifdef BUILDING_DLL
105
# define DAS_API __declspec(dllexport)
106
# else
107
# define DAS_API __declspec(dllimport)
108
# endif
109
#else
110
#define DAS_API
111
#endif
112
113
#if defined(_WIN32)
114
#define DAS_DEPRECATED __declspec(deprecated)
115
#else
116
#define DAS_DEPRECATED __attribute__((__deprecated__))
117
#endif
118
119
/* Ask the compiler to check printf-style calls the way it checks printf
120
itself. FMT_IDX and ARG_IDX are 1-based parameter positions of the format
121
string and the first variadic argument. Not part of any C standard;
122
expands to nothing where the compiler lacks it. */
123
#if defined(__GNUC__) || defined(__clang__)
124
#define _das_fmt_check(FMT_IDX, ARG_IDX) \
125
__attribute__((__format__(__printf__, FMT_IDX, ARG_IDX)))
126
#else
127
#define _das_fmt_check(FMT_IDX, ARG_IDX)
128
#endif
129
130
#ifdef _WIN32
132
#define DAS_DSEPC '\\'
133
135
#define DAS_DSEPS "\\"
136
137
#else
138
140
#define DAS_DSEPC '/'
141
143
#define DAS_DSEPS "/"
144
#endif
145
147
#define DAS_FIELD_SZ(type, field) (sizeof(((type*)NULL)->field))
148
149
#ifdef __cplusplus
150
extern
"C"
{
151
#endif
152
163
#define DAS_22_STREAM_VER "2.2"
164
#define DAS_30_STREAM_VER "3.0"
165
166
167
/* On Solaris systems NAME_MAX is not defined because pathconf() is supposed
168
* to be used to get the exact limit by filesystem. Since all the filesystems
169
* in common use today have support 255 characters, let's just define that
170
* to be NAME_MAX in the absence of something better.
171
*/
172
#ifdef __sun
173
#ifndef NAME_MAX
174
#define NAME_MAX 255
175
#endif
176
#endif
177
178
/* Make it obvious when we are just moving data as opposed to characters */
179
typedef
uint8_t ubyte;
180
184
typedef
int
DasErrCode
;
185
187
#define DAS_OKAY 0
188
189
#define DASERR_NOTIMP 8
190
#define DASERR_ASSERT 9
191
#define DASERR_INIT 11
192
#define DASERR_BUF 12
193
#define DASERR_UTIL 13
194
#define DASERR_ENC 14
195
#define DASERR_UNITS 15
196
#define DASERR_DESC 16
197
#define DASERR_PLANE 17
198
#define DASERR_PKT 18
199
#define DASERR_STREAM 19
200
#define DASERR_OOB 20
201
#define DASERR_IO 22
202
#define DASERR_DSDF 23
203
#define DASERR_DFT 24
204
#define DASERR_LOG 25
205
#define DASERR_ARRAY 26
206
#define DASERR_VAR 27
207
#define DASERR_DIM 28
208
#define DASERR_DS 29
209
#define DASERR_BLDR 30
210
#define DASERR_HTTP 31
211
#define DASERR_DATUM 32
212
#define DASERR_VALUE 33
213
#define DASERR_OP 34
214
#define DASERR_CRED 35
215
#define DASERR_NODE 36
216
#define DASERR_TIME 37
217
#define DASERR_PROP 38
218
#define DASERR_CTX 39
219
#define DASERR_VEC 40
220
#define DASERR_SERIAL 41
221
#define DASERR_ITER 42
222
#define DASERR_SPICE 43
223
#define DASERR_URI 44
224
#define DASERR_FORM 45
225
#define DASERR_GEN 46
226
#define DASERR_MAX 46
227
228
#ifdef __cplusplus
229
}
230
#endif
231
232
#endif
/* _das_defs_h_ */
233
234
DasErrCode
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition
defs.h:184
Generated by
1.9.8