fix(build): Use gai_strerrorA not gai_strerror on Windows

* Explicitly call gai_strerrorA (for Windows builds), so that the code work correctly in 32bit or 64bit builds.

* Implement GAI_STRERROR macro to deal with Windows vs. Non-Windows compiles for 64-bit.

* make usocket.c consistent with other modules that call macro GAI_STRERROR

* Use different name not just different case for macro wrapping function

Co-authored-by: Caleb Maclennan <caleb@alerque.com>
This commit is contained in:
rpatters1 2022-07-27 01:51:35 -05:00 committed by GitHub
parent d1ad8160cb
commit 5a7e3f0888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 6 deletions

4
src/inet.c Normal file → Executable file
View file

@ -253,7 +253,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
lua_pushstring(L, LUA_GAI_STRERROR(err));
return 2;
}
lua_pushstring(L, name);
@ -286,7 +286,7 @@ int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
lua_pushstring(L, LUA_GAI_STRERROR(err));
return 2;
}
lua_pushstring(L, name);