3 * sys_errlist[] and errno's for compilers with limited errnos.
4 * For WIN32, we do NOT use the <winsock.h> WSAE* codes.
6 * G. Vanem <giva@bgnett.no> 1998 - 2004
10 #define __SYS_WERRNO_H
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
18 #ifndef __SYS_W32API_H
19 #include <sys/w32api.h>
22 /* Hack: fix for compiling with djgpp 2.04, but
23 * ./util/dj_err.exe was compiled with 2.03
25 #if defined(MIXING_DJGPP_203_AND_204)
29 #if defined(__MINGW32__)
30 #include <sys/mingw32.err>
32 #elif defined(__HIGHC__)
35 #include <sys/highc.err>
37 #elif defined(__BORLANDC__)
39 #undef ENAMETOOLONG /* bcc32 4.0 */
44 #include <sys/borlandc.err>
46 #elif defined(__TURBOC__)
47 #include <sys/turboc.err>
49 #elif defined(__WATCOMC__)
50 #include <sys/watcom.err>
52 #elif defined(__DJGPP__)
53 #include <sys/djgpp.err>
55 #elif defined(__DMC__) /* Digital Mars Compiler */
56 #include <sys/digmars.err>
58 #elif defined(_MSC_VER) && (_MSC_VER <= 800) /* MSC 8.0 or older */
59 #include <sys/quickc.err>
61 #elif defined(_MSC_VER) && (_MSC_VER > 800) /* Visual C on Windows */
63 #include <sys/visualc.err>
65 #elif defined(__CCDL__) /* LadSoft's cc386.exe */
66 #include <sys/ladsoft.err>
68 #elif defined(__LCC__)
69 #include <sys/lcc.err>
71 #elif defined(__POCC__)
72 #include <sys/pellesc.err>
75 #error Unknown target in <sys/werrno.h>.
79 * Ugly hack ahead. Someone tell me a better way, but
80 * errno and friends are macros on Windows. Redefine them
81 * to point to our variables.
83 * On Windows, the usual 'errno' is a macro "(*_errno)()" that
84 * is problematic to use as a lvalue.
85 * On other platforms we modify the global 'errno' variable directly.
86 * (see SOCK_ERRNO() in misc.h). So no need to redefine it in any way.
89 W32_DATA int _w32_errno;
90 W32_DATA int _w32_sys_nerr;
91 W32_DATA char *_w32_sys_errlist[];
95 #define sys_nerr _w32_sys_nerr
98 #define _sys_nerr _w32_sys_nerr
101 #define __sys_nerr _w32_sys_nerr
104 #define sys_errlist _w32_sys_errlist
107 #define _sys_errlist _w32_sys_errlist
110 #define __sys_errlist _w32_sys_errlist
114 * Incase you have trouble with duplicate defined symbols,
115 * make sure the "*_s()" versions are referenced before normal
116 * perror() and strerror() in your C-library.
118 W32_FUNC void perror_s (const char *str);
119 W32_FUNC char *strerror_s (int errnum);
121 #if defined(__cplusplus) /* Damn C++ */
125 #elif !defined(_MSC_VER) && !defined(WIN32)
126 #if !defined(_INC_STDLIB) && !defined(_STDLIB_H_) && !defined(_STDIO_H)
127 W32_FUNC void perror (const char *str);
130 #if !defined(_INC_STRING) && !defined(_STRING_H) && !defined(_STRING_H_)
131 W32_FUNC char *strerror (int errnum);
135 #if defined(WIN32) || defined(_WIN32)
136 W32_FUNC int __stdcall WSAGetLastError (void);
137 W32_FUNC void __stdcall WSASetLastError (int err);
140 #endif /* __SYS_WERRNO_H */