1 | /** @file
|
---|
2 | * IPRT - errno.h wrapper.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2012-2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_errno_h
|
---|
27 | #define IPRT_INCLUDED_errno_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #ifndef IPRT_NO_CRT
|
---|
33 | # if defined(RT_OS_DARWIN) && defined(KERNEL)
|
---|
34 | # include <sys/errno.h>
|
---|
35 | # elif defined(RT_OS_LINUX) && defined(__KERNEL__)
|
---|
36 | # include <linux/errno.h>
|
---|
37 | # elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
|
---|
38 | # include <sys/errno.h>
|
---|
39 | # elif defined(RT_OS_NETBSD) && defined(_KERNEL)
|
---|
40 | # include <sys/errno.h>
|
---|
41 | # else
|
---|
42 | # include <errno.h>
|
---|
43 | # endif
|
---|
44 | #endif
|
---|
45 |
|
---|
46 |
|
---|
47 | /*
|
---|
48 | * Supply missing errno values according to the current RT_OS_XXX definition.
|
---|
49 | *
|
---|
50 | * Note! These supplements are for making no-CRT mode, as well as making UNIXy
|
---|
51 | * code that makes used of odd errno defines internally, work smoothly.
|
---|
52 | *
|
---|
53 | * When adding more error codes, always check the following errno.h sources:
|
---|
54 | * - RT_OS_DARWIN: http://fxr.watson.org/fxr/source/bsd/sys/errno.h?v=xnu-1699.24.8
|
---|
55 | * - RT_OS_FREEBSD: http://fxr.watson.org/fxr/source/sys/errno.h?v=DFBSD
|
---|
56 | * - RT_OS_NETBSD: http://fxr.watson.org/fxr/source/sys/errno.h?v=NETBSD
|
---|
57 | * - RT_OS_OPENBSD: http://fxr.watson.org/fxr/source/sys/errno.h?v=OPENBSD
|
---|
58 | * - RT_OS_OS2: http://svn.netlabs.org/libc/browser/trunk/libc/include/sys/errno.h
|
---|
59 | * - RT_OS_LINUX: http://fxr.watson.org/fxr/source/include/asm-generic/errno.h?v=linux-2.6
|
---|
60 | * - RT_OS_SOLARIS: http://fxr.watson.org/fxr/source/common/sys/errno.h?v=OPENSOLARIS
|
---|
61 | * - RT_OS_WINDOWS: tools/win.x86/vcc/v8sp1/include/errno.h
|
---|
62 | */
|
---|
63 |
|
---|
64 | #if defined(RT_OS_DARWIN) \
|
---|
65 | || defined(RT_OS_FREEBSD) \
|
---|
66 | || defined(RT_OS_NETBSD) \
|
---|
67 | || defined(RT_OS_OPENBSD) \
|
---|
68 | || defined(RT_OS_OS2)
|
---|
69 | # define RT_ERRNO_OS_BSD
|
---|
70 | #endif
|
---|
71 | #ifdef RT_OS_SOLARIS
|
---|
72 | # define RT_ERRNO_OS_SYSV_HARDCORE /* ?? */
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | /* The relatively similar part. */
|
---|
76 | #ifndef EPERM
|
---|
77 | # define EPERM (1)
|
---|
78 | #endif
|
---|
79 | #ifndef ENOENT
|
---|
80 | # define ENOENT (2)
|
---|
81 | #endif
|
---|
82 | #ifndef ESRCH
|
---|
83 | # define ESRCH (3)
|
---|
84 | #endif
|
---|
85 | #ifndef EINTR
|
---|
86 | # define EINTR (4)
|
---|
87 | #endif
|
---|
88 | #ifndef EIO
|
---|
89 | # define EIO (5)
|
---|
90 | #endif
|
---|
91 | #ifndef ENXIO
|
---|
92 | # define ENXIO (6)
|
---|
93 | #endif
|
---|
94 | #ifndef E2BIG
|
---|
95 | # define E2BIG (7)
|
---|
96 | #endif
|
---|
97 | #ifndef ENOEXEC
|
---|
98 | # define ENOEXEC (8)
|
---|
99 | #endif
|
---|
100 | #ifndef EBADF
|
---|
101 | # define EBADF (9)
|
---|
102 | #endif
|
---|
103 | #ifndef ECHILD
|
---|
104 | # define ECHILD (10)
|
---|
105 | #endif
|
---|
106 | #ifndef EAGAIN
|
---|
107 | # if defined(RT_ERRNO_OS_BSD)
|
---|
108 | # define EAGAIN (35)
|
---|
109 | # else
|
---|
110 | # define EAGAIN (11)
|
---|
111 | # endif
|
---|
112 | #endif
|
---|
113 | #ifndef EWOULDBLOCK
|
---|
114 | # define EWOULDBLOCK EAGAIN
|
---|
115 | #endif
|
---|
116 | #ifndef EDEADLK
|
---|
117 | # if defined(RT_ERRNO_OS_BSD)
|
---|
118 | # define EDEADLK (11)
|
---|
119 | # elif defined(RT_OS_LINUX)
|
---|
120 | # define EDEADLK (35)
|
---|
121 | # elif defined(RT_OS_WINDOWS)
|
---|
122 | # define EDEADLK (36)
|
---|
123 | # else
|
---|
124 | # define EDEADLK (45) /* solaris */
|
---|
125 | # endif
|
---|
126 | #endif
|
---|
127 | #ifndef EDEADLOCK
|
---|
128 | # define EDEADLOCK EDEADLK
|
---|
129 | #endif
|
---|
130 | #ifndef ENOMEM
|
---|
131 | # define ENOMEM (12)
|
---|
132 | #endif
|
---|
133 | #ifndef EACCES
|
---|
134 | # define EACCES (13)
|
---|
135 | #endif
|
---|
136 | #ifndef EFAULT
|
---|
137 | # define EFAULT (14)
|
---|
138 | #endif
|
---|
139 | #ifndef ENOTBLK
|
---|
140 | # define ENOTBLK (15)
|
---|
141 | #endif
|
---|
142 | #ifndef EBUSY
|
---|
143 | # define EBUSY (16)
|
---|
144 | #endif
|
---|
145 | #ifndef EEXIST
|
---|
146 | # define EEXIST (17)
|
---|
147 | #endif
|
---|
148 | #ifndef EXDEV
|
---|
149 | # define EXDEV (18)
|
---|
150 | #endif
|
---|
151 | #ifndef ENODEV
|
---|
152 | # define ENODEV (19)
|
---|
153 | #endif
|
---|
154 | #ifndef ENOTDIR
|
---|
155 | # define ENOTDIR (20)
|
---|
156 | #endif
|
---|
157 | #ifndef EISDIR
|
---|
158 | # define EISDIR (21)
|
---|
159 | #endif
|
---|
160 | #ifndef EINVAL
|
---|
161 | # define EINVAL (22)
|
---|
162 | #endif
|
---|
163 | #ifndef ENFILE
|
---|
164 | # define ENFILE (23)
|
---|
165 | #endif
|
---|
166 | #ifndef EMFILE
|
---|
167 | # define EMFILE (24)
|
---|
168 | #endif
|
---|
169 | #ifndef ENOTTY
|
---|
170 | # define ENOTTY (25)
|
---|
171 | #endif
|
---|
172 | #ifndef ETXTBSY
|
---|
173 | # define ETXTBSY (26)
|
---|
174 | #endif
|
---|
175 | #ifndef EFBIG
|
---|
176 | # define EFBIG (27)
|
---|
177 | #endif
|
---|
178 | #ifndef ENOSPC
|
---|
179 | # define ENOSPC (28)
|
---|
180 | #endif
|
---|
181 | #ifndef ESPIPE
|
---|
182 | # define ESPIPE (29)
|
---|
183 | #endif
|
---|
184 | #ifndef EROFS
|
---|
185 | # define EROFS (30)
|
---|
186 | #endif
|
---|
187 | #ifndef EMLINK
|
---|
188 | # define EMLINK (31)
|
---|
189 | #endif
|
---|
190 | #ifndef EPIPE
|
---|
191 | # define EPIPE (32)
|
---|
192 | #endif
|
---|
193 | #ifndef EDOM
|
---|
194 | # define EDOM (33)
|
---|
195 | #endif
|
---|
196 | #ifndef ERANGE
|
---|
197 | # define ERANGE (34)
|
---|
198 | #endif
|
---|
199 |
|
---|
200 | /* 35 - also EAGAIN on BSD and EDEADLK on Linux. */
|
---|
201 | #ifndef ENOMSG
|
---|
202 | # if defined(RT_OS_DARWIN)
|
---|
203 | # define ENOMSG (91)
|
---|
204 | # elif defined(RT_OS_FREEBSD)
|
---|
205 | # define ENOMSG (83)
|
---|
206 | # elif defined(RT_OS_LINUX)
|
---|
207 | # define ENOMSG (42)
|
---|
208 | # elif defined(RT_OS_WINDOWS)
|
---|
209 | # define ENOMSG (122)
|
---|
210 | # else
|
---|
211 | # define ENOMSG (35)
|
---|
212 | # endif
|
---|
213 | #endif
|
---|
214 |
|
---|
215 | /* 36 - Also EDEADLK on Windows. */
|
---|
216 | #ifndef EIDRM
|
---|
217 | # if defined(RT_OS_DARWIN)
|
---|
218 | # define EIDRM (90)
|
---|
219 | # elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
|
---|
220 | # define EIDRM (82)
|
---|
221 | # elif defined(RT_OS_OPENBSD)
|
---|
222 | # define EIDRM (89)
|
---|
223 | # elif defined(RT_OS_LINUX)
|
---|
224 | # define EIDRM (43)
|
---|
225 | # elif defined(RT_OS_WINDOWS)
|
---|
226 | # define EIDRM (111)
|
---|
227 | # else
|
---|
228 | # define EIDRM (36)
|
---|
229 | # endif
|
---|
230 | #endif
|
---|
231 | #ifndef EINPROGRESS
|
---|
232 | # if defined(RT_ERRNO_OS_BSD)
|
---|
233 | # define EINPROGRESS (36)
|
---|
234 | # elif defined(RT_OS_LINUX)
|
---|
235 | # define EINPROGRESS (115)
|
---|
236 | # elif defined(RT_OS_WINDOWS)
|
---|
237 | # define EINPROGRESS (112)
|
---|
238 | # else
|
---|
239 | # define EINPROGRESS (150) /* solaris */
|
---|
240 | # endif
|
---|
241 | #endif
|
---|
242 | #ifndef ENAMETOOLONG
|
---|
243 | # if defined(RT_ERRNO_OS_BSD)
|
---|
244 | # define ENAMETOOLONG (63)
|
---|
245 | # elif defined(RT_OS_LINUX)
|
---|
246 | # define ENAMETOOLONG (36)
|
---|
247 | # elif defined(RT_OS_WINDOWS)
|
---|
248 | # define ENAMETOOLONG (38)
|
---|
249 | # else
|
---|
250 | # define ENAMETOOLONG (78) /* solaris */
|
---|
251 | # endif
|
---|
252 | #endif
|
---|
253 |
|
---|
254 | /* 37 */
|
---|
255 | #ifndef ECHRNG
|
---|
256 | # if defined(RT_ERRNO_OS_SYSV_HARDCORE)
|
---|
257 | # define ECHRNG (37)
|
---|
258 | # else
|
---|
259 | # define ECHRNG (599)
|
---|
260 | # endif
|
---|
261 | #endif
|
---|
262 | #ifndef ENOLCK
|
---|
263 | # if defined(RT_ERRNO_OS_BSD)
|
---|
264 | # define ENOLCK (77)
|
---|
265 | # elif defined(RT_OS_LINUX)
|
---|
266 | # define ENOLCK (37)
|
---|
267 | # elif defined(RT_OS_WINDOWS)
|
---|
268 | # define ENOLCK (39)
|
---|
269 | # else
|
---|
270 | # define ENOLCK (46)
|
---|
271 | # endif
|
---|
272 | #endif
|
---|
273 | #ifndef EALREADY
|
---|
274 | # if defined(RT_ERRNO_OS_BSD)
|
---|
275 | # define EALREADY (37)
|
---|
276 | # elif defined(RT_OS_LINUX)
|
---|
277 | # define EALREADY (114)
|
---|
278 | # elif defined(RT_OS_WINDOWS)
|
---|
279 | # define EALREADY (103)
|
---|
280 | # else
|
---|
281 | # define EALREADY (149)
|
---|
282 | # endif
|
---|
283 | #endif
|
---|
284 |
|
---|
285 | /* 38 - Also ENAMETOOLONG on Windows. */
|
---|
286 | #ifndef ENOSYS
|
---|
287 | # if defined(RT_ERRNO_OS_BSD)
|
---|
288 | # define ENOSYS (78)
|
---|
289 | # elif defined(RT_OS_LINUX)
|
---|
290 | # define ENOSYS (38)
|
---|
291 | # elif defined(RT_OS_WINDOWS)
|
---|
292 | # define ENOSYS (40)
|
---|
293 | # else
|
---|
294 | # define ENOSYS (89) /* solaris */
|
---|
295 | # endif
|
---|
296 | #endif
|
---|
297 | #ifndef ENOTSOCK
|
---|
298 | # if defined(RT_ERRNO_OS_BSD)
|
---|
299 | # define ENOTSOCK (38)
|
---|
300 | # elif defined(RT_OS_LINUX)
|
---|
301 | # define ENOTSOCK (88)
|
---|
302 | # elif defined(RT_OS_WINDOWS)
|
---|
303 | # define ENOTSOCK (128)
|
---|
304 | # else
|
---|
305 | # define ENOTSOCK (95) /* solaris */
|
---|
306 | # endif
|
---|
307 | #endif
|
---|
308 | #ifndef EL2NSYNC
|
---|
309 | # if defined(RT_OS_LINUX)
|
---|
310 | # define EL2NSYNC (45)
|
---|
311 | # elif defined(RT_ERRNO_OS_SYSV_HARDCORE)
|
---|
312 | # define EL2NSYNC (38) /* solaris */
|
---|
313 | # endif
|
---|
314 | #endif
|
---|
315 |
|
---|
316 | /* 39 - Also ENOLCK on Windows. */
|
---|
317 | #ifndef ENOTEMPTY
|
---|
318 | # if defined(RT_ERRNO_OS_BSD)
|
---|
319 | # define ENOTEMPTY (66)
|
---|
320 | # elif defined(RT_OS_LINUX)
|
---|
321 | # define ENOTEMPTY (39)
|
---|
322 | # elif defined(RT_OS_WINDOWS)
|
---|
323 | # define ENOTEMPTY (41)
|
---|
324 | # else
|
---|
325 | # define ENOTEMPTY (93) /* solaris */
|
---|
326 | # endif
|
---|
327 | #endif
|
---|
328 | #ifndef EDESTADDRREQ
|
---|
329 | # if defined(RT_ERRNO_OS_BSD)
|
---|
330 | # define EDESTADDRREQ (39)
|
---|
331 | # elif defined(RT_OS_LINUX)
|
---|
332 | # define EDESTADDRREQ (89)
|
---|
333 | # elif defined(RT_OS_WINDOWS)
|
---|
334 | # define EDESTADDRREQ (109)
|
---|
335 | # else
|
---|
336 | # define EDESTADDRREQ (96) /* solaris */
|
---|
337 | # endif
|
---|
338 | #endif
|
---|
339 | #ifndef EL3HLT
|
---|
340 | # if defined(RT_OS_LINUX)
|
---|
341 | # define EL3HLT (46)
|
---|
342 | # elif defined(RT_ERRNO_OS_SYSV_HARDCORE)
|
---|
343 | # define EL3HLT (39) /* solaris */
|
---|
344 | # endif
|
---|
345 | #endif
|
---|
346 |
|
---|
347 | /* 40 - Also ENOSYS on Windows. */
|
---|
348 | #ifndef ELOOP
|
---|
349 | # if defined(RT_ERRNO_OS_BSD)
|
---|
350 | # define ELOOP (62)
|
---|
351 | # elif defined(RT_OS_LINUX)
|
---|
352 | # define ELOOP (40)
|
---|
353 | # elif defined(RT_OS_WINDOWS)
|
---|
354 | # define ELOOP (114)
|
---|
355 | # else
|
---|
356 | # define ELOOP (90) /* solaris */
|
---|
357 | # endif
|
---|
358 | #endif
|
---|
359 | #ifndef EMSGSIZE
|
---|
360 | # if defined(RT_ERRNO_OS_BSD)
|
---|
361 | # define EMSGSIZE (40)
|
---|
362 | # elif defined(RT_OS_LINUX)
|
---|
363 | # define EMSGSIZE (90)
|
---|
364 | # elif defined(RT_OS_WINDOWS)
|
---|
365 | # define EMSGSIZE (115)
|
---|
366 | # else
|
---|
367 | # define EMSGSIZE (97) /* solaris */
|
---|
368 | # endif
|
---|
369 | #endif
|
---|
370 | #ifndef EL3RST
|
---|
371 | # if defined(RT_OS_LINUX)
|
---|
372 | # define EL3RST (47)
|
---|
373 | # elif defined(RT_ERRNO_OS_SYSV_HARDCORE)
|
---|
374 | # define EL3RST (40) /* solaris */
|
---|
375 | # endif
|
---|
376 | #endif
|
---|
377 |
|
---|
378 | /** @todo errno constants {41..44}. */
|
---|
379 |
|
---|
380 | /* 45 - also EDEADLK on Solaris, EL2NSYNC on Linux. */
|
---|
381 | #ifndef ENOTSUP
|
---|
382 | # if defined(RT_ERRNO_OS_BSD)
|
---|
383 | # define ENOTSUP (45)
|
---|
384 | # elif defined(RT_OS_LINUX)
|
---|
385 | # define ENOTSUP (95)
|
---|
386 | # elif defined(RT_OS_WINDOWS)
|
---|
387 | # define ENOTSUP (129)
|
---|
388 | # else
|
---|
389 | # define ENOTSUP (48)
|
---|
390 | # endif
|
---|
391 | #endif
|
---|
392 | #ifndef EOPNOTSUPP
|
---|
393 | # if defined(RT_ERRNO_OS_BSD)
|
---|
394 | # define EOPNOTSUPP ENOTSUP
|
---|
395 | # elif defined(RT_OS_LINUX)
|
---|
396 | # define EOPNOTSUPP ENOTSUP
|
---|
397 | # elif defined(RT_OS_WINDOWS)
|
---|
398 | # define EOPNOTSUPP (130)
|
---|
399 | # else
|
---|
400 | # define EOPNOTSUPP (122)
|
---|
401 | # endif
|
---|
402 | #endif
|
---|
403 |
|
---|
404 | /** @todo errno constants {46..74}. */
|
---|
405 |
|
---|
406 | /* 75 - note that Solaris has constant with value 75. */
|
---|
407 | #ifndef EOVERFLOW
|
---|
408 | # if defined(RT_OS_OPENBSD)
|
---|
409 | # define EOVERFLOW (87)
|
---|
410 | # elif defined(RT_ERRNO_OS_BSD)
|
---|
411 | # define EOVERFLOW (84)
|
---|
412 | # elif defined(RT_OS_LINUX)
|
---|
413 | # define EOVERFLOW (75)
|
---|
414 | # elif defined(RT_OS_WINDOWS)
|
---|
415 | # define EOVERFLOW (132)
|
---|
416 | # else
|
---|
417 | # define EOVERFLOW (79)
|
---|
418 | # endif
|
---|
419 | #endif
|
---|
420 | #ifndef EPROGMISMATCH
|
---|
421 | # if defined(RT_ERRNO_OS_BSD)
|
---|
422 | # define EPROGMISMATCH (75)
|
---|
423 | # else
|
---|
424 | # define EPROGMISMATCH (598)
|
---|
425 | # endif
|
---|
426 | #endif
|
---|
427 |
|
---|
428 | /** @todo errno constants {76..}. */
|
---|
429 |
|
---|
430 |
|
---|
431 | #endif /* !IPRT_INCLUDED_errno_h */
|
---|