Watt-32 tcp/ip  2.2 dev-rel.10
werrno.h
Go to the documentation of this file.
1 
9 #ifndef __SYS_WERRNO_H
10 #define __SYS_WERRNO_H
11 
12 /* When doing "gcc -MM" with gcc 3.0 we must include <sys/version.h>
13  * (via stdio.h) in order for __DJGPP__ to be defined
14  */
15 #include <stdio.h>
16 #include <errno.h>
17 
18 #ifndef __SYS_W32API_H
19 #include <sys/w32api.h>
20 #endif
21 
22 /* Hack: fix for compiling with djgpp 2.04, but
23  * ./util/dj_err.exe was compiled with 2.03
24  */
25 #if defined(MIXING_DJGPP_203_AND_204)
26 #undef ELOOP
27 #endif
28 
29 #if defined(__MINGW64__)
30  #undef EDEADLOCK
31  #include <sys/mingw64.err>
32 
33 #elif defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR)
34  /*
35  * '__MINGW32__' is defined by BOTH mingw.org and by the MinGW-w64
36  * project [1], because both can target Win32. '__MINGW64__' is defined
37  * only when targetting Win64 (__x86_64__).
38  *
39  * [1] http://mingw-w64.sourceforge.net/
40  *
41  * Hopefully both targets define the same range of errnos.
42  * Hence use the one generated for __MINGW64__.
43  */
44  #undef EDEADLOCK
45  #include <sys/mingw32.err>
46 
47 #elif defined(__MINGW32__) /* Original from mingw.org */
48  #include <sys/mingw32.err>
49 
50 #elif defined(__HIGHC__)
51  #undef EDEADLK
52  #undef EDEADLOCK
53  #include <sys/highc.err>
54 
55 #elif defined(__BORLANDC__)
56  #ifdef __FLAT__
57  #undef ENAMETOOLONG /* bcc32 4.0 */
58  #endif
59  #ifdef _WIN32
60  #undef ENOTEMPTY
61  #endif
62  #include <sys/borlandc.err>
63 
64 #elif defined(__TURBOC__)
65  #include <sys/turboc.err>
66 
67 #elif defined(__WATCOMC__)
68  #include <sys/watcom.err>
69 
70 #elif defined(__DJGPP__)
71  #include <sys/djgpp.err>
72 
73 #elif defined(__DMC__) /* Digital Mars Compiler */
74  #include <sys/digmars.err>
75 
76 #elif defined(__CYGWIN__)
77  /*
78  * Since CygWin's <sys/errno.h> provides all the errno-values
79  * we need, there is no need to use util/errnos.c to create new
80  * ones for CygWin. Simply pull in <sys/errno.h>. Done by
81  * #include_next <sys/errno.h> in our '<sys/errno.h>'.
82  */
83 #elif defined(_MSC_VER) && (_MSC_VER <= 800) /* MSC 8.0 or older */
84  #include <sys/quickc.err>
85 
86 #elif defined(_MSC_VER) && (_MSC_VER > 800) /* Visual C on Windows */
87  #undef EDEADLOCK
88  #include <sys/visualc.err>
89 
90 #elif defined(__CCDL__) /* LadSoft's cc386.exe */
91  #include <sys/ladsoft.err>
92 
93 #elif defined(__LCC__)
94  #include <sys/lcc.err>
95 
96 #elif defined(__POCC__)
97  #include <sys/pellesc.err>
98 
99 #else
100  #error Unknown target in <sys/werrno.h>.
101 #endif
102 
103 /*
104  * Ugly hack ahead. Someone tell me a better way, but
105  * errno and friends are macros on Windows. Redefine them
106  * to point to our variables.
107  *
108  * On Windows, the usual 'errno' is a macro "(*_errno)()" that
109  * is problematic to use as a lvalue.
110  * On other platforms we modify the global 'errno' variable directly.
111  * (see SOCK_ERRNO() in misc.h). So no need to redefine it in any way.
112  */
113 
114 W32_DATA int _w32_errno;
115 W32_DATA int _w32_sys_nerr;
116 W32_DATA char *_w32_sys_errlist[];
117 
118 #if 0
119  #undef sys_nerr
120  #define sys_nerr _w32_sys_nerr
121 
122  #undef _sys_nerr
123  #define _sys_nerr _w32_sys_nerr
124 
125  #undef __sys_nerr
126  #define __sys_nerr _w32_sys_nerr
127 
128  #undef sys_errlist
129  #define sys_errlist _w32_sys_errlist
130 
131  #undef _sys_errlist
132  #define _sys_errlist _w32_sys_errlist
133 
134  #undef __sys_errlist
135  #define __sys_errlist _w32_sys_errlist
136 #endif
137 
138 /*
139  * Incase you have trouble with duplicate defined symbols,
140  * make sure the "*_s()" versions are referenced before normal
141  * perror() and strerror() in your C-library.
142  */
143 W32_FUNC void W32_CALL perror_s (const char *str);
144 W32_FUNC char *W32_CALL strerror_s_ (int errnum);
145 
146 #if defined(__WATCOMC__) && (__WATCOMC__ >= 1250) /* OW 1.5+ */
147  #define W32_OPENWATCOM_15
148 #endif
149 
150 #if defined(__cplusplus)
151  #include <stdlib.h>
152  #include <string.h>
153 
154 #elif !defined(_MSC_VER) && !defined(WIN32) && !defined(W32_OPENWATCOM_15)
155  #if !defined(_INC_STDLIB) && !defined(_STDLIB_H_) && !defined(_STDIO_H)
156  W32_FUNC void W32_CALL perror (const char *str);
157  #endif
158 
159  #if !defined(_INC_STRING) && !defined(_STRING_H) && !defined(_STRING_H_)
160  W32_FUNC char *W32_CALL strerror (int errnum);
161  #endif
162 #endif
163 
164 #if defined (WATT32_ON_WINDOWS)
165  W32_FUNC int __stdcall WSAGetLastError (void);
166  W32_FUNC void __stdcall WSASetLastError (int err);
167 #endif
168 
169 #endif /* __SYS_WERRNO_H */
170