From f13aba250fca66c6aa696751b6d35666bc1c6751 Mon Sep 17 00:00:00 2001 From: duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:26:59 -0500 Subject: [PATCH 1/3] configure.ac: look for the socket functions in libnetwork too Haiku has inet_pton(), the other socket functions and h_errno in libnetwork. Without it, the JNI libraries fail to load (undefined __h_errno) and configure does not find the socket functions. Co-Authored-By: Claude Opus 5.5 Signed-off-by: duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com> --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 5c79f3cfd..a106e1eed 100644 --- a/configure.ac +++ b/configure.ac @@ -440,7 +440,8 @@ if test "x${COMPILE_JNI}" = xyes; then AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t])) AC_SEARCH_LIBS([clock_gettime], [rt]) - AC_SEARCH_LIBS([inet_pton],[nsl]) + dnl Haiku has the socket functions and h_errno in libnetwork. + AC_SEARCH_LIBS([inet_pton],[nsl network]) AC_CHECK_LIB([socket], [gethostname]) AC_CHECK_FUNCS([ftruncate fsync select \ From b01aa0732f1b41e7a6f901224816465204d7a5d0 Mon Sep 17 00:00:00 2001 From: duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:26:59 -0500 Subject: [PATCH 2/3] VMNetworkInterface: define IFF_RUNNING if the system lacks it Haiku does not define IFF_RUNNING. Co-Authored-By: Claude Opus 5.5 Signed-off-by: duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com> --- native/jni/java-net/java_net_VMNetworkInterface.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/native/jni/java-net/java_net_VMNetworkInterface.c b/native/jni/java-net/java_net_VMNetworkInterface.c index 658299733..90da75857 100644 --- a/native/jni/java-net/java_net_VMNetworkInterface.c +++ b/native/jni/java-net/java_net_VMNetworkInterface.c @@ -51,6 +51,11 @@ exception statement from your version. */ #include #include + +/* Haiku does not define IFF_RUNNING. */ +#ifndef IFF_RUNNING +#define IFF_RUNNING 0x40 +#endif #include /* Required on Solaris. */ #include From 611618a11dae84fe1ad376810ca4f723bbe96d38 Mon Sep 17 00:00:00 2001 From: duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:26:59 -0500 Subject: [PATCH 3/3] 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 <206344294+duncanmcqueen@users.noreply.github.com> --- 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)