Add uv-common.c, move uv_err_name() there
This commit is contained in:
parent
9c2dd6bea9
commit
0177751ff5
@ -32,11 +32,14 @@ RUNNER_LINKFLAGS=$(LINKFLAGS)
|
||||
RUNNER_LIBS=-lws2_32
|
||||
RUNNER_SRC=test/runner-win.c
|
||||
|
||||
uv.a: uv-win.o
|
||||
$(AR) rcs uv.a uv-win.o
|
||||
uv.a: uv-win.o uv-common.o
|
||||
$(AR) rcs uv.a uv-win.o uv-common.o
|
||||
|
||||
uv-win.o: uv-win.c uv.h uv-win.h
|
||||
$(CC) $(CFLAGS) -c uv-win.c -o uv-win.o
|
||||
|
||||
uv-common.o: uv-common.c uv.h uv-win.h
|
||||
$(CC) $(CFLAGS) -c uv-common.c -o uv-common.o
|
||||
|
||||
distclean-platform:
|
||||
clean-platform:
|
||||
|
||||
@ -35,12 +35,15 @@ RUNNER_LINKFLAGS=$(LINKFLAGS) -pthread
|
||||
RUNNER_LIBS=
|
||||
RUNNER_SRC=test/runner-unix.c
|
||||
|
||||
uv.a: uv-unix.o ev/ev.o
|
||||
$(AR) rcs uv.a uv-unix.o ev/ev.o
|
||||
uv.a: uv-unix.o uv-common.o ev/ev.o
|
||||
$(AR) rcs uv.a uv-unix.o uv-common.o ev/ev.o
|
||||
|
||||
uv-unix.o: uv-unix.c uv.h uv-unix.h
|
||||
$(CC) $(CFLAGS) -c uv-unix.c -o uv-unix.o
|
||||
|
||||
uv-common.o: uv-common.c uv.h uv-unix.h
|
||||
$(CC) $(CFLAGS) -c uv-common.c -o uv-common.o
|
||||
|
||||
ev/ev.o: ev/config.h ev/ev.c
|
||||
$(MAKE) -C ev
|
||||
|
||||
|
||||
@ -119,9 +119,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\uv-win.c" />
|
||||
<ClCompile Include="..\uv-common.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\AUTHORS" />
|
||||
<None Include="..\config-mingw.mk" />
|
||||
<None Include="..\config-unix.mk" />
|
||||
<None Include="..\iocp-links.html" />
|
||||
<None Include="..\LICENSE" />
|
||||
<None Include="..\Makefile" />
|
||||
|
||||
68
uv-common.c
Normal file
68
uv-common.c
Normal file
@ -0,0 +1,68 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "uv.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
const char* uv_err_name(uv_err_t err) {
|
||||
switch (err.code) {
|
||||
case UV_UNKNOWN: return "UNKNOWN";
|
||||
case UV_OK: return "OK";
|
||||
case UV_EOF: return "EOF";
|
||||
case UV_EACCESS: return "EACCESS";
|
||||
case UV_EAGAIN: return "EAGAIN";
|
||||
case UV_EADDRINUSE: return "EADDRINUSE";
|
||||
case UV_EADDRNOTAVAIL: return "EADDRNOTAVAIL";
|
||||
case UV_EAFNOSUPPORT: return "EAFNOSUPPORT";
|
||||
case UV_EALREADY: return "EALREADY";
|
||||
case UV_EBADF: return "EBADF";
|
||||
case UV_EBUSY: return "EBUSY";
|
||||
case UV_ECONNABORTED: return "ECONNABORTED";
|
||||
case UV_ECONNREFUSED: return "ECONNREFUSED";
|
||||
case UV_ECONNRESET: return "ECONNRESET";
|
||||
case UV_EDESTADDRREQ: return "EDESTADDRREQ";
|
||||
case UV_EFAULT: return "EFAULT";
|
||||
case UV_EHOSTUNREACH: return "EHOSTUNREACH";
|
||||
case UV_EINTR: return "EINTR";
|
||||
case UV_EINVAL: return "EINVAL";
|
||||
case UV_EISCONN: return "EISCONN";
|
||||
case UV_EMFILE: return "EMFILE";
|
||||
case UV_ENETDOWN: return "ENETDOWN";
|
||||
case UV_ENETUNREACH: return "ENETUNREACH";
|
||||
case UV_ENFILE: return "ENFILE";
|
||||
case UV_ENOBUFS: return "ENOBUFS";
|
||||
case UV_ENOMEM: return "ENOMEM";
|
||||
case UV_ENONET: return "ENONET";
|
||||
case UV_ENOPROTOOPT: return "ENOPROTOOPT";
|
||||
case UV_ENOTCONN: return "ENOTCONN";
|
||||
case UV_ENOTSOCK: return "ENOTSOCK";
|
||||
case UV_ENOTSUP: return "ENOTSUP";
|
||||
case UV_EPROTO: return "EPROTO";
|
||||
case UV_EPROTONOSUPPORT: return "EPROTONOSUPPORT";
|
||||
case UV_EPROTOTYPE: return "EPROTOTYPE";
|
||||
case UV_ETIMEDOUT: return "ETIMEDOUT";
|
||||
default:
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
44
uv-unix.c
44
uv-unix.c
@ -44,50 +44,6 @@ int uv_tcp_open(uv_handle_t*, int fd);
|
||||
static void uv__finish_close(uv_handle_t* handle);
|
||||
|
||||
|
||||
const char* uv_err_tostr(uv_err_code code) {
|
||||
switch (code) {
|
||||
case UV_UNKNOWN: return "UNKNOWN";
|
||||
case UV_OK: return "OK";
|
||||
case UV_EOF: return "EOF";
|
||||
case UV_EACCESS: return "EACCESS";
|
||||
case UV_EAGAIN: return "EAGAIN";
|
||||
case UV_EADDRINUSE: return "EADDRINUSE";
|
||||
case UV_EADDRNOTAVAIL: return "EADDRNOTAVAIL";
|
||||
case UV_EAFNOSUPPORT: return "EAFNOSUPPORT";
|
||||
case UV_EALREADY: return "EALREADY";
|
||||
case UV_EBADF: return "EBADF";
|
||||
case UV_EBUSY: return "EBUSY";
|
||||
case UV_ECONNABORTED: return "ECONNABORTED";
|
||||
case UV_ECONNREFUSED: return "ECONNREFUSED";
|
||||
case UV_ECONNRESET: return "ECONNRESET";
|
||||
case UV_EDESTADDRREQ: return "EDESTADDRREQ";
|
||||
case UV_EFAULT: return "EFAULT";
|
||||
case UV_EHOSTUNREACH: return "EHOSTUNREACH";
|
||||
case UV_EINTR: return "EINTR";
|
||||
case UV_EINVAL: return "EINVAL";
|
||||
case UV_EISCONN: return "EISCONN";
|
||||
case UV_EMFILE: return "EMFILE";
|
||||
case UV_ENETDOWN: return "ENETDOWN";
|
||||
case UV_ENETUNREACH: return "ENETUNREACH";
|
||||
case UV_ENFILE: return "ENFILE";
|
||||
case UV_ENOBUFS: return "ENOBUFS";
|
||||
case UV_ENOMEM: return "ENOMEM";
|
||||
case UV_ENONET: return "ENONET";
|
||||
case UV_ENOPROTOOPT: return "ENOPROTOOPT";
|
||||
case UV_ENOTCONN: return "ENOTCONN";
|
||||
case UV_ENOTSOCK: return "ENOTSOCK";
|
||||
case UV_ENOTSUP: return "ENOTSUP";
|
||||
case UV_EPROTO: return "EPROTO";
|
||||
case UV_EPROTONOSUPPORT: return "EPROTONOSUPPORT";
|
||||
case UV_EPROTOTYPE: return "EPROTOTYPE";
|
||||
case UV_ETIMEDOUT: return "ETIMEDOUT";
|
||||
default:
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* flags */
|
||||
enum {
|
||||
UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user