Home | History | Annotate | Line # | Download | only in uv
      1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
      2  *
      3  * Permission is hereby granted, free of charge, to any person obtaining a copy
      4  * of this software and associated documentation files (the "Software"), to
      5  * deal in the Software without restriction, including without limitation the
      6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
      7  * sell copies of the Software, and to permit persons to whom the Software is
      8  * furnished to do so, subject to the following conditions:
      9  *
     10  * The above copyright notice and this permission notice shall be included in
     11  * all copies or substantial portions of the Software.
     12  *
     13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     18  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     19  * IN THE SOFTWARE.
     20  */
     21 
     22 #ifndef UV_ERRNO_H_
     23 #define UV_ERRNO_H_
     24 
     25 #include <errno.h>
     26 #if EDOM > 0
     27 # define UV__ERR(x) (-(x))
     28 #else
     29 # define UV__ERR(x) (x)
     30 #endif
     31 
     32 #define UV__EOF     (-4095)
     33 #define UV__UNKNOWN (-4094)
     34 
     35 #define UV__EAI_ADDRFAMILY  (-3000)
     36 #define UV__EAI_AGAIN       (-3001)
     37 #define UV__EAI_BADFLAGS    (-3002)
     38 #define UV__EAI_CANCELED    (-3003)
     39 #define UV__EAI_FAIL        (-3004)
     40 #define UV__EAI_FAMILY      (-3005)
     41 #define UV__EAI_MEMORY      (-3006)
     42 #define UV__EAI_NODATA      (-3007)
     43 #define UV__EAI_NONAME      (-3008)
     44 #define UV__EAI_OVERFLOW    (-3009)
     45 #define UV__EAI_SERVICE     (-3010)
     46 #define UV__EAI_SOCKTYPE    (-3011)
     47 #define UV__EAI_BADHINTS    (-3013)
     48 #define UV__EAI_PROTOCOL    (-3014)
     49 
     50 /* Only map to the system errno on non-Windows platforms. It's apparently
     51  * a fairly common practice for Windows programmers to redefine errno codes.
     52  */
     53 #if defined(E2BIG) && !defined(_WIN32)
     54 # define UV__E2BIG UV__ERR(E2BIG)
     55 #else
     56 # define UV__E2BIG (-4093)
     57 #endif
     58 
     59 #if defined(EACCES) && !defined(_WIN32)
     60 # define UV__EACCES UV__ERR(EACCES)
     61 #else
     62 # define UV__EACCES (-4092)
     63 #endif
     64 
     65 #if defined(EADDRINUSE) && !defined(_WIN32)
     66 # define UV__EADDRINUSE UV__ERR(EADDRINUSE)
     67 #else
     68 # define UV__EADDRINUSE (-4091)
     69 #endif
     70 
     71 #if defined(EADDRNOTAVAIL) && !defined(_WIN32)
     72 # define UV__EADDRNOTAVAIL UV__ERR(EADDRNOTAVAIL)
     73 #else
     74 # define UV__EADDRNOTAVAIL (-4090)
     75 #endif
     76 
     77 #if defined(EAFNOSUPPORT) && !defined(_WIN32)
     78 # define UV__EAFNOSUPPORT UV__ERR(EAFNOSUPPORT)
     79 #else
     80 # define UV__EAFNOSUPPORT (-4089)
     81 #endif
     82 
     83 #if defined(EAGAIN) && !defined(_WIN32)
     84 # define UV__EAGAIN UV__ERR(EAGAIN)
     85 #else
     86 # define UV__EAGAIN (-4088)
     87 #endif
     88 
     89 #if defined(EALREADY) && !defined(_WIN32)
     90 # define UV__EALREADY UV__ERR(EALREADY)
     91 #else
     92 # define UV__EALREADY (-4084)
     93 #endif
     94 
     95 #if defined(EBADF) && !defined(_WIN32)
     96 # define UV__EBADF UV__ERR(EBADF)
     97 #else
     98 # define UV__EBADF (-4083)
     99 #endif
    100 
    101 #if defined(EBUSY) && !defined(_WIN32)
    102 # define UV__EBUSY UV__ERR(EBUSY)
    103 #else
    104 # define UV__EBUSY (-4082)
    105 #endif
    106 
    107 #if defined(ECANCELED) && !defined(_WIN32)
    108 # define UV__ECANCELED UV__ERR(ECANCELED)
    109 #else
    110 # define UV__ECANCELED (-4081)
    111 #endif
    112 
    113 #if defined(ECHARSET) && !defined(_WIN32)
    114 # define UV__ECHARSET UV__ERR(ECHARSET)
    115 #else
    116 # define UV__ECHARSET (-4080)
    117 #endif
    118 
    119 #if defined(ECONNABORTED) && !defined(_WIN32)
    120 # define UV__ECONNABORTED UV__ERR(ECONNABORTED)
    121 #else
    122 # define UV__ECONNABORTED (-4079)
    123 #endif
    124 
    125 #if defined(ECONNREFUSED) && !defined(_WIN32)
    126 # define UV__ECONNREFUSED UV__ERR(ECONNREFUSED)
    127 #else
    128 # define UV__ECONNREFUSED (-4078)
    129 #endif
    130 
    131 #if defined(ECONNRESET) && !defined(_WIN32)
    132 # define UV__ECONNRESET UV__ERR(ECONNRESET)
    133 #else
    134 # define UV__ECONNRESET (-4077)
    135 #endif
    136 
    137 #if defined(EDESTADDRREQ) && !defined(_WIN32)
    138 # define UV__EDESTADDRREQ UV__ERR(EDESTADDRREQ)
    139 #else
    140 # define UV__EDESTADDRREQ (-4076)
    141 #endif
    142 
    143 #if defined(EEXIST) && !defined(_WIN32)
    144 # define UV__EEXIST UV__ERR(EEXIST)
    145 #else
    146 # define UV__EEXIST (-4075)
    147 #endif
    148 
    149 #if defined(EFAULT) && !defined(_WIN32)
    150 # define UV__EFAULT UV__ERR(EFAULT)
    151 #else
    152 # define UV__EFAULT (-4074)
    153 #endif
    154 
    155 #if defined(EHOSTUNREACH) && !defined(_WIN32)
    156 # define UV__EHOSTUNREACH UV__ERR(EHOSTUNREACH)
    157 #else
    158 # define UV__EHOSTUNREACH (-4073)
    159 #endif
    160 
    161 #if defined(EINTR) && !defined(_WIN32)
    162 # define UV__EINTR UV__ERR(EINTR)
    163 #else
    164 # define UV__EINTR (-4072)
    165 #endif
    166 
    167 #if defined(EINVAL) && !defined(_WIN32)
    168 # define UV__EINVAL UV__ERR(EINVAL)
    169 #else
    170 # define UV__EINVAL (-4071)
    171 #endif
    172 
    173 #if defined(EIO) && !defined(_WIN32)
    174 # define UV__EIO UV__ERR(EIO)
    175 #else
    176 # define UV__EIO (-4070)
    177 #endif
    178 
    179 #if defined(EISCONN) && !defined(_WIN32)
    180 # define UV__EISCONN UV__ERR(EISCONN)
    181 #else
    182 # define UV__EISCONN (-4069)
    183 #endif
    184 
    185 #if defined(EISDIR) && !defined(_WIN32)
    186 # define UV__EISDIR UV__ERR(EISDIR)
    187 #else
    188 # define UV__EISDIR (-4068)
    189 #endif
    190 
    191 #if defined(ELOOP) && !defined(_WIN32)
    192 # define UV__ELOOP UV__ERR(ELOOP)
    193 #else
    194 # define UV__ELOOP (-4067)
    195 #endif
    196 
    197 #if defined(EMFILE) && !defined(_WIN32)
    198 # define UV__EMFILE UV__ERR(EMFILE)
    199 #else
    200 # define UV__EMFILE (-4066)
    201 #endif
    202 
    203 #if defined(EMSGSIZE) && !defined(_WIN32)
    204 # define UV__EMSGSIZE UV__ERR(EMSGSIZE)
    205 #else
    206 # define UV__EMSGSIZE (-4065)
    207 #endif
    208 
    209 #if defined(ENAMETOOLONG) && !defined(_WIN32)
    210 # define UV__ENAMETOOLONG UV__ERR(ENAMETOOLONG)
    211 #else
    212 # define UV__ENAMETOOLONG (-4064)
    213 #endif
    214 
    215 #if defined(ENETDOWN) && !defined(_WIN32)
    216 # define UV__ENETDOWN UV__ERR(ENETDOWN)
    217 #else
    218 # define UV__ENETDOWN (-4063)
    219 #endif
    220 
    221 #if defined(ENETUNREACH) && !defined(_WIN32)
    222 # define UV__ENETUNREACH UV__ERR(ENETUNREACH)
    223 #else
    224 # define UV__ENETUNREACH (-4062)
    225 #endif
    226 
    227 #if defined(ENFILE) && !defined(_WIN32)
    228 # define UV__ENFILE UV__ERR(ENFILE)
    229 #else
    230 # define UV__ENFILE (-4061)
    231 #endif
    232 
    233 #if defined(ENOBUFS) && !defined(_WIN32)
    234 # define UV__ENOBUFS UV__ERR(ENOBUFS)
    235 #else
    236 # define UV__ENOBUFS (-4060)
    237 #endif
    238 
    239 #if defined(ENODEV) && !defined(_WIN32)
    240 # define UV__ENODEV UV__ERR(ENODEV)
    241 #else
    242 # define UV__ENODEV (-4059)
    243 #endif
    244 
    245 #if defined(ENOENT) && !defined(_WIN32)
    246 # define UV__ENOENT UV__ERR(ENOENT)
    247 #else
    248 # define UV__ENOENT (-4058)
    249 #endif
    250 
    251 #if defined(ENOMEM) && !defined(_WIN32)
    252 # define UV__ENOMEM UV__ERR(ENOMEM)
    253 #else
    254 # define UV__ENOMEM (-4057)
    255 #endif
    256 
    257 #if defined(ENONET) && !defined(_WIN32)
    258 # define UV__ENONET UV__ERR(ENONET)
    259 #else
    260 # define UV__ENONET (-4056)
    261 #endif
    262 
    263 #if defined(ENOSPC) && !defined(_WIN32)
    264 # define UV__ENOSPC UV__ERR(ENOSPC)
    265 #else
    266 # define UV__ENOSPC (-4055)
    267 #endif
    268 
    269 #if defined(ENOSYS) && !defined(_WIN32)
    270 # define UV__ENOSYS UV__ERR(ENOSYS)
    271 #else
    272 # define UV__ENOSYS (-4054)
    273 #endif
    274 
    275 #if defined(ENOTCONN) && !defined(_WIN32)
    276 # define UV__ENOTCONN UV__ERR(ENOTCONN)
    277 #else
    278 # define UV__ENOTCONN (-4053)
    279 #endif
    280 
    281 #if defined(ENOTDIR) && !defined(_WIN32)
    282 # define UV__ENOTDIR UV__ERR(ENOTDIR)
    283 #else
    284 # define UV__ENOTDIR (-4052)
    285 #endif
    286 
    287 #if defined(ENOTEMPTY) && !defined(_WIN32)
    288 # define UV__ENOTEMPTY UV__ERR(ENOTEMPTY)
    289 #else
    290 # define UV__ENOTEMPTY (-4051)
    291 #endif
    292 
    293 #if defined(ENOTSOCK) && !defined(_WIN32)
    294 # define UV__ENOTSOCK UV__ERR(ENOTSOCK)
    295 #else
    296 # define UV__ENOTSOCK (-4050)
    297 #endif
    298 
    299 #if defined(ENOTSUP) && !defined(_WIN32)
    300 # define UV__ENOTSUP UV__ERR(ENOTSUP)
    301 #else
    302 # define UV__ENOTSUP (-4049)
    303 #endif
    304 
    305 #if defined(EPERM) && !defined(_WIN32)
    306 # define UV__EPERM UV__ERR(EPERM)
    307 #else
    308 # define UV__EPERM (-4048)
    309 #endif
    310 
    311 #if defined(EPIPE) && !defined(_WIN32)
    312 # define UV__EPIPE UV__ERR(EPIPE)
    313 #else
    314 # define UV__EPIPE (-4047)
    315 #endif
    316 
    317 #if defined(EPROTO) && !defined(_WIN32)
    318 # define UV__EPROTO UV__ERR(EPROTO)
    319 #else
    320 # define UV__EPROTO (-4046)
    321 #endif
    322 
    323 #if defined(EPROTONOSUPPORT) && !defined(_WIN32)
    324 # define UV__EPROTONOSUPPORT UV__ERR(EPROTONOSUPPORT)
    325 #else
    326 # define UV__EPROTONOSUPPORT (-4045)
    327 #endif
    328 
    329 #if defined(EPROTOTYPE) && !defined(_WIN32)
    330 # define UV__EPROTOTYPE UV__ERR(EPROTOTYPE)
    331 #else
    332 # define UV__EPROTOTYPE (-4044)
    333 #endif
    334 
    335 #if defined(EROFS) && !defined(_WIN32)
    336 # define UV__EROFS UV__ERR(EROFS)
    337 #else
    338 # define UV__EROFS (-4043)
    339 #endif
    340 
    341 #if defined(ESHUTDOWN) && !defined(_WIN32)
    342 # define UV__ESHUTDOWN UV__ERR(ESHUTDOWN)
    343 #else
    344 # define UV__ESHUTDOWN (-4042)
    345 #endif
    346 
    347 #if defined(ESPIPE) && !defined(_WIN32)
    348 # define UV__ESPIPE UV__ERR(ESPIPE)
    349 #else
    350 # define UV__ESPIPE (-4041)
    351 #endif
    352 
    353 #if defined(ESRCH) && !defined(_WIN32)
    354 # define UV__ESRCH UV__ERR(ESRCH)
    355 #else
    356 # define UV__ESRCH (-4040)
    357 #endif
    358 
    359 #if defined(ETIMEDOUT) && !defined(_WIN32)
    360 # define UV__ETIMEDOUT UV__ERR(ETIMEDOUT)
    361 #else
    362 # define UV__ETIMEDOUT (-4039)
    363 #endif
    364 
    365 #if defined(ETXTBSY) && !defined(_WIN32)
    366 # define UV__ETXTBSY UV__ERR(ETXTBSY)
    367 #else
    368 # define UV__ETXTBSY (-4038)
    369 #endif
    370 
    371 #if defined(EXDEV) && !defined(_WIN32)
    372 # define UV__EXDEV UV__ERR(EXDEV)
    373 #else
    374 # define UV__EXDEV (-4037)
    375 #endif
    376 
    377 #if defined(EFBIG) && !defined(_WIN32)
    378 # define UV__EFBIG UV__ERR(EFBIG)
    379 #else
    380 # define UV__EFBIG (-4036)
    381 #endif
    382 
    383 #if defined(ENOPROTOOPT) && !defined(_WIN32)
    384 # define UV__ENOPROTOOPT UV__ERR(ENOPROTOOPT)
    385 #else
    386 # define UV__ENOPROTOOPT (-4035)
    387 #endif
    388 
    389 #if defined(ERANGE) && !defined(_WIN32)
    390 # define UV__ERANGE UV__ERR(ERANGE)
    391 #else
    392 # define UV__ERANGE (-4034)
    393 #endif
    394 
    395 #if defined(ENXIO) && !defined(_WIN32)
    396 # define UV__ENXIO UV__ERR(ENXIO)
    397 #else
    398 # define UV__ENXIO (-4033)
    399 #endif
    400 
    401 #if defined(EMLINK) && !defined(_WIN32)
    402 # define UV__EMLINK UV__ERR(EMLINK)
    403 #else
    404 # define UV__EMLINK (-4032)
    405 #endif
    406 
    407 /* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is
    408  * defined. Fortunately, its value is always 64 so it's possible albeit
    409  * icky to hard-code it.
    410  */
    411 #if defined(EHOSTDOWN) && !defined(_WIN32)
    412 # define UV__EHOSTDOWN UV__ERR(EHOSTDOWN)
    413 #elif defined(__APPLE__) || \
    414       defined(__DragonFly__) || \
    415       defined(__FreeBSD__) || \
    416       defined(__NetBSD__) || \
    417       defined(__OpenBSD__)
    418 # define UV__EHOSTDOWN (-64)
    419 #else
    420 # define UV__EHOSTDOWN (-4031)
    421 #endif
    422 
    423 #if defined(EREMOTEIO) && !defined(_WIN32)
    424 # define UV__EREMOTEIO UV__ERR(EREMOTEIO)
    425 #else
    426 # define UV__EREMOTEIO (-4030)
    427 #endif
    428 
    429 #if defined(ENOTTY) && !defined(_WIN32)
    430 # define UV__ENOTTY UV__ERR(ENOTTY)
    431 #else
    432 # define UV__ENOTTY (-4029)
    433 #endif
    434 
    435 #if defined(EFTYPE) && !defined(_WIN32)
    436 # define UV__EFTYPE UV__ERR(EFTYPE)
    437 #else
    438 # define UV__EFTYPE (-4028)
    439 #endif
    440 
    441 #if defined(EILSEQ) && !defined(_WIN32)
    442 # define UV__EILSEQ UV__ERR(EILSEQ)
    443 #else
    444 # define UV__EILSEQ (-4027)
    445 #endif
    446 
    447 #if defined(EOVERFLOW) && !defined(_WIN32)
    448 # define UV__EOVERFLOW UV__ERR(EOVERFLOW)
    449 #else
    450 # define UV__EOVERFLOW (-4026)
    451 #endif
    452 
    453 #if defined(ESOCKTNOSUPPORT) && !defined(_WIN32)
    454 # define UV__ESOCKTNOSUPPORT UV__ERR(ESOCKTNOSUPPORT)
    455 #else
    456 # define UV__ESOCKTNOSUPPORT (-4025)
    457 #endif
    458 
    459 /* FreeBSD defines ENODATA in /usr/include/c++/v1/errno.h which is only visible
    460  * if C++ is being used. Define it directly to avoid problems when integrating
    461  * libuv in a C++ project.
    462  */
    463 #if defined(ENODATA) && !defined(_WIN32)
    464 # define UV__ENODATA UV__ERR(ENODATA)
    465 #elif defined(__FreeBSD__)
    466 # define UV__ENODATA (-9919)
    467 #else
    468 # define UV__ENODATA (-4024)
    469 #endif
    470 
    471 #if defined(EUNATCH) && !defined(_WIN32)
    472 # define UV__EUNATCH UV__ERR(EUNATCH)
    473 #else
    474 # define UV__EUNATCH (-4023)
    475 #endif
    476 
    477 #if defined(ENOEXEC) && !defined(_WIN32)
    478 # define UV__ENOEXEC UV__ERR(ENOEXEC)
    479 #else
    480 # define UV__ENOEXEC (-4022)
    481 #endif
    482 
    483 #endif /* UV_ERRNO_H_ */
    484