source: Daodan/MinGW/include/ptw32_errno.h@ 1163

Last change on this file since 1163 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 6.5 KB
RevLine 
[1046]1/*
2 * Module: ptw32_errno.h
3 *
4 * Purpose:
5 * Provides a replacement for <errno.h>, with supplementary
6 * definitions for platforms which already provide their own
7 * implementation, or a complete substitute for WinCE.
8 *
9 * --------------------------------------------------------------------------
10 *
11 * Pthreads-win32 - POSIX Threads Library for Win32
12 * Copyright(C) 1998 John E. Bossom
13 * Copyright(C) 1999-2012, 2016, Pthreads-win32 contributors
14 *
15 * Homepage1: http://sourceware.org/pthreads-win32/
16 * Homepage2: http://sourceforge.net/projects/pthreads4w/
17 *
18 * The current list of contributors is contained
19 * in the file CONTRIBUTORS included with the source
20 * code distribution. The list can also be seen at the
21 * following World Wide Web location:
22 * http://sources.redhat.com/pthreads-win32/contributors.html
23 *
24 * This library is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU Lesser General Public
26 * License as published by the Free Software Foundation; either
27 * version 2 of the License, or (at your option) any later version.
28 *
29 * This library is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public
35 * License along with this library in the file COPYING.LIB;
36 * if not, write to the Free Software Foundation, Inc.,
37 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
38 *
39 */
40#ifndef _PTW32_ERRNO_H
41#define _PTW32_ERRNO_H
42
43/* We must ensure that the core pthreads-win32 definitions are
44 * read in.
45 */
46#include <_ptw32.h>
47
48#if HAVE_ERRNO_H || !(defined(_WIN32_WCE) || defined(UNDER_CE))
49/* Most Win32 platforms, except for WinCE, provide their own <errno.h>,
50 * so, when not compiling for WinCE, or its presence has been explicitly
51 * detected during project configuration, use it.
52 */
53# include <errno.h>
54
55#else
56/* Compiling for WinCE: we must furnish a replacement; these error codes
57 * are abstracted from MinGW.org's <errno.h>
58 */
59#define EPERM 1 /* Operation not permitted */
60#define ENOFILE 2 /* No such file or directory */
61#define ENOENT 2
62#define ESRCH 3 /* No such process */
63#define EINTR 4 /* Interrupted function call */
64#define EIO 5 /* Input/output error */
65#define ENXIO 6 /* No such device or address */
66#define E2BIG 7 /* Arg list too long */
67#define ENOEXEC 8 /* Exec format error */
68#define EBADF 9 /* Bad file descriptor */
69#define ECHILD 10 /* No child processes */
70#define EAGAIN 11 /* Resource temporarily unavailable */
71#define ENOMEM 12 /* Not enough space */
72#define EACCES 13 /* Permission denied */
73#define EFAULT 14 /* Bad address */
74/* 15 - Unknown Error */
75#define EBUSY 16 /* strerror reports "Resource device" */
76#define EEXIST 17 /* File exists */
77#define EXDEV 18 /* Improper link (cross-device link?) */
78#define ENODEV 19 /* No such device */
79#define ENOTDIR 20 /* Not a directory */
80#define EISDIR 21 /* Is a directory */
81#define EINVAL 22 /* Invalid argument */
82#define ENFILE 23 /* Too many open files in system */
83#define EMFILE 24 /* Too many open files */
84#define ENOTTY 25 /* Inappropriate I/O control operation */
85/* 26 - Unknown Error */
86#define EFBIG 27 /* File too large */
87#define ENOSPC 28 /* No space left on device */
88#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */
89#define EROFS 30 /* Read-only file system */
90#define EMLINK 31 /* Too many links */
91#define EPIPE 32 /* Broken pipe */
92#define EDOM 33 /* Domain error (math functions) */
93#define ERANGE 34 /* Result too large (possibly too small) */
94/* 35 - Unknown Error */
95#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
96#define EDEADLK 36
97/* 37 - Unknown Error */
98#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
99#define ENOLCK 39 /* No locks available (46 in Cyg?) */
100#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
101#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
102#define EILSEQ 42 /* Illegal byte sequence */
103
104#ifndef RC_INVOKED
105
106__PTW32_BEGIN_C_DECLS
107/* Definition of errno. For _doserrno, sys_nerr, and * sys_errlist,
108 * see stdlib.h. (FIXME: this represents the implementation which is
109 * provided by MSVCRT.DLL, on all regular Windows Desktop and Server
110 * platforms; we may need to provide a replacement implementation,
111 * which will be suitable for WinCE).
112 */
113__declspec(dllimport) int __cdecl *_errno(void);
114#define errno (*_errno())
115
116__PTW32_END_C_DECLS
117
118#endif /* ! RC_INVOKED */
119#endif /* ! HAVE_ERRNO_H */
120
121/* Regardless of whether or not the target platform provides its own
122 * <errno.h>, we depend on several error codes which may not have been
123 * defined; ensure that we provide fall-back definitions.
124 */
125#define __PTW32_DEFINE_ERRNO(__CODE__) (__PTW32_ERRNO_BASE__+__CODE__)
126
127#if __PTW32_VERSION_MAJOR > 2
128# define __PTW32_ERRNO_BASE__ (1000 - 42)
129#else
130/* FIXME: This matches the original pthreads-win32 v2 definitions,
131 * but creates a conflict between EOWNERDEAD and EILSEQ.
132 */
133# define __PTW32_ERRNO_BASE__ 0
134#endif
135
136/* POSIX.1-2008 robust mutex support.
137 */
138#define __PTW32_EOWNERDEAD __PTW32_DEFINE_ERRNO( 42 )
139#define __PTW32_ENOTRECOVERABLE __PTW32_DEFINE_ERRNO( 43 )
140
141#ifndef EOWNERDEAD
142#define EOWNERDEAD __PTW32_EOWNERDEAD
143#endif
144
145#ifndef ENOTRECOVERABLE
146#define ENOTRECOVERABLE __PTW32_ENOTRECOVERABLE
147#endif
148
149#if !defined(EDEADLK)
150/* This is the standard name, prescribed by POSIX.1. MinGW.org's
151 * <errno.h> already defines it, but some other platforms may not.
152 */
153# if defined(EDEADLOCK)
154# define EDEADLK EDEADLOCK /* Some older MS tools defined it thus... */
155# else
156# define EDEADLK 36 /* ...while MinGW.org defines both thus. */
157# endif
158#endif
159
160#if !defined(ENOTSUP)
161# define ENOTSUP 48 /* This is the value in Solaris. */
162#endif
163
164#if !defined(ENOSYS)
165# define ENOSYS 140 /* Semi-arbitrary value */
166#endif
167
168#if !defined(ETIMEDOUT)
169/* Not normally defined in Win32 <errno.h>, but at one time it may
170 * have been defined in <winsock.h>; this seems to be no longer the
171 * case, but WSAETIMEDOUT may offer a suitable substitute.
172 *
173 * FIXME: this may be incompatible with any application which wants
174 * to use <winsock2.h>
175 */
176# include <winsock.h>
177# if !defined(ETIMEDOUT)
178# if defined(WSAETIMEDOUT)
179# define ETIMEDOUT WSAETIMEDOUT
180# else
181# define ETIMEDOUT 10060 /* This is the value of WSAETIMEDOUT in winsock.h. */
182# endif
183# endif
184#endif
185
186#endif /* ! _PTW32_ERRNO_H_ */
Note: See TracBrowser for help on using the repository browser.