40#ifndef CONFIG_H_INCLUDED
41#define CONFIG_H_INCLUDED
53#define PRODUCTIONDATE __DATE__
55#define PRODUCTIONDATE "DD-MM-YYYY"
64#define _FILE_OFFSET_BITS 64
81#define _FILE_OFFSET_BITS 64
91#define HAVE_UNORDERED_MAP
92#define HAVE_UNORDERED_SET
101#define _CRT_SECURE_NO_WARNINGS
107#if !defined(WITHPTHREADS) && defined(WITHPOSIXCLOCK)
111#if !defined(__cplusplus) && !defined(inline)
112#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
114#elif defined(__GNUC__)
116#define inline __inline__
117#elif defined(_MSC_VER)
119#define inline __inline
136#define snprintf _snprintf
160#define STATIC_ASSERT(condition) STATIC_ASSERT__1(condition,__LINE__)
161#define STATIC_ASSERT__1(X,L) STATIC_ASSERT__2(X,L)
162#define STATIC_ASSERT__2(X,L) STATIC_ASSERT__3(X,L)
163#define STATIC_ASSERT__3(X,L) \
164 typedef char static_assertion_failed_##L[(!!(X))*2-1]
172#elif defined(WINDOWS)
174#define WIN32_LEAN_AND_MEAN
180#define WORD FORM_WORD
181#define LONG FORM_LONG
182#define ULONG FORM_ULONG
183#define BOOL FORM_BOOL
186#define OpenFile FORM_OpenFile
187#define ReOpenFile FORM_ReOpenFile
188#define ReadFile FORM_ReadFile
189#define WriteFile FORM_WriteFile
190#define DeleteObject FORM_DeleteObject
192#error UNIX or WINDOWS must be defined!
197#if UINTPTR_MAX == UINT64_MAX
198 typedef int32_t WORD;
199 typedef int64_t LONG;
200 typedef uint32_t UWORD;
201 typedef uint64_t ULONG;
202 #define BITSINWORD 32
203 #define BITSINLONG 64
204 #define WORD_MIN_VALUE INT32_MIN
205 #define WORD_MAX_VALUE INT32_MAX
206 #define LONG_MIN_VALUE INT64_MIN
207 #define LONG_MAX_VALUE INT64_MAX
208#elif UINTPTR_MAX == UINT32_MAX
209 typedef int16_t WORD;
210 typedef int32_t LONG;
211 typedef uint16_t UWORD;
212 typedef uint32_t ULONG;
213 #define BITSINWORD 16
214 #define BITSINLONG 32
215 #define WORD_MIN_VALUE INT16_MIN
216 #define WORD_MAX_VALUE INT16_MAX
217 #define LONG_MIN_VALUE INT32_MIN
218 #define LONG_MAX_VALUE INT32_MAX
220 #error Can not detect if this is a 32-bit or 64-bit platform.
223STATIC_ASSERT(
sizeof(WORD) * 8 == BITSINWORD);
224STATIC_ASSERT(
sizeof(LONG) * 8 == BITSINLONG);
225STATIC_ASSERT(
sizeof(WORD) * 2 ==
sizeof(LONG));
226STATIC_ASSERT(
sizeof(LONG) >=
sizeof(
int *));
227STATIC_ASSERT(
sizeof(LONG) >=
sizeof(
int *));
228STATIC_ASSERT(
sizeof(
int *) >=
sizeof(
int));
229STATIC_ASSERT(
sizeof(
int) >=
sizeof(WORD));
230STATIC_ASSERT(
sizeof(WORD) >=
sizeof(
char));
231STATIC_ASSERT(
sizeof(
char) == 1);
233typedef signed char SBYTE;
234typedef unsigned char UBYTE;
235typedef unsigned int UINT;
237typedef int64_t MLONG;
244#define TOPBITONLY ((ULONG)1 << (BITSINWORD - 1))
245#define TOPLONGBITONLY ((ULONG)1 << (BITSINLONG - 1))
246#define SPECMASK ((UWORD)1 << (BITSINWORD - 1))
247#define WILDMASK ((UWORD)1 << (BITSINWORD - 2))
248#define WORDMASK ((ULONG)FULLMAX - 1)
249#define AWORDMASK (WORDMASK << BITSINWORD)
250#define FULLMAX ((LONG)1 << BITSINWORD)
251#define MAXPOSITIVE ((LONG)(TOPBITONLY - 1))
252#define MAXLONG ((LONG)(TOPLONGBITONLY - 1))
253#define MAXPOSITIVE2 (MAXPOSITIVE / 2)
254#define MAXPOSITIVE4 (MAXPOSITIVE / 4)
260#if !defined(form_alignof)
263#define form_alignof(type) __alignof__(type)
264#elif defined(_MSC_VER)
266#define form_alignof(type) __alignof(type)
267#elif !defined(__cplusplus)
270#define form_alignof(type) offsetof(struct { char c_; type x_; }, x_)
274namespace alignof_impl_ {
275template<
typename T>
struct calc {
276 struct X {
char c_; T x_; };
277 enum { value = offsetof(X, x_) };
280#define form_alignof(type) alignof_impl_::calc<type>::value
310#include <zstd_zlibwrapper.h>
323#if defined(WITHMPI) || defined(WITHPTHREADS)
334STATIC_ASSERT(
sizeof(off_t) >=
sizeof(LONG));
342typedef struct FiLeS {
345extern FILES *Uopen(
char *,
char *);
346extern int Uclose(FILES *);
347extern size_t Uread(
char *,
size_t,
size_t,FILES *);
348extern size_t Uwrite(
char *,
size_t,
size_t,FILES *);
349extern int Useek(FILES *,off_t,
int);
350extern off_t Utell(FILES *);
351extern void Uflush(FILES *);
352extern int Ugetpos(FILES *,fpos_t *);
353extern int Usetpos(FILES *,fpos_t *);
354extern void Usetbuf(FILES *,
char *);
355#define Usync(f) fsync(f->descriptor)
356#define Utruncate(f) { \
357 if ( ftruncate(f->descriptor, 0) ) { \
358 MLOCK(ErrorMessageLock); \
359 MesPrint("Utruncate failed"); \
360 MUNLOCK(ErrorMessageLock); \
365extern FILES *Ustdout;
366#define MAX_OPEN_FILES getdtablesize()
367#define GetPID() ((LONG)getpid())
372#define Uopen(x,y) fopen(x,y)
373#define Uflush(x) fflush(x)
374#define Uclose(x) fclose(x)
375#define Uread(x,y,z,u) fread(x,y,z,u)
376#define Uwrite(x,y,z,u) fwrite(x,y,z,u)
377#define Usetbuf(x,y) setbuf(x,y)
378#define Useek(x,y,z) fseek(x,y,z)
379#define Utell(x) ftell(x)
380#define Ugetpos(x,y) fgetpos(x,y)
381#define Usetpos(x,y) fsetpos(x,y)
382#define Usync(x) fflush(x)
383#define Utruncate(x) _chsize(_fileno(x),0)
384#define Ustdout stdout
385#define MAX_OPEN_FILES FOPEN_MAX
386#define bzero(b,len) (memset((b), 0, (len)), (void)0)
387#define GetPID() ((LONG)GetCurrentProcessId())