-
Notifications
You must be signed in to change notification settings - Fork 914
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
5 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,24 +182,13 @@ public int getGID() { | |
|
||
} | ||
|
||
@CoreMethod(names = "getgroups", isModuleFunction = true, required = 2, lowerFixnum = 1, unsafe = {UnsafeGroup.MEMORY, UnsafeGroup.PROCESSES}) | ||
@CoreMethod(names = "getgroups", isModuleFunction = true, unsafe = {UnsafeGroup.MEMORY, UnsafeGroup.PROCESSES}) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
eregon
Author
Member
|
||
public abstract static class GetGroupsNode extends CoreMethodArrayArgumentsNode { | ||
|
||
@TruffleBoundary | ||
@Specialization(guards = "isNil(pointer)") | ||
public int getGroupsNil(int max, DynamicObject pointer) { | ||
return getGroups().length; | ||
} | ||
|
||
@TruffleBoundary | ||
@Specialization(guards = "isRubyPointer(pointer)") | ||
public int getGroups(int max, DynamicObject pointer) { | ||
final Pointer pointerValue = Layouts.POINTER.getPointer(pointer); | ||
@Specialization | ||
public DynamicObject getgroups() { | ||
final long[] groups = getGroups(); | ||
for (int n = 0; n < groups.length; n++) { | ||
pointerValue.putInt(4 * n, (int) groups[n]); | ||
} | ||
return groups.length; | ||
return createArray(groups, groups.length); | ||
} | ||
|
||
@TruffleBoundary | ||
|
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
Is this still unsafe then, since we're using a JDK method. At the very least, I'd think it's memory-safe.