Skip to content

Commit

Permalink
[Truffle] Put getgroups into TrufflePosix, but still use the JDK impl…
Browse files Browse the repository at this point in the history
…ementation for now.
  • Loading branch information
chrisseaton committed Oct 9, 2016
1 parent 8f3c006 commit fc52ea4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Expand Up @@ -20,7 +20,6 @@
import jnr.constants.platform.Fcntl;
import jnr.ffi.Pointer;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.platform.Platform;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
Expand Down Expand Up @@ -191,13 +190,13 @@ public abstract static class GetGroupsNode extends CoreMethodArrayArgumentsNode

@Specialization(guards = "isNil(pointer)")
public int getGroupsNil(int max, DynamicObject pointer) {
return Platform.getPlatform().getGroups(null).length;
return getContext().getNativePlatform().getPosix().getgroups().length;
}

@CompilerDirectives.TruffleBoundary
@Specialization(guards = "isRubyPointer(pointer)")
public int getGroups(int max, DynamicObject pointer) {
final long[] groups = Platform.getPlatform().getGroups(null);
final long[] groups = getContext().getNativePlatform().getPosix().getgroups();

final Pointer pointerValue = Layouts.POINTER.getPointer(pointer);

Expand Down
Expand Up @@ -19,6 +19,7 @@
import jnr.posix.SignalHandler;
import jnr.posix.SpawnFileAction;
import jnr.posix.Times;
import org.jruby.platform.Platform;
import org.jruby.truffle.core.CoreLibrary;

import java.io.FileDescriptor;
Expand Down Expand Up @@ -434,4 +435,9 @@ public int isatty(int fd) {
public int mkfifo(String path, int mode) {
return posix.mkfifo(path, mode);
}

@Override
public long[] getgroups() {
return Platform.getPlatform().getGroups(null);
}
}
Expand Up @@ -103,5 +103,6 @@ public interface TrufflePosix {
int fsync(int fd);
int isatty(int fd);
int mkfifo(String path, int mode);
long[] getgroups();

}

0 comments on commit fc52ea4

Please sign in to comment.