40 #ifndef CONFIG_H_INCLUDED
41 #define CONFIG_H_INCLUDED
47 #define MAJORVERSION 4
48 #define MINORVERSION 2
51 #define PRODUCTIONDATE __DATE__
53 #define PRODUCTIONDATE "06-jul-2017"
62 #define SIZEOF_LONG_LONG 8
63 #define _FILE_OFFSET_BITS 64
66 #define WITHPOSIXCLOCK
75 #define WITHPOSIXCLOCK
81 #define SIZEOF_LONG_LONG 8
82 #define _FILE_OFFSET_BITS 64
91 #define WITHPOSIXCLOCK
92 #define HAVE_UNORDERED_MAP
93 #define HAVE_UNORDERED_SET
99 #define SIZEOF_LONG_LONG 8
104 #define _CRT_SECURE_NO_WARNINGS
107 #elif defined(_WIN32)
109 #define SIZEOF_LONG_LONG 8
116 #if !defined(WITHPTHREADS) && defined(WITHPOSIXCLOCK)
117 #undef WITHPOSIXCLOCK
120 #if !defined(__cplusplus) && !defined(inline)
121 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
123 #elif defined(__GNUC__)
125 #define inline __inline__
126 #elif defined(_MSC_VER)
128 #define inline __inline
138 #if defined(_MSC_VER)
146 #define _ALLOW_KEYWORD_MACROS
154 #define snprintf _snprintf
175 #define STATIC_ASSERT(condition) STATIC_ASSERT__1(condition,__LINE__)
176 #define STATIC_ASSERT__1(X,L) STATIC_ASSERT__2(X,L)
177 #define STATIC_ASSERT__2(X,L) STATIC_ASSERT__3(X,L)
178 #define STATIC_ASSERT__3(X,L) \
179 typedef char static_assertion_failed_##L[(!!(X))*2-1]
187 #elif defined(WINDOWS)
189 #define WIN32_LEAN_AND_MEAN
195 #define WORD FORM_WORD
196 #define LONG FORM_LONG
197 #define ULONG FORM_ULONG
200 #define OpenFile FORM_OpenFile
201 #define ReOpenFile FORM_ReOpenFile
202 #define ReadFile FORM_ReadFile
203 #define WriteFile FORM_WriteFile
204 #define DeleteObject FORM_DeleteObject
206 #error UNIX or WINDOWS must be defined!
222 typedef unsigned short UWORD;
223 typedef unsigned long ULONG;
224 #define BITSINWORD 16
225 #define BITSINLONG 32
231 #ifdef SIZEOF_LONG_LONG
232 #if SIZEOF_LONG_LONG == 8
233 #define INT64 long long
238 #error INT64 is not available!
241 #define WORD_MIN_VALUE SHRT_MIN
242 #define WORD_MAX_VALUE SHRT_MAX
243 #define LONG_MIN_VALUE LONG_MIN
244 #define LONG_MAX_VALUE LONG_MAX
249 typedef long long LONG;
250 typedef unsigned int UWORD;
251 typedef unsigned long long ULONG;
252 #define BITSINWORD 32
253 #define BITSINLONG 64
256 #define INT64 long long
259 #define WORD_MIN_VALUE INT_MIN
260 #define WORD_MAX_VALUE INT_MAX
261 #define LONG_MIN_VALUE LLONG_MIN
262 #define LONG_MAX_VALUE LLONG_MAX
268 typedef unsigned int UWORD;
269 typedef unsigned long ULONG;
270 #define BITSINWORD 32
271 #define BITSINLONG 64
277 #define WORD_MIN_VALUE INT_MIN
278 #define WORD_MAX_VALUE INT_MAX
279 #define LONG_MIN_VALUE LONG_MIN
280 #define LONG_MAX_VALUE LONG_MAX
283 #error ILP32 or LLP64 or LP64 must be defined!
286 STATIC_ASSERT(
sizeof(WORD) * 8 == BITSINWORD);
287 STATIC_ASSERT(
sizeof(LONG) * 8 == BITSINLONG);
288 STATIC_ASSERT(
sizeof(WORD) * 2 ==
sizeof(LONG));
289 STATIC_ASSERT(
sizeof(LONG) >=
sizeof(
int *));
290 STATIC_ASSERT(
sizeof(INT16) == 2);
291 STATIC_ASSERT(
sizeof(INT32) == 4);
292 STATIC_ASSERT(
sizeof(INT64) == 8);
294 STATIC_ASSERT(
sizeof(INT128) == 16);
302 typedef signed char SBYTE;
303 typedef unsigned char UBYTE;
304 typedef unsigned int UINT;
308 #define TOPBITONLY ((ULONG)1 << (BITSINWORD - 1))
309 #define TOPLONGBITONLY ((ULONG)1 << (BITSINLONG - 1))
310 #define SPECMASK ((UWORD)1 << (BITSINWORD - 1))
311 #define WILDMASK ((UWORD)1 << (BITSINWORD - 2))
312 #define WORDMASK ((ULONG)FULLMAX - 1)
313 #define AWORDMASK (WORDMASK << BITSINWORD)
314 #define FULLMAX ((LONG)1 << BITSINWORD)
315 #define MAXPOSITIVE ((LONG)(TOPBITONLY - 1))
316 #define MAXLONG ((LONG)(TOPLONGBITONLY - 1))
317 #define MAXPOSITIVE2 (MAXPOSITIVE / 2)
318 #define MAXPOSITIVE4 (MAXPOSITIVE / 4)
324 #if !defined(alignof)
325 #if defined(__GNUC__)
327 #define alignof(type) __alignof__(type)
328 #elif defined(_MSC_VER)
330 #define alignof(type) __alignof(type)
331 #elif !defined(__cplusplus)
334 #define alignof(type) offsetof(struct { char c_; type x_; }, x_)
338 namespace alignof_impl_ {
339 template<
typename T>
struct calc {
340 struct X {
char c_; T x_; };
341 enum { value = offsetof(X, x_) };
344 #define alignof(type) alignof_impl_::calc<type>::value
379 #define PADDUMMY(type, size) \
380 UBYTE d_u_m_m_y[alignof(type) - ((size) & (alignof(type) - 1))]
381 #define PADPOSITION(ptr_,long_,int_,word_,byte_) \
383 + sizeof(int *) * (ptr_) \
384 + sizeof(LONG) * (long_) \
385 + sizeof(int) * (int_) \
386 + sizeof(WORD) * (word_) \
387 + sizeof(UBYTE) * (byte_) \
389 #define PADPOINTER(long_,int_,word_,byte_) \
391 + sizeof(LONG) * (long_) \
392 + sizeof(int) * (int_) \
393 + sizeof(WORD) * (word_) \
394 + sizeof(UBYTE) * (byte_) \
396 #define PADLONG(int_,word_,byte_) \
398 + sizeof(int) * (int_) \
399 + sizeof(WORD) * (word_) \
400 + sizeof(UBYTE) * (byte_) \
402 #define PADINT(word_,byte_) \
404 + sizeof(WORD) * (word_) \
405 + sizeof(UBYTE) * (byte_) \
407 #define PADWORD(byte_) \
409 + sizeof(UBYTE) * (byte_) \
435 #include <sys/file.h>
449 #if defined(WITHMPI) || defined(WITHPTHREADS)
466 typedef struct FiLeS {
469 extern FILES *Uopen(
char *,
char *);
470 extern int Uclose(FILES *);
471 extern size_t Uread(
char *,
size_t,
size_t,FILES *);
472 extern size_t Uwrite(
char *,
size_t,
size_t,FILES *);
473 extern int Useek(FILES *,off_t,
int);
474 extern off_t Utell(FILES *);
475 extern void Uflush(FILES *);
476 extern int Ugetpos(FILES *,fpos_t *);
477 extern int Usetpos(FILES *,fpos_t *);
478 extern void Usetbuf(FILES *,
char *);
479 #define Usync(f) fsync(f->descriptor)
480 #define Utruncate(f) { \
481 if ( ftruncate(f->descriptor, 0) ) { \
482 MLOCK(ErrorMessageLock); \
483 MesPrint("Utruncate failed"); \
484 MUNLOCK(ErrorMessageLock); \
489 extern FILES *Ustdout;
490 #define MAX_OPEN_FILES getdtablesize()
491 #define GetPID() ((LONG)getpid())
496 #define Uopen(x,y) fopen(x,y)
497 #define Uflush(x) fflush(x)
498 #define Uclose(x) fclose(x)
499 #define Uread(x,y,z,u) fread(x,y,z,u)
500 #define Uwrite(x,y,z,u) fwrite(x,y,z,u)
501 #define Usetbuf(x,y) setbuf(x,y)
502 #define Useek(x,y,z) fseek(x,y,z)
503 #define Utell(x) ftell(x)
504 #define Ugetpos(x,y) fgetpos(x,y)
505 #define Usetpos(x,y) fsetpos(x,y)
506 #define Usync(x) fflush(x)
507 #define Utruncate(x) _chsize(_fileno(x),0)
508 #define Ustdout stdout
509 #define MAX_OPEN_FILES FOPEN_MAX
510 #define bzero(b,len) (memset((b), 0, (len)), (void)0)
511 #define GetPID() ((LONG)GetCurrentProcessId())