mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-09-08 18:59:35 +00:00
lib-socket: implement gai_strerror (#4508)
cf. https://pubs.opengroup.org/onlinepubs/9799919799/functions/gai_strerror.html
This commit is contained in:
parent
224b426d70
commit
f34d28cfbc
|
@ -219,6 +219,9 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
|
|||
|
||||
void
|
||||
freeaddrinfo(struct addrinfo *res);
|
||||
|
||||
const char *
|
||||
gai_strerror(int code);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -590,6 +590,28 @@ freeaddrinfo(struct addrinfo *res)
|
|||
free(res);
|
||||
}
|
||||
|
||||
const char *
|
||||
gai_strerror(int code)
|
||||
{
|
||||
switch (code) {
|
||||
#define ERR(a) \
|
||||
case a: \
|
||||
return #a
|
||||
ERR(EAI_AGAIN);
|
||||
ERR(EAI_BADFLAGS);
|
||||
ERR(EAI_FAIL);
|
||||
ERR(EAI_FAMILY);
|
||||
ERR(EAI_MEMORY);
|
||||
ERR(EAI_NONAME);
|
||||
ERR(EAI_OVERFLOW);
|
||||
ERR(EAI_SERVICE);
|
||||
ERR(EAI_SOCKTYPE);
|
||||
ERR(EAI_SYSTEM);
|
||||
#undef ERR
|
||||
}
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
static struct timeval
|
||||
time_us_to_timeval(uint64_t time_us)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user