56
56
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
57
57
#endif /* HAVE_purify */
58
58
#define uint4korr(A) (*((uint32_t *) (A)))
59
#define uint5korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
60
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
61
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
62
(((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
63
(((uint64_t) ((unsigned char) (A)[4])) << 32))
64
#define uint6korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) + \
65
(((uint32_t) ((unsigned char) (A)[1])) << 8) + \
66
(((uint32_t) ((unsigned char) (A)[2])) << 16) + \
67
(((uint32_t) ((unsigned char) (A)[3])) << 24)) + \
68
(((uint64_t) ((unsigned char) (A)[4])) << 32) + \
69
(((uint64_t) ((unsigned char) (A)[5])) << 40))
70
59
#define uint8korr(A) (*((uint64_t *) (A)))
71
60
#define sint8korr(A) (*((int64_t *) (A)))
72
61
#define int2store(T,A) *((uint16_t*) (T))= (uint16_t) (A)
74
63
*(T+1)=(unsigned char) (((uint32_t) (A) >> 8));\
75
64
*(T+2)=(unsigned char) (((A) >> 16)); } while (0)
76
65
#define int4store(T,A) *((long *) (T))= (long) (A)
77
#define int5store(T,A) do { *(T)= (unsigned char)((A));\
78
*((T)+1)=(unsigned char) (((A) >> 8));\
79
*((T)+2)=(unsigned char) (((A) >> 16));\
80
*((T)+3)=(unsigned char) (((A) >> 24)); \
81
*((T)+4)=(unsigned char) (((A) >> 32)); } while(0)
82
#define int6store(T,A) do { *(T)= (unsigned char)((A)); \
83
*((T)+1)=(unsigned char) (((A) >> 8)); \
84
*((T)+2)=(unsigned char) (((A) >> 16)); \
85
*((T)+3)=(unsigned char) (((A) >> 24)); \
86
*((T)+4)=(unsigned char) (((A) >> 32)); \
87
*((T)+5)=(unsigned char) (((A) >> 40)); } while(0)
88
66
#define int8store(T,A) *((uint64_t *) (T))= (uint64_t) (A)
102
80
#define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0)
103
81
#define float8get(V,M) doubleget((V),(M))
104
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
105
82
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
106
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
107
83
#define float8store(V,M) doublestore((V),(M))
135
111
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
136
112
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
137
113
(((uint32_t) ((unsigned char) (A)[3])) << 24))
138
#define uint5korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
139
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
140
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
141
(((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
142
(((uint64_t) ((unsigned char) (A)[4])) << 32))
143
#define uint6korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) + \
144
(((uint32_t) ((unsigned char) (A)[1])) << 8) + \
145
(((uint32_t) ((unsigned char) (A)[2])) << 16) + \
146
(((uint32_t) ((unsigned char) (A)[3])) << 24)) + \
147
(((uint64_t) ((unsigned char) (A)[4])) << 32) + \
148
(((uint64_t) ((unsigned char) (A)[5])) << 40))
149
114
#define uint8korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
150
115
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
151
116
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
168
133
*(((char *)(T))+1)=(char) (((A) >> 8));\
169
134
*(((char *)(T))+2)=(char) (((A) >> 16));\
170
135
*(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
171
#define int5store(T,A) do { *((char *)(T))= (char)((A)); \
172
*(((char *)(T))+1)= (char)(((A) >> 8)); \
173
*(((char *)(T))+2)= (char)(((A) >> 16)); \
174
*(((char *)(T))+3)= (char)(((A) >> 24)); \
175
*(((char *)(T))+4)= (char)(((A) >> 32)); \
177
#define int6store(T,A) do { *((char *)(T))= (char)((A)); \
178
*(((char *)(T))+1)= (char)(((A) >> 8)); \
179
*(((char *)(T))+2)= (char)(((A) >> 16)); \
180
*(((char *)(T))+3)= (char)(((A) >> 24)); \
181
*(((char *)(T))+4)= (char)(((A) >> 32)); \
182
*(((char *)(T))+5)= (char)(((A) >> 40)); \
184
136
#define int8store(T,A) do { uint32_t def_temp= (uint32_t) (A), def_temp2= (uint32_t) ((A) >> 32); \
185
137
int4store((T),def_temp); \
186
138
int4store((T+4),def_temp2); } while(0)
187
139
#ifdef WORDS_BIGENDIAN
188
#define float4store(T,A) do { *(T)= ((unsigned char *) &A)[3];\
189
*((T)+1)=(char) ((unsigned char *) &A)[2];\
190
*((T)+2)=(char) ((unsigned char *) &A)[1];\
191
*((T)+3)=(char) ((unsigned char *) &A)[0]; } while(0)
193
140
#define float4get(V,M) do { float def_temp;\
194
141
((unsigned char*) &def_temp)[0]=(M)[3];\
195
142
((unsigned char*) &def_temp)[1]=(M)[2];\
217
164
(V) = def_temp; } while(0)
219
166
#define float4get(V,M) memcpy(&V, (M), sizeof(float))
220
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
222
168
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
223
169
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((unsigned char *) &V)[4];\
248
194
#endif /* __i386__ */
251
Macro for reading 32-bit integer from network byte order (big-endian)
252
from unaligned memory location.
254
#define int4net(A) (int32_t) (((uint32_t) ((unsigned char) (A)[3])) |\
255
(((uint32_t) ((unsigned char) (A)[2])) << 8) |\
256
(((uint32_t) ((unsigned char) (A)[1])) << 16) |\
257
(((uint32_t) ((unsigned char) (A)[0])) << 24))
259
197
Define-funktions for reading and storing in machine format from/to
260
198
short/long to/from some place in memory V should be a (not
261
199
register) variable, M is a pointer to byte
264
202
#ifdef WORDS_BIGENDIAN
266
#define ushortget(V,M) do { V = (uint16_t) (((uint16_t) ((unsigned char) (M)[1]))+\
267
((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
268
204
#define shortget(V,M) do { V = (short) (((short) ((unsigned char) (M)[1]))+\
269
205
((short) ((short) (M)[0]) << 8)); } while(0)
270
206
#define longget(V,M) do { int32_t def_temp;\
273
209
((unsigned char*) &def_temp)[2]=(M)[2];\
274
210
((unsigned char*) &def_temp)[3]=(M)[3];\
275
211
(V)=def_temp; } while(0)
276
#define ulongget(V,M) do { uint32_t def_temp;\
277
((unsigned char*) &def_temp)[0]=(M)[0];\
278
((unsigned char*) &def_temp)[1]=(M)[1];\
279
((unsigned char*) &def_temp)[2]=(M)[2];\
280
((unsigned char*) &def_temp)[3]=(M)[3];\
281
(V)=def_temp; } while(0)
282
212
#define shortstore(T,A) do { uint32_t def_temp=(uint32_t) (A) ;\
283
213
*(((char*)T)+1)=(char)(def_temp); \
284
214
*(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
287
217
*(((char*)T)+1)=(((A) >> 16));\
288
218
*(((char*)T)+0)=(((A) >> 24)); } while(0)
290
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
291
220
#define floatstore(T, V) memcpy((T), (&V), sizeof(float))
292
221
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))
293
222
#define doublestore(T, V) memcpy((T), &V, sizeof(double))
299
#define ushortget(V,M) do { V = uint2korr(M); } while(0)
300
228
#define shortget(V,M) do { V = sint2korr(M); } while(0)
301
229
#define longget(V,M) do { V = sint4korr(M); } while(0)
302
#define ulongget(V,M) do { V = uint4korr(M); } while(0)
303
230
#define shortstore(T,V) int2store(T,V)
304
231
#define longstore(T,V) int4store(T,V)
305
232
#ifndef floatstore
306
233
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
307
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
309
235
#ifndef doubleget
310
236
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))