das2C
das core C utilities (v3)
das2
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
#ifdef _WIN32
115
#define DAS_DSEPC '\\'
116
118
#define DAS_DSEPS "\\"
119
120
#else
121
123
#define DAS_DSEPC '/'
124
126
#define DAS_DSEPS "/"
127
#endif
128
129
#ifdef __cplusplus
130
extern
"C"
{
131
#endif
132
143
#define DAS_22_STREAM_VER "2.2"
144
#define DAS_30_STREAM_VER "3.0"
145
146
147
/* On Solaris systems NAME_MAX is not defined because pathconf() is supposed
148
* to be used to get the exact limit by filesystem. Since all the filesystems
149
* in common use today have support 255 characters, let's just define that
150
* to be NAME_MAX in the absence of something better.
151
*/
152
#ifdef __sun
153
#ifndef NAME_MAX
154
#define NAME_MAX 255
155
#endif
156
#endif
157
158
/* Make it obvious when we are just moving data as opposed to characters */
159
typedef
uint8_t ubyte;
160
164
typedef
int
DasErrCode
;
165
167
#define DAS_OKAY 0
168
169
#define DASERR_NOTIMP 8
170
#define DASERR_ASSERT 9
171
#define DASERR_INIT 11
172
#define DASERR_BUF 12
173
#define DASERR_UTIL 13
174
#define DASERR_ENC 14
175
#define DASERR_UNITS 15
176
#define DASERR_DESC 16
177
#define DASERR_PLANE 17
178
#define DASERR_PKT 18
179
#define DASERR_STREAM 19
180
#define DASERR_OOB 20
181
#define DASERR_IO 22
182
#define DASERR_DSDF 23
183
#define DASERR_DFT 24
184
#define DASERR_LOG 25
185
#define DASERR_ARRAY 26
186
#define DASERR_VAR 27
187
#define DASERR_DIM 28
188
#define DASERR_DS 29
189
#define DASERR_BLDR 30
190
#define DASERR_HTTP 31
191
#define DASERR_DATUM 32
192
#define DASERR_VALUE 33
193
#define DASERR_OP 34
194
#define DASERR_CRED 35
195
#define DASERR_NODE 36
196
#define DASERR_TIME 37
197
#define DASERR_PROP 38
198
#define DASERR_FRM 39
199
#define DASERR_VEC 40
200
#define DASERR_SERIAL 41
201
#define DASERR_MAX 41
202
203
#ifdef __cplusplus
204
}
205
#endif
206
207
#endif
/* _das_defs_h_ */
208
209
DasErrCode
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition:
defs.h:164
Generated by
1.9.1