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