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