Skip to content

lib-socket: implement gai_strerror #4508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
22 changes: 22 additions & 0 deletions core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading