Skip to content

Commit 6772b86

Browse files
committed
Fix some platform specific errno values
1 parent d27f43d commit 6772b86

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OSErrorEnum.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
6262
import com.oracle.truffle.api.CompilerDirectives.ValueType;
6363

64+
import static com.oracle.graal.python.builtins.modules.SysModuleBuiltins.PLATFORM_DARWIN;
65+
import static com.oracle.graal.python.util.PythonUtils.getPythonOSName;
66+
6467
public enum OSErrorEnum {
6568

6669
/**
@@ -84,8 +87,8 @@ public enum OSErrorEnum {
8487
ENOEXEC(8, "Exec format error"),
8588
EBADF(9, "Bad file number"),
8689
ECHILD(10, "No child processes"),
87-
EWOULDBLOCK(11, "Operation would block"),
88-
EAGAIN(11, "Try again"),
90+
EWOULDBLOCK(platformSpecific(11, 35), "Operation would block"),
91+
EAGAIN(platformSpecific(11, 35), "Try again"),
8992
ENOMEM(12, "Out of memory"),
9093
EACCES(13, "Permission denied"),
9194
EFAULT(14, "Bad address"),
@@ -109,15 +112,15 @@ public enum OSErrorEnum {
109112
EPIPE(32, "Broken pipe"),
110113
EDOM(33, "Math argument out of domain of func"),
111114
ERANGE(34, "Math result not representable"),
112-
EDEADLOCK(35),
113-
EDEADLK(35, "Resource deadlock would occur"),
114-
ENAMETOOLONG(36, "File name too long"),
115-
ENOLCK(37, "No record locks available"),
116-
ENOSYS(38, "Invalid system call number"),
117-
ENOTEMPTY(39, "Directory not empty"),
118-
ELOOP(40, "Too many symbolic links encountered", "Too many levels of symbolic links"),
119-
ENOMSG(42, "No message of desired type"),
120-
EIDRM(43, "Identifier removed"),
115+
EDEADLOCK(platformSpecific(35, 11)),
116+
EDEADLK(platformSpecific(35, 11), "Resource deadlock would occur"),
117+
ENAMETOOLONG(platformSpecific(36, 63), "File name too long"),
118+
ENOLCK(platformSpecific(37, 77), "No record locks available"),
119+
ENOSYS(platformSpecific(38, 78), "Invalid system call number"),
120+
ENOTEMPTY(platformSpecific(39, 66), "Directory not empty"),
121+
ELOOP(platformSpecific(40, 62), "Too many symbolic links encountered", "Too many levels of symbolic links"),
122+
ENOMSG(platformSpecific(42, 91), "No message of desired type"),
123+
EIDRM(platformSpecific(43, 90), "Identifier removed"),
121124
ECHRNG(44, "Channel number out of range"),
122125
EL2NSYNC(45, "Level 2 not synchronized"),
123126
EL3HLT(46, "Level 3 halted"),
@@ -348,4 +351,8 @@ public ErrorAndMessagePair(OSErrorEnum oserror, String message) {
348351
this.message = message;
349352
}
350353
}
354+
355+
private static int platformSpecific(int linuxValue, int darwinValue) {
356+
return getPythonOSName().equals(PLATFORM_DARWIN) ? darwinValue : linuxValue;
357+
}
351358
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
public final class PosixConstants {
4949

50+
// @formatter:off Generated code
5051
// start generated by gen_native_cfg.py
5152
public static final MandatoryIntConstant FD_SETSIZE;
5253
public static final MandatoryIntConstant PATH_MAX;
@@ -201,6 +202,7 @@ public final class PosixConstants {
201202
accessMode = new IntConstant[]{R_OK, W_OK, X_OK, F_OK};
202203
}
203204
// end generated by gen_native_cfg.py
205+
// @formatter:on
204206

205207
public abstract static class IntConstant {
206208
public final String name;

0 commit comments

Comments
 (0)