Drop support for 3 argument gethostbyname_r()

This seems to have been used by old versions of IRIX and shouldn't be in
use anywhere any more, so simplify the code by not taking this prototype
into account any more.
This commit is contained in:
Vadim Zeitlin
2026-04-07 23:38:23 +02:00
parent 6ad18e66cb
commit 771c730ac8
5 changed files with 4 additions and 44 deletions
-6
View File
@@ -367,12 +367,6 @@ if(UNIX)
check_symbol_exists(gethostbyname netdb.h HAVE_GETHOSTBYNAME)
check_symbol_exists(gethostbyname_r netdb.h HAVE_GETHOSTBYNAME_R)
if(HAVE_GETHOSTBYNAME_R)
check_prototype_definition(gethostbyname_r
"int gethostbyname_r(const char *name, struct hostent *hp, struct hostent_data *hdata)"
"0"
"netdb.h"
HAVE_FUNC_GETHOSTBYNAME_R_3)
check_prototype_definition(gethostbyname_r
"struct hostent *gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, int *herr)"
"NULL"
-3
View File
@@ -971,9 +971,6 @@
/* Define if you have a gethostbyname_r function taking 5 arguments. */
#cmakedefine HAVE_FUNC_GETHOSTBYNAME_R_5 1
/* Define if you have a gethostbyname_r function taking 3 arguments. */
#cmakedefine HAVE_FUNC_GETHOSTBYNAME_R_3 1
/* Define if you only have a gethostbyname function */
#cmakedefine HAVE_GETHOSTBYNAME 1
-3
View File
@@ -970,9 +970,6 @@
/* Define if you have a gethostbyname_r function taking 5 arguments. */
#undef HAVE_FUNC_GETHOSTBYNAME_R_5
/* Define if you have a gethostbyname_r function taking 3 arguments. */
#undef HAVE_FUNC_GETHOSTBYNAME_R_3
/* Define if you only have a gethostbyname function */
#undef HAVE_GETHOSTBYNAME
-3
View File
@@ -1040,9 +1040,6 @@ typedef pid_t GPid;
/* Define if you have a gethostbyname_r function taking 5 arguments. */
#undef HAVE_FUNC_GETHOSTBYNAME_R_5
/* Define if you have a gethostbyname_r function taking 3 arguments. */
#undef HAVE_FUNC_GETHOSTBYNAME_R_3
/* Define if you only have a gethostbyname function */
#define HAVE_GETHOSTBYNAME 1
+4 -29
View File
@@ -103,9 +103,6 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress);
// tests for gethostbyaddr_r() to configure later
#define HAVE_GETHOSTBYADDR HAVE_GETHOSTBYNAME
#ifdef HAVE_FUNC_GETHOSTBYNAME_R_3
#define HAVE_FUNC_GETHOSTBYADDR_R_3
#endif
#ifdef HAVE_FUNC_GETHOSTBYNAME_R_5
#define HAVE_FUNC_GETHOSTBYADDR_R_5
#endif
@@ -113,21 +110,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress);
#define HAVE_FUNC_GETHOSTBYADDR_R_6
#endif
// the _r functions need the extra buffer parameter but unfortunately its type
// differs between different systems and for the systems which use opaque
// structs for it (at least AIX and OpenBSD) it must be zero-filled before
// being passed to the system functions
#ifdef HAVE_FUNC_GETHOSTBYNAME_R_3
struct wxGethostBuf : hostent_data
{
wxGethostBuf()
{
memset(this, 0, sizeof(hostent_data));
}
};
#else
typedef char wxGethostBuf[4096];
#endif
typedef char wxGethostBuf[4096];
#ifdef HAVE_FUNC_GETSERVBYNAME_R_4
struct wxGetservBuf : servent_data
@@ -166,8 +149,7 @@ namespace
#if defined(HAVE_GETHOSTBYNAME) && \
!defined(HAVE_FUNC_GETHOSTBYNAME_R_6) && \
!defined(HAVE_FUNC_GETHOSTBYNAME_R_5) && \
!defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
!defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
hostent *deepCopyHostent(hostent *h,
const hostent *he,
@@ -264,11 +246,8 @@ hostent *wxGethostbyname_r(const char *hostname,
gethostbyname_r(hostname, h, buffer, size, &he, err);
#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
he = gethostbyname_r(hostname, h, buffer, size, err);
#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
wxUnusedVar(var);
*err = gethostbyname_r(hostname, h, &buffer);
he = h;
#elif defined(HAVE_GETHOSTBYNAME)
#else
// Fall back on gethostbyname() which is assumed to be always available.
wxLOCK_GETBY_MUTEX(name);
he = gethostbyname(hostname);
@@ -296,10 +275,6 @@ hostent *wxGethostbyaddr_r(const char *addr_buf,
gethostbyaddr_r(addr_buf, buf_size, proto, h, buffer, size, &he, err);
#elif defined(HAVE_FUNC_GETHOSTBYADDR_R_5)
he = gethostbyaddr_r(addr_buf, buf_size, proto, h, buffer, size, err);
#elif defined(HAVE_FUNC_GETHOSTBYADDR_R_3)
wxUnusedVar(size);
*err = gethostbyaddr_r(addr_buf, buf_size, proto, h, &buffer);
he = h;
#elif defined(HAVE_GETHOSTBYADDR)
wxLOCK_GETBY_MUTEX(addr);