Skip to content

Commit f34d28c

Browse files
authored
1 parent 224b426 commit f34d28c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
219219

220220
void
221221
freeaddrinfo(struct addrinfo *res);
222+
223+
const char *
224+
gai_strerror(int code);
222225
#endif
223226

224227
/**

core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,28 @@ freeaddrinfo(struct addrinfo *res)
590590
free(res);
591591
}
592592

593+
const char *
594+
gai_strerror(int code)
595+
{
596+
switch (code) {
597+
#define ERR(a) \
598+
case a: \
599+
return #a
600+
ERR(EAI_AGAIN);
601+
ERR(EAI_BADFLAGS);
602+
ERR(EAI_FAIL);
603+
ERR(EAI_FAMILY);
604+
ERR(EAI_MEMORY);
605+
ERR(EAI_NONAME);
606+
ERR(EAI_OVERFLOW);
607+
ERR(EAI_SERVICE);
608+
ERR(EAI_SOCKTYPE);
609+
ERR(EAI_SYSTEM);
610+
#undef ERR
611+
}
612+
return "Unknown error";
613+
}
614+
593615
static struct timeval
594616
time_us_to_timeval(uint64_t time_us)
595617
{

0 commit comments

Comments
 (0)