7191275: Cleanup OS specific blocks in PlainDatagramSocketImpl.c to support more unix-like platforms
authordingxmin
Fri, 17 Aug 2012 17:10:56 +0800
changeset 13574 9d58db93e184
parent 13573 083e6f329de6
child 13575 017f49f1f3cb
7191275: Cleanup OS specific blocks in PlainDatagramSocketImpl.c to support more unix-like platforms Reviewed-by: chegar
jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
--- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Thu Aug 16 14:35:26 2012 +0100
+++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Fri Aug 17 17:10:56 2012 +0800
@@ -1350,19 +1350,18 @@
          * value is an InetAddress.
          */
 #ifdef AF_INET6
-#if defined(__solaris__) || defined(MACOSX)
+#ifdef __linux__
+        mcast_set_if_by_addr_v4(env, this, fd, value);
+        if (ipv6_available()) {
+            mcast_set_if_by_addr_v6(env, this, fd, value);
+        }
+#else  /* __linux__ not defined */
         if (ipv6_available()) {
             mcast_set_if_by_addr_v6(env, this, fd, value);
         } else {
             mcast_set_if_by_addr_v4(env, this, fd, value);
         }
-#endif
-#ifdef __linux__
-        mcast_set_if_by_addr_v4(env, this, fd, value);
-        if (ipv6_available()) {
-            mcast_set_if_by_addr_v6(env, this, fd, value);
-        }
-#endif
+#endif  /* __linux__ */
 #else
         mcast_set_if_by_addr_v4(env, this, fd, value);
 #endif  /* AF_INET6 */
@@ -1373,19 +1372,18 @@
          * value is a NetworkInterface.
          */
 #ifdef AF_INET6
-#if defined(__solaris__) || defined(MACOSX)
+#ifdef __linux__
+        mcast_set_if_by_if_v4(env, this, fd, value);
+        if (ipv6_available()) {
+            mcast_set_if_by_if_v6(env, this, fd, value);
+        }
+#else  /* __linux__ not defined */
         if (ipv6_available()) {
             mcast_set_if_by_if_v6(env, this, fd, value);
         } else {
             mcast_set_if_by_if_v4(env, this, fd, value);
         }
-#endif
-#ifdef __linux__
-        mcast_set_if_by_if_v4(env, this, fd, value);
-        if (ipv6_available()) {
-            mcast_set_if_by_if_v6(env, this, fd, value);
-        }
-#endif
+#endif  /* __linux__ */
 #else
         mcast_set_if_by_if_v4(env, this, fd, value);
 #endif  /* AF_INET6 */
@@ -1456,19 +1454,18 @@
 static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
                                   jint opt, jobject value) {
 #ifdef AF_INET6
-#if defined(__solaris__) || defined(MACOSX)
+#ifdef __linux__
+    mcast_set_loop_v4(env, this, fd, value);
+    if (ipv6_available()) {
+        mcast_set_loop_v6(env, this, fd, value);
+    }
+#else  /* __linux__ not defined */
     if (ipv6_available()) {
         mcast_set_loop_v6(env, this, fd, value);
     } else {
         mcast_set_loop_v4(env, this, fd, value);
     }
-#endif
-#ifdef __linux__
-    mcast_set_loop_v4(env, this, fd, value);
-    if (ipv6_available()) {
-        mcast_set_loop_v6(env, this, fd, value);
-    }
-#endif
+#endif  /* __linux__ */
 #else
     mcast_set_loop_v4(env, this, fd, value);
 #endif  /* AF_INET6 */
@@ -2030,13 +2027,6 @@
     }
     /* setsockopt to be correct ttl */
 #ifdef AF_INET6
-#if defined(__solaris__) || defined(MACOSX)
-    if (ipv6_available()) {
-        setHopLimit(env, fd, ttl);
-    } else {
-        setTTL(env, fd, ttl);
-    }
-#endif
 #ifdef __linux__
     setTTL(env, fd, ttl);
     if (ipv6_available()) {
@@ -2045,7 +2035,13 @@
             (*env)->SetIntField(env, this, pdsi_ttlID, ttl);
         }
     }
-#endif  // __linux__
+#else  /*  __linux__ not defined */
+    if (ipv6_available()) {
+        setHopLimit(env, fd, ttl);
+    } else {
+        setTTL(env, fd, ttl);
+    }
+#endif  /* __linux__ */
 #else
     setTTL(env, fd, ttl);
 #endif  /* AF_INET6 */