From c4e3f027f2a94df99d78e3ad0c013ae0bf04c83a Mon Sep 17 00:00:00 2001 From: duncanmcqueen Date: Wed, 14 Oct 2026 08:26:59 -0500 Subject: [PATCH] cpnet: use gethostbyname_r() only when its declaration is known On Haiku, gethostbyname_r() is in libnetwork but no header declares it, so configure finds the function but not the number of arguments, and cpnet.c stops with #error. Use gethostbyname() in that case. Co-Authored-By: Claude Opus 5.5 Signed-off-by: duncanmcqueen --- native/jni/native-lib/cpnet.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/native/jni/native-lib/cpnet.c b/native/jni/native-lib/cpnet.c index 534eaa46e..eeced7d6a 100644 --- a/native/jni/native-lib/cpnet.c +++ b/native/jni/native-lib/cpnet.c @@ -645,7 +645,12 @@ jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***ad { buf = (char *)JCL_malloc(env, buflen); -#ifdef HAVE_GETHOSTBYNAME_R +/* Use gethostbyname_r only if its declaration was found. Haiku has the + function in libnetwork but does not declare it. */ +#if defined(HAVE_GETHOSTBYNAME_R) \ + && (defined(HAVE_FUNC_GETHOSTBYNAME_R_6) \ + || defined(HAVE_FUNC_GETHOSTBYNAME_R_5) \ + || defined(HAVE_FUNC_GETHOSTBYNAME_R_3)) # if defined(HAVE_FUNC_GETHOSTBYNAME_R_6) ret = gethostbyname_r (hostname, &hret, buf, buflen, &result, &herr); # elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)