Skip to content

Commit bdd73ee

Browse files
committed
[GR-33126] Fix deprecated stat64 on Darwin.
PullRequest: graal/9544
2 parents d201ce2 + 17d9a28 commit bdd73ee

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixStat.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public static boolean isOpen(int fd) {
4444
LinuxStat.stat64 stat = StackValue.get(LinuxStat.stat64.class);
4545
result = LinuxStat.fstat64(fd, stat);
4646
} else if (Platform.includedIn(Platform.DARWIN.class)) {
47-
DarwinStat.stat64 stat = StackValue.get(DarwinStat.stat64.class);
48-
result = DarwinStat.fstat64(fd, stat);
47+
DarwinStat.stat stat = StackValue.get(DarwinStat.stat.class);
48+
result = DarwinStat.fstat(fd, stat);
4949
} else {
5050
throw VMError.shouldNotReachHere("Unsupported platform");
5151
}
@@ -62,8 +62,8 @@ public static SignedWord getSize(int fd) {
6262
size = stat.st_size();
6363
}
6464
} else if (Platform.includedIn(Platform.DARWIN.class)) {
65-
DarwinStat.stat64 stat = StackValue.get(DarwinStat.stat64.class);
66-
if (DarwinStat.NoTransitions.fstat64(fd, stat) == 0) {
65+
DarwinStat.stat stat = StackValue.get(DarwinStat.stat.class);
66+
if (DarwinStat.NoTransitions.fstat(fd, stat) == 0) {
6767
size = stat.st_size();
6868
}
6969
}

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/headers/PosixDirectives.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ public List<String> getOptions() {
9595

9696
@Override
9797
public List<String> getMacroDefinitions() {
98-
return Arrays.asList("_GNU_SOURCE", "_LARGEFILE64_SOURCE");
98+
return Arrays.asList("_GNU_SOURCE", "_LARGEFILE64_SOURCE", "_DARWIN_USE_64_BIT_INODE");
9999
}
100100
}

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/headers/darwin/DarwinStat.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,23 @@
4040
@CContext(PosixDirectives.class)
4141
public class DarwinStat {
4242

43+
/*
44+
* NOTE that we set _DARWIN_USE_64_BIT_INODE in the C directives to force a layout for struct
45+
* stat with a 64-bit st_ino, and we have to call functions with a $INODE64 suffix to match,
46+
* such as fstat$INODE64.
47+
*/
48+
4349
@CStruct(addStructKeyword = true)
44-
public interface stat64 extends PointerBase {
50+
public interface stat extends PointerBase {
4551
@CField
4652
long st_size();
4753
}
4854

49-
@CFunction("fstat64")
50-
public static native int fstat64(int fd, stat64 buf);
55+
@CFunction("fstat$INODE64")
56+
public static native int fstat(int fd, stat buf);
5157

5258
public static class NoTransitions {
53-
@CFunction(transition = CFunction.Transition.NO_TRANSITION)
54-
public static native int fstat64(int fd, stat64 buf);
59+
@CFunction(value = "fstat$INODE64", transition = CFunction.Transition.NO_TRANSITION)
60+
public static native int fstat(int fd, stat buf);
5561
}
5662
}

0 commit comments

Comments
 (0)