Skip to content

Commit e48615e

Browse files
author
Franziska Geiger
committed
- Little reworks
- Added some truffle boundaries
1 parent 739a2a6 commit e48615e

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

graalpython/com.oracle.graal.python.cext/src/tupleobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,14 @@ int getPid() {
331331

332332
@Builtin(name = "getuid", minNumOfPositionalArgs = 0)
333333
@GenerateNodeFactory
334-
public abstract static class GetUidNode extends PythonBuiltinNode {
334+
public abstract static class GetUidNode extends PythonUnaryBuiltinNode {
335335
@Specialization
336336
int getPid() {
337+
return getSystemUid();
338+
}
339+
340+
@TruffleBoundary
341+
int getSystemUid() {
337342
String osName = System.getProperty("os.name");
338343
if (osName.contains("Linux")) {
339344
return (int) new com.sun.security.auth.module.UnixSystem().getUid();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
4949
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
5050
import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
51+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
5152
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
5253
import com.oracle.truffle.api.dsl.NodeFactory;
5354
import com.oracle.truffle.api.dsl.Specialization;
@@ -69,6 +70,11 @@ public abstract static class GetpwuidNode extends PythonUnaryBuiltinNode {
6970

7071
@Specialization
7172
Object doGetpwuid(int uid) {
73+
return factory().createTuple(createPwuidObject(uid));
74+
}
75+
76+
@TruffleBoundary
77+
public Object[] createPwuidObject(int uid) {
7278
String osName = System.getProperty("os.name");
7379
String username = System.getProperty("user.name");
7480
String password = "NOT_AVAILABLE";
@@ -83,15 +89,17 @@ Object doGetpwuid(int uid) {
8389
gid = unix.getGid();
8490
shell = "/bin/sh";
8591
}
86-
return factory().createTuple(new Object[]{
87-
username,
88-
password,
89-
uid,
90-
gid,
91-
gecos,
92-
homeDir,
93-
shell
94-
});
92+
93+
return new Object[]{
94+
username,
95+
password,
96+
uid,
97+
gid,
98+
gecos,
99+
homeDir,
100+
shell
101+
};
95102
}
96103
}
104+
97105
}

0 commit comments

Comments
 (0)