|
24 | 24 | */ |
25 | 25 | package com.oracle.svm.core.posix.headers.darwin; |
26 | 26 |
|
| 27 | +import com.oracle.svm.core.util.VMError; |
| 28 | +import org.graalvm.nativeimage.Platform; |
| 29 | +import org.graalvm.nativeimage.Platforms; |
27 | 30 | import org.graalvm.nativeimage.c.CContext; |
28 | 31 | import org.graalvm.nativeimage.c.function.CFunction; |
29 | 32 | import org.graalvm.nativeimage.c.struct.CField; |
@@ -53,10 +56,42 @@ public interface stat extends PointerBase { |
53 | 56 | } |
54 | 57 |
|
55 | 58 | @CFunction("fstat$INODE64") |
56 | | - public static native int fstat(int fd, stat buf); |
| 59 | + @Platforms({Platform.DARWIN_AMD64.class}) |
| 60 | + public static native int fstat_amd64(int fd, stat buf); |
| 61 | + |
| 62 | + @CFunction("fstat") |
| 63 | + @Platforms({Platform.DARWIN_AARCH64.class}) |
| 64 | + public static native int fstat_aarch64(int fd, stat buf); |
| 65 | + |
| 66 | + @Platforms(Platform.DARWIN.class) |
| 67 | + public static int fstat(int fd, stat buf) { |
| 68 | + if (Platform.includedIn(Platform.AMD64.class)) { |
| 69 | + return fstat_amd64(fd, buf); |
| 70 | + } else if (Platform.includedIn(Platform.AARCH64.class)) { |
| 71 | + return fstat_aarch64(fd, buf); |
| 72 | + } else { |
| 73 | + throw VMError.shouldNotReachHere(); |
| 74 | + } |
| 75 | + } |
57 | 76 |
|
58 | 77 | public static class NoTransitions { |
59 | 78 | @CFunction(value = "fstat$INODE64", transition = CFunction.Transition.NO_TRANSITION) |
60 | | - public static native int fstat(int fd, stat buf); |
| 79 | + @Platforms({Platform.DARWIN_AMD64.class}) |
| 80 | + public static native int fstat_amd64(int fd, stat buf); |
| 81 | + |
| 82 | + @CFunction(value = "fstat", transition = CFunction.Transition.NO_TRANSITION) |
| 83 | + @Platforms({Platform.DARWIN_AARCH64.class}) |
| 84 | + public static native int fstat_aarch64(int fd, stat buf); |
| 85 | + |
| 86 | + @Platforms(Platform.DARWIN.class) |
| 87 | + public static int fstat(int fd, stat buf) { |
| 88 | + if (Platform.includedIn(Platform.AMD64.class)) { |
| 89 | + return fstat_amd64(fd, buf); |
| 90 | + } else if (Platform.includedIn(Platform.AARCH64.class)) { |
| 91 | + return fstat_aarch64(fd, buf); |
| 92 | + } else { |
| 93 | + throw VMError.shouldNotReachHere(); |
| 94 | + } |
| 95 | + } |
61 | 96 | } |
62 | 97 | } |
0 commit comments