Merged gcj-eclipse branch to trunk.

From-SVN: r120621
This commit is contained in:
Tom Tromey 2007-01-09 19:58:05 +00:00
parent c648dedbde
commit 97b8365caf
17478 changed files with 606493 additions and 100744 deletions

View file

@ -37,6 +37,9 @@ exception statement from your version. */
package gnu.java.nio;
import gnu.classpath.SystemProperties;
import java.io.IOException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.Pipe;
@ -47,6 +50,11 @@ import java.nio.channels.spi.SelectorProvider;
public class SelectorProviderImpl extends SelectorProvider
{
private static final String SELECTOR_IMPL_KQUEUE = "kqueue";
private static final String SELECTOR_IMPL_EPOLL = "epoll";
private static final String SELECTOR_IMPL = "gnu.java.nio.selectorImpl";
private static boolean epoll_failed = false;
public SelectorProviderImpl ()
{
}
@ -66,6 +74,35 @@ public class SelectorProviderImpl extends SelectorProvider
public AbstractSelector openSelector ()
throws IOException
{
String selectorImpl = "default";
if (KqueueSelectorImpl.kqueue_supported())
selectorImpl = SELECTOR_IMPL_KQUEUE;
if (EpollSelectorImpl.epoll_supported() && !epoll_failed)
selectorImpl = SELECTOR_IMPL_EPOLL;
selectorImpl = SystemProperties.getProperty(SELECTOR_IMPL, selectorImpl);
if (selectorImpl.equals(SELECTOR_IMPL_KQUEUE))
return new KqueueSelectorImpl(this);
if (selectorImpl.equals(SELECTOR_IMPL_EPOLL))
{
// We jump through these hoops because even though epoll may look
// like it's available (sys/epoll.h exists, and you can link against
// all the epoll functions) it may not be available in the kernel
// (especially 2.4 kernels), meaning you will get ENOSYS at run time.
//
// Madness!
try
{
return new EpollSelectorImpl(this);
}
catch (InternalError e)
{
// epoll_create throws this on ENOSYS.
epoll_failed = true;
}
}
return new SelectorImpl (this);
}