-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather than storing them in a loop-global field. A code snippet like this one: if (uv_foo(loop) < 0) { uv_err_t err = uv_last_error(loop); fprintf(stderr, "%s\n", uv_strerror(err)); } Should be rewritten like this: int err = uv_foo(loop); if (err < 0) fprintf(stderr, "%s\n", uv_strerror(err)); The rationale for this change is that it should make creating bindings for other languages a lot easier: dealing with struct return values is painful with most FFIs and often downright buggy.
- Loading branch information
1 parent
13f73fa
commit 3ee4d3f
Showing
109 changed files
with
2,586 additions
and
2,438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,365 @@ | ||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef UV_ERRNO_H_ | ||
#define UV_ERRNO_H_ | ||
|
||
#include <errno.h> | ||
|
||
#define UV__EOF (-4095) | ||
#define UV__UNKNOWN (-4094) | ||
|
||
#define UV__EAI_ADDRFAMILY (-3000) | ||
#define UV__EAI_AGAIN (-3001) | ||
#define UV__EAI_BADFLAGS (-3002) | ||
#define UV__EAI_CANCELED (-3003) | ||
#define UV__EAI_FAIL (-3004) | ||
#define UV__EAI_FAMILY (-3005) | ||
#define UV__EAI_MEMORY (-3006) | ||
#define UV__EAI_NODATA (-3007) | ||
#define UV__EAI_NONAME (-3008) | ||
#define UV__EAI_OVERFLOW (-3009) | ||
#define UV__EAI_SERVICE (-3010) | ||
#define UV__EAI_SOCKTYPE (-3011) | ||
#define UV__EAI_SYSTEM (-3012) /* TODO(bnoordhuis) Return system error. */ | ||
|
||
/* Only map to the system errno on non-Windows platforms. It's apparently | ||
* a fairly common practice for Windows programmers to redefine errno codes. | ||
*/ | ||
#if defined(EACCES) && !defined(_WIN32) | ||
# define UV__EACCES (-EACCES) | ||
#else | ||
# define UV__EACCES (-4093) | ||
#endif | ||
|
||
#if defined(EADDRINFO) && !defined(_WIN32) | ||
# define UV__EADDRINFO EADDRINFO | ||
#else | ||
# define UV__EADDRINFO (-4092) | ||
#endif | ||
|
||
#if defined(EADDRINUSE) && !defined(_WIN32) | ||
# define UV__EADDRINUSE (-EADDRINUSE) | ||
#else | ||
# define UV__EADDRINUSE (-4092) | ||
#endif | ||
|
||
#if defined(EADDRNOTAVAIL) && !defined(_WIN32) | ||
# define UV__EADDRNOTAVAIL (-EADDRNOTAVAIL) | ||
#else | ||
# define UV__EADDRNOTAVAIL (-4091) | ||
#endif | ||
|
||
#if defined(EAFNOSUPPORT) && !defined(_WIN32) | ||
# define UV__EAFNOSUPPORT (-EAFNOSUPPORT) | ||
#else | ||
# define UV__EAFNOSUPPORT (-4090) | ||
#endif | ||
|
||
#if defined(EAGAIN) && !defined(_WIN32) | ||
# define UV__EAGAIN (-EAGAIN) | ||
#else | ||
# define UV__EAGAIN (-4089) | ||
#endif | ||
|
||
#if defined(EALREADY) && !defined(_WIN32) | ||
# define UV__EALREADY (-EALREADY) | ||
#else | ||
# define UV__EALREADY (-4085) | ||
#endif | ||
|
||
#if defined(EBADF) && !defined(_WIN32) | ||
# define UV__EBADF (-EBADF) | ||
#else | ||
# define UV__EBADF (-4084) | ||
#endif | ||
|
||
#if defined(EBUSY) && !defined(_WIN32) | ||
# define UV__EBUSY (-EBUSY) | ||
#else | ||
# define UV__EBUSY (-4083) | ||
#endif | ||
|
||
#if defined(ECANCELED) && !defined(_WIN32) | ||
# define UV__ECANCELED (-ECANCELED) | ||
#else | ||
# define UV__ECANCELED (-4082) | ||
#endif | ||
|
||
#if defined(ECHARSET) && !defined(_WIN32) | ||
# define UV__ECHARSET (-ECHARSET) | ||
#else | ||
# define UV__ECHARSET (-4081) | ||
#endif | ||
|
||
#if defined(ECONNABORTED) && !defined(_WIN32) | ||
# define UV__ECONNABORTED (-ECONNABORTED) | ||
#else | ||
# define UV__ECONNABORTED (-4080) | ||
#endif | ||
|
||
#if defined(ECONNREFUSED) && !defined(_WIN32) | ||
# define UV__ECONNREFUSED (-ECONNREFUSED) | ||
#else | ||
# define UV__ECONNREFUSED (-4079) | ||
#endif | ||
|
||
#if defined(ECONNRESET) && !defined(_WIN32) | ||
# define UV__ECONNRESET (-ECONNRESET) | ||
#else | ||
# define UV__ECONNRESET (-4078) | ||
#endif | ||
|
||
#if defined(EDESTADDRREQ) && !defined(_WIN32) | ||
# define UV__EDESTADDRREQ (-EDESTADDRREQ) | ||
#else | ||
# define UV__EDESTADDRREQ (-4077) | ||
#endif | ||
|
||
#if defined(EEXIST) && !defined(_WIN32) | ||
# define UV__EEXIST (-EEXIST) | ||
#else | ||
# define UV__EEXIST (-4076) | ||
#endif | ||
|
||
#if defined(EFAULT) && !defined(_WIN32) | ||
# define UV__EFAULT (-EFAULT) | ||
#else | ||
# define UV__EFAULT (-4075) | ||
#endif | ||
|
||
#if defined(EHOSTUNREACH) && !defined(_WIN32) | ||
# define UV__EHOSTUNREACH (-EHOSTUNREACH) | ||
#else | ||
# define UV__EHOSTUNREACH (-4074) | ||
#endif | ||
|
||
#if defined(EINTR) && !defined(_WIN32) | ||
# define UV__EINTR (-EINTR) | ||
#else | ||
# define UV__EINTR (-4073) | ||
#endif | ||
|
||
#if defined(EINVAL) && !defined(_WIN32) | ||
# define UV__EINVAL (-EINVAL) | ||
#else | ||
# define UV__EINVAL (-4072) | ||
#endif | ||
|
||
#if defined(EIO) && !defined(_WIN32) | ||
# define UV__EIO (-EIO) | ||
#else | ||
# define UV__EIO (-4071) | ||
#endif | ||
|
||
#if defined(EISCONN) && !defined(_WIN32) | ||
# define UV__EISCONN (-EISCONN) | ||
#else | ||
# define UV__EISCONN (-4070) | ||
#endif | ||
|
||
#if defined(EISDIR) && !defined(_WIN32) | ||
# define UV__EISDIR (-EISDIR) | ||
#else | ||
# define UV__EISDIR (-4069) | ||
#endif | ||
|
||
#if defined(ELOOP) && !defined(_WIN32) | ||
# define UV__ELOOP (-ELOOP) | ||
#else | ||
# define UV__ELOOP (-4068) | ||
#endif | ||
|
||
#if defined(EMFILE) && !defined(_WIN32) | ||
# define UV__EMFILE (-EMFILE) | ||
#else | ||
# define UV__EMFILE (-4067) | ||
#endif | ||
|
||
#if defined(EMSGSIZE) && !defined(_WIN32) | ||
# define UV__EMSGSIZE (-EMSGSIZE) | ||
#else | ||
# define UV__EMSGSIZE (-4066) | ||
#endif | ||
|
||
#if defined(ENAMETOOLONG) && !defined(_WIN32) | ||
# define UV__ENAMETOOLONG (-ENAMETOOLONG) | ||
#else | ||
# define UV__ENAMETOOLONG (-4065) | ||
#endif | ||
|
||
#if defined(ENETDOWN) && !defined(_WIN32) | ||
# define UV__ENETDOWN (-ENETDOWN) | ||
#else | ||
# define UV__ENETDOWN (-4064) | ||
#endif | ||
|
||
#if defined(ENETUNREACH) && !defined(_WIN32) | ||
# define UV__ENETUNREACH (-ENETUNREACH) | ||
#else | ||
# define UV__ENETUNREACH (-4063) | ||
#endif | ||
|
||
#if defined(ENFILE) && !defined(_WIN32) | ||
# define UV__ENFILE (-ENFILE) | ||
#else | ||
# define UV__ENFILE (-4062) | ||
#endif | ||
|
||
#if defined(ENOBUFS) && !defined(_WIN32) | ||
# define UV__ENOBUFS (-ENOBUFS) | ||
#else | ||
# define UV__ENOBUFS (-4061) | ||
#endif | ||
|
||
#if defined(ENODEV) && !defined(_WIN32) | ||
# define UV__ENODEV (-ENODEV) | ||
#else | ||
# define UV__ENODEV (-4060) | ||
#endif | ||
|
||
#if defined(ENOENT) && !defined(_WIN32) | ||
# define UV__ENOENT (-ENOENT) | ||
#else | ||
# define UV__ENOENT (-4059) | ||
#endif | ||
|
||
#if defined(ENOMEM) && !defined(_WIN32) | ||
# define UV__ENOMEM (-ENOMEM) | ||
#else | ||
# define UV__ENOMEM (-4058) | ||
#endif | ||
|
||
#if defined(ENONET) && !defined(_WIN32) | ||
# define UV__ENONET (-ENONET) | ||
#else | ||
# define UV__ENONET (-4057) | ||
#endif | ||
|
||
#if defined(ENOSPC) && !defined(_WIN32) | ||
# define UV__ENOSPC (-ENOSPC) | ||
#else | ||
# define UV__ENOSPC (-4056) | ||
#endif | ||
|
||
#if defined(ENOSYS) && !defined(_WIN32) | ||
# define UV__ENOSYS (-ENOSYS) | ||
#else | ||
# define UV__ENOSYS (-4055) | ||
#endif | ||
|
||
#if defined(ENOTCONN) && !defined(_WIN32) | ||
# define UV__ENOTCONN (-ENOTCONN) | ||
#else | ||
# define UV__ENOTCONN (-4054) | ||
#endif | ||
|
||
#if defined(ENOTDIR) && !defined(_WIN32) | ||
# define UV__ENOTDIR (-ENOTDIR) | ||
#else | ||
# define UV__ENOTDIR (-4053) | ||
#endif | ||
|
||
#if defined(ENOTEMPTY) && !defined(_WIN32) | ||
# define UV__ENOTEMPTY (-ENOTEMPTY) | ||
#else | ||
# define UV__ENOTEMPTY (-4052) | ||
#endif | ||
|
||
#if defined(ENOTSOCK) && !defined(_WIN32) | ||
# define UV__ENOTSOCK (-ENOTSOCK) | ||
#else | ||
# define UV__ENOTSOCK (-4051) | ||
#endif | ||
|
||
#if defined(ENOTSUP) && !defined(_WIN32) | ||
# define UV__ENOTSUP (-ENOTSUP) | ||
#else | ||
# define UV__ENOTSUP (-4050) | ||
#endif | ||
|
||
#if defined(EPERM) && !defined(_WIN32) | ||
# define UV__EPERM (-EPERM) | ||
#else | ||
# define UV__EPERM (-4049) | ||
#endif | ||
|
||
#if defined(EPIPE) && !defined(_WIN32) | ||
# define UV__EPIPE (-EPIPE) | ||
#else | ||
# define UV__EPIPE (-4048) | ||
#endif | ||
|
||
#if defined(EPROTO) && !defined(_WIN32) | ||
# define UV__EPROTO (-EPROTO) | ||
#else | ||
# define UV__EPROTO (-4047) | ||
#endif | ||
|
||
#if defined(EPROTONOSUPPORT) && !defined(_WIN32) | ||
# define UV__EPROTONOSUPPORT (-EPROTONOSUPPORT) | ||
#else | ||
# define UV__EPROTONOSUPPORT (-4046) | ||
#endif | ||
|
||
#if defined(EPROTOTYPE) && !defined(_WIN32) | ||
# define UV__EPROTOTYPE (-EPROTOTYPE) | ||
#else | ||
# define UV__EPROTOTYPE (-4045) | ||
#endif | ||
|
||
#if defined(EROFS) && !defined(_WIN32) | ||
# define UV__EROFS (-EROFS) | ||
#else | ||
# define UV__EROFS (-4044) | ||
#endif | ||
|
||
#if defined(ESHUTDOWN) && !defined(_WIN32) | ||
# define UV__ESHUTDOWN (-ESHUTDOWN) | ||
#else | ||
# define UV__ESHUTDOWN (-4043) | ||
#endif | ||
|
||
#if defined(ESPIPE) && !defined(_WIN32) | ||
# define UV__ESPIPE (-ESPIPE) | ||
#else | ||
# define UV__ESPIPE (-4042) | ||
#endif | ||
|
||
#if defined(ESRCH) && !defined(_WIN32) | ||
# define UV__ESRCH (-ESRCH) | ||
#else | ||
# define UV__ESRCH (-4041) | ||
#endif | ||
|
||
#if defined(ETIMEDOUT) && !defined(_WIN32) | ||
# define UV__ETIMEDOUT (-ETIMEDOUT) | ||
#else | ||
# define UV__ETIMEDOUT (-4040) | ||
#endif | ||
|
||
#if defined(EXDEV) && !defined(_WIN32) | ||
# define UV__EXDEV (-EXDEV) | ||
#else | ||
# define UV__EXDEV (-4038) | ||
#endif | ||
|
||
#endif /* UV_ERRNO_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.