[ec18957a] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jiri Zarevucky
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup libposix
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
[4cf8ca6] | 32 | /** @file System error numbers.
|
---|
[ec18957a] | 33 | */
|
---|
| 34 |
|
---|
| 35 | #ifndef POSIX_ERRNO_H_
|
---|
| 36 | #define POSIX_ERRNO_H_
|
---|
| 37 |
|
---|
| 38 | #include "libc/errno.h"
|
---|
| 39 |
|
---|
| 40 | /* IMPORTANT:
|
---|
| 41 | * Since libc uses negative errorcodes, some sort of conversion is necessary to
|
---|
| 42 | * keep POSIX programs and libraries from breaking. This file maps POSIX error
|
---|
| 43 | * codes to absolute values of corresponding libc codes where available, and
|
---|
| 44 | * assigns new code where there is no prior definition in libc.
|
---|
| 45 | *
|
---|
| 46 | * A new errno variable is defined. When accessed, the function first looks at
|
---|
| 47 | * libc errno and iff it is != 0, sets the POSIX errno to absolute value of
|
---|
| 48 | * libc errno. Given that no library function sets errno to 0 and that all
|
---|
| 49 | * POSIX libraries will be used solely by POSIX programs (thus, there only needs
|
---|
| 50 | * to be one way correspondence between errno and posix_errno), this approach
|
---|
| 51 | * should work as expected in most cases and does not require any wrappers for
|
---|
| 52 | * libc routines that would just change errno values.
|
---|
| 53 | *
|
---|
| 54 | * There is no conditioning by LIBPOSIX_INTERNAL for redefinitions of macros.
|
---|
| 55 | * If there is a need to check errno for a value not defined by POSIX, it's
|
---|
| 56 | * necessary to compare errno against abs(ECODE), because there is no
|
---|
| 57 | * redefinition for such error codes.
|
---|
| 58 | *
|
---|
[6921178] | 59 | * XXX: maybe all HOS error codes should be redefined
|
---|
[ec18957a] | 60 | *
|
---|
| 61 | * NOTE: This redefinition is slightly POSIX incompatible, since the
|
---|
| 62 | * specification requires the macro values to be usable in preprocessing
|
---|
| 63 | * directives. I don't think that's very important, though.
|
---|
| 64 | */
|
---|
| 65 |
|
---|
| 66 | #undef errno
|
---|
| 67 | #define errno (*__posix_errno())
|
---|
| 68 |
|
---|
[af42a2b] | 69 | #include "unistd.h"
|
---|
| 70 |
|
---|
[ddc63fd] | 71 | extern int *__posix_errno(void);
|
---|
[ec18957a] | 72 |
|
---|
| 73 | #define __TOP_ERRNO (-NO_DATA)
|
---|
| 74 |
|
---|
| 75 | enum {
|
---|
| 76 | POSIX_E2BIG = __TOP_ERRNO + 1,
|
---|
| 77 | POSIX_EACCES = __TOP_ERRNO + 2,
|
---|
| 78 | POSIX_EADDRINUSE = -EADDRINUSE,
|
---|
| 79 | POSIX_EADDRNOTAVAIL = -EADDRNOTAVAIL,
|
---|
| 80 | POSIX_EAFNOSUPPORT = -EAFNOSUPPORT,
|
---|
| 81 | POSIX_EAGAIN = -EAGAIN,
|
---|
| 82 | POSIX_EALREADY = __TOP_ERRNO + 3,
|
---|
| 83 | POSIX_EBADF = -EBADF,
|
---|
| 84 | POSIX_EBADMSG = __TOP_ERRNO + 4,
|
---|
| 85 | POSIX_EBUSY = -EBUSY,
|
---|
| 86 | POSIX_ECANCELED = __TOP_ERRNO + 5,
|
---|
| 87 | POSIX_ECHILD = __TOP_ERRNO + 6,
|
---|
| 88 | POSIX_ECONNABORTED = __TOP_ERRNO + 7,
|
---|
| 89 | POSIX_ECONNREFUSED = __TOP_ERRNO + 8,
|
---|
| 90 | POSIX_ECONNRESET = __TOP_ERRNO + 9,
|
---|
| 91 | POSIX_EDEADLK = __TOP_ERRNO + 10,
|
---|
| 92 | POSIX_EDESTADDRREQ = -EDESTADDRREQ,
|
---|
| 93 | POSIX_EDOM = __TOP_ERRNO + 11,
|
---|
| 94 | POSIX_EDQUOT = __TOP_ERRNO + 12,
|
---|
| 95 | POSIX_EEXIST = -EEXIST,
|
---|
| 96 | POSIX_EFAULT = __TOP_ERRNO + 13,
|
---|
| 97 | POSIX_EFBIG = __TOP_ERRNO + 14,
|
---|
| 98 | POSIX_EHOSTUNREACH = __TOP_ERRNO + 15,
|
---|
| 99 | POSIX_EIDRM = __TOP_ERRNO + 16,
|
---|
| 100 | POSIX_EILSEQ = __TOP_ERRNO + 17,
|
---|
| 101 | POSIX_EINPROGRESS = -EINPROGRESS,
|
---|
| 102 | POSIX_EINTR = -EINTR,
|
---|
| 103 | POSIX_EINVAL = -EINVAL,
|
---|
| 104 | POSIX_EIO = -EIO,
|
---|
| 105 | POSIX_EISCONN = __TOP_ERRNO + 18,
|
---|
| 106 | POSIX_EISDIR = -EISDIR,
|
---|
| 107 | POSIX_ELOOP = __TOP_ERRNO + 19,
|
---|
| 108 | POSIX_EMFILE = -EMFILE,
|
---|
| 109 | POSIX_EMLINK = -EMLINK,
|
---|
| 110 | POSIX_EMSGSIZE = __TOP_ERRNO + 20,
|
---|
| 111 | POSIX_EMULTIHOP = __TOP_ERRNO + 21,
|
---|
| 112 | POSIX_ENAMETOOLONG = -ENAMETOOLONG,
|
---|
| 113 | POSIX_ENETDOWN = __TOP_ERRNO + 22,
|
---|
| 114 | POSIX_ENETRESET = __TOP_ERRNO + 23,
|
---|
| 115 | POSIX_ENETUNREACH = __TOP_ERRNO + 24,
|
---|
| 116 | POSIX_ENFILE = __TOP_ERRNO + 25,
|
---|
| 117 | POSIX_ENOBUFS = __TOP_ERRNO + 26,
|
---|
| 118 | POSIX_ENODATA = -NO_DATA,
|
---|
| 119 | POSIX_ENODEV = __TOP_ERRNO + 27,
|
---|
| 120 | POSIX_ENOENT = -ENOENT,
|
---|
| 121 | POSIX_ENOEXEC = __TOP_ERRNO + 28,
|
---|
| 122 | POSIX_ENOLCK = __TOP_ERRNO + 29,
|
---|
| 123 | POSIX_ENOLINK = __TOP_ERRNO + 30,
|
---|
| 124 | POSIX_ENOMEM = -ENOMEM,
|
---|
| 125 | POSIX_ENOMSG = __TOP_ERRNO + 31,
|
---|
| 126 | POSIX_ENOPROTOOPT = __TOP_ERRNO + 32,
|
---|
| 127 | POSIX_ENOSPC = -ENOSPC,
|
---|
| 128 | POSIX_ENOSR = __TOP_ERRNO + 33,
|
---|
| 129 | POSIX_ENOSTR = __TOP_ERRNO + 34,
|
---|
| 130 | POSIX_ENOSYS = __TOP_ERRNO + 35,
|
---|
| 131 | POSIX_ENOTCONN = -ENOTCONN,
|
---|
| 132 | POSIX_ENOTDIR = -ENOTDIR,
|
---|
| 133 | POSIX_ENOTEMPTY = -ENOTEMPTY,
|
---|
| 134 | POSIX_ENOTRECOVERABLE = __TOP_ERRNO + 36,
|
---|
| 135 | POSIX_ENOTSOCK = -ENOTSOCK,
|
---|
| 136 | POSIX_ENOTSUP = -ENOTSUP,
|
---|
| 137 | POSIX_ENOTTY = __TOP_ERRNO + 37,
|
---|
| 138 | POSIX_ENXIO = __TOP_ERRNO + 38,
|
---|
[903bd436] | 139 | POSIX_EOPNOTSUPP = __TOP_ERRNO + 39,
|
---|
[ec18957a] | 140 | POSIX_EOVERFLOW = -EOVERFLOW,
|
---|
[903bd436] | 141 | POSIX_EOWNERDEAD = __TOP_ERRNO + 40,
|
---|
[ec18957a] | 142 | POSIX_EPERM = -EPERM,
|
---|
[903bd436] | 143 | POSIX_EPIPE = __TOP_ERRNO + 41,
|
---|
| 144 | POSIX_EPROTO = __TOP_ERRNO + 42,
|
---|
[ec18957a] | 145 | POSIX_EPROTONOSUPPORT = -EPROTONOSUPPORT,
|
---|
[903bd436] | 146 | POSIX_EPROTOTYPE = __TOP_ERRNO + 43,
|
---|
[ec18957a] | 147 | POSIX_ERANGE = -ERANGE,
|
---|
[903bd436] | 148 | POSIX_EROFS = __TOP_ERRNO + 44,
|
---|
| 149 | POSIX_ESPIPE = __TOP_ERRNO + 45,
|
---|
| 150 | POSIX_ESRCH = __TOP_ERRNO + 46,
|
---|
| 151 | POSIX_ESTALE = __TOP_ERRNO + 47,
|
---|
| 152 | POSIX_ETIME = __TOP_ERRNO + 48,
|
---|
| 153 | POSIX_ETIMEDOUT = __TOP_ERRNO + 49,
|
---|
| 154 | POSIX_ETXTBSY = __TOP_ERRNO + 50,
|
---|
| 155 | POSIX_EWOULDBLOCK = __TOP_ERRNO + 51,
|
---|
[ec18957a] | 156 | POSIX_EXDEV = -EXDEV,
|
---|
| 157 | };
|
---|
| 158 |
|
---|
| 159 | #undef __TOP_ERRNO
|
---|
| 160 |
|
---|
| 161 | #undef E2BIG
|
---|
| 162 | #undef EACCES
|
---|
| 163 | #undef EADDRINUSE
|
---|
| 164 | #undef EADDRNOTAVAIL
|
---|
| 165 | #undef EAFNOSUPPORT
|
---|
| 166 | #undef EAGAIN
|
---|
| 167 | #undef EALREADY
|
---|
| 168 | #undef EBADF
|
---|
| 169 | #undef EBADMSG
|
---|
| 170 | #undef EBUSY
|
---|
| 171 | #undef ECANCELED
|
---|
| 172 | #undef ECHILD
|
---|
| 173 | #undef ECONNABORTED
|
---|
| 174 | #undef ECONNREFUSED
|
---|
| 175 | #undef ECONNRESET
|
---|
| 176 | #undef EDEADLK
|
---|
| 177 | #undef EDESTADDRREQ
|
---|
| 178 | #undef EDOM
|
---|
| 179 | #undef EDQUOT
|
---|
| 180 | #undef EEXIST
|
---|
| 181 | #undef EFAULT
|
---|
| 182 | #undef EFBIG
|
---|
| 183 | #undef EHOSTUNREACH
|
---|
| 184 | #undef EIDRM
|
---|
| 185 | #undef EILSEQ
|
---|
| 186 | #undef EINPROGRESS
|
---|
| 187 | #undef EINTR
|
---|
| 188 | #undef EINVAL
|
---|
| 189 | #undef EIO
|
---|
| 190 | #undef EISCONN
|
---|
| 191 | #undef EISDIR
|
---|
| 192 | #undef ELOOP
|
---|
| 193 | #undef EMFILE
|
---|
| 194 | #undef EMLINK
|
---|
| 195 | #undef EMSGSIZE
|
---|
| 196 | #undef EMULTIHOP
|
---|
| 197 | #undef ENAMETOOLONG
|
---|
| 198 | #undef ENETDOWN
|
---|
| 199 | #undef ENETRESET
|
---|
| 200 | #undef ENETUNREACH
|
---|
| 201 | #undef ENFILE
|
---|
| 202 | #undef ENOBUFS
|
---|
| 203 | #undef ENODATA
|
---|
| 204 | #undef ENODEV
|
---|
| 205 | #undef ENOENT
|
---|
| 206 | #undef ENOEXEC
|
---|
| 207 | #undef ENOLCK
|
---|
| 208 | #undef ENOLINK
|
---|
| 209 | #undef ENOMEM
|
---|
| 210 | #undef ENOMSG
|
---|
| 211 | #undef ENOPROTOOPT
|
---|
| 212 | #undef ENOSPC
|
---|
| 213 | #undef ENOSR
|
---|
| 214 | #undef ENOSTR
|
---|
| 215 | #undef ENOSYS
|
---|
| 216 | #undef ENOTCONN
|
---|
| 217 | #undef ENOTDIR
|
---|
| 218 | #undef ENOTEMPTY
|
---|
| 219 | #undef ENOTRECOVERABLE
|
---|
| 220 | #undef ENOTSOCK
|
---|
| 221 | #undef ENOTSUP
|
---|
| 222 | #undef ENOTTY
|
---|
| 223 | #undef ENXIO
|
---|
| 224 | #undef EOPNOTSUPP
|
---|
| 225 | #undef EOVERFLOW
|
---|
| 226 | #undef EOWNERDEAD
|
---|
| 227 | #undef EPERM
|
---|
| 228 | #undef EPIPE
|
---|
| 229 | #undef EPROTO
|
---|
| 230 | #undef EPROTONOSUPPORT
|
---|
| 231 | #undef EPROTOTYPE
|
---|
| 232 | #undef ERANGE
|
---|
| 233 | #undef EROFS
|
---|
| 234 | #undef ESPIPE
|
---|
| 235 | #undef ESRCH
|
---|
| 236 | #undef ESTALE
|
---|
| 237 | #undef ETIME
|
---|
| 238 | #undef ETIMEDOUT
|
---|
| 239 | #undef ETXTBSY
|
---|
| 240 | #undef EWOULDBLOCK
|
---|
| 241 | #undef EXDEV
|
---|
| 242 |
|
---|
| 243 | #define E2BIG POSIX_E2BIG
|
---|
| 244 | #define EACCES POSIX_EACCES
|
---|
| 245 | #define EADDRINUSE POSIX_EADDRINUSE
|
---|
| 246 | #define EADDRNOTAVAIL POSIX_EADDRNOTAVAIL
|
---|
| 247 | #define EAFNOSUPPORT POSIX_EAFNOSUPPORT
|
---|
| 248 | #define EAGAIN POSIX_EAGAIN
|
---|
| 249 | #define EALREADY POSIX_EALREADY
|
---|
| 250 | #define EBADF POSIX_EBADF
|
---|
| 251 | #define EBADMSG POSIX_EBADMSG
|
---|
| 252 | #define EBUSY POSIX_EBUSY
|
---|
| 253 | #define ECANCELED POSIX_ECANCELED
|
---|
| 254 | #define ECHILD POSIX_ECHILD
|
---|
| 255 | #define ECONNABORTED POSIX_ECONNABORTED
|
---|
| 256 | #define ECONNREFUSED POSIX_ECONNREFUSED
|
---|
| 257 | #define ECONNRESET POSIX_ECONNRESET
|
---|
| 258 | #define EDEADLK POSIX_EDEADLK
|
---|
| 259 | #define EDESTADDRREQ POSIX_EDESTADDRREQ
|
---|
| 260 | #define EDOM POSIX_EDOM
|
---|
| 261 | #define EDQUOT POSIX_EDQUOT
|
---|
| 262 | #define EEXIST POSIX_EEXIST
|
---|
| 263 | #define EFAULT POSIX_EFAULT
|
---|
| 264 | #define EFBIG POSIX_EFBIG
|
---|
| 265 | #define EHOSTUNREACH POSIX_EHOSTUNREACH
|
---|
| 266 | #define EIDRM POSIX_EIDRM
|
---|
| 267 | #define EILSEQ POSIX_EILSEQ
|
---|
| 268 | #define EINPROGRESS POSIX_EINPROGRESS
|
---|
| 269 | #define EINTR POSIX_EINTR
|
---|
| 270 | #define EINVAL POSIX_EINVAL
|
---|
| 271 | #define EIO POSIX_EIO
|
---|
| 272 | #define EISCONN POSIX_EISCONN
|
---|
| 273 | #define EISDIR POSIX_EISDIR
|
---|
| 274 | #define ELOOP POSIX_ELOOP
|
---|
| 275 | #define EMFILE POSIX_EMFILE
|
---|
| 276 | #define EMLINK POSIX_EMLINK
|
---|
| 277 | #define EMSGSIZE POSIX_EMSGSIZE
|
---|
| 278 | #define EMULTIHOP POSIX_EMULTIHOP
|
---|
| 279 | #define ENAMETOOLONG POSIX_ENAMETOOLONG
|
---|
| 280 | #define ENETDOWN POSIX_ENETDOWN
|
---|
| 281 | #define ENETRESET POSIX_ENETRESET
|
---|
| 282 | #define ENETUNREACH POSIX_ENETUNREACH
|
---|
| 283 | #define ENFILE POSIX_ENFILE
|
---|
| 284 | #define ENOBUFS POSIX_ENOBUFS
|
---|
| 285 | #define ENODATA POSIX_ENODATA
|
---|
| 286 | #define ENODEV POSIX_ENODEV
|
---|
| 287 | #define ENOENT POSIX_ENOENT
|
---|
| 288 | #define ENOEXEC POSIX_ENOEXEC
|
---|
| 289 | #define ENOLCK POSIX_ENOLCK
|
---|
| 290 | #define ENOLINK POSIX_ENOLINK
|
---|
| 291 | #define ENOMEM POSIX_ENOMEM
|
---|
| 292 | #define ENOMSG POSIX_ENOMSG
|
---|
| 293 | #define ENOPROTOOPT POSIX_ENOPROTOOPT
|
---|
| 294 | #define ENOSPC POSIX_ENOSPC
|
---|
| 295 | #define ENOSR POSIX_ENOSR
|
---|
| 296 | #define ENOSTR POSIX_ENOSTR
|
---|
| 297 | #define ENOSYS POSIX_ENOSYS
|
---|
| 298 | #define ENOTCONN POSIX_ENOTCONN
|
---|
| 299 | #define ENOTDIR POSIX_ENOTDIR
|
---|
| 300 | #define ENOTEMPTY POSIX_ENOTEMPTY
|
---|
| 301 | #define ENOTRECOVERABLE POSIX_ENOTRECOVERABLE
|
---|
| 302 | #define ENOTSOCK POSIX_ENOTSOCK
|
---|
| 303 | #define ENOTSUP POSIX_ENOTSUP
|
---|
| 304 | #define ENOTTY POSIX_ENOTTY
|
---|
| 305 | #define ENXIO POSIX_ENXIO
|
---|
| 306 | #define EOPNOTSUPP POSIX_EOPNOTSUPP
|
---|
| 307 | #define EOVERFLOW POSIX_EOVERFLOW
|
---|
| 308 | #define EOWNERDEAD POSIX_EOWNERDEAD
|
---|
| 309 | #define EPERM POSIX_EPERM
|
---|
| 310 | #define EPIPE POSIX_EPIPE
|
---|
| 311 | #define EPROTO POSIX_EPROTO
|
---|
| 312 | #define EPROTONOSUPPORT POSIX_EPROTONOSUPPORT
|
---|
| 313 | #define EPROTOTYPE POSIX_EPROTOTYPE
|
---|
| 314 | #define ERANGE POSIX_ERANGE
|
---|
| 315 | #define EROFS POSIX_EROFS
|
---|
| 316 | #define ESPIPE POSIX_ESPIPE
|
---|
| 317 | #define ESRCH POSIX_ESRCH
|
---|
| 318 | #define ESTALE POSIX_ESTALE
|
---|
| 319 | #define ETIME POSIX_ETIME
|
---|
| 320 | #define ETIMEDOUT POSIX_ETIMEDOUT
|
---|
| 321 | #define ETXTBSY POSIX_ETXTBSY
|
---|
| 322 | #define EWOULDBLOCK POSIX_EWOULDBLOCK
|
---|
| 323 | #define EXDEV POSIX_EXDEV
|
---|
| 324 |
|
---|
| 325 | #endif /* POSIX_ERRNO_H_ */
|
---|
| 326 |
|
---|
| 327 | /** @}
|
---|
| 328 | */
|
---|