8031997: PPC64: Make the various POLL constants system dependant
authorsimonis
Mon, 20 Jan 2014 09:24:25 +0100
changeset 22604 9b394795e216
parent 22603 816588059f9d
child 22605 dba3d6b22818
8031997: PPC64: Make the various POLL constants system dependant Reviewed-by: alanb
jdk/make/mapfiles/libnio/mapfile-linux
jdk/make/mapfiles/libnio/mapfile-macosx
jdk/make/mapfiles/libnio/mapfile-solaris
jdk/src/aix/classes/sun/nio/ch/AixPollPort.java
jdk/src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java
jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java
jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
jdk/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java
jdk/src/share/classes/sun/nio/ch/Net.java
jdk/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java
jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java
jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/EPollPort.java
jdk/src/solaris/classes/sun/nio/ch/KQueuePort.java
jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java
jdk/src/solaris/classes/sun/nio/ch/Port.java
jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java
jdk/src/solaris/native/sun/nio/ch/IOUtil.c
jdk/src/solaris/native/sun/nio/ch/Net.c
jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java
jdk/src/windows/classes/sun/nio/ch/SinkChannelImpl.java
jdk/src/windows/classes/sun/nio/ch/SourceChannelImpl.java
jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java
jdk/src/windows/native/sun/nio/ch/Net.c
jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c
jdk/src/windows/native/sun/nio/ch/nio_util.h
--- a/jdk/make/mapfiles/libnio/mapfile-linux	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/make/mapfiles/libnio/mapfile-linux	Mon Jan 20 09:24:25 2014 +0100
@@ -117,6 +117,12 @@
 		Java_sun_nio_ch_Net_getInterface6;
 		Java_sun_nio_ch_Net_shutdown;
 		Java_sun_nio_ch_Net_poll;
+		Java_sun_nio_ch_Net_pollinValue;
+		Java_sun_nio_ch_Net_polloutValue;
+		Java_sun_nio_ch_Net_pollerrValue;
+		Java_sun_nio_ch_Net_pollhupValue;
+		Java_sun_nio_ch_Net_pollnvalValue;
+		Java_sun_nio_ch_Net_pollconnValue;
                 Java_sun_nio_ch_Net_isExclusiveBindAvailable;
                 Java_sun_nio_ch_PollArrayWrapper_interrupt;
                 Java_sun_nio_ch_PollArrayWrapper_poll0;
--- a/jdk/make/mapfiles/libnio/mapfile-macosx	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/make/mapfiles/libnio/mapfile-macosx	Mon Jan 20 09:24:25 2014 +0100
@@ -109,6 +109,12 @@
 		Java_sun_nio_ch_Net_getInterface6;
 		Java_sun_nio_ch_Net_shutdown;
 		Java_sun_nio_ch_Net_poll;
+		Java_sun_nio_ch_Net_pollinValue;
+		Java_sun_nio_ch_Net_polloutValue;
+		Java_sun_nio_ch_Net_pollerrValue;
+		Java_sun_nio_ch_Net_pollhupValue;
+		Java_sun_nio_ch_Net_pollnvalValue;
+		Java_sun_nio_ch_Net_pollconnValue;
                 Java_sun_nio_ch_Net_isExclusiveBindAvailable;
                 Java_sun_nio_ch_PollArrayWrapper_interrupt;
                 Java_sun_nio_ch_PollArrayWrapper_poll0;
--- a/jdk/make/mapfiles/libnio/mapfile-solaris	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/make/mapfiles/libnio/mapfile-solaris	Mon Jan 20 09:24:25 2014 +0100
@@ -105,6 +105,12 @@
 		Java_sun_nio_ch_Net_getInterface6;
 		Java_sun_nio_ch_Net_shutdown;
 		Java_sun_nio_ch_Net_poll;
+		Java_sun_nio_ch_Net_pollinValue;
+		Java_sun_nio_ch_Net_polloutValue;
+		Java_sun_nio_ch_Net_pollerrValue;
+		Java_sun_nio_ch_Net_pollhupValue;
+		Java_sun_nio_ch_Net_pollnvalValue;
+		Java_sun_nio_ch_Net_pollconnValue;
                 Java_sun_nio_ch_Net_isExclusiveBindAvailable;
                 Java_sun_nio_ch_PollArrayWrapper_interrupt;
                 Java_sun_nio_ch_PollArrayWrapper_poll0;
--- a/jdk/src/aix/classes/sun/nio/ch/AixPollPort.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/aix/classes/sun/nio/ch/AixPollPort.java	Mon Jan 20 09:24:25 2014 +0100
@@ -148,7 +148,7 @@
         try {
             socketpair(sv);
             // register one end with pollset
-            pollsetCtl(pollset, PS_ADD, sv[0], POLLIN);
+            pollsetCtl(pollset, PS_ADD, sv[0], Net.POLLIN);
         } catch (IOException x) {
             pollsetDestroy(pollset);
             throw x;
@@ -160,7 +160,7 @@
         try {
             socketpair(sv);
             // register one end with pollset
-            pollsetCtl(pollset, PS_ADD, sv[0], POLLIN);
+            pollsetCtl(pollset, PS_ADD, sv[0], Net.POLLIN);
         } catch (IOException x) {
             pollsetDestroy(pollset);
             throw x;
@@ -353,7 +353,7 @@
 
                                 // This is the only file descriptor without
                                 // one shot semantic => register it again.
-                                pollsetCtl(pollset, PS_ADD, sp[0], POLLIN);
+                                pollsetCtl(pollset, PS_ADD, sp[0], Net.POLLIN);
 
                                 // queue special event if there are more events
                                 // to handle.
@@ -370,7 +370,7 @@
                                     drain1(ctlSp[0]);
                                     // This file descriptor does not have
                                     // one shot semantic => register it again.
-                                    pollsetCtl(pollset, PS_ADD, ctlSp[0], POLLIN);
+                                    pollsetCtl(pollset, PS_ADD, ctlSp[0], Net.POLLIN);
                                     processControlQueue();
                                 }
                                 continue;
--- a/jdk/src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java	Mon Jan 20 09:24:25 2014 +0100
@@ -53,10 +53,6 @@
  */
 
 class KQueueArrayWrapper {
-    // Event masks
-    static final short POLLIN       = AbstractPollArrayWrapper.POLLIN;
-    static final short POLLOUT      = AbstractPollArrayWrapper.POLLOUT;
-
     // kevent filters
     static short EVFILT_READ;
     static short EVFILT_WRITE;
@@ -129,9 +125,9 @@
         //   SinkChannelImpl, SourceChannelImpl, DatagramChannelImpl,
         //   ServerSocketChannelImpl, SocketChannelImpl
         if (filter == EVFILT_READ) {
-            result |= POLLIN;
+            result |= Net.POLLIN;
         } else if (filter == EVFILT_WRITE) {
-            result |= POLLOUT;
+            result |= Net.POLLOUT;
         }
 
         return result;
@@ -180,7 +176,7 @@
                 if (!ch.isOpen())
                     continue;
 
-                register0(kq, ch.getFDVal(), u.events & POLLIN, u.events & POLLOUT);
+                register0(kq, ch.getFDVal(), u.events & Net.POLLIN, u.events & Net.POLLOUT);
             }
         }
     }
--- a/jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java	Mon Jan 20 09:24:25 2014 +0100
@@ -37,14 +37,6 @@
 
 public abstract class AbstractPollArrayWrapper {
 
-    // Event masks
-    public static final short POLLIN       = 0x0001;
-    public static final short POLLOUT      = 0x0004;
-    public static final short POLLERR      = 0x0008;
-    public static final short POLLHUP      = 0x0010;
-    public static final short POLLNVAL     = 0x0020;
-    public static final short POLLREMOVE   = 0x0800;
-
     // Miscellaneous constants
     static final short SIZE_POLLFD   = 8;
     static final short FD_OFFSET     = 0;
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -1042,25 +1042,24 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+        if ((ops & Net.POLLNVAL) != 0) {
             // This should only happen if this channel is pre-closed while a
             // selection operation is in progress
             // ## Throw an error if this channel has not been pre-closed
             return false;
         }
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_READ) != 0))
             newOps |= SelectionKey.OP_READ;
 
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+        if (((ops & Net.POLLOUT) != 0) &&
             ((intOps & SelectionKey.OP_WRITE) != 0))
             newOps |= SelectionKey.OP_WRITE;
 
@@ -1105,11 +1104,11 @@
         int newOps = 0;
 
         if ((ops & SelectionKey.OP_READ) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
+            newOps |= Net.POLLIN;
         if ((ops & SelectionKey.OP_WRITE) != 0)
-            newOps |= PollArrayWrapper.POLLOUT;
+            newOps |= Net.POLLOUT;
         if ((ops & SelectionKey.OP_CONNECT) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
+            newOps |= Net.POLLIN;
         sk.selector.putEventOps(sk, newOps);
     }
 
--- a/jdk/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java	Mon Jan 20 09:24:25 2014 +0100
@@ -187,9 +187,9 @@
                 if (!dc.isOpen())
                      throw new ClosedChannelException();
                 long st = System.currentTimeMillis();
-                int result = dc.poll(PollArrayWrapper.POLLIN, to);
+                int result = dc.poll(Net.POLLIN, to);
                 if (result > 0 &&
-                        ((result & PollArrayWrapper.POLLIN) != 0)) {
+                        ((result & Net.POLLIN) != 0)) {
                     if ((sender = dc.receive(bb)) != null)
                         return sender;
                 }
--- a/jdk/src/share/classes/sun/nio/ch/Net.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/Net.java	Mon Jan 20 09:24:25 2014 +0100
@@ -581,9 +581,34 @@
 
     private static native void initIDs();
 
+    /**
+     * Event masks for the various poll system calls.
+     * They will be set platform dependant in the static initializer below.
+     */
+    public static final short POLLIN;
+    public static final short POLLOUT;
+    public static final short POLLERR;
+    public static final short POLLHUP;
+    public static final short POLLNVAL;
+    public static final short POLLCONN;
+
+    static native short pollinValue();
+    static native short polloutValue();
+    static native short pollerrValue();
+    static native short pollhupValue();
+    static native short pollnvalValue();
+    static native short pollconnValue();
+
     static {
         IOUtil.load();
         initIDs();
+
+        POLLIN     = pollinValue();
+        POLLOUT    = polloutValue();
+        POLLERR    = pollerrValue();
+        POLLHUP    = pollhupValue();
+        POLLNVAL   = pollnvalValue();
+        POLLCONN   = pollconnValue();
     }
 
 }
--- a/jdk/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java	Mon Jan 20 09:24:25 2014 +0100
@@ -113,7 +113,7 @@
                         if (!ssc.isOpen())
                             throw new ClosedChannelException();
                         long st = System.currentTimeMillis();
-                        int result = ssc.poll(PollArrayWrapper.POLLIN, to);
+                        int result = ssc.poll(Net.POLLIN, to);
                         if (result > 0 && ((sc = ssc.accept()) != null))
                             return sc.socket();
                         to -= System.currentTimeMillis() - st;
--- a/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -309,21 +309,20 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+        if ((ops & Net.POLLNVAL) != 0) {
             // This should only happen if this channel is pre-closed while a
             // selection operation is in progress
             // ## Throw an error if this channel has not been pre-closed
             return false;
         }
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_ACCEPT) != 0))
                 newOps |= SelectionKey.OP_ACCEPT;
 
@@ -369,7 +368,7 @@
 
         // Translate ops
         if ((ops & SelectionKey.OP_ACCEPT) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
+            newOps |= Net.POLLIN;
         // Place ops into pollfd array
         sk.selector.putEventOps(sk, newOps);
     }
--- a/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java	Mon Jan 20 09:24:25 2014 +0100
@@ -107,7 +107,7 @@
                             throw new ClosedChannelException();
                         long st = System.currentTimeMillis();
 
-                        int result = sc.poll(PollArrayWrapper.POLLCONN, to);
+                        int result = sc.poll(Net.POLLCONN, to);
                         if (result > 0 && sc.finishConnect())
                             break;
                         to -= System.currentTimeMillis() - st;
@@ -201,7 +201,7 @@
                         if (!sc.isOpen())
                             throw new ClosedChannelException();
                         long st = System.currentTimeMillis();
-                        int result = sc.poll(PollArrayWrapper.POLLIN, to);
+                        int result = sc.poll(Net.POLLIN, to);
                         if (result > 0) {
                             if ((n = sc.read(bb)) != 0)
                                 return n;
--- a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -884,15 +884,14 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+        if ((ops & Net.POLLNVAL) != 0) {
             // This should only happen if this channel is pre-closed while a
             // selection operation is in progress
             // ## Throw an error if this channel has not been pre-closed
             return false;
         }
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             // No need to poll again in checkConnect,
@@ -901,19 +900,19 @@
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_READ) != 0) &&
             (state == ST_CONNECTED))
             newOps |= SelectionKey.OP_READ;
 
-        if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
+        if (((ops & Net.POLLCONN) != 0) &&
             ((intOps & SelectionKey.OP_CONNECT) != 0) &&
             ((state == ST_UNCONNECTED) || (state == ST_PENDING))) {
             newOps |= SelectionKey.OP_CONNECT;
             readyToConnect = true;
         }
 
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+        if (((ops & Net.POLLOUT) != 0) &&
             ((intOps & SelectionKey.OP_WRITE) != 0) &&
             (state == ST_CONNECTED))
             newOps |= SelectionKey.OP_WRITE;
@@ -958,11 +957,11 @@
     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
         int newOps = 0;
         if ((ops & SelectionKey.OP_READ) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
+            newOps |= Net.POLLIN;
         if ((ops & SelectionKey.OP_WRITE) != 0)
-            newOps |= PollArrayWrapper.POLLOUT;
+            newOps |= Net.POLLOUT;
         if ((ops & SelectionKey.OP_CONNECT) != 0)
-            newOps |= PollArrayWrapper.POLLCONN;
+            newOps |= Net.POLLCONN;
         sk.selector.putEventOps(sk, newOps);
     }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java	Mon Jan 20 09:24:25 2014 +0100
@@ -93,7 +93,7 @@
         try {
             socketpair(sv);
             // register one end with epoll
-            epollCtl(epfd, EPOLL_CTL_ADD, sv[0], POLLIN);
+            epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
         } catch (IOException x) {
             close0(epfd);
             throw x;
--- a/jdk/src/solaris/classes/sun/nio/ch/KQueuePort.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/KQueuePort.java	Mon Jan 20 09:24:25 2014 +0100
@@ -172,9 +172,9 @@
         // TBD: Measure cost of EV_ONESHOT vs. EV_CLEAR, either will do here.
         int err = 0;
         int flags = (EV_ADD|EV_ONESHOT);
-        if ((events & Port.POLLIN) > 0)
+        if ((events & Net.POLLIN) > 0)
             err = keventRegister(kqfd, fd, EVFILT_READ, flags);
-        if (err == 0 && (events & Port.POLLOUT) > 0)
+        if (err == 0 && (events & Net.POLLOUT) > 0)
             err = keventRegister(kqfd, fd, EVFILT_WRITE, flags);
         if (err != 0)
             throw new InternalError("kevent failed: " + err);  // should not happen
@@ -227,9 +227,9 @@
                                 int filter = getFilter(keventAddress);
                                 int events = 0;
                                 if (filter == EVFILT_READ)
-                                    events = Port.POLLIN;
+                                    events = Net.POLLIN;
                                 else if (filter == EVFILT_WRITE)
-                                    events = Port.POLLOUT;
+                                    events = Net.POLLOUT;
 
                                 Event ev = new Event(channel, events);
 
--- a/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java	Mon Jan 20 09:24:25 2014 +0100
@@ -43,8 +43,6 @@
 
 public class PollArrayWrapper extends AbstractPollArrayWrapper {
 
-    public static final short POLLCONN = POLLOUT;
-
     // File descriptor to write for interrupt
     int interruptFD;
 
@@ -58,7 +56,7 @@
     void initInterrupt(int fd0, int fd1) {
         interruptFD = fd1;
         putDescriptor(0, fd0);
-        putEventOps(0, POLLIN);
+        putEventOps(0, Net.POLLIN);
         putReventOps(0, 0);
     }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/Port.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/Port.java	Mon Jan 20 09:24:25 2014 +0100
@@ -40,10 +40,6 @@
  */
 
 abstract class Port extends AsynchronousChannelGroupImpl {
-    static final short POLLIN       = 0x0001;
-    static final short POLLOUT      = 0x0004;
-    static final short POLLERR      = 0x0008;
-    static final short POLLHUP      = 0x0010;
 
     /**
      * Implemented by clients registered with this port.
--- a/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -118,17 +118,16 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0)
+        if ((ops & Net.POLLNVAL) != 0)
             throw new Error("POLLNVAL detected");
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+        if (((ops & Net.POLLOUT) != 0) &&
             ((intOps & SelectionKey.OP_WRITE) != 0))
             newOps |= SelectionKey.OP_WRITE;
 
@@ -146,7 +145,7 @@
 
     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
         if (ops == SelectionKey.OP_WRITE)
-            ops = PollArrayWrapper.POLLOUT;
+            ops = Net.POLLOUT;
         sk.selector.putEventOps(sk, ops);
     }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -118,17 +118,16 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0)
+        if ((ops & Net.POLLNVAL) != 0)
             throw new Error("POLLNVAL detected");
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_READ) != 0))
             newOps |= SelectionKey.OP_READ;
 
@@ -146,7 +145,7 @@
 
     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
         if (ops == SelectionKey.OP_READ)
-            ops = PollArrayWrapper.POLLIN;
+            ops = Net.POLLIN;
         sk.selector.putEventOps(sk, ops);
     }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -148,7 +148,7 @@
                 synchronized (updateLock) {
                     acceptPending = true;
                 }
-                port.startPoll(fdVal, Port.POLLIN);
+                port.startPoll(fdVal, Net.POLLIN);
                 return;
             }
 
@@ -299,7 +299,7 @@
                 }
 
                 // register for connections
-                port.startPoll(fdVal, Port.POLLIN);
+                port.startPoll(fdVal, Net.POLLIN);
                 return result;
             }
         } catch (Throwable x) {
--- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -142,9 +142,9 @@
         assert Thread.holdsLock(updateLock);
         int events = 0;
         if (readPending)
-            events |= Port.POLLIN;
+            events |= Net.POLLIN;
         if (connectPending || writePending)
-            events |= Port.POLLOUT;
+            events |= Net.POLLOUT;
         if (events != 0)
             port.startPoll(fdVal, events);
     }
@@ -204,9 +204,9 @@
      */
     @Override
     public void onEvent(int events, boolean mayInvokeDirect) {
-        boolean readable = (events & Port.POLLIN) > 0;
-        boolean writable = (events & Port.POLLOUT) > 0;
-        if ((events & (Port.POLLERR | Port.POLLHUP)) > 0) {
+        boolean readable = (events & Net.POLLIN) > 0;
+        boolean writable = (events & Net.POLLOUT) > 0;
+        if ((events & (Net.POLLERR | Net.POLLHUP)) > 0) {
             readable = true;
             writable = true;
         }
--- a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -589,15 +589,14 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+        if ((ops & Net.POLLNVAL) != 0) {
             /* This should only happen if this channel is pre-closed while a
              * selection operation is in progress
              * ## Throw an error if this channel has not been pre-closed */
             return false;
         }
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             /* No need to poll again in checkConnect,
@@ -606,19 +605,19 @@
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_READ) != 0) &&
             isConnected())
             newOps |= SelectionKey.OP_READ;
 
-        if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
+        if (((ops & Net.POLLCONN) != 0) &&
             ((intOps & SelectionKey.OP_CONNECT) != 0) &&
             ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
             newOps |= SelectionKey.OP_CONNECT;
             readyToConnect = true;
         }
 
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+        if (((ops & Net.POLLOUT) != 0) &&
             ((intOps & SelectionKey.OP_WRITE) != 0) &&
             isConnected())
             newOps |= SelectionKey.OP_WRITE;
@@ -642,11 +641,11 @@
     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
         int newOps = 0;
         if ((ops & SelectionKey.OP_READ) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
+            newOps |= Net.POLLIN;
         if ((ops & SelectionKey.OP_WRITE) != 0)
-            newOps |= PollArrayWrapper.POLLOUT;
+            newOps |= Net.POLLOUT;
         if ((ops & SelectionKey.OP_CONNECT) != 0)
-            newOps |= PollArrayWrapper.POLLCONN;
+            newOps |= Net.POLLCONN;
         sk.selector.putEventOps(sk, newOps);
     }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -321,25 +321,24 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+        if ((ops & Net.POLLNVAL) != 0) {
             /* This should only happen if this channel is pre-closed while a
              * selection operation is in progress
              * ## Throw an error if this channel has not been pre-closed */
             return false;
         }
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_READ) != 0))
             newOps |= SelectionKey.OP_READ;
 
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+        if (((ops & Net.POLLOUT) != 0) &&
             ((intOps & SelectionKey.OP_WRITE) != 0))
             newOps |= SelectionKey.OP_WRITE;
 
@@ -361,9 +360,9 @@
     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
         int newOps = 0;
         if ((ops & SelectionKey.OP_READ) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
+            newOps |= Net.POLLIN;
         if ((ops & SelectionKey.OP_WRITE) != 0)
-            newOps |= PollArrayWrapper.POLLOUT;
+            newOps |= Net.POLLOUT;
         sk.selector.putEventOps(sk, newOps);
     }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -314,21 +314,20 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+        if ((ops & Net.POLLNVAL) != 0) {
             /* This should only happen if this channel is pre-closed while a
              * selection operation is in progress
              * ## Throw an error if this channel has not been pre-closed */
             return false;
         }
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_ACCEPT) != 0))
                 newOps |= SelectionKey.OP_ACCEPT;
 
@@ -352,7 +351,7 @@
 
         /* Translate ops */
         if ((ops & SelectionKey.OP_ACCEPT) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
+            newOps |= Net.POLLIN;
         /* Place ops into pollfd array */
         sk.selector.putEventOps(sk, newOps);
 
--- a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c	Mon Jan 20 09:24:25 2014 +0100
@@ -145,7 +145,6 @@
     return (jint)iov_max;
 }
 
-
 /* Declared in nio_util.h for use elsewhere in NIO */
 
 jint
--- a/jdk/src/solaris/native/sun/nio/ch/Net.c	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/solaris/native/sun/nio/ch/Net.c	Mon Jan 20 09:24:25 2014 +0100
@@ -23,6 +23,7 @@
  * questions.
  */
 
+#include <sys/poll.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <string.h>
@@ -749,6 +750,42 @@
     }
 }
 
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollinValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLIN;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_polloutValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLOUT;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollerrValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLERR;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollhupValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLHUP;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollnvalValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLNVAL;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLOUT;
+}
+
 
 /* Declared in nio_util.h */
 
--- a/jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java	Mon Jan 20 09:24:25 2014 +0100
@@ -53,15 +53,6 @@
 
     static short SIZE_POLLFD = 8; // sizeof pollfd struct
 
-    // events masks
-    @Native static final short POLLIN     = AbstractPollArrayWrapper.POLLIN;
-    @Native static final short POLLOUT    = AbstractPollArrayWrapper.POLLOUT;
-    @Native static final short POLLERR    = AbstractPollArrayWrapper.POLLERR;
-    @Native static final short POLLHUP    = AbstractPollArrayWrapper.POLLHUP;
-    @Native static final short POLLNVAL   = AbstractPollArrayWrapper.POLLNVAL;
-    @Native static final short POLLREMOVE = AbstractPollArrayWrapper.POLLREMOVE;
-    @Native static final short POLLCONN   = 0x0002;
-
     private int size; // Size of the pollArray
 
     PollArrayWrapper(int newSize) {
@@ -119,6 +110,6 @@
     // Adds Windows wakeup socket at a given index.
     void addWakeupSocket(int fdVal, int index) {
         putDescriptor(index, fdVal);
-        putEventOps(index, POLLIN);
+        putEventOps(index, Net.POLLIN);
     }
 }
--- a/jdk/src/windows/classes/sun/nio/ch/SinkChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/windows/classes/sun/nio/ch/SinkChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -78,17 +78,16 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0)
+        if ((ops & Net.POLLNVAL) != 0)
             throw new Error("POLLNVAL detected");
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+        if (((ops & Net.POLLOUT) != 0) &&
             ((intOps & SelectionKey.OP_WRITE) != 0))
             newOps |= SelectionKey.OP_WRITE;
 
@@ -106,7 +105,7 @@
 
     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
         if ((ops & SelectionKey.OP_WRITE) != 0)
-            ops = PollArrayWrapper.POLLOUT;
+            ops = Net.POLLOUT;
         sk.selector.putEventOps(sk, ops);
     }
 
--- a/jdk/src/windows/classes/sun/nio/ch/SourceChannelImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/windows/classes/sun/nio/ch/SourceChannelImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -77,17 +77,16 @@
         int oldOps = sk.nioReadyOps();
         int newOps = initialOps;
 
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0)
+        if ((ops & Net.POLLNVAL) != 0)
             throw new Error("POLLNVAL detected");
 
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
+        if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) {
             newOps = intOps;
             sk.nioReadyOps(newOps);
             return (newOps & ~oldOps) != 0;
         }
 
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+        if (((ops & Net.POLLIN) != 0) &&
             ((intOps & SelectionKey.OP_READ) != 0))
             newOps |= SelectionKey.OP_READ;
 
@@ -105,7 +104,7 @@
 
     public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
         if ((ops & SelectionKey.OP_READ) != 0)
-            ops = PollArrayWrapper.POLLIN;
+            ops = Net.POLLIN;
         sk.selector.putEventOps(sk, ops);
     }
 
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Mon Jan 20 09:24:25 2014 +0100
@@ -313,16 +313,16 @@
         private int processSelectedKeys(long updateCount) {
             int numKeysUpdated = 0;
             numKeysUpdated += processFDSet(updateCount, readFds,
-                                           PollArrayWrapper.POLLIN,
+                                           Net.POLLIN,
                                            false);
             numKeysUpdated += processFDSet(updateCount, writeFds,
-                                           PollArrayWrapper.POLLCONN |
-                                           PollArrayWrapper.POLLOUT,
+                                           Net.POLLCONN |
+                                           Net.POLLOUT,
                                            false);
             numKeysUpdated += processFDSet(updateCount, exceptFds,
-                                           PollArrayWrapper.POLLIN |
-                                           PollArrayWrapper.POLLCONN |
-                                           PollArrayWrapper.POLLOUT,
+                                           Net.POLLIN |
+                                           Net.POLLCONN |
+                                           Net.POLLOUT,
                                            true);
             return numKeysUpdated;
         }
--- a/jdk/src/windows/native/sun/nio/ch/Net.c	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/windows/native/sun/nio/ch/Net.c	Mon Jan 20 09:24:25 2014 +0100
@@ -554,11 +554,11 @@
     FD_ZERO(&rd);
     FD_ZERO(&wr);
     FD_ZERO(&ex);
-    if (events & sun_nio_ch_PollArrayWrapper_POLLIN) {
+    if (events & POLLIN) {
         FD_SET(fd, &rd);
     }
-    if (events & sun_nio_ch_PollArrayWrapper_POLLOUT ||
-        events & sun_nio_ch_PollArrayWrapper_POLLCONN) {
+    if (events & POLLOUT ||
+        events & POLLCONN) {
         FD_SET(fd, &wr);
     }
     FD_SET(fd, &ex);
@@ -572,14 +572,50 @@
     } else if (rv >= 0) {
         rv = 0;
         if (FD_ISSET(fd, &rd)) {
-            rv |= sun_nio_ch_PollArrayWrapper_POLLIN;
+            rv |= POLLIN;
         }
         if (FD_ISSET(fd, &wr)) {
-            rv |= sun_nio_ch_PollArrayWrapper_POLLOUT;
+            rv |= POLLOUT;
         }
         if (FD_ISSET(fd, &ex)) {
-            rv |= sun_nio_ch_PollArrayWrapper_POLLERR;
+            rv |= POLLERR;
         }
     }
     return rv;
 }
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollinValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLIN;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_polloutValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLOUT;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollerrValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLERR;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollhupValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLHUP;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollnvalValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLNVAL;
+}
+
+JNIEXPORT jshort JNICALL
+Java_sun_nio_ch_Net_pollconnValue(JNIEnv *env, jclass this)
+{
+    return (jshort)POLLCONN;
+}
--- a/jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c	Mon Jan 20 09:24:25 2014 +0100
@@ -33,13 +33,15 @@
 #define FD_SETSIZE 1024
 
 #include <stdlib.h>
+#include <winsock2.h>
+
 #include "jvm.h"
 #include "jni.h"
 #include "jni_util.h"
 #include "sun_nio_ch_WindowsSelectorImpl.h"
 #include "sun_nio_ch_PollArrayWrapper.h"
-#include "winsock2.h"
 
+#include "nio_util.h" /* Needed for POLL* constants (includes "winsock2.h") */
 
 typedef struct {
     jint fd;
@@ -79,12 +81,11 @@
 
     /* Set FD_SET structures required for select */
     for (i = 0; i < numfds; i++) {
-        if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) {
+        if (fds[i].events & POLLIN) {
            readfds.fd_array[read_count] = fds[i].fd;
            read_count++;
         }
-        if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT |
-                             sun_nio_ch_PollArrayWrapper_POLLCONN))
+        if (fds[i].events & (POLLOUT | POLLCONN))
         {
            writefds.fd_array[write_count] = fds[i].fd;
            write_count++;
@@ -110,12 +111,11 @@
             /* prepare select structures for the i-th socket */
             errreadfds.fd_count = 0;
             errwritefds.fd_count = 0;
-            if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) {
+            if (fds[i].events & POLLIN) {
                errreadfds.fd_array[0] = fds[i].fd;
                errreadfds.fd_count = 1;
             }
-            if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT |
-                                 sun_nio_ch_PollArrayWrapper_POLLCONN))
+            if (fds[i].events & (POLLOUT | POLLCONN))
             {
                 errwritefds.fd_array[0] = fds[i].fd;
                 errwritefds.fd_count = 1;
--- a/jdk/src/windows/native/sun/nio/ch/nio_util.h	Mon Jan 20 09:20:13 2014 +0100
+++ b/jdk/src/windows/native/sun/nio/ch/nio_util.h	Mon Jan 20 09:24:25 2014 +0100
@@ -23,6 +23,8 @@
  * questions.
  */
 
+#include <winsock2.h>
+
 #include "jni.h"
 
 /**
@@ -55,3 +57,19 @@
 };
 
 #endif
+
+#ifndef POLLIN
+    /* WSAPoll()/WSAPOLLFD and the corresponding constants are only defined   */
+    /* in Windows Vista / Windows Server 2008 and later. If we are on an      */
+    /* older release we just use the Solaris constants as this was previously */
+    /* done in PollArrayWrapper.java.                                         */
+    #define POLLIN       0x0001
+    #define POLLOUT      0x0004
+    #define POLLERR      0x0008
+    #define POLLHUP      0x0010
+    #define POLLNVAL     0x0020
+    #define POLLCONN     0x0002
+#else
+    /* POLLCONN must not equal any of the other constants (see winsock2.h).   */
+    #define POLLCONN     0x2000
+#endif