40 #ifndef CONFIG_H_INCLUDED
41 #define CONFIG_H_INCLUDED
47 #define MAJORVERSION 4
48 #define MINORVERSION 2
51 #define PRODUCTIONDATE 20170706
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
97 #define SIZEOF_LONG_LONG 8
102 #define _CRT_SECURE_NO_WARNINGS
105 #elif defined(_WIN32)
107 #define SIZEOF_LONG_LONG 8
114 #if !defined(WITHPTHREADS) && defined(WITHPOSIXCLOCK)
115 #undef WITHPOSIXCLOCK
118 #if !defined(__cplusplus) && !defined(inline)
119 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
121 #elif defined(__GNUC__)
123 #define inline __inline__
124 #elif defined(_MSC_VER)
126 #define inline __inline
136 #if defined(_MSC_VER)
144 #define _ALLOW_KEYWORD_MACROS
152 #define snprintf _snprintf
173 #define STATIC_ASSERT(condition) STATIC_ASSERT__1(condition,__LINE__)
174 #define STATIC_ASSERT__1(X,L) STATIC_ASSERT__2(X,L)
175 #define STATIC_ASSERT__2(X,L) STATIC_ASSERT__3(X,L)
176 #define STATIC_ASSERT__3(X,L) \
177 typedef char static_assertion_failed_##L[(!!(X))*2-1]
185 #elif defined(WINDOWS)
187 #define WIN32_LEAN_AND_MEAN
193 #define WORD FORM_WORD
194 #define LONG FORM_LONG
195 #define ULONG FORM_ULONG
198 #define OpenFile FORM_OpenFile
199 #define ReOpenFile FORM_ReOpenFile
200 #define ReadFile FORM_ReadFile
201 #define WriteFile FORM_WriteFile
202 #define DeleteObject FORM_DeleteObject
204 #error UNIX or WINDOWS must be defined!
220 typedef unsigned short UWORD;
221 typedef unsigned long ULONG;
222 #define BITSINWORD 16
223 #define BITSINLONG 32
229 #ifdef SIZEOF_LONG_LONG
230 #if SIZEOF_LONG_LONG == 8
231 #define INT64 long long
236 #error INT64 is not available!
242 typedef long long LONG;
243 typedef unsigned int UWORD;
244 typedef unsigned long long ULONG;
245 #define BITSINWORD 32
246 #define BITSINLONG 64
249 #define INT64 long long
256 typedef unsigned int UWORD;
257 typedef unsigned long ULONG;
258 #define BITSINWORD 32
259 #define BITSINLONG 64
266 #error ILP32 or LLP64 or LP64 must be defined!
269 STATIC_ASSERT(
sizeof(WORD) * 8 == BITSINWORD);
270 STATIC_ASSERT(
sizeof(LONG) * 8 == BITSINLONG);
271 STATIC_ASSERT(
sizeof(WORD) * 2 ==
sizeof(LONG));
272 STATIC_ASSERT(
sizeof(LONG) >=
sizeof(
int *));
273 STATIC_ASSERT(
sizeof(INT16) == 2);
274 STATIC_ASSERT(
sizeof(INT32) == 4);
275 STATIC_ASSERT(
sizeof(INT64) == 8);
277 STATIC_ASSERT(
sizeof(INT128) == 16);
285 typedef signed char SBYTE;
286 typedef unsigned char UBYTE;
287 typedef unsigned int UINT;
291 #define TOPBITONLY ((ULONG)1 << (BITSINWORD - 1))
292 #define TOPLONGBITONLY ((ULONG)1 << (BITSINLONG - 1))
293 #define SPECMASK ((UWORD)1 << (BITSINWORD - 1))
294 #define WILDMASK ((UWORD)1 << (BITSINWORD - 2))
295 #define WORDMASK ((ULONG)FULLMAX - 1)
296 #define AWORDMASK (WORDMASK << BITSINWORD)
297 #define FULLMAX ((LONG)1 << BITSINWORD)
298 #define MAXPOSITIVE ((LONG)(TOPBITONLY - 1))
299 #define MAXLONG ((LONG)(TOPLONGBITONLY - 1))
300 #define MAXPOSITIVE2 (MAXPOSITIVE / 2)
301 #define MAXPOSITIVE4 (MAXPOSITIVE / 4)
307 #if !defined(alignof)
308 #if defined(__GNUC__)
310 #define alignof(type) __alignof__(type)
311 #elif defined(_MSC_VER)
313 #define alignof(type) __alignof(type)
314 #elif !defined(__cplusplus)
317 #define alignof(type) offsetof(struct { char c_; type x_; }, x_)
321 namespace alignof_impl_ {
322 template<
typename T>
struct calc {
323 struct X {
char c_; T x_; };
324 enum { value = offsetof(X, x_) };
327 #define alignof(type) alignof_impl_::calc<type>::value
362 #define PADDUMMY(type, size) \
363 UBYTE d_u_m_m_y[alignof(type) - ((size) & (alignof(type) - 1))]
364 #define PADPOSITION(ptr_,long_,int_,word_,byte_) \
366 + sizeof(int *) * (ptr_) \
367 + sizeof(LONG) * (long_) \
368 + sizeof(int) * (int_) \
369 + sizeof(WORD) * (word_) \
370 + sizeof(UBYTE) * (byte_) \
372 #define PADPOINTER(long_,int_,word_,byte_) \
374 + sizeof(LONG) * (long_) \
375 + sizeof(int) * (int_) \
376 + sizeof(WORD) * (word_) \
377 + sizeof(UBYTE) * (byte_) \
379 #define PADLONG(int_,word_,byte_) \
381 + sizeof(int) * (int_) \
382 + sizeof(WORD) * (word_) \
383 + sizeof(UBYTE) * (byte_) \
385 #define PADINT(word_,byte_) \
387 + sizeof(WORD) * (word_) \
388 + sizeof(UBYTE) * (byte_) \
390 #define PADWORD(byte_) \
392 + sizeof(UBYTE) * (byte_) \
417 #include <sys/file.h>
431 #if defined(WITHMPI) || defined(WITHPTHREADS)
448 typedef struct FiLeS {
451 extern FILES *Uopen(
char *,
char *);
452 extern int Uclose(FILES *);
453 extern size_t Uread(
char *,
size_t,
size_t,FILES *);
454 extern size_t Uwrite(
char *,
size_t,
size_t,FILES *);
455 extern int Useek(FILES *,off_t,
int);
456 extern off_t Utell(FILES *);
457 extern void Uflush(FILES *);
458 extern int Ugetpos(FILES *,fpos_t *);
459 extern int Usetpos(FILES *,fpos_t *);
460 extern void Usetbuf(FILES *,
char *);
461 #define Usync(f) fsync(f->descriptor)
462 #define Utruncate(f) { \
463 if ( ftruncate(f->descriptor, 0) ) { \
464 MLOCK(ErrorMessageLock); \
465 MesPrint("Utruncate failed"); \
466 MUNLOCK(ErrorMessageLock); \
471 extern FILES *Ustdout;
472 #define MAX_OPEN_FILES getdtablesize()
473 #define GetPID() ((LONG)getpid())
478 #define Uopen(x,y) fopen(x,y)
479 #define Uflush(x) fflush(x)
480 #define Uclose(x) fclose(x)
481 #define Uread(x,y,z,u) fread(x,y,z,u)
482 #define Uwrite(x,y,z,u) fwrite(x,y,z,u)
483 #define Usetbuf(x,y) setbuf(x,y)
484 #define Useek(x,y,z) fseek(x,y,z)
485 #define Utell(x) ftell(x)
486 #define Ugetpos(x,y) fgetpos(x,y)
487 #define Usetpos(x,y) fsetpos(x,y)
488 #define Usync(x) fflush(x)
489 #define Utruncate(x) _chsize(_fileno(x),0)
490 #define Ustdout stdout
491 #define MAX_OPEN_FILES FOPEN_MAX
492 #define bzero(b,len) (memset((b), 0, (len)), (void)0)
493 #define GetPID() ((LONG)GetCurrentProcessId())