1 /* $Id: compiler.h 293 2020-02-13 15:42:36Z dukelsky $
2 
3 *  SMAPI; Modified Squish MSGAPI
4 *
5 *  Squish MSGAPI0 is copyright 1991 by Scott J. Dudley.  All rights reserved.
6 *  Modifications released to the public domain.
7 *
8 *  Use of this file is subject to the restrictions contain in the Squish
9 *  MSGAPI0 licence agreement.  Please refer to licence.txt for complete
10 *  details of the licencing restrictions.  If you do not find the text
11 *  of this agreement in licence.txt, or if you do not have this file,
12 *  you should contact Scott Dudley at FidoNet node 1:249/106 or Internet
13 *  e-mail Scott.Dudley@f106.n249.z1.fidonet.org.
14 *
15 *  In no event should you proceed to use any of the source files in this
16 *  archive without having accepted the terms of the MSGAPI0 licensing
17 *  agreement, or such other agreement as you are able to reach with the
18 *  author.
19 *
20 *  Modifications from MSGAPI are made by HUSKY: https://github.com/huskyproject
21 */
22 
23 /*
24  * Please define this compiler-specific stuff for each new compiler:
25  *
26  * _stdc    - Standard calling sequence.  This should be the type of function
27  *            required for function pointers for qsort() et al.
28  *
29  * _fast    - Fastest calling sequence supported.  If the default calling
30  *            sequence is the fastest, or if your compiler only has one,
31  *            define this to nothing.
32  *
33  * _intr    - For defining interrupt functions.  For some idiotic reason,
34  *            MSC requires that interrupt routines be declared
35  *            as "cdecl interrupt", instead of just "interrupt".
36  *
37  * _intcast - interrupt cast modifyer
38  *
39  * _veccast - vector cast modifyer
40  *
41  * far      - use pointer with any segment part, actually for x86 16 bit only
42  *            and in other cases must be set to empty value
43  *
44  * near     - (used for x86 16 bit only) use one-segment pointer
45  *
46  * pascal   - pascal style calling conversion code modifyer
47  *
48  * cdecl    - C declarations modifyer (alternate to pascal usually)
49  *            Declare if compiler don't support this.
50  *
51  * _loadds  - (used for x86 16 bit only) 'load data segment' code modifyer
52  *
53  * SMAPI_EXT - external variables & external functions call modifier
54  *             (usualy 'extern' for static linkage)
55  *
56  * _XPENTRY  - system procedures calling (conversion) modifyer
57  *             ("pascal", "_system" & etc)
58  *
59  *
60  *======================
61  * HAS_* please set to 1 for usage: #if HAS_...
62  *======================
63  * HAS_snprintf        - snprintf() presents
64  * HAS_asprintf        - asprintf() presents
65  * HAS_asnprintf       - asnprintf() presents
66  * HAS_vasprintf       - vasprintf() presents
67  * HAS_vsnprintf       - vsnprintf() presents
68  * HAS_spawnvp         - spawnwp() presents
69  * HAS_getpid          - getpid() presents
70  * HAS_mktime          - mktime() presents or defined here
71  * HAS_strftime        - strftime() presents
72  * HAS_sopen           - sopen() presents
73  * HAS_sleep           - sleep() presents or defined here
74  * HAS_dos_read        - dos_read() presents or defined here
75  * HAS_dos_write       - dos_write() presents or defined here
76  * HAS_popen_close     - popen(); pclose() ("pipe open" and "pipe close")
77  * HAS_strupr		 - strupr() presents
78  * HAS_strcasecmp      - strcasecmp()   usualy in <string.h>
79  * HAS_strncasecmp     - strncasecmp()  usualy in <string.h>
80  * HAS_stricmp         - stricmp()   eq strcasecmp()
81  * HAS_strnicmp        - strnicmp()  eq strncasecmp()
82  * HAS_strlwr          - strlwr()   lower string (string.h)
83  * HAS_strupr          - strupr()   upper string (string.h)
84  *
85  * HAS_MALLOC_H        - may be used "#include <malloc.h>" for malloc() etc.
86  * HAS_DOS_H           - may be used "#include <dos.h>"
87  * HAS_DPMI_H          - may be used "#include <dpmi.h>"
88  * HAS_DIR_H           - may be used "#include <dir.h>" for findfirst() etc.
89  * HAS_DIRENT_H        - may be used "#include <dirent.h>" for opendir() etc.
90  * HAS_IO_H            - may be used "#include <io.h>"
91  * HAS_UNISTD_H        - may be used "#include <unistd.h>"
92  * HAS_PROCESS_H       - may be used "#include <process.h>"
93  * HAS_SHARE_H         - may be used "#include <share.h>" for sopen() etc.
94  * HAS_PWD_H           - may be used "#include <pwd.h>"
95  * HAS_GRP_H           - may be used "#include <grp.h>"
96  * HAS_UTIME_H         - may be used "#include <utime.h>"
97  * HAS_SYS_UTIME_H     - #include <sys/utime.h> in alternate to <utime.h>
98  * HAS_SYS_PARAM_H     - #include <sys/params.h>
99  * HAS_SYS_MOUNT_H     - #include <sys/mount.h>
100  * HAS_SYS_WAIT_H      - #include <sys/wait.h>
101  * HAS_SYS_STATVFS_H   - #include <sys/statvfs.h>
102  * HAS_SYS_VFS_H       - #include <sys/vfs.h>
103  * HAS_SYS_SYSEXITS_H  - #include <sys/sysexits.h>
104  * HAS_SYSEXITS_H      - #include <sysexits.h>
105  *
106  * USE_SYSTEM_COPY     - OS have system call for files copiing (see
107  *                       copy_file() and move_file() functions)
108  * USE_SYSTEM_COPY_WIN32  - Windows 9x/NT system copy routine
109  * USE_SYSTEM_COPY_OS2    - OS/2 system copy routine
110  * USE_STAT_MACROS     - may use stat() macro and non-POSIX (important!)
111  *                       S_ISREG and S_ISDIR macros. (See fexist.c)
112  *
113  *
114  ***************************************************************************
115  * Functions "my*" & etc
116  *
117  * mysleep(x)         - wait x seconds
118  * mymkdir(d)         - make directory
119  * strcasecmp(s1,s2)  - case-incencitive strings comparition, declare if
120  *                      present with other name or include header-file
121  * stricmp(s1,s2)     - also as above
122  * strncasecmp(s1,s2) - case-incencitive strings comparition not more n chars,
123  *                      declare if present with other name or include header
124  * strnicmp(s1,s2)    - also as above
125  *
126  * farread(a,b,c)     - for flat memory models declare as read(a,b,c)
127  * farwrite(a,b,c)    - for flat memory models declare as write(a,b,c)
128  * NEED_trivial_farread  - macro-flag: need use my own trivial_farread()
129  *                         instead farread() (implemented in structrw.c)
130  * NEED_trivial_farwrite - macro-flag: need use my own trivial_farwrite()
131  *                         instead farwrite() (implemented in structrw.c)
132  * MAXPATHLEN         - max path len value for disk i/o functions
133  *
134  ***************************************************************************
135  * Memory and platforms
136  *
137  * __BIG_ENDIAN__    - big endian bytes order in memory
138  * __LITTLE_ENDIAN__ - little endian bytes order in memory (like Intel x86)
139  *
140  * 16bit Intel x86 memory models (compiler-predefined)
141  * __TINY__    - 64K data, 64K code, stack in code or data
142  * __SMALL__   - 64K data, 64K code, stack apart
143  * __MEDIUM__  - 64K data, 1M (640K+HMB+UMB) code, stack apart
144  * __COMPACT__ - 1M data, 64K code, stack apart
145  * __LARGE__   - 1M data, 1M code, stack apart
146  * __HUGE__    - similar to the __LARGE__ except for two additional features:
147  *               Its segment is normalized during pointer arithmetic so that
148  *               pointer comparisons are accurate. And, huge pointers can be
149  *               incremented without suffering from segment wrap around.
150  * __NEARCODE__ - 64K code
151  * __FARCODE__  - 1M code
152  * __NEARDATA__ - 64K data
153  * __FARDATA__  - 1M data
154  *
155  * __FLAT__  - must be declared for any flat memory model, usualy all
156  *             not 16 bit dos, os/2 and windows; predefined for some compilers
157  *             - 64K data
158  *
159  ***************************************************************************
160  * Platforms & OS (binary targets)
161  *
162  * __NT__    - Windows NT/2000/XP target
163  * __WIN32__ - Windows 95/98/Me/NT/2000/XP target
164  * __OS2__   - OS/2 target (32 bit or 16 bit), 32bit is __OS2__ && __FLAT__
165  * __DOS__   - MS/PC/... DOS target (32 bit or 16 bit), 32bit is __DOS__ && __FLAT__
166  * __DOS16__ - MS/PC/... DOS target 16 bit
167  * __DPMI__  - DOS 32 bit (extenders: dos4g, farcall, rsx, ...)
168  * __MACOS__ - MacOS (Unix clone)
169  * __unix__  - All unix-like OS
170  * __BSD__   - BSD UNIX clones (BSDI, BSD/OS, FreeBSD, NetBSD, OpenBSD & etc)
171  * __linux__ - GNU/Linux (unix clone)
172  * __AMIGA__ - AmigaOS
173  * __ALPHA__ - The Alpha CPU
174  * __X86__   - Intel's x86 series CPU
175  * __PPC__   - The PowerPC CPU
176  * __MPPC__  - The PowerPC CPU on Apple Macintosh
177  *
178  *--------------------------------------------------------------------------
179  * CPU
180  *
181  * __186__   - Intel 80186 CPU
182  * __286__   - Intel 80286 CPU
183  * __386__   - Intel 80386 CPU
184  * __486__   - Intel 80486 CPU
185  * __586__   - Intel Pentium CPU
186  * __686__   - Intel Pentium Pro CPU
187  * __786__   - Intel Pentium II CPU
188  *
189  */
190 
191 /**************************************************************************
192  * For informaion: list of predefined macroses for known compilers.       *
193  **************************************************************************
194    Common macroses for GNU C
195    -------------------------------------------------------------------
196     __GNUC__          Major version number (2.95.* : 2)
197     __GNUC_MINOR__    Minor version number (2.95.* : 95)
198     __VERSION__       String's compiler version representation
199    ===================================================================
200    MINGW32 for 32-bit Windows NT on Intel and AXP; (GNU C clone)
201    MINGW32 cross-compiler from unixes;             (GNU C clone)
202    Cygwin GCC with option -mno-cygwin.             (GNU C clone)
203    -------------------------------------------------------------------
204     __MINGW32__ __GNUC__  __STDC__
205    --CygWin v1.3.16-1 with gcc 3.2:-----------------------------------
206      __GNUC__=3 (0x3); __GNUC_MINOR__=2 (0x2)
207      __VERSION__=3.2 20020927 (prerelease)
208    --MinGW v1.1 with gcc-2.95.3---------------------------------------
209    __GNUC__=2 (0x2); __GNUC_MINOR__=95 (0x5F)
210    __VERSION__=2.95.3-6 (mingw special)
211    ===================================================================
212    DJGPP (DOS DPMI)                          (GNU C clone)
213    -------------------------------------------------------------------
214     __DJGPP__ __DJGPP DJGPP MSDOS __MSDOS__  __GNUC__  __STDC__
215     __unix__  unix  __i386__
216    Some values:
217    __GNUC__=3 (0x3); __GNUC_MINOR__=2 (0x2)
218    __VERSION__=3.2
219    __DJGPP__ =__DJGPP =DJGPP  =2
220    DJGPP_MINOR = __DJGPP_MINOR =__DJGPP_MINOR__ =3
221    ===================================================================
222    EMX (OS/2)                                (GNU C clone)
223    -------------------------------------------------------------------
224     __EMX__
225     __GNUC__ __VERSION__ __STDC__
226     __CHAR_UNSIGNED__ (or __CHAR_SIGNED__)
227     __32BIT__ - if build 32bit code
228    ---Some values (EMX rev 61):---------------------------------------
229     __GNUC__=2 (0x2); __GNUC_MINOR__=8 (0x8)
230     __VERSION__=2.8.1
231     __STDC__=1 (0x1); __STDC_VERSION__=199409 (0x30AF1);
232    ===================================================================
233    GNU C on FreeBSD
234    -------------------------------------------------------------------
235     __FreeBSD__  __unix__  unix  __GNUC__  __STDC__
236    --- Some values (FreeBSD 4.7) -------------------------------------
237    __GNUC__=2 (0x2); __GNUC_MINOR__=95 (0x5F)
238    __VERSION__=2.95.4 20020320 [FreeBSD]
239    __STDC__=1 (0x1); __STDC_VERSION__=199409 (0x30AF1);
240    __unix__ = 1
241    __FreeBSD__ = 4
242    ===================================================================
243    GNU C on Sun
244    -------------------------------------------------------------------
245    __sun__
246    ===================================================================
247    GNU C on BeOS 5
248    -------------------------------------------------------------------
249    __BEOS__ __i386__ _X86_ __i386 i386  __ELF__ __INTEL__ __PIC__ __pic__
250    Values:
251    __declspec(x) __attribute__((x))
252    __cdecl __attribute__((__cdecl__))
253    __stdcall __attribute__((__stdcall__))
254    intel pentium specific defines:
255     __pentium__ __i586__  i586 __i586 __pentium pentium
256    ===================================================================
257 
258    ===================================================================
259    Watcom C: OS/2 32bit target
260    -------------------------------------------------------------------
261    __WATCOMC__  __OS2__ __FLAT__ __386__ M_I386 _M_I386 __STDC__
262    ===================================================================
263    Watcom C: OS/2 16bit target
264    -------------------------------------------------------------------
265    __WATCOMC__  __OS2__ __I86__ M_I86 _M_I86
266    ===================================================================
267    Watcom C: Windows NT and Windows 95 target (-bt=nt)
268    -------------------------------------------------------------------
269    __WATCOMC__  __NT__ __FLAT__ __386__ M_I386 _M_I386
270    ===================================================================
271    Watcom C: Windows 16bit or 32bit target (-bt=windows), not win95/nt
272    -------------------------------------------------------------------
273    Win32s:  __WATCOMC__  __WINDOWS__ __WINDOWS_386__ __386__ M_I386 _M_I386
274    Windows: __WATCOMC__  __WINDOWS__ _WINDOWS  __I86__ M_I86 _M_I86
275    ===================================================================
276    Watcom C: DOS 16 bit destination (-bt=dos)
277    -------------------------------------------------------------------
278    __WATCOMC__  __DOS__ _DOS  MSDOS __I86__ M_I86 _M_I86
279    ===================================================================
280    Memory model macroses in Watcom C DOS 16 bit destination:
281    -------------------------------------------------------------------
282    Model small:     __SMALL__   M_I86SM _M_I86SM
283    Model medium:    __MEDIUM__  M_I86MM _M_I86MM
284    Model compact:   __COMPACT__ M_I86CM _M_I86CM
285    Model large:     __LARGE__   M_I86LM _M_I86LM
286    Model huge:      __HUGE__    M_I86HM _M_I86HM
287    ===================================================================
288    Watcom C: DOS/4G destination (-bt=dos4g) - from WatcomC help
289    -------------------------------------------------------------------
290    __WATCOMC__ __DOS4G__  __FLAT__ __386__ __DOS4G__ M_I386 _M_I386
291    ===================================================================
292    Watcom C other - from WatcomC help & test program
293    -------------------------------------------------------------------
294    The __NETWARE__ and __NETWARE_386__ macros are defined when the build
295    target is "NETWARE" (Novell NetWare)
296    The __QNX__ macro is defined when the build target is "QNX" (16-bit
297    or 32-bit QNX).
298    Watcom C++ predefines the macro __cplusplus to identify the compiler
299    as a C++ compiler. Also __WATCOM_CPLUSPLUS
300    -------------------------------------------------------------------
301    __WATCOMC__ value is compiler_version*100
302    __WATCOMC__=1100 (0x44C) - Watcom C 11.0c
303    ===================================================================
304    Watcom C compiler options macros - from WatcomC help
305    -------------------------------------------------------------------
306     Option Macro
307     ====== ===================
308     bm     _MT
309     br     _DLL
310     fpi    __FPI__
311     fpi87  __FPI__
312     j      __CHAR_SIGNED__
313     oi      __INLINE_FUNCTIONS
314     za     NO_EXT_KEYS
315     zw     __WINDOWS__
316     zW     __WINDOWS__
317     zWs    __WINDOWS__
318     ====== ===================
319     Option     All        16-bit only       32-bit only
320     ====== =========== ================= =================
321     mf     __FLAT__                      M_386FM _M_386FM
322     ms     __SMALL__   M_I86SM _M_I86SM  M_386SM _M_386SM
323     mm     __MEDIUM__  M_I86MM _M_I86MM  M_386MM _M_386MM
324     mc     __COMPACT__ M_I86CM _M_I86CM  M_386CM _M_386CM
325     ml     __LARGE__   M_I86LM _M_I86LM  M_386LM _M_386LM
326     mh     __HUGE__    M_I86HM _M_I86HM
327    ===================================================================
328 
329 
330    ===================================================================
331    Borland C and Turbo C
332    -------------------------------------------------------------------
333    __TURBOC__  = 397 (0x18D) for TurboC 2.0
334    __TURBOC__  =1040 (0x410) for Borland C++ 3.1
335    __TURBOC__  =1120 (0x460) for Borland C++ 5.02
336    __TURBOC__  =1360 (0x550) for Borland C++ 5.5
337    __BCPLUSPLUS__  =0x340   Borland C++ 5.0 (Defined for C++ compilation)
338    __BORLANDC__    =0x500   Borland C++ 5.0 Version number
339    ===================================================================
340    Borland C and Turbo C for DOS
341    -------------------------------------------------------------------
342    __TURBOC__ __MSDOS__
343    ===================================================================
344    Borland C for Win32
345    -------------------------------------------------------------------
346    __TURBOC__ __WIN32__ __FLAT__
347    ===================================================================
348    Borland C for OS/2
349    -------------------------------------------------------------------
350    __TURBOC__ __OS2__
351    ===================================================================
352    Otther Borland C macros
353    -------------------------------------------------------------------
354    __BCOPT__       =1       Defined in any compiler that has an optimizer
355    __CDECL__       =1       Defined if Calling Convention is set to C;
356                             otherwise undefined
357    _CHAR_UNSIGNED  1   Defined by default indicating that the default char is
358    unsigned char. Use the -K option to undefine this macro.
359    ===================================================================
360 
361    ===================================================================
362    Microsoft Visual C/C++
363    -------------------------------------------------------------------
364    _MSC_VER    value is greated or eq 1200
365    _MSC_VER=1200 (0x4B0) - MS Visual C++ v6.0 sp5:
366    --------
367    _WIN32      Defined for applications for Win32. Always defined.
368    _CHAR_UNSIGNED Default char type is unsigned. Defined when /J is specified.
369    __cplusplus Defined for C++ programs only.
370    _CPPRTTI Defined for code compiled with /GR (Enable Run-Time Type Information).
371    _CPPUNWIND Defined for code compiled with /GX (Enable Exception Handling).
372    _DLL Defined when /MD or /MDd (Multithread DLL) is specified.
373    _M_ALPHA Defined for DEC ALPHA platforms. It is defined as 1 by the ALPHA compiler, and it is not defined if another compiler is used.
374    _M_IX86 Defined for x86 processors. See Table 1.3 for more details.
375    _M_MPPC Defined for Power Macintosh platforms. Default is 601 (/QP601). See Table 1.4 for more details.
376    _M_MRX000 Defined for MIPS platforms. Default is 4000 (/QMR4000). See Table 1.5 for more details.
377    _M_PPC Defined for PowerPC platforms. Default is 604 (/QP604). See Table 1.6 for more details.
378    _MFC_VER Defines the MFC version. Defined as 0x0421 for Microsoft Foundation Class Library 4.21. Always defined.
379    _MSC_EXTENSIONS This macro is defined when compiling with the /Ze compiler option (the default).  Its value, when defined, is 1.
380    _MSC_VER Defines the compiler version. Defined as 1200 for Microsoft Visual C++ 6.0. Always defined.
381    _MT Defined when /MD or /MDd (Multithreaded DLL) or /MT or /MTd (Multithreaded) is specified.
382    -------------------------------------------------------------------
383    _M_IX86 = 300  - CPU 80486 (/G3)
384    _M_IX86 = 400  - CPU 80486 (/G4)
385    _M_IX86 = 500  - CPU 80486 (/G5) - default
386    _M_IX86 = 600  - CPU 80486 (/G6)
387    _M_MPPC = 601  - PowerPC 601 (/QP601) - Default
388    _M_MPPC = 603  - PowerPC 603 (/QP603)
389    _M_MPPC = 604  - PowerPC 604 (/QP604)
390    _M_MPPC = 620  - PowerPC 620 (/QP620)
391    _M_PPC = 601  - PowerPC 601 /QP601
392    _M_PPC = 603  - PowerPC 603 /QP603
393    _M_PPC = 604  - PowerPC 604 /QP604 - Default
394    _M_PPC = 620  - PowerPC 620 /QP620
395    _M_MRX000 = 4000  - R4000 (/QMR4000) - Default
396    _M_MRX000 = 4100  - R4100 (/QMR4100)
397    _M_MRX000 = 4200  - R4200 (/QMR4200)
398    _M_MRX000 = 4400  - R4400 (/QMR4400)
399    _M_MRX000 = 4600  - R4600 (/QMR4600)
400    _M_MRX000 = 10000 - R10000 (/QMR10000)
401 
402    ===================================================================
403    Microsoft C for MS-DOS or OS/2
404    -------------------------------------------------------------------
405    _MSC_VER    value is less 1200
406    ===================================================================
407    Microsoft Quick C 2.0 for MS-DOS
408    -------------------------------------------------------------------
409    _QC  MSDOS  __STDC__  M_I86  M_I8086
410    M_I286   is defined if buld code for system based on 80286
411    _QC      = 1
412    __STDC__ = 0
413    ===================================================================
414 
415    ===================================================================
416    MetaWare High C/C++ for OS/2
417    -------------------------------------------------------------------
418    __HIGHC__
419    ===================================================================
420 
421    ===================================================================
422    IBM C/Set++
423    -------------------------------------------------------------------
424    __IBMC__
425    ===================================================================
426 
427  **************************************************************************/
428 
429 
430 #ifndef __COMPILER_H__
431 #define __COMPILER_H__
432 
433 /* small code to demonstrate gcc 2.96 bugs:
434 char q[2048], *p;
435 int qq(void)
436 { return p[p-q-1];
437 }
438 */
439 
440 #if defined(__GNUC__)
441     #if (__GNUC__==2) && (__GNUC_MINOR__>95)   /* don't place in one line for prevent old compilers warnings */
442         #warning Latest GNU C branch 2 is 2.95.*. Your version is not GNU C and not supported. You may use it for your risk.
443         #warning Download and install GNU C release from www.gnu.org only, please.
444     #endif
445 #endif
446 
447 #if defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L
448     #ifndef HAS_STDINT_H
449         #define HAS_STDINT_H 1
450     #endif
451 #endif
452 
453 /**** Compiler defines ****/
454 
455 #if defined(__DJGPP__) /* DJGPP for MS-DOS (DPMI)*/
456     #ifndef __DPMI__
457         #define __DPMI__
458     #endif
459     #ifndef __FLAT__
460         #define __FLAT__
461     #endif
462 #endif
463 
464 #if defined(__RSXNT__)
465     #ifndef __NT__
466         #define __NT__
467     #endif
468 #endif
469 
470 #if defined(__EMX__) && defined(__NT__)
471     #ifndef __RSXNT__
472         #define __RSXNT__
473     #endif
474 #endif
475 
476 #if defined(__EMX__) && defined(__32BIT__)
477     #ifndef __386__
478         #define __386__
479     #endif
480     #ifndef __X86__
481         #define __X86__
482     #endif
483 #endif
484 
485 #if defined(__MINGW32__) /* MinGW32 & cygwin's 'gcc -mno-cygwin' ***********/
486     #ifndef __NT__
487         #define __NT__
488     #endif
489     #ifndef __WIN32__
490         #define __WIN32__
491     #endif
492     #ifndef __FLAT__
493         #define __FLAT__
494     #endif
495 #endif
496 
497 #if defined(_MSC_VER)
498     #if (_MSC_VER >= 1200) /* MS Visual C/C++ */
499         #define __MSVC__
500         #ifndef __WIN32__
501             #define __WIN32__
502         #endif
503     #endif
504     #if (_MSC_VER < 1200)
505         /* Microsoft C or Microsoft QuickC for MS-DOS or OS/2 */
506         #define __MSC__
507         #ifdef __OS2__
508             #ifndef __MSC__OS2__
509                 #define __MSC__OS2__
510             #endif
511         #endif
512         #ifdef __DOS__
513             #ifndef __MSC__DOS__
514                 #define __MSC__DOS__
515             #endif
516         #endif
517     #endif
518 #endif
519 
520 /* Watcom C */
521 #if defined(__WATCOMC__)
522     #if defined(__DOS__) && !defined(__WATCOMC__DOS__)
523         #define __WATCOMC__DOS__
524     #endif
525     #if defined(__DOS4G__) && !defined(__WATCOMC__DOS4G__)
526         #define __WATCOMC__DOS4G__
527     #endif
528     #if (defined(__OS2__) || defined(__OS2V2__)) && !defined(__WATCOMC__OS2__)
529         #define __WATCOMC__OS2__
530     #endif
531     #if defined(__NT__)
532         #ifndef __WIN32__
533             #define __WIN32__
534         #endif
535         #if !defined(__WATCOMC__NT__)
536             #define __WATCOMC__NT__
537         #endif
538         #if !defined(__WATCOMC__WIN32__)
539             #define __WATCOMC__WIN32__
540         #endif
541     #endif
542     #if defined(__QNX__)
543         #if !defined(__unix__)
544             #define __unix__
545         #endif
546         #if !defined(__WATCOMC__QNX__)
547             #define __WATCOMC__QNX__
548         #endif
549     #endif
550 #endif
551 
552 /* Turbo C/C++ & Borland C/C++ */
553 #if defined(__TURBOC__)
554     #if defined(__MSDOS__)   /* Turbo C/C++ & Borland C/C++ for MS-DOS */
555         #if !defined(__TURBOC__DOS__)
556             #define __TURBOC__DOS__
557         #endif
558     #endif
559     #if defined(__WIN32__) && !defined(__TURBOC__WIN32__)
560         #define __TURBOC__WIN32__ /* Borland C/C++ for Win32 */
561     #endif
562     #if defined(__OS2__) && !defined(__TURBOC__OS2__)
563         #define __TURBOC__OS2__   /* Borland C/C++ for OS/2 */
564     #endif
565 #endif
566 
567 /* IBM C */
568 #if defined(__IBMC__)
569     #if !defined(UNIX)
570         #if !defined(__IBMC__OS2__)
571             #define __IBMC__OS2__     /* IBM C/Set++ for OS/2 */
572         #endif
573     #else
574         #if !defined(__IBMC__UNIX__)
575             #define __IBMC__UNIX__     /* IBM C/Set++ for unix */
576         #endif
577         #if !defined(__unix__)
578             #define __unix__
579         #endif
580     #endif
581 #endif
582 
583 #if defined(__sun__)
584     #if !defined(__SUN__)
585         #define __SUN__
586     #endif
587 #endif
588 
589 #if defined(__linux__) || defined(__Linux__) || defined(linux) || defined(__linux) || defined(LINUX) || defined(__LINUX__)
590     #if !defined(__LINUX__)
591         #define __LINUX__
592     #endif
593     #if !defined(__linux__)
594         #define __linux__
595     #endif
596     #if !defined(__UNIX__)
597         #define __UNIX__
598     #endif
599     #if !defined(__unix__)
600         #define __unix__
601     #endif
602 #endif
603 
604 #if defined(__QNXNTO__)
605     #if !defined(__UNIX__)
606         #define __UNIX__
607     #endif
608     #if !defined(__unix__)
609         #define __unix__
610     #endif
611 #endif
612 
613 #if defined( __svr4__ ) || defined( __SVR4 )
614     #if !defined(__SVR4__)
615         #define __SVR4__
616     #endif
617     #if !defined(__unix__)
618         #define __unix__
619     #endif
620 #endif
621 
622 #if defined(BSD)
623     #if !defined(__BSD__)
624         #define __BSD__
625     #endif
626     #if !defined(__UNIX__)
627         #define __UNIX__
628     #endif
629     #if !defined(__unix__)
630         #define __unix__
631     #endif
632 #endif
633 
634 #if defined(__APPLE__) && defined(__MACH__)
635     #if !defined(__UNIX__)
636         #define __UNIX__
637     #endif
638     #if !defined(__unix__)
639         #define __unix__
640     #endif
641 #endif
642 
643 #if defined(__DOS4G__) /* DOS4G/W dos-dpmi extender */
644     #ifndef __DPMI__
645         #define __DPMI__
646     #endif
647     #ifndef __FLAT__
648         #define __FLAT__
649     #endif
650 #endif
651 
652 /**** OS defines ****/
653 
654 #if defined(__TURBOC__DOS__) && !defined(__DOS__)
655     #define __DOS__
656 #endif
657 
658 #if defined(__MSDOS__) || defined(DOS) || defined(MSDOS)
659     #if !defined(__DOS__)
660         #define __DOS__
661     #endif
662 #endif
663 
664 #if defined(__DOS__)
665     #if !defined(__FLAT__) && !defined(__DPMI__)
666         #define __DOS16__
667     #endif
668 #endif
669 
670 #if defined(__OS2V2__) && !defined(__OS2__)
671     /*  Watcom C: wcl -bt=os2v2 */
672     #define __OS2__
673 #endif
674 
675 #if defined(_M_MPPC)
676     #if !defined(__MACOS__)
677         #define __MACOS__
678     #endif
679 #endif
680 
681 #if defined(__WIN32) || defined(_WIN32) || defined(WIN32)
682     #if !defined(__WIN32__)
683         #define __WIN32__
684     #endif
685 #endif
686 
687 #if defined(NT) || defined(WINNT)
688     #if !defined(__NT__)
689         #define __NT__
690     #endif
691 #endif
692 
693 /* defined in MINGW32 & cygwin's gcc with '-mno_cygwin' option  *
694  * This is NOT needed for pure Cygwin builds, Cygwin == UNIX !! */
695 #if defined(__MINGW32__) && !defined(__NT__)
696     #define __NT__
697 #endif
698 
699 #if defined(__CYGWIN__) && !defined(__unix__)  /* Pure cygwin */
700     #define __unix__
701 #endif
702 
703 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
704     #if !defined(__UNIX__)
705         #define __UNIX__
706     #endif
707     #if !defined(__unix__)
708         #define __unix__
709     #endif
710     #if !defined(__BSD__)
711         #define __BSD__
712     #endif
713 #endif
714 
715 #if defined(__SUN__)
716     #if !defined(__UNIX__)
717         #define __UNIX__
718     #endif
719     #if !defined(__unix__)
720         #define __unix__
721     #endif
722 #endif
723 
724 #if defined(_AIX)
725     #if !defined(__AIX__)
726         #define __AIX__
727     #endif
728     #if !defined(__UNIX__)
729         #define __UNIX__
730     #endif
731     #if !defined(__unix__)
732         #define __unix__
733     #endif
734 #endif
735 
736 #if defined(__osf__)
737     #if !defined(__OSF__)
738         #define __OSF__
739     #endif
740     #if !defined(__UNIX__)
741         #define __UNIX__
742     #endif
743     #if !defined(__unix__)
744         #define __unix__
745     #endif
746 #endif
747 
748 #if defined(__hpux)
749     #if !defined(__HPUX__)
750         #define __HPUX__
751     #endif
752     #if !defined(__UNIX__)
753         #define __UNIX__
754     #endif
755     #if !defined(__unix__)
756         #define __unix__
757     #endif
758 #endif
759 
760 
761 /*
762   BeOS is NOT Unix, but sometime it seem's to Be ... ;)
763 */
764 #if defined (__BEOS__) || defined(__BeOS__)
765     #if !defined(__UNIX__)
766         #define __UNIX__
767     #endif
768     #if !defined(__unix__)
769         #define __unix__
770     #endif
771 #endif
772 
773 #if defined(SASC)  /* SAS C for AmigaDOS ***************/
774     #if !defined(__UNIX__)
775         #define __UNIX__
776     #endif
777     #if !defined(__unix__)
778         #define __unix__
779     #endif
780 #endif
781 
782 #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) || defined(__unix) || defined(__unix__) ||  defined(unix)
783     #ifdef __DJGPP__
784         #undef UNIX
785         #undef _UNIX
786         #undef __UNIX__
787         #undef __unix
788         #undef __unix__
789         #undef unix
790         #undef _unix
791     #else
792         #ifndef __UNIX__
793             #define __UNIX__
794         #endif
795         #ifndef __unix__
796             #define __unix__
797         #endif
798     #endif
799 #endif
800 
801 /***** Platforms *************************************************************/
802 
803 #if defined(arm) || defined(_arm) || defined(__arm) || defined(__arm__) || defined(__ARMEL__) || defined(__ARM_EABI__)
804     #if !defined(__ARM__)
805         #define __ARM__
806     #endif
807     #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
808         #define __LITTLE_ENDIAN__
809     #endif
810     #ifndef __FLAT__
811         #define __FLAT__
812     #endif
813 #endif
814 
815 #if defined(SASC) && !defined(__AMIGA__) /* SAS C for AmigaDOS ***************/
816     #define __AMIGA__
817 #endif
818 
819 #if defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA) || defined(M_ALPHA)
820     #ifndef __ALPHA__
821         #define __ALPHA__
822     #endif
823 #endif
824 
825 #if defined(__x86_64__)
826     #ifndef __X86_64__
827         #define __X86_64__
828     #endif
829 #endif
830 
831 #if defined(_M_IX86)  /* MS Visual C predefined */
832     #ifndef __X86__
833         #define __X86__
834     #endif
835     #if _M_IX86 >= 300
836         #ifndef __386__
837             #define __386__
838         #endif
839     #endif
840     #if _M_IX86 >= 400
841         #ifndef __486__
842             #define __486__
843         #endif
844     #endif
845     #if _M_IX86 >= 500
846         #ifndef __586__
847             #define __586__
848         #endif
849     #endif
850     #if _M_IX86 >= 600
851         #ifndef __686__
852             #define __686__
853         #endif
854     #endif
855 #endif
856 
857 #if defined(__IX86__) || defined(_X86_)
858     #ifndef __X86__
859         #define __X86__
860     #endif
861 #endif
862 
863 #if defined(__i386__) || defined(__i386) || defined(i386)
864     #ifndef __X86__
865         #define __X86__
866     #endif
867     #ifndef __386__
868         #define __386__
869     #endif
870 #endif
871 
872 #if defined(__i686__) || defined(__i686) || defined(i686)
873     #ifndef __X86__
874         #define __X86__
875     #endif
876     #ifndef __686__
877         #define __686__
878     #endif
879 #endif
880 
881 #if defined(_M_MPPC) /* Power PC Macintosh */
882 #endif
883 
884 #if defined(_M_PPC) /* Power PC */
885     #ifndef __PPC__
886         #define __PPC__
887     #endif
888 #endif
889 
890 #if defined(_M_MRX000) /* MIPS */
891 #endif
892 
893 #if defined(sparc) || defined(_sparc) || defined(__sparc) || defined(__sparc__)
894     /* Sun SparcStation */
895     #ifndef __SPARC__
896         #define __SPARC__
897     #endif
898 #endif
899 
900 #ifdef __SPARC__
901     #ifndef __BIG_ENDIAN__
902         #define __BIG_ENDIAN__
903     #endif
904     #ifndef __FLAT__
905         #define __FLAT__
906     #endif
907 #endif
908 
909 #ifdef __ALPHA__
910     #ifndef __BIG_ENDIAN__
911         #define __BIG_ENDIAN__
912     #endif
913     #ifndef __FLAT__
914         #define __FLAT__
915     #endif
916 #endif
917 
918 #if defined(__X86__)
919     #ifndef __LITTLE_ENDIAN__
920         #define __LITTLE_ENDIAN__
921     #endif
922 #endif
923 
924 
925 #ifdef __SUN__
926     #ifndef __FLAT__
927         #define __FLAT__
928     #endif
929 #endif
930 
931 
932 #if defined (__CYGWIN__) || defined(__MINGW32__)
933     #ifndef __X86__
934         #define __X86__
935     #endif
936     #ifndef __386__
937         #define __386__
938     #endif
939     #ifndef __LITTLE_ENDIAN__
940         #define __LITTLE_ENDIAN__
941     #endif
942     #ifndef __FLAT__
943         #define __FLAT__
944     #endif
945 #endif
946 
947 #if defined(__DOS__) || defined(__DPMI__)
948     #ifndef __LITTLE_ENDIAN__
949         #define __LITTLE_ENDIAN__
950     #endif
951 #endif
952 
953 #if defined(__NT__)
954     #if !defined(__WIN32__)
955         #define __WIN32__
956     #endif
957 #endif
958 
959 #ifdef __386__
960     #ifndef __LITTLE_ENDIAN__
961         #define __LITTLE_ENDIAN__
962     #endif
963     #ifndef __FLAT__
964         #define __FLAT__
965     #endif
966     #ifndef __X86__
967         #define __X86__
968     #endif
969     #ifndef __186__
970         #define __186__
971     #endif
972     #ifndef __286__
973         #define __286__
974     #endif
975 #endif
976 
977 /***** memory models *********************************************************/
978 
979 #if defined(__DPMI__) || defined(__WIN32__) || defined(__NT__) || defined(__unix__) || defined(__UNIX__)
980     #ifndef __FLAT__
981         #define __FLAT__
982     #endif
983 #endif
984 
985 #if defined(__OS2__) && !defined(_MSC_VER)
986     #if !defined(__386__) && !defined(__FLAT__)
987         #error Please check your compiler to target: 16 bit or 32 bit and send report to rntrack developers: https:\/\/sf.net/projects/ftrack-as
988     #endif
989     #ifndef __386__
990         #define __386__
991     #endif
992     #ifndef __FLAT__
993         #define __FLAT__
994     #endif
995 #endif
996 
997 
998 #ifdef __WATCOMC__DOS__
999 
1000     /* WATCOM has both M_I86xxx and __modeltype__ macros */
1001 
1002     #if defined(M_I86SM) && ! defined(__SMALL__)
1003         #define __SMALL__
1004     #endif
1005 
1006     #if defined(M_I86MM) && !defined(__MEDIUM__)
1007         #define __MEDIUM__
1008     #endif
1009 
1010     #if defined(M_I86CM) && !defined(__COMPACT__)
1011         #define __COMPACT__
1012     #endif
1013 
1014     #if defined(M_I86LM) && !defined(__LARGE__)
1015         #define __LARGE__
1016     #endif
1017 
1018     #if defined(M_I86HM) && !defined(__HUGE__)
1019         #define __HUGE__
1020     #endif
1021 
1022 #endif /* ifdef __WATCOMC__DOS__ */
1023 
1024 /* Handle 386 "flat" memory model */
1025 
1026 #if defined(__FLAT__)
1027 
1028     /* Other macros may get defined by braindead compilers */
1029 
1030     #ifdef __SMALL__
1031         #undef __SMALL__
1032     #endif
1033 
1034     #ifdef __TINY__
1035         #undef __TINY__
1036     #endif
1037 
1038     #ifdef __MEDIUM__
1039         #undef __MEDIUM__
1040     #endif
1041 
1042     #ifdef __COMPACT__
1043         #undef __COMPACT__
1044     #endif
1045 
1046     #ifdef __LARGE__
1047         #undef __LARGE__
1048     #endif
1049 
1050     #ifdef __HUGE__
1051         #undef __HUGE__
1052     #endif
1053 
1054     /*
1055     *  Code is really "near"
1056     */
1057 
1058     #undef __FARCODE__
1059     #undef __FARDATA__
1060 
1061     /* Everything should be "near" in the flat model */
1062 
1063     #ifdef near
1064         #undef near
1065         #define near
1066     #endif
1067 
1068     #ifdef far
1069         #undef far
1070         #define far
1071     #endif
1072 
1073     #ifdef huge
1074         #undef huge
1075         #define huge
1076     #endif
1077 
1078 #endif  /* ifdef __FLAT__ */
1079 
1080 #if defined(__SMALL__) || defined(__TINY__)
1081     #define __NEARCODE__
1082     #define __NEARDATA__
1083 #endif
1084 
1085 #ifdef __MEDIUM__
1086     #define __FARCODE__
1087     #define __NEARDATA__
1088 #endif
1089 
1090 #ifdef __COMPACT__
1091     #define __NEARCODE__
1092     #define __FARDATA__
1093 #endif
1094 
1095 #if defined(__LARGE__) || defined(__HUGE__)
1096     #define __FARCODE__
1097     #define __FARDATA__
1098 #endif
1099 
1100 /***** compiler-specific stuff **********************************************/
1101 
1102 #ifdef __MSVC__  /* MS Visual C/C++ *****************************************/
1103     #include "MSVC.h"
1104 #elif defined(__MSC__) /* Microsoft C or Microsoft QuickC for MS-DOS or OS/2 */
1105     #include "MSC.h"
1106 #elif defined(__WATCOMC__)/* Watcom C/C++ (DOS-16, DOS-32, Win, OS/2, QNX) */
1107     #include "WATCOMC.h"
1108 #elif defined(__HIGHC__) /* MetaWare High C/C++ for OS/2 ***********************/
1109     #include "HIGHC.h"
1110 #elif defined(__MINGW32__) /* MinGW32 & cygwin's 'gcc -mno-cygwin' ***********/
1111     #include "MINGW32.h"
1112     /* Applied to:
1113     - MINGW32 for 32-bit Windows NT on Intel and AXP;
1114     - MINGW32 cross-compiler from unixes;
1115     - Cygwin GCC with option -mno-cygwin.
1116     */
1117 #elif defined(__EMX__)/* EMX for 32-bit OS/2 and RSX for Windows NT **********/
1118     #include "EMX.h"
1119 #elif defined(__DJGPP__) /* DJGPP for MS-DOS (DPMI)***************************/
1120     #include "DJGPP.h"
1121 #elif defined(__TURBOC__)/* Borland Turbo C/C++ & Borland C/C++ **************/
1122     #include "BORLANDC.h"
1123 #elif defined(__IBMC__OS2__) /* IBM C/Set++ for OS/2**************************/
1124     #include "IBMC_OS2.h"
1125 #elif defined(__BEOS__)    /* BeOS (Unix clone, GNU C) */
1126     #include "BEOS5.h"
1127 #elif ( defined(__unix__) || defined(__UNIX__) ) && !defined(__BEOS__)
1128     /* Unix clones: Linux, FreeBSD, SUNOS (Solaris), MacOS etc. */
1129     #include "UNIX.h"
1130 #elif defined(SASC) /* SAS C for AmigaDOS ************************************/
1131     #include "SASC.h"
1132 #else
1133     #  error compiler.h: Unknown compiler! Please compile and run ../test/compiler.c (you possibly need RTFM of your compiler: section "Predefined macros" and update ../test/compiler.c)
1134 #endif   /* End compiler-specific decrarations */
1135 
1136 /**** Test defines and/or set default values *********************************/
1137 
1138 #if defined(__FLAT__)      /* 32 bit or 64 bit  = moved from smapi/prog.h */
1139 
1140     #define farcalloc  calloc
1141     #define farmalloc  malloc
1142     #define farrealloc realloc
1143     #define farfree    free
1144     #if !defined (__NT__)
1145         /* exclude for Watcom C on WIn32 */
1146         #define _fmalloc   malloc
1147     #endif
1148 
1149 #elif defined(__FARDATA__)  /* 16 bit (possible obsolete?) - moved from smapi/prog.h */
1150 
1151     #define malloc(n)     farmalloc(n)
1152     #define calloc(n,u)   farcalloc(n,u)
1153     #define free(p)       farfree(p)
1154     #define realloc(p,n)  farrealloc(p,n)
1155 
1156 #endif /* defined(__FARDATA__) */
1157 
1158 #if defined(HAS_MALLOC_H)
1159     #include <malloc.h>
1160 #endif
1161 
1162 /* Default separator for path specification */
1163 
1164 #ifndef PATH_DELIM   /* moved from smapi/prog.h */
1165     #if defined(__unix__) || defined(__AMIGA__)
1166         #define PATH_DELIM  '/'
1167     #else
1168         #define PATH_DELIM  '\\'
1169     #endif
1170 #endif
1171 
1172 #ifndef PATHLEN
1173     #ifdef MAXPATHLEN
1174         #define PATHLEN   MAXPATHLEN
1175     #else                    /* moved from smapi/prog.h */ /* OS-depended vallue! */
1176         #define PATHLEN   120   /* Max. length of path */
1177     #endif
1178 #endif
1179 
1180 
1181 #ifdef HAS_SHARE_H
1182     #include <share.h>
1183     #if !defined(SH_DENYNO) && defined(_SH_DENYNO)
1184         #define SH_DENYNO _SH_DENYNO
1185     #endif
1186     #ifdef SH_DENYNO
1187         #ifndef SH_DENYNONE
1188             #define SH_DENYNONE SH_DENYNO
1189         #endif
1190     #endif
1191 #endif
1192 
1193 /* File open and file modes */
1194 #include <fcntl.h>
1195 #if !defined(O_BINARY) && defined(_O_BINARY)
1196     #define O_BINARY    _O_BINARY
1197 #endif
1198 #if !defined(O_TEXT) && defined(_O_TEXT)
1199     #define O_TEXT      _O_TEXT
1200 #endif
1201 #if !defined(O_RDWR) && defined(_O_RDWR)
1202     #define O_RDWR      _O_RDWR
1203 #endif
1204 #if !defined(O_RDONLY) && defined(_O_RDONLY)
1205     #define O_RDONLY      _O_RDONLY
1206 #endif
1207 #if !defined(O_WRONLY) && defined(_O_WRONLY)
1208     #define O_WRONLY      _O_WRONLY
1209 #endif
1210 #if !defined(O_NONBLOCK) && defined(_O_NONBLOCK)
1211     #define O_NONBLOCK      _O_NONBLOCK
1212 #endif
1213 #if !defined(O_APPEND) && defined(_O_APPEND)
1214     #define O_APPEND      _O_APPEND
1215 #endif
1216 #if !defined(O_CREAT) && defined(_O_CREAT)
1217     #define O_CREAT      _O_CREAT
1218 #endif
1219 #if !defined(O_TRUNC) && defined(_O_TRUNC)
1220     #define O_TRUNC      _O_TRUNC
1221 #endif
1222 #if !defined(O_EXCL) && defined(_O_EXCL)
1223     #define O_EXCL      _O_EXCL
1224 #endif
1225 #if !defined(O_SYNC) && defined(_O_SYNC)
1226     #define O_SYNC      _O_SYNC
1227 #endif
1228 #if !defined(O_NOCTTY) && defined(_O_NOCTTY)
1229     #define O_NOCTTY      _O_NOCTTY
1230 #endif
1231 #if !defined(O_SIZE) && defined(_O_SIZE)
1232     #define O_SIZE      _O_SIZE
1233 #endif
1234 #if !defined(O_NDELAY) && defined(_O_NDELAY)
1235     #define O_NDELAY      _O_NDELAY
1236 #endif
1237 #if !defined(O_NOINHERIT) && defined(_O_NOINHERIT)
1238     #define O_NOINHERIT      _O_NOINHERIT
1239 #endif
1240 
1241 #if !defined(HAS_UNISTD_H)
1242     #if !defined (F_OK)
1243         #define F_OK 0
1244     #endif
1245     #if !defined (X_OK)
1246         #define X_OK 1
1247     #endif
1248     #if !defined (W_OK)
1249         #define W_OK 2
1250     #endif
1251     #if !defined (R_OK)
1252         #define R_OK 4
1253     #endif
1254 #endif
1255 
1256 
1257 #include <sys/types.h>
1258 #include <sys/stat.h>
1259 #if defined(HAS_UNISTD_H)
1260     #include <unistd.h>
1261 #endif
1262 #if !defined(S_IFMT) && defined(_S_IFMT)
1263     #define S_IFMT      _S_IFMT
1264 #endif
1265 #if !defined(S_IFDIR) && defined(_S_IFDIR)
1266     #define S_IFDIR     _S_IFDIR
1267 #endif
1268 
1269 #ifndef mymkdir
1270     #ifdef __GNUC__
1271         #       warning mymkdir() call set to default value. Please check your compiler documentation for it and write define into compiler.h
1272     #else
1273         #pragma message("mymkdir() call undefined. Please check your compiler documentation for it and write define into compiler.h")
1274     #endif
1275     #define mymkdir mkdir
1276 #endif
1277 
1278 #ifndef mysleep
1279     #ifdef __GNUC__
1280         #	warning sleep() call undefined. Please check your compiler documentation for it and write "#define mysleep" into compiler.h
1281     #else
1282         #pragma message("sleep() call undefined. Please check your compiler documentation for it and write define into compiler.h")
1283     #endif
1284     #define mysleep(x)
1285 #endif
1286 
1287 #ifndef SMAPI_EXT
1288     #ifdef __GNUC__
1289         #       warning Please set SMAPI_EXT to extern or proprietary token
1290     #else
1291         #pragma message("Please set SMAPI_EXT to extern or proprietary token")
1292     #endif
1293     #define SMAPI_EXT extern
1294 #endif
1295 
1296 #ifndef _XPENTRY
1297     #ifdef __GNUC__
1298         #       warning Please check your compiler to system functions call modifyer and define _XPENTRY
1299     #else
1300         #pragma message("Please check your compiler to system functions call modifyer and define _XPENTRY")
1301     #endif
1302     #define _XPENTRY
1303 #endif
1304 
1305 #ifndef _stdc
1306     #   error Please check your compiler to standard C code modifyer and define _stdc in compiler.h
1307 #endif
1308 
1309 #ifndef _intr
1310     #   error Please check your compiler to interrupt handler modifyer (usually 'interrupt') and define _intr in compiler.h
1311 #endif
1312 
1313 #ifndef _fast
1314     #ifdef __GNUC__
1315         #       warning Please check your compiler to fast functions call modifyer and define _fast in compiler.h
1316     #else
1317         #pragma message("Please check your compiler to fast functions call modifyer and define _fast in compiler.h")
1318     #endif
1319     #define _fast
1320 #endif
1321 
1322 #ifndef farread
1323     #   error Please check your compiler to far calling implementation of read() function and define farread in compiler.h
1324 #endif
1325 
1326 #ifndef farwrite
1327     #   error Please check your compiler to far calling implementation of write() function and define farwrite in compiler.h
1328 #endif
1329 
1330 /* waitlock works like lock, but blocks until the lock can be
1331  * performed.
1332  * waitlock2 works like a timed waitlock.
1333  */
1334 /* moved to locking.h */
1335 /* extern int waitlock(int, long, long); */
1336 /* extern int waitlock2(int, long, long, long); */
1337 
1338 #if !defined(HAS_mktime)
1339 
1340     /* If compiler doesn't include a mktime(), we need our own */
1341     /* But our own mktime not implemented yet...
1342     #include <time.h>
1343     time_t _stdc mktime(struct tm *tm_ptr);
1344     */
1345     #error Our own mktime() not implemented yet... sorry.
1346 #endif
1347 
1348 /* If compiler doesn't include a strftime(), we need our own (see strftim.c) */
1349 #if !defined(HAS_strftime)
1350 
1351 #define strftime(str,max,fmt,tm) strftim(str,max,fmt,tm)
1352 size_t _stdc strftim( char *str, size_t maxsize, const char *fmt,
1353                       const struct tm *tm_ptr );
1354 
1355 #endif
1356 
1357 
1358 #if !defined(HAS_strupr)
1359     char *strupr(char *str);
1360 #endif
1361 
1362 /* Some implementations not include the min() macro or function. Usually C++ */
1363 #ifndef min
1364     #define min(a,b)              (((a) < (b)) ? (a) : (b))
1365 #endif
1366 #ifndef max
1367     #define max(a,b)              (((a) > (b)) ? (a) : (b))
1368 #endif
1369 
1370 #ifdef HAS_PROCESS_H
1371     #include <process.h>
1372 #endif
1373 #if !defined(P_WAIT) && defined(_P_WAIT) /*for spawn* in process.h*/
1374     #define P_WAIT          _P_WAIT
1375 #endif
1376 
1377 #ifdef NEED_trivial_farread
1378     int trivial_farread( int handle, void far *buffer, unsigned len );
1379 #endif
1380 #ifdef NEED_trivial_farwrite
1381     int trivial_farwrite( int handle, void far *buffer, unsigned len );
1382 #endif
1383 
1384 #ifndef TRUE
1385     #define TRUE            1
1386 #endif
1387 #ifndef FALSE
1388     #define FALSE           0
1389 #endif
1390 
1391 #include "typesize.h"
1392 
1393 /* variable sizes for common (platform-independed) rntrack types **************/
1394 
1395 #define MAX_hBYTE    0xff        /* Max value for var type "byte"  */
1396 #define MIN_hBYTE    0           /* Min value for var type "byte"  */
1397 #define MAX_hSBYTE   0xef        /* Max value for var type "sbyte" */
1398 #define MIN_hSBYTE   0x80        /* Min value for var type "sbyte" */
1399 
1400 #define MAX_hWORD    0xffff      /* Max value for var type "word"  */
1401 #define MIN_hWORD    0           /* Min value for var type "word"  */
1402 #define MAX_hSWORD   0xefff      /* Max value for var type "sword" */
1403 #define MIN_hSWORD   0x8000      /* Max value for var type "sword" */
1404 
1405 #define MAX_hDWORD   0xffffffffl /* Max value for var type "dword"  */
1406 #define MIN_hDWORD   0l          /* Max value for var type "dword"  */
1407 #define MAX_hSDWORD  0xefffffffl /* Max value for var type "sdword" */
1408 #define MIN_hSDWORD  0x80000000l /* Max value for var type "sdword" */
1409 
1410 #define MAX_hUCHAR   0xff
1411 #define MIN_hUCHAR   0
1412 #define MAX_hCHAR    0xef
1413 #define MIN_hCHAR    0x80
1414 #define MAX_hSCHAR   0xef
1415 #define MIN_hSCHAR   0x80
1416 
1417 #define MAX_hUINT8   0xff
1418 #define MIN_hUINT8   0
1419 #define MAX_hINT8    0xef
1420 #define MIN_hINT8    0x80
1421 #define MAX_hSINT8   0xef
1422 #define MIN_hSINT8   0x80
1423 
1424 #define MAX_hUINT16  0xffff
1425 #define MIN_hUINT16  0
1426 #define MAX_hINT16   0xefff
1427 #define MIN_hINT16   0x8000
1428 #define MAX_hSINT16  0xefff
1429 #define MIN_hSINT16  0x8000
1430 
1431 #define MAX_hUINT32  0xffffffffl
1432 #define MIN_hUINT32  0l
1433 #define MAX_hINT32   0xefffffffl
1434 #define MIN_hINT32   0x80000000l
1435 #define MAX_hSINT32  0xefffffffl
1436 #define MIN_hSINT32  0x80000000l
1437 
1438 
1439 #ifdef HAS_INT64
1440     #define MAX_hUINT64  0xffffffffffffffffULL
1441     #define MIN_hUINT64  0ULL
1442     #define MAX_hINT64   0xefffffffffffffffLL
1443     #define MIN_hINT64   0x8000000000000000LL
1444     #define MAX_hSINT64  0xefffffffffffffffLL
1445     #define MIN_hSINT64  0x8000000000000000LL
1446 #endif
1447 
1448 #define unsigned_char_max ((unsigned char)-1)
1449 #define   signed_char_max ((signed char)(((unsigned  char)-1)>>1))
1450 #define   signed_char_min ((signed char)((((unsigned char)-1)>>1)+1))
1451 #define unsigned_int_max  ((unsigned int)-1)
1452 #define   signed_int_max  ((signed int)(((unsigned  int)-1)>>1))
1453 #define   signed_int_min  ((signed int)((((unsigned int)-1)>>1)+1))
1454 #define unsigned_long_max ((unsigned long)-1l)
1455 #define   signed_long_max ((signed long)(((unsigned long)-1l)>>1))
1456 #define   signed_long_min ((signed long)((((unsigned long)-1l)>>1)+1))
1457 
1458 #endif
1459