1 /* $Id$
2  * Mingw32 and cygwin in mingw-mode compiler-specific declarations
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 /* MinGW32 & cygwin's 'gcc -mno-cygwin' */
28 
29 /* Applied to:
30    - MINGW32 for 32-bit Windows NT on Intel and AXP;
31    - MINGW32 cross-compiler from unixes;
32    - Cygwin GCC with option -mno-cygwin.
33 */
34 
35 #ifndef HUSKY_MINGW32_H
36 #define HUSKY_MINGW32_H
37 
38 #ifndef __GNUC__
39   #error This file may be used only with GNU C !
40 #endif
41 
42 #ifndef __MINGW32__
43   #error This file may be used only with MSys/MinGW (GNU C) on unix-like OS or Cygwin (GNU C) on Win32 !
44 #endif
45 
46 
47 #ifndef __LITTLE_ENDIAN__
48 #  define __LITTLE_ENDIAN__
49 #endif
50 
51 #  define _stdc
52 #  define _intr
53 #  define _intcast
54 #  define _veccast
55 #  define _fast
56 #  define _loadds
57 #  define cdecl
58 #  define pascal __stdcall
59 #  define near
60 #  undef  far
61 #  define far
62 #  define _XPENTRY
63 
64 #  define farread _read
65 #  define farwrite _write
66 #  define fdopen _fdopen
67 #  define close _close
68 #  define open _open
69 #  define lseek _lseek
70 #  define tell _tell
71 #  define write _write
72 #  define read _read
73 
74 #  define sleep(sec) Sleep((sec)*1000l)
75 #  define mysleep(sec) Sleep((sec)*1000l)
76 #  define HAS_sleep     1
77 
78 #  define mymkdir mkdir
79 
80 /*#  define strcasecmp  stricmp*/
81 /*#  define strncasecmp strnicmp*/
82 
83 #  ifndef LONG_MAX
84 #    include <limits.h>
85 #  endif
86 
87 /* older mingw headers are too lazy ... */
88 #  include <share.h>
89 #  define sopen _sopen
90 #  ifndef SH_DENYRW
91 #    define SH_DENYRW 0x10
92 #  endif
93 #  ifndef SH_DENYWR
94 #    define SH_DENYWR 0x20
95 #  endif
96 #  ifndef SH_DENYRD
97 #    define SH_DENYRD 0x30
98 #  endif
99 #  ifndef SH_DENYNO
100 #    define SH_DENYNO 0x40
101 #  endif
102 
103 #  define HAS_spawnvp    /* spawnvp() present */
104 #  define HAS_mktime     /* time.h */
105 #  define HAS_strftime   /* time.h */
106 #  define HAS_ACCESS    /* access() in io.h */
107 #  define HAS_sopen     3   /* sopen() : in io.h, 3 or 4 parameters */
108 
109 #  define HAS_MALLOC_H   /* may use "#include <malloc.h>" for malloc() etc. */
110 #  define HAS_IO_H       /* may use "#include <io.h> */
111 #  define HAS_SHARE_H    /* may use "#include <share.h> */
112 #  define HAS_DIRENT_H   /* may use "#include <dirent.h> */
113 #  define HAS_SYS_UTIME_H  /* #include <sys/utime.h> in alternate to <utime.h> */
114 #  define HAS_PROCESS_H   /* may use "#include <process.h> */
115 
116 /* Latest version has sys/param.h for sure, though its equivalence
117  * with unix sys/param.h is questionable. Added for MAXPATHLEN definition */
118 #  define HAS_SYS_PARAM_H /* may use "#include <sys/param.h> */
119 
120 #  define USE_STAT_MACROS
121 
122 typedef unsigned bit;
123 
124 typedef unsigned char byte;
125 typedef signed char sbyte;
126 
127 typedef unsigned short word;
128 typedef signed short sword;
129 
130 typedef unsigned long dword;
131 typedef signed long sdword;
132 
133 typedef signed short sshort;
134 /*typedef unsigned short ushort;*/
135 
136 typedef signed long slong;
137 typedef unsigned long ulong;
138 
139 
140 typedef   signed char        hCHAR;              /*  1 byte */
141 typedef   signed char       hSCHAR;              /*  1 byte */
142 typedef unsigned char       hUCHAR;              /*  1 byte */
143 
144 typedef   signed char        hINT8;              /*  1 byte */
145 typedef   signed char       hSINT8;              /*  1 byte */
146 typedef unsigned char       hUINT8;              /*  1 byte */
147 
148 typedef   signed short      hINT16;              /*  2 bytes */
149 typedef   signed short     hSINT16;              /*  2 bytes */
150 typedef unsigned short     hUINT16;              /*  2 bytes */
151 
152 typedef   signed int        hINT32;              /*  4 bytes */
153 typedef   signed int       hSINT32;              /*  4 bytes */
154 typedef unsigned int       hUINT32;              /*  4 bytes */
155 
156 /* Not all GCC support this, test please (Stas Degteff) */
157 typedef   signed long long  hINT64;              /*  8 bytes */
158 typedef   signed long long hSINT64;              /*  8 bytes */
159 typedef unsigned long long hUINT64;              /*  8 bytes */
160 #define HAS_INT64
161 
162 #endif
163