From 7355353cafc81403c3d14ccb088e82370ce73c55 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 29 Oct 2020 14:07:26 +0100
Subject: Haiku: workaround for NetworkInterface ioctl calls

ATM the Haiku network stack checks for ioctl syscall length parameter.

diff --git a/src/java.base/unix/native/libnet/NetworkInterface.c b/src/java.base/unix/native/libnet/NetworkInterface.c
index e558463..fbb0e40 100644
--- a/src/java.base/unix/native/libnet/NetworkInterface.c
+++ b/src/java.base/unix/native/libnet/NetworkInterface.c
@@ -2299,7 +2299,7 @@ static int getIndex(int sock, const char *name) {
     memset((char *)&if2, 0, sizeof(if2));
     strncpy(if2.ifr_name, name, sizeof(if2.ifr_name) - 1);
 
-    if (ioctl(sock, SIOCGIFINDEX, (char *)&if2) < 0) {
+    if (ioctl(sock, SIOCGIFINDEX, (char *)&if2, sizeof(if2)) < 0) {
         return -1;
     }
 
@@ -2347,7 +2347,7 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
     memset((char *)&if2, 0, sizeof(if2));
     strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
 
-    if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
+    if (ioctl(sock, SIOCGIFMTU, (char *)&if2, sizeof(if2)) < 0) {
         NET_ThrowByNameWithLastError
             (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFMTU) failed");
         return -1;
@@ -2361,7 +2361,7 @@ static int getFlags(int sock, const char *ifname, int *flags) {
     memset((char *)&if2, 0, sizeof(if2));
     strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
 
-    if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
+    if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2, sizeof(if2)) < 0) {
         return -1;
     }
 
-- 
2.28.0


From 1c8df12a67297d5819762870c8580058a5e2d2a9 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 30 Oct 2020 19:57:47 +0100
Subject: workaround undef true and false macros


diff --git a/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template b/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template
index 26273d9..adc6f65 100644
--- a/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template
+++ b/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template
@@ -55,6 +55,8 @@
 /* On Solaris, "sun" is defined as a macro. Undefine to make package
    declaration valid */
 #undef sun
+#undef true
+#undef false
 
 /* To be able to name the Java constants the same as the C constants without
    having the preprocessor rewrite those identifiers, add PREFIX_ to all
-- 
2.28.0

