-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into truffle-head
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
Showing
32 changed files
with
684 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
truffle/src/main/java/org/jruby/truffle/platform/NativePlatform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform; | ||
|
||
import jnr.posix.POSIX; | ||
import org.jruby.truffle.platform.signal.SignalManager; | ||
|
||
public interface NativePlatform { | ||
|
||
POSIX getPosix(); | ||
|
||
SignalManager getSignalManager(); | ||
|
||
ProcessName getProcessName(); | ||
|
||
Sockets getSockets(); | ||
|
||
ClockGetTime getClockGetTime(); | ||
|
||
RubiniusConfiguration getRubiniusConfiguration(); | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
truffle/src/main/java/org/jruby/truffle/platform/NativePlatformFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform; | ||
|
||
import org.jruby.ext.ffi.Platform; | ||
import org.jruby.truffle.RubyContext; | ||
import org.jruby.truffle.platform.darwin.DarwinPlatform; | ||
import org.jruby.truffle.platform.java.JavaPlatform; | ||
import org.jruby.truffle.platform.linux.LinuxPlatform; | ||
|
||
public abstract class NativePlatformFactory { | ||
|
||
public static NativePlatform createPlatform(RubyContext context) { | ||
if (context.getOptions().POSIX_USE_JAVA) { | ||
return new JavaPlatform(context); | ||
} | ||
|
||
if (Platform.getPlatform().getOS() == Platform.OS_TYPE.LINUX) { | ||
return new LinuxPlatform(context); | ||
} | ||
|
||
if (Platform.getPlatform().getOS() == Platform.OS_TYPE.DARWIN) { | ||
return new DarwinPlatform(context); | ||
} | ||
|
||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
truffle/src/main/java/org/jruby/truffle/platform/ProcessName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform; | ||
|
||
public interface ProcessName { | ||
|
||
boolean canSet(); | ||
|
||
void set(String name); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
truffle/src/main/java/org/jruby/truffle/platform/darwin/DarwinPlatform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.darwin; | ||
|
||
import jnr.ffi.LibraryLoader; | ||
import jnr.posix.POSIX; | ||
import jnr.posix.POSIXFactory; | ||
import org.jruby.truffle.RubyContext; | ||
import org.jruby.truffle.platform.*; | ||
import org.jruby.truffle.platform.java.JavaClockGetTime; | ||
import org.jruby.truffle.platform.signal.SignalManager; | ||
import org.jruby.truffle.platform.sunmisc.SunMiscSignalManager; | ||
|
||
public class DarwinPlatform implements NativePlatform { | ||
|
||
private final POSIX posix; | ||
private final SignalManager signalManager; | ||
private final ProcessName processName; | ||
private final Sockets sockets; | ||
private final ClockGetTime clockGetTime; | ||
private final RubiniusConfiguration rubiniusConfiguration; | ||
|
||
public DarwinPlatform(RubyContext context) { | ||
posix = POSIXFactory.getNativePOSIX(new TrufflePOSIXHandler(context)); | ||
signalManager = new SunMiscSignalManager(); | ||
processName = new DarwinProcessName(); | ||
sockets = LibraryLoader.create(Sockets.class).library("c").load(); | ||
clockGetTime = new JavaClockGetTime(); | ||
rubiniusConfiguration = new RubiniusConfiguration(); | ||
DefaultRubiniusConfiguration.load(rubiniusConfiguration, context); | ||
DarwinRubiniusConfiguration.load(rubiniusConfiguration, context); | ||
} | ||
|
||
@Override | ||
public POSIX getPosix() { | ||
return posix; | ||
} | ||
|
||
@Override | ||
public SignalManager getSignalManager() { | ||
return signalManager; | ||
} | ||
|
||
@Override | ||
public ProcessName getProcessName() { | ||
return processName; | ||
} | ||
|
||
@Override | ||
public Sockets getSockets() { | ||
return sockets; | ||
} | ||
|
||
@Override | ||
public ClockGetTime getClockGetTime() { | ||
return clockGetTime; | ||
} | ||
|
||
@Override | ||
public RubiniusConfiguration getRubiniusConfiguration() { | ||
return rubiniusConfiguration; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
truffle/src/main/java/org/jruby/truffle/platform/darwin/DarwinProcessName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.jruby.truffle.platform.darwin; | ||
|
||
import jnr.ffi.LibraryLoader; | ||
import jnr.ffi.Pointer; | ||
import org.jruby.truffle.platform.ProcessName; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
public class DarwinProcessName implements ProcessName { | ||
|
||
/* | ||
* When we call _NSGetArgv we seem to always get a string that looks like what we'd expect from running ps, but | ||
* with a null character inserted early. I don't know where this comes from, but it means I don't know how to get | ||
* the length of space available for writing in the new program name. We therefore about 40 characters, which is | ||
* a number without any foundation, but it at leaast allows the specs to pass, the functionality to be useful, | ||
* and probably avoid crashing anyone's programs. I can't pretend this is great engineering. | ||
*/ | ||
private static final int MAX_PROGRAM_NAME_LENGTH = 40; | ||
|
||
private final CrtExterns crtExterns; | ||
|
||
public DarwinProcessName() { | ||
crtExterns = LibraryLoader.create(CrtExterns.class).failImmediately().library("libSystem.B.dylib").load(); | ||
} | ||
|
||
@Override | ||
public boolean canSet() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void set(String name) { | ||
final Pointer programNameAddress = crtExterns._NSGetArgv().getPointer(0).getPointer(0); | ||
programNameAddress.putString(0, name, MAX_PROGRAM_NAME_LENGTH, StandardCharsets.UTF_8); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
truffle/src/main/java/org/jruby/truffle/platform/java/JavaClockGetTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.java; | ||
|
||
import org.jruby.truffle.core.ffi.TimeSpec; | ||
import org.jruby.truffle.platform.ClockGetTime; | ||
|
||
public class JavaClockGetTime implements ClockGetTime { | ||
|
||
@Override | ||
public int clock_gettime(int clock_id, TimeSpec timeSpec) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
truffle/src/main/java/org/jruby/truffle/platform/java/JavaPlatform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.java; | ||
|
||
import jnr.posix.POSIX; | ||
import jnr.posix.POSIXFactory; | ||
import org.jruby.truffle.RubyContext; | ||
import org.jruby.truffle.platform.*; | ||
import org.jruby.truffle.platform.darwin.DarwinRubiniusConfiguration; | ||
import org.jruby.truffle.platform.linux.LinuxRubiniusConfiguration; | ||
import org.jruby.truffle.platform.signal.SignalManager; | ||
import org.jruby.truffle.platform.sunmisc.SunMiscSignalManager; | ||
|
||
public class JavaPlatform implements NativePlatform { | ||
|
||
private final POSIX posix; | ||
private final SignalManager signalManager; | ||
private final ProcessName processName; | ||
private final Sockets sockets; | ||
private final ClockGetTime clockGetTime; | ||
private final RubiniusConfiguration rubiniusConfiguration; | ||
|
||
public JavaPlatform(RubyContext context) { | ||
posix = new TruffleJavaPOSIX(context, POSIXFactory.getJavaPOSIX(new TrufflePOSIXHandler(context))); | ||
signalManager = new SunMiscSignalManager(); | ||
processName = new JavaProcessName(); | ||
sockets = new JavaSockets(); | ||
clockGetTime = new JavaClockGetTime(); | ||
rubiniusConfiguration = new RubiniusConfiguration(); | ||
DefaultRubiniusConfiguration.load(rubiniusConfiguration, context); | ||
LinuxRubiniusConfiguration.load(rubiniusConfiguration, context); // Just load the Linux one - let errors happen later | ||
} | ||
|
||
@Override | ||
public POSIX getPosix() { | ||
return posix; | ||
} | ||
|
||
@Override | ||
public SignalManager getSignalManager() { | ||
return signalManager; | ||
} | ||
|
||
@Override | ||
public ProcessName getProcessName() { | ||
return processName; | ||
} | ||
|
||
@Override | ||
public Sockets getSockets() { | ||
return sockets; | ||
} | ||
|
||
@Override | ||
public ClockGetTime getClockGetTime() { | ||
return clockGetTime; | ||
} | ||
|
||
@Override | ||
public RubiniusConfiguration getRubiniusConfiguration() { | ||
return rubiniusConfiguration; | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
truffle/src/main/java/org/jruby/truffle/platform/java/JavaProcessName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.java; | ||
|
||
import org.jruby.truffle.platform.ProcessName; | ||
|
||
public class JavaProcessName implements ProcessName { | ||
|
||
@Override | ||
public boolean canSet() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void set(String name) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
93 changes: 93 additions & 0 deletions
93
truffle/src/main/java/org/jruby/truffle/platform/java/JavaSockets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.java; | ||
|
||
import jnr.ffi.Pointer; | ||
import jnr.posix.Timeval; | ||
import org.jruby.truffle.platform.Sockets; | ||
|
||
public class JavaSockets implements Sockets { | ||
|
||
@Override | ||
public int getaddrinfo(CharSequence hostname, CharSequence servname, Pointer hints, Pointer res) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void freeaddrinfo(Pointer ai) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getnameinfo(Pointer sa, int salen, Pointer host, int hostlen, Pointer serv, int servlen, int flags) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int socket(int domain, int type, int protocol) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int setsockopt(int socket, int level, int option_name, Pointer option_value, int option_len) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int bind(int socket, Pointer address, int address_len) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int listen(int socket, int backlog) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int accept(int socket, Pointer address, int[] addressLength) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int gethostname(Pointer name, int namelen) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int select(int nfds, Pointer readfds, Pointer writefds, Pointer errorfds, Timeval timeout) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getpeername(int socket, Pointer address, Pointer address_len) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getsockname(int socket, Pointer address, Pointer address_len) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getsockopt(int sockfd, int level, int optname, Pointer optval, Pointer optlen) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int connect(int socket, Pointer address, int address_len) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int shutdown(int socket, int how) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
truffle/src/main/java/org/jruby/truffle/platform/linux/LinuxPlatform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.linux; | ||
|
||
import jnr.ffi.LibraryLoader; | ||
import jnr.posix.POSIX; | ||
import jnr.posix.POSIXFactory; | ||
import org.jruby.truffle.RubyContext; | ||
import org.jruby.truffle.platform.*; | ||
import org.jruby.truffle.platform.java.JavaProcessName; | ||
import org.jruby.truffle.platform.signal.SignalManager; | ||
import org.jruby.truffle.platform.sunmisc.SunMiscSignalManager; | ||
|
||
public class LinuxPlatform implements NativePlatform { | ||
|
||
private final POSIX posix; | ||
private final SignalManager signalManager; | ||
private final ProcessName processName; | ||
private final Sockets sockets; | ||
private final ClockGetTime clockGetTime; | ||
private final RubiniusConfiguration rubiniusConfiguration; | ||
|
||
public LinuxPlatform(RubyContext context) { | ||
posix = POSIXFactory.getNativePOSIX(new TrufflePOSIXHandler(context)); | ||
signalManager = new SunMiscSignalManager(); | ||
processName = new JavaProcessName(); | ||
sockets = LibraryLoader.create(Sockets.class).library("c").load(); | ||
clockGetTime = LibraryLoader.create(ClockGetTime.class).library("c").load(); | ||
rubiniusConfiguration = new RubiniusConfiguration(); | ||
DefaultRubiniusConfiguration.load(rubiniusConfiguration, context); | ||
LinuxRubiniusConfiguration.load(rubiniusConfiguration, context); | ||
} | ||
|
||
@Override | ||
public POSIX getPosix() { | ||
return posix; | ||
} | ||
|
||
@Override | ||
public SignalManager getSignalManager() { | ||
return signalManager; | ||
} | ||
|
||
@Override | ||
public ProcessName getProcessName() { | ||
return processName; | ||
} | ||
|
||
@Override | ||
public Sockets getSockets() { | ||
return sockets; | ||
} | ||
|
||
@Override | ||
public ClockGetTime getClockGetTime() { | ||
return clockGetTime; | ||
} | ||
|
||
@Override | ||
public RubiniusConfiguration getRubiniusConfiguration() { | ||
return rubiniusConfiguration; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
truffle/src/main/java/org/jruby/truffle/platform/signal/SignalManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.signal; | ||
|
||
import org.jruby.RubySignal; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public interface SignalManager { | ||
|
||
Map<String, Integer> SIGNALS_LIST = Collections.unmodifiableMap(RubySignal.list()); | ||
|
||
SignalHandler IGNORE_HANDLER = new SignalHandler() { | ||
@Override | ||
public void handle(Signal arg0) { | ||
// Just ignore the signal. | ||
} | ||
}; | ||
|
||
Signal createSignal(String name); | ||
|
||
void watchSignal(Signal signal, SignalHandler newHandler) throws IllegalArgumentException; | ||
|
||
void watchDefaultForSignal(Signal signal) throws IllegalArgumentException; | ||
|
||
void handle(final Signal signal, final SignalHandler newHandler) throws IllegalArgumentException; | ||
|
||
void handleDefault(final Signal signal) throws IllegalArgumentException; | ||
|
||
void raise(Signal signal) throws IllegalArgumentException; | ||
|
||
} |
40 changes: 0 additions & 40 deletions
40
truffle/src/main/java/org/jruby/truffle/platform/signal/SignalOperations.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
truffle/src/main/java/org/jruby/truffle/platform/sunmisc/SunMiscSignal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.sunmisc; | ||
|
||
import org.jruby.truffle.platform.signal.Signal; | ||
|
||
public class SunMiscSignal implements Signal { | ||
|
||
private final sun.misc.Signal sunMiscSignal; | ||
|
||
public SunMiscSignal(String name) { | ||
sunMiscSignal = new sun.misc.Signal(name); | ||
} | ||
|
||
public sun.misc.Signal getSunMiscSignal() { | ||
return sunMiscSignal; | ||
} | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
truffle/src/main/java/org/jruby/truffle/platform/sunmisc/SunMiscSignalManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.platform.sunmisc; | ||
|
||
import org.jruby.RubySignal; | ||
import org.jruby.truffle.platform.signal.Signal; | ||
import org.jruby.truffle.platform.signal.SignalHandler; | ||
import org.jruby.truffle.platform.signal.SignalManager; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.ConcurrentMap; | ||
|
||
public class SunMiscSignalManager implements SignalManager { | ||
|
||
public final Map<String, Integer> SIGNALS_LIST = Collections.unmodifiableMap(RubySignal.list()); | ||
|
||
public final SignalHandler IGNORE_HANDLER = new SignalHandler() { | ||
@Override | ||
public void handle(Signal arg0) { | ||
// Just ignore the signal. | ||
} | ||
}; | ||
private final ConcurrentMap<sun.misc.Signal, sun.misc.SignalHandler> DEFAULT_HANDLERS = new ConcurrentHashMap<sun.misc.Signal, sun.misc.SignalHandler>(); | ||
|
||
@Override | ||
public Signal createSignal(String name) { | ||
return new SunMiscSignal(name); | ||
} | ||
|
||
@Override | ||
public void watchSignal(Signal signal, SignalHandler newHandler) throws IllegalArgumentException { | ||
handle((SunMiscSignal) signal, newHandler); | ||
} | ||
|
||
@Override | ||
public void watchDefaultForSignal(Signal signal) throws IllegalArgumentException { | ||
handleDefault((SunMiscSignal) signal); | ||
} | ||
|
||
@Override | ||
public void handle(final Signal signal, final SignalHandler newHandler) throws IllegalArgumentException { | ||
final SunMiscSignal smSignal = (SunMiscSignal) signal; | ||
final sun.misc.SignalHandler oldSunHandler = sun.misc.Signal.handle(smSignal.getSunMiscSignal(), wrapHandler(signal, newHandler)); | ||
DEFAULT_HANDLERS.putIfAbsent(smSignal.getSunMiscSignal(), oldSunHandler); | ||
} | ||
|
||
@Override | ||
public void handleDefault(final Signal signal) throws IllegalArgumentException { | ||
final SunMiscSignal smSignal = (SunMiscSignal) signal; | ||
final sun.misc.SignalHandler defaultHandler = DEFAULT_HANDLERS.get(smSignal.getSunMiscSignal()); | ||
if (defaultHandler != null) { // otherwise it is already the default signal | ||
sun.misc.Signal.handle(smSignal.getSunMiscSignal(), defaultHandler); | ||
} | ||
} | ||
|
||
private sun.misc.SignalHandler wrapHandler(final Signal signal, final SignalHandler newHandler) { | ||
final SunMiscSignal smSignal = (SunMiscSignal) signal; | ||
return new sun.misc.SignalHandler() { | ||
@Override | ||
public void handle(sun.misc.Signal wrappedSignal) { | ||
newHandler.handle(smSignal); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public void raise(Signal signal) throws IllegalArgumentException { | ||
sun.misc.Signal.raise(((SunMiscSignal) signal).getSunMiscSignal()); | ||
} | ||
} |