Revert "[Ravenwood] Internal clean up, more PFD APIs, OsConstant..."
Revert submission 27402077-2024-05-17-PFD
Reason for revert: Broke tests
Reverted changes: /q/submissionid:27402077-2024-05-17-PFD
Change-Id: If2b50329dbcaccb5f13f7631f1fa4df532bfcc60
diff --git a/core/java/android/os/ParcelFileDescriptor.java b/core/java/android/os/ParcelFileDescriptor.java
index 71957ee..17dfdda 100644
--- a/core/java/android/os/ParcelFileDescriptor.java
+++ b/core/java/android/os/ParcelFileDescriptor.java
@@ -52,8 +52,6 @@
import android.util.Log;
import android.util.Slog;
-import com.android.internal.ravenwood.RavenwoodEnvironment;
-
import dalvik.system.VMRuntime;
import libcore.io.IoUtils;
@@ -390,6 +388,7 @@
* new file descriptor shared state such as file position with the
* original file descriptor.
*/
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor dup(FileDescriptor orig) throws IOException {
try {
final FileDescriptor fd = new FileDescriptor();
@@ -407,6 +406,7 @@
* new file descriptor shared state such as file position with the
* original file descriptor.
*/
+ @RavenwoodThrow(reason = "Requires JNI support")
public ParcelFileDescriptor dup() throws IOException {
if (mWrapped != null) {
return mWrapped.dup();
@@ -425,6 +425,7 @@
* @return Returns a new ParcelFileDescriptor holding a FileDescriptor
* for a dup of the given fd.
*/
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor fromFd(int fd) throws IOException {
final FileDescriptor original = new FileDescriptor();
setFdInt(original, fd);
@@ -484,7 +485,7 @@
*
* @throws UncheckedIOException if {@link #dup(FileDescriptor)} throws IOException.
*/
- @RavenwoodThrow(reason = "Socket.getFileDescriptor$()")
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor fromSocket(Socket socket) {
FileDescriptor fd = socket.getFileDescriptor$();
try {
@@ -518,7 +519,7 @@
*
* @throws UncheckedIOException if {@link #dup(FileDescriptor)} throws IOException.
*/
- @RavenwoodThrow(reason = "DatagramSocket.getFileDescriptor$()")
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor fromDatagramSocket(DatagramSocket datagramSocket) {
FileDescriptor fd = datagramSocket.getFileDescriptor$();
try {
@@ -533,6 +534,7 @@
* ParcelFileDescriptor in the returned array is the read side; the second
* is the write side.
*/
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor[] createPipe() throws IOException {
try {
final FileDescriptor[] fds = Os.pipe2(ifAtLeastQ(O_CLOEXEC));
@@ -554,6 +556,7 @@
* calling {@link #checkError()}, usually after detecting an EOF.
* This can also be used to detect remote crashes.
*/
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor[] createReliablePipe() throws IOException {
try {
final FileDescriptor[] comm = createCommSocketPair();
@@ -570,7 +573,7 @@
* Create two ParcelFileDescriptors structured as a pair of sockets
* connected to each other. The two sockets are indistinguishable.
*/
- @RavenwoodThrow(reason = "Os.socketpair()")
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor[] createSocketPair() throws IOException {
return createSocketPair(SOCK_STREAM);
}
@@ -578,7 +581,7 @@
/**
* @hide
*/
- @RavenwoodThrow(reason = "Os.socketpair()")
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor[] createSocketPair(int type) throws IOException {
try {
final FileDescriptor fd0 = new FileDescriptor();
@@ -601,7 +604,7 @@
* calling {@link #checkError()}, usually after detecting an EOF.
* This can also be used to detect remote crashes.
*/
- @RavenwoodThrow(reason = "Os.socketpair()")
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor[] createReliableSocketPair() throws IOException {
return createReliableSocketPair(SOCK_STREAM);
}
@@ -609,7 +612,7 @@
/**
* @hide
*/
- @RavenwoodThrow(reason = "Os.socketpair()")
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor[] createReliableSocketPair(int type) throws IOException {
try {
final FileDescriptor[] comm = createCommSocketPair();
@@ -624,7 +627,7 @@
}
}
- @RavenwoodThrow(reason = "Os.socketpair()")
+ @RavenwoodThrow(reason = "Requires JNI support")
private static FileDescriptor[] createCommSocketPair() throws IOException {
try {
// Use SOCK_SEQPACKET so that we have a guarantee that the status
@@ -653,7 +656,7 @@
*/
@UnsupportedAppUsage
@Deprecated
- @RavenwoodThrow(blockedBy = MemoryFile.class)
+ @RavenwoodThrow(reason = "Requires JNI support")
public static ParcelFileDescriptor fromData(byte[] data, String name) throws IOException {
if (data == null) return null;
MemoryFile file = new MemoryFile(name, data.length);
@@ -709,7 +712,7 @@
* @hide
*/
@TestApi
- @RavenwoodThrow(reason = "Os.readlink() and Os.stat()")
+ @RavenwoodThrow(reason = "Requires kernel support")
public static File getFile(FileDescriptor fd) throws IOException {
try {
final String path = Os.readlink("/proc/self/fd/" + getFdInt(fd));
@@ -741,7 +744,7 @@
* Return the total size of the file representing this fd, as determined by
* {@code stat()}. Returns -1 if the fd is not a file.
*/
- @RavenwoodThrow(reason = "Os.readlink() and Os.stat()")
+ @RavenwoodThrow(reason = "Requires JNI support")
public long getStatSize() {
if (mWrapped != null) {
return mWrapped.getStatSize();
@@ -766,6 +769,7 @@
* @hide
*/
@UnsupportedAppUsage
+ @RavenwoodThrow(reason = "Requires JNI support")
public long seekTo(long pos) throws IOException {
if (mWrapped != null) {
return mWrapped.seekTo(pos);
@@ -1033,6 +1037,7 @@
* take care of calling {@link ParcelFileDescriptor#close
* ParcelFileDescriptor.close()} for you when the stream is closed.
*/
+ @RavenwoodKeepWholeClass
public static class AutoCloseInputStream extends FileInputStream {
private final ParcelFileDescriptor mPfd;
@@ -1321,15 +1326,12 @@
}
- @RavenwoodReplace
+ @RavenwoodThrow
private static boolean isAtLeastQ() {
return (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.Q);
}
- private static boolean isAtLeastQ$ravenwood() {
- return RavenwoodEnvironment.workaround().isTargetSdkAtLeastQ();
- }
-
+ @RavenwoodThrow
private static int ifAtLeastQ(int value) {
return isAtLeastQ() ? value : 0;
}
diff --git a/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java b/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java
index 2f98844..1340156 100644
--- a/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java
+++ b/core/java/com/android/internal/ravenwood/RavenwoodEnvironment.java
@@ -15,17 +15,12 @@
*/
package com.android.internal.ravenwood;
-import android.ravenwood.annotation.RavenwoodNativeSubstitutionClass;
-
/**
* Class to interact with the Ravenwood environment.
*/
@android.ravenwood.annotation.RavenwoodKeepWholeClass
-@RavenwoodNativeSubstitutionClass(
- "com.android.platform.test.ravenwood.nativesubstitution.RavenwoodEnvironment_host")
public class RavenwoodEnvironment {
private static RavenwoodEnvironment sInstance = new RavenwoodEnvironment();
- private static Workaround sWorkaround = new Workaround();
private RavenwoodEnvironment() {
}
@@ -57,30 +52,4 @@
public boolean isRunningOnRavenwood$ravenwood() {
return true;
}
-
- /**
- * See {@link Workaround}. It's only usablke on Ravenwood.
- */
- public static Workaround workaround() {
- if (getInstance().isRunningOnRavenwood()) {
- return sWorkaround;
- }
- throw new IllegalStateException("Workaround can only be used on Ravenwood");
- }
-
- /**
- * A set of APIs used to work around missing features on Ravenwood. Ideally, this class should
- * be empty, and all its APIs should be able to be implemented properly.
- */
- public static class Workaround {
- Workaround() {
- }
-
- /**
- * @return whether the app's target SDK level is at least Q.
- */
- public boolean isTargetSdkAtLeastQ() {
- return true;
- }
- }
}
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp
index 055a05c..95cbb6b 100644
--- a/ravenwood/Android.bp
+++ b/ravenwood/Android.bp
@@ -56,24 +56,11 @@
visibility: ["//visibility:public"],
}
-java_library {
- name: "ravenwood-runtime-common",
- host_supported: true,
- sdk_version: "core_current",
- srcs: [
- "runtime-common-src/**/*.java",
- ],
- visibility: ["//visibility:private"],
-}
-
java_library_host {
name: "ravenwood-helper-libcore-runtime.host",
srcs: [
"runtime-helper-src/libcore-fake/**/*.java",
],
- static_libs: [
- "ravenwood-runtime-common",
- ],
visibility: ["//visibility:private"],
}
@@ -90,9 +77,6 @@
srcs: [
"runtime-helper-src/framework/**/*.java",
],
- static_libs: [
- "ravenwood-runtime-common",
- ],
libs: [
"framework-minus-apex.ravenwood",
"ravenwood-junit",
@@ -121,7 +105,6 @@
],
static_libs: [
"androidx.test.monitor-for-device",
- "ravenwood-runtime-common",
],
libs: [
"android.test.mock",
@@ -162,9 +145,6 @@
"junit-flag-src/**/*.java",
],
sdk_version: "test_current",
- static_libs: [
- "ravenwood-runtime-common",
- ],
libs: [
"junit",
"flag-junit",
@@ -219,7 +199,7 @@
],
srcs: [
- "runtime-jni/*.cpp",
+ "runtime-helper-src/jni/*.cpp",
],
shared_libs: [
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
index 70523d6..56a3c64 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
@@ -86,6 +86,10 @@
sPendingUncaughtException.compareAndSet(null, throwable);
};
+ public static boolean isOnRavenwood() {
+ return true;
+ }
+
public static void init(RavenwoodRule rule) {
if (ENABLE_UNCAUGHT_EXCEPTION_DETECTION) {
maybeThrowPendingUncaughtException(false);
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
index 68b5aeb..9d12f85 100644
--- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
@@ -29,8 +29,6 @@
import android.platform.test.annotations.EnabledOnRavenwood;
import android.platform.test.annotations.IgnoreUnderRavenwood;
-import com.android.ravenwood.common.RavenwoodCommonUtils;
-
import org.junit.Assume;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -56,7 +54,7 @@
* before a test class is fully initialized.
*/
public class RavenwoodRule implements TestRule {
- static final boolean IS_ON_RAVENWOOD = RavenwoodCommonUtils.isOnRavenwood();
+ static final boolean IS_ON_RAVENWOOD = RavenwoodRuleImpl.isOnRavenwood();
/**
* When probing is enabled, all tests will be unconditionally run on Ravenwood to detect
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java
index 19c1bff..99ab327 100644
--- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java
@@ -15,7 +15,9 @@
*/
package android.platform.test.ravenwood;
-import com.android.ravenwood.common.RavenwoodCommonUtils;
+import java.io.File;
+import java.io.PrintStream;
+import java.util.Arrays;
/**
* Utilities for writing (bivalent) ravenwood tests.
@@ -24,6 +26,15 @@
private RavenwoodUtils() {
}
+ private static final String RAVENWOOD_NATIVE_RUNTIME_NAME = "ravenwood_runtime";
+
+ // LibcoreRavenwoodUtils calls it with reflections.
+ public static void loadRavenwoodNativeRuntime() {
+ if (RavenwoodRule.isOnRavenwood()) {
+ RavenwoodUtils.loadJniLibrary(RAVENWOOD_NATIVE_RUNTIME_NAME);
+ }
+ }
+
/**
* Load a JNI library respecting {@code java.library.path}
* (which reflects {@code LD_LIBRARY_PATH}).
@@ -45,6 +56,85 @@
* it uses {@code JNI_OnLoad()} as the entry point name on both.
*/
public static void loadJniLibrary(String libname) {
- RavenwoodCommonUtils.loadJniLibrary(libname);
+ if (RavenwoodRule.isOnRavenwood()) {
+ loadLibraryOnRavenwood(libname);
+ } else {
+ // Just delegate to the loadLibrary().
+ System.loadLibrary(libname);
+ }
+ }
+
+ private static void loadLibraryOnRavenwood(String libname) {
+ var path = System.getProperty("java.library.path");
+ var filename = "lib" + libname + ".so";
+
+ System.out.println("Looking for library " + libname + ".so in java.library.path:" + path);
+
+ try {
+ if (path == null) {
+ throw new UnsatisfiedLinkError("Cannot load library " + libname + "."
+ + " Property java.library.path not set!");
+ }
+ for (var dir : path.split(":")) {
+ var file = new File(dir + "/" + filename);
+ if (file.exists()) {
+ System.load(file.getAbsolutePath());
+ return;
+ }
+ }
+ throw new UnsatisfiedLinkError("Library " + libname + " not found in "
+ + "java.library.path: " + path);
+ } catch (Throwable e) {
+ dumpFiles(System.out);
+ throw e;
+ }
+ }
+
+ private static void dumpFiles(PrintStream out) {
+ try {
+ var path = System.getProperty("java.library.path");
+ out.println("# java.library.path=" + path);
+
+ for (var dir : path.split(":")) {
+ listFiles(out, new File(dir), "");
+
+ var gparent = new File((new File(dir)).getAbsolutePath() + "../../..")
+ .getCanonicalFile();
+ if (gparent.getName().contains("testcases")) {
+ // Special case: if we found this directory, dump its contents too.
+ listFiles(out, gparent, "");
+ }
+ }
+
+ var gparent = new File("../..").getCanonicalFile();
+ out.println("# ../..=" + gparent);
+ listFiles(out, gparent, "");
+ } catch (Throwable th) {
+ out.println("Error: " + th.toString());
+ th.printStackTrace(out);
+ }
+ }
+
+ private static void listFiles(PrintStream out, File dir, String prefix) {
+ if (!dir.isDirectory()) {
+ out.println(prefix + dir.getAbsolutePath() + " is not a directory!");
+ return;
+ }
+ out.println(prefix + ":" + dir.getAbsolutePath() + "/");
+ // First, list the files.
+ for (var file : Arrays.stream(dir.listFiles()).sorted().toList()) {
+ out.println(prefix + " " + file.getName() + "" + (file.isDirectory() ? "/" : ""));
+ }
+
+ // Then recurse.
+ if (dir.getAbsolutePath().startsWith("/usr") || dir.getAbsolutePath().startsWith("/lib")) {
+ // There would be too many files, so don't recurse.
+ return;
+ }
+ for (var file : Arrays.stream(dir.listFiles()).sorted().toList()) {
+ if (file.isDirectory()) {
+ listFiles(out, file, prefix + " ");
+ }
+ }
}
}
diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
index 483b98a..773a89a 100644
--- a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
+++ b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
@@ -20,6 +20,10 @@
import org.junit.runners.model.Statement;
public class RavenwoodRuleImpl {
+ public static boolean isOnRavenwood() {
+ return false;
+ }
+
public static void init(RavenwoodRule rule) {
// No-op when running on a real device
}
diff --git a/ravenwood/runtime-common-src/com/android/ravenwood/common/JvmWorkaround.java b/ravenwood/runtime-common-src/com/android/ravenwood/common/JvmWorkaround.java
deleted file mode 100644
index ee28099..0000000
--- a/ravenwood/runtime-common-src/com/android/ravenwood/common/JvmWorkaround.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ravenwood.common;
-
-import java.io.FileDescriptor;
-
-/**
- * Collection of methods to workaround limitation in the hostside JVM.
- */
-public abstract class JvmWorkaround {
- JvmWorkaround() {
- }
-
- // We only support OpenJDK for now.
- private static JvmWorkaround sInstance =
- RavenwoodCommonUtils.isOnRavenwood() ? new OpenJdkWorkaround() : new NullWorkaround();
-
- public static JvmWorkaround getInstance() {
- return sInstance;
- }
-
- /**
- * Equivalent to Android's FileDescriptor.setInt$().
- */
- public abstract void setFdInt(FileDescriptor fd, int fdInt);
-
-
- /**
- * Equivalent to Android's FileDescriptor.getInt$().
- */
- public abstract int getFdInt(FileDescriptor fd);
-
- /**
- * Placeholder implementation for the host side.
- *
- * Even on the host side, we don't want to throw just because the class is loaded,
- * which could cause weird random issues, so we throw from individual methods rather
- * than from the constructor.
- */
- private static class NullWorkaround extends JvmWorkaround {
- private RuntimeException calledOnHostside() {
- throw new RuntimeException("This method shouldn't be called on the host side");
- }
-
- @Override
- public void setFdInt(FileDescriptor fd, int fdInt) {
- throw calledOnHostside();
- }
-
- @Override
- public int getFdInt(FileDescriptor fd) {
- throw calledOnHostside();
- }
- }
-}
diff --git a/ravenwood/runtime-common-src/com/android/ravenwood/common/OpenJdkWorkaround.java b/ravenwood/runtime-common-src/com/android/ravenwood/common/OpenJdkWorkaround.java
deleted file mode 100644
index 9aedaab..0000000
--- a/ravenwood/runtime-common-src/com/android/ravenwood/common/OpenJdkWorkaround.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ravenwood.common;
-
-import java.io.FileDescriptor;
-
-class OpenJdkWorkaround extends JvmWorkaround {
- @Override
- public void setFdInt(FileDescriptor fd, int fdInt) {
- try {
- final Object obj = Class.forName("jdk.internal.access.SharedSecrets").getMethod(
- "getJavaIOFileDescriptorAccess").invoke(null);
- Class.forName("jdk.internal.access.JavaIOFileDescriptorAccess").getMethod(
- "set", FileDescriptor.class, int.class).invoke(obj, fd, fdInt);
- } catch (ReflectiveOperationException e) {
- throw new RuntimeException("Failed to interact with raw FileDescriptor internals;"
- + " perhaps JRE has changed?", e);
- }
- }
-
- @Override
- public int getFdInt(FileDescriptor fd) {
- try {
- final Object obj = Class.forName("jdk.internal.access.SharedSecrets").getMethod(
- "getJavaIOFileDescriptorAccess").invoke(null);
- return (int) Class.forName("jdk.internal.access.JavaIOFileDescriptorAccess").getMethod(
- "get", FileDescriptor.class).invoke(obj, fd);
- } catch (ReflectiveOperationException e) {
- throw new RuntimeException("Failed to interact with raw FileDescriptor internals;"
- + " perhaps JRE has changed?", e);
- }
- }
-}
diff --git a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java b/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java
deleted file mode 100644
index a94cab2..0000000
--- a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ravenwood.common;
-
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.PrintStream;
-import java.util.Arrays;
-
-public class RavenwoodCommonUtils {
- private RavenwoodCommonUtils() {
- }
-
- private static final Object sLock = new Object();
-
- /** Name of `libravenwood_runtime` */
- private static final String RAVENWOOD_NATIVE_RUNTIME_NAME = "ravenwood_runtime";
-
- /** Directory name of `out/host/linux-x86/testcases/ravenwood-runtime` */
- private static final String RAVENWOOD_RUNTIME_DIR_NAME = "ravenwood-runtime";
-
- private static boolean sEnableExtraRuntimeCheck =
- "1".equals(System.getenv("RAVENWOOD_ENABLE_EXTRA_RUNTIME_CHECK"));
-
- private static final boolean IS_ON_RAVENWOOD = isOnRavenwoodInternal();
-
- private static final String RAVEWOOD_RUNTIME_PATH = getRavenwoodRuntimePathInternal();
-
- /**
- * @return if we're running on Ravenwood.
- */
- public static boolean isOnRavenwood() {
- return IS_ON_RAVENWOOD;
- }
-
- private static boolean isOnRavenwoodInternal() {
- // Call RavenwoodEnvironment.getInstance().isRunningOnRavenwood(),
- // but here we can't use Android APIs directly, so use reflections.
- try {
- var clazz = Class.forName("com.android.internal.ravenwood.RavenwoodEnvironment");
- var getInstance = clazz.getMethod("getInstance");
- var isRunningOnRavenwood = clazz.getMethod("isRunningOnRavenwood");
-
- var instance = getInstance.invoke(null);
- return (boolean) isRunningOnRavenwood.invoke(instance);
-
- } catch (Exception e) {
- throw new RuntimeException("Can't access RavenwoodEnvironment", e);
- }
- }
-
- /**
- * Throws if the runtime is not Ravenwood.
- */
- public static void ensureOnRavenwood() {
- if (!isOnRavenwood()) {
- throw new RavenwoodRuntimeException("This is only supposed to be used on Ravenwood");
- }
- }
-
- /**
- * @return if the various extra runtime check should be enabled.
- */
- public static boolean shouldEnableExtraRuntimeCheck() {
- return sEnableExtraRuntimeCheck;
- }
-
- /**
- * Load the main runtime JNI library.
- */
- public static void loadRavenwoodNativeRuntime() {
- ensureOnRavenwood();
- loadJniLibrary(RAVENWOOD_NATIVE_RUNTIME_NAME);
- }
-
- /**
- * Internal implementation of
- * {@link android.platform.test.ravenwood.RavenwoodUtils#loadJniLibrary(String)}
- */
- public static void loadJniLibrary(String libname) {
- if (RavenwoodCommonUtils.isOnRavenwood()) {
- loadJniLibraryInternal(libname);
- } else {
- System.loadLibrary(libname);
- }
- }
-
- /**
- * Function equivalent to ART's System.loadLibrary. See RavenwoodUtils for why we need it.
- */
- private static void loadJniLibraryInternal(String libname) {
- var path = System.getProperty("java.library.path");
- var filename = "lib" + libname + ".so";
-
- System.out.println("Looking for library " + libname + ".so in java.library.path:" + path);
-
- try {
- if (path == null) {
- throw new UnsatisfiedLinkError("Cannot load library " + libname + "."
- + " Property java.library.path not set!");
- }
- for (var dir : path.split(":")) {
- var file = new File(dir + "/" + filename);
- if (file.exists()) {
- System.load(file.getAbsolutePath());
- return;
- }
- }
- throw new UnsatisfiedLinkError("Library " + libname + " not found in "
- + "java.library.path: " + path);
- } catch (Throwable e) {
- dumpFiles(System.out);
- throw e;
- }
- }
-
- private static void dumpFiles(PrintStream out) {
- try {
- var path = System.getProperty("java.library.path");
- out.println("# java.library.path=" + path);
-
- for (var dir : path.split(":")) {
- listFiles(out, new File(dir), "");
-
- var gparent = new File((new File(dir)).getAbsolutePath() + "../../..")
- .getCanonicalFile();
- if (gparent.getName().contains("testcases")) {
- // Special case: if we found this directory, dump its contents too.
- listFiles(out, gparent, "");
- }
- }
-
- var gparent = new File("../..").getCanonicalFile();
- out.println("# ../..=" + gparent);
- listFiles(out, gparent, "");
- } catch (Throwable th) {
- out.println("Error: " + th.toString());
- th.printStackTrace(out);
- }
- }
-
- private static void listFiles(PrintStream out, File dir, String prefix) {
- if (!dir.isDirectory()) {
- out.println(prefix + dir.getAbsolutePath() + " is not a directory!");
- return;
- }
- out.println(prefix + ":" + dir.getAbsolutePath() + "/");
- // First, list the files.
- for (var file : Arrays.stream(dir.listFiles()).sorted().toList()) {
- out.println(prefix + " " + file.getName() + "" + (file.isDirectory() ? "/" : ""));
- }
-
- // Then recurse.
- if (dir.getAbsolutePath().startsWith("/usr") || dir.getAbsolutePath().startsWith("/lib")) {
- // There would be too many files, so don't recurse.
- return;
- }
- for (var file : Arrays.stream(dir.listFiles()).sorted().toList()) {
- if (file.isDirectory()) {
- listFiles(out, file, prefix + " ");
- }
- }
- }
-
- /**
- * @return the full directory path that contains the "ravenwood-runtime" files.
- *
- * This method throws if called on the device side.
- */
- public static String getRavenwoodRuntimePath() {
- ensureOnRavenwood();
- return RAVEWOOD_RUNTIME_PATH;
- }
-
- private static String getRavenwoodRuntimePathInternal() {
- if (!isOnRavenwood()) {
- return null;
- }
- var path = System.getProperty("java.library.path");
-
- System.out.println("Looking for " + RAVENWOOD_RUNTIME_DIR_NAME + " directory"
- + " in java.library.path:" + path);
-
- try {
- if (path == null) {
- throw new IllegalStateException("java.library.path shouldn't be null");
- }
- for (var dir : path.split(":")) {
-
- // For each path, see if the path contains RAVENWOOD_RUNTIME_DIR_NAME.
- var d = new File(dir);
- for (;;) {
- if (d.getParent() == null) {
- break; // Root dir, stop.
- }
- if (RAVENWOOD_RUNTIME_DIR_NAME.equals(d.getName())) {
- var ret = d.getAbsolutePath() + "/";
- System.out.println("Found: " + ret);
- return ret;
- }
- d = d.getParentFile();
- }
- }
- throw new IllegalStateException(RAVENWOOD_RUNTIME_DIR_NAME + " not found");
- } catch (Throwable e) {
- dumpFiles(System.out);
- throw e;
- }
- }
-
- /** Close an {@link AutoCloseable}. */
- public static void closeQuietly(AutoCloseable c) {
- if (c != null) {
- try {
- c.close();
- } catch (Exception e) {
- // Ignore
- }
- }
- }
-
- /** Close a {@link FileDescriptor}. */
- public static void closeQuietly(FileDescriptor fd) {
- var is = new FileInputStream(fd);
- RavenwoodCommonUtils.closeQuietly(is);
- }
-}
diff --git a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodRuntimeException.java b/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodRuntimeException.java
deleted file mode 100644
index 7b0cebc..0000000
--- a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodRuntimeException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ravenwood.common;
-
-public class RavenwoodRuntimeException extends RuntimeException {
- public RavenwoodRuntimeException(String message) {
- super(message);
- }
-
- public RavenwoodRuntimeException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodRuntimeNative.java b/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodRuntimeNative.java
deleted file mode 100644
index 6540221..0000000
--- a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodRuntimeNative.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ravenwood.common;
-
-import java.io.FileDescriptor;
-
-/**
- * Class to host all the JNI methods used in ravenwood runtime.
- */
-public class RavenwoodRuntimeNative {
- private RavenwoodRuntimeNative() {
- }
-
- static {
- RavenwoodCommonUtils.ensureOnRavenwood();
- RavenwoodCommonUtils.loadRavenwoodNativeRuntime();
- }
-
- public static native void applyFreeFunction(long freeFunction, long nativePtr);
-
- public static native long nLseek(int fd, long offset, int whence);
-
- public static native int[] nPipe2(int flags);
-
- public static native int nDup(int oldfd);
-
- public static native int nFcntlInt(int fd, int cmd, int arg);
-
- public static long lseek(FileDescriptor fd, long offset, int whence) {
- return nLseek(JvmWorkaround.getInstance().getFdInt(fd), offset, whence);
- }
-
- public static FileDescriptor[] pipe2(int flags) {
- var fds = nPipe2(flags);
- var ret = new FileDescriptor[] {
- new FileDescriptor(),
- new FileDescriptor(),
- };
- JvmWorkaround.getInstance().setFdInt(ret[0], fds[0]);
- JvmWorkaround.getInstance().setFdInt(ret[1], fds[1]);
-
- return ret;
- }
-
- public static FileDescriptor dup(FileDescriptor fd) {
- var fdInt = nDup(JvmWorkaround.getInstance().getFdInt(fd));
-
- var retFd = new java.io.FileDescriptor();
- JvmWorkaround.getInstance().setFdInt(retFd, fdInt);
- return retFd;
- }
-
- public static int fcntlInt(FileDescriptor fd, int cmd, int arg) {
- var fdInt = JvmWorkaround.getInstance().getFdInt(fd);
-
- return nFcntlInt(fdInt, cmd, arg);
- }
-}
diff --git a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/ParcelFileDescriptor_host.java b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/ParcelFileDescriptor_host.java
index 8fe6853..2d79914 100644
--- a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/ParcelFileDescriptor_host.java
+++ b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/ParcelFileDescriptor_host.java
@@ -26,7 +26,6 @@
import static android.os.ParcelFileDescriptor.MODE_WRITE_ONLY;
import com.android.internal.annotations.GuardedBy;
-import com.android.ravenwood.common.JvmWorkaround;
import java.io.File;
import java.io.FileDescriptor;
@@ -47,11 +46,27 @@
private static final Map<FileDescriptor, RandomAccessFile> sActive = new HashMap<>();
public static void native_setFdInt$ravenwood(FileDescriptor fd, int fdInt) {
- JvmWorkaround.getInstance().setFdInt(fd, fdInt);
+ try {
+ final Object obj = Class.forName("jdk.internal.access.SharedSecrets").getMethod(
+ "getJavaIOFileDescriptorAccess").invoke(null);
+ Class.forName("jdk.internal.access.JavaIOFileDescriptorAccess").getMethod(
+ "set", FileDescriptor.class, int.class).invoke(obj, fd, fdInt);
+ } catch (ReflectiveOperationException e) {
+ throw new RuntimeException("Failed to interact with raw FileDescriptor internals;"
+ + " perhaps JRE has changed?", e);
+ }
}
public static int native_getFdInt$ravenwood(FileDescriptor fd) {
- return JvmWorkaround.getInstance().getFdInt(fd);
+ try {
+ final Object obj = Class.forName("jdk.internal.access.SharedSecrets").getMethod(
+ "getJavaIOFileDescriptorAccess").invoke(null);
+ return (int) Class.forName("jdk.internal.access.JavaIOFileDescriptorAccess").getMethod(
+ "get", FileDescriptor.class).invoke(obj, fd);
+ } catch (ReflectiveOperationException e) {
+ throw new RuntimeException("Failed to interact with raw FileDescriptor internals;"
+ + " perhaps JRE has changed?", e);
+ }
}
public static FileDescriptor native_open$ravenwood(File file, int pfdMode) throws IOException {
diff --git a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/RavenwoodEnvironment_host.java b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/RavenwoodEnvironment_host.java
deleted file mode 100644
index 1173ca4..0000000
--- a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/RavenwoodEnvironment_host.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.platform.test.ravenwood.nativesubstitution;
-
-import com.android.internal.ravenwood.RavenwoodEnvironment;
-
-/**
- * Class used by {@link RavenwoodEnvironment} to talk to the ravenwood runtime.
- *
- * (So far, it's empty.)
- */
-public class RavenwoodEnvironment_host {
- private RavenwoodEnvironment_host() {
- }
-}
diff --git a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java
index e198646..69ff262 100644
--- a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java
+++ b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java
@@ -15,7 +15,7 @@
*/
package com.android.platform.test.ravenwood.runtimehelper;
-import com.android.ravenwood.common.RavenwoodCommonUtils;
+import android.platform.test.ravenwood.RavenwoodUtils;
import java.io.File;
import java.lang.reflect.Modifier;
@@ -141,7 +141,7 @@
log("Loading " + LIBANDROID_RUNTIME_NAME + " for '" + libanrdoidClasses + "' and '"
+ libhwuiClasses + "'");
- RavenwoodCommonUtils.loadJniLibrary(LIBANDROID_RUNTIME_NAME);
+ RavenwoodUtils.loadJniLibrary(LIBANDROID_RUNTIME_NAME);
}
/**
diff --git a/ravenwood/runtime-helper-src/jni/ravenwood_runtime.cpp b/ravenwood/runtime-helper-src/jni/ravenwood_runtime.cpp
new file mode 100644
index 0000000..8e3a21d
--- /dev/null
+++ b/ravenwood/runtime-helper-src/jni/ravenwood_runtime.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <nativehelper/JNIHelp.h>
+#include "jni.h"
+#include "utils/Log.h"
+#include "utils/misc.h"
+
+
+typedef void (*FreeFunction)(void*);
+
+static void NativeAllocationRegistry_applyFreeFunction(JNIEnv*,
+ jclass,
+ jlong freeFunction,
+ jlong ptr) {
+ void* nativePtr = reinterpret_cast<void*>(static_cast<uintptr_t>(ptr));
+ FreeFunction nativeFreeFunction
+ = reinterpret_cast<FreeFunction>(static_cast<uintptr_t>(freeFunction));
+ nativeFreeFunction(nativePtr);
+}
+
+static const JNINativeMethod sMethods_NAR[] =
+{
+ { "applyFreeFunction", "(JJ)V", (void*)NativeAllocationRegistry_applyFreeFunction },
+};
+
+extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
+{
+ JNIEnv* env = NULL;
+ jint result = -1;
+
+ if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
+ ALOGE("GetEnv failed!");
+ return result;
+ }
+ ALOG_ASSERT(env, "Could not retrieve the env!");
+
+ ALOGI("%s: JNI_OnLoad", __FILE__);
+
+ // Initialize the Ravenwood version of NativeAllocationRegistry.
+ // We don't use this JNI on the device side, but if we ever have to do, skip this part.
+#ifndef __ANDROID__
+ int res = jniRegisterNativeMethods(env, "libcore/util/NativeAllocationRegistry",
+ sMethods_NAR, NELEM(sMethods_NAR));
+ if (res < 0) {
+ return res;
+ }
+#endif
+
+ return JNI_VERSION_1_4;
+}
diff --git a/ravenwood/runtime-helper-src/libcore-fake/android/system/ErrnoException.java b/ravenwood/runtime-helper-src/libcore-fake/android/system/ErrnoException.java
index 843455d..388156a 100644
--- a/ravenwood/runtime-helper-src/libcore-fake/android/system/ErrnoException.java
+++ b/ravenwood/runtime-helper-src/libcore-fake/android/system/ErrnoException.java
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-// [ravenwood] Copied from libcore.
-
package android.system;
import java.io.IOException;
diff --git a/ravenwood/runtime-helper-src/libcore-fake/android/system/Os.java b/ravenwood/runtime-helper-src/libcore-fake/android/system/Os.java
deleted file mode 100644
index e031eb2..0000000
--- a/ravenwood/runtime-helper-src/libcore-fake/android/system/Os.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.system;
-
-import com.android.ravenwood.common.RavenwoodRuntimeNative;
-
-import java.io.FileDescriptor;
-
-/**
- * OS class replacement used on Ravenwood. For now, we just implement APIs as we need them...
- * TODO(b/340887115): Need a better integration with libcore.
- */
-public final class Os {
- private Os() {}
-
- public static long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException {
- return RavenwoodRuntimeNative.lseek(fd, offset, whence);
- }
-
-
- public static FileDescriptor[] pipe2(int flags) throws ErrnoException {
- return RavenwoodRuntimeNative.pipe2(flags);
- }
-
- public static FileDescriptor dup(FileDescriptor fd) throws ErrnoException {
- return RavenwoodRuntimeNative.dup(fd);
- }
-
- public static int fcntlInt(FileDescriptor fd, int cmd, int arg) throws ErrnoException {
- return RavenwoodRuntimeNative.fcntlInt(fd, cmd, arg);
- }
-}
diff --git a/ravenwood/runtime-helper-src/libcore-fake/android/system/OsConstants.java b/ravenwood/runtime-helper-src/libcore-fake/android/system/OsConstants.java
deleted file mode 100644
index c56ec8a..0000000
--- a/ravenwood/runtime-helper-src/libcore-fake/android/system/OsConstants.java
+++ /dev/null
@@ -1,1259 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.system;
-
-import com.android.ravenwood.common.RavenwoodCommonUtils;
-
-/**
- * Copied from libcore's version, with the local changes:
- * - All the imports are removed. (they're only used in javadoc)
- * - All the annotations are removed.
- * - The initConstants() method is moved to a nested class.
- *
- * TODO(b/340887115): Need a better integration with libcore.
- */
-
-public class OsConstants {
-// @UnsupportedAppUsage
- private OsConstants() {
- }
-
- /**
- * Returns the index of the element in the {@link StructCapUserData} (cap_user_data)
- * array that this capability is stored in.
- *
- * @param x capability
- * @return index of the element in the {@link StructCapUserData} array storing this capability
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static int CAP_TO_INDEX(int x) { return x >>> 5; }
-
- /**
- * Returns the mask for the given capability. This is relative to the capability's
- * {@link StructCapUserData} (cap_user_data) element, the index of which can be
- * retrieved with {@link CAP_TO_INDEX}.
- *
- * @param x capability
- * @return mask for given capability
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static int CAP_TO_MASK(int x) { return 1 << (x & 31); }
-
- /**
- * Tests whether the given mode is a block device.
- */
- public static boolean S_ISBLK(int mode) { return (mode & S_IFMT) == S_IFBLK; }
-
- /**
- * Tests whether the given mode is a character device.
- */
- public static boolean S_ISCHR(int mode) { return (mode & S_IFMT) == S_IFCHR; }
-
- /**
- * Tests whether the given mode is a directory.
- */
- public static boolean S_ISDIR(int mode) { return (mode & S_IFMT) == S_IFDIR; }
-
- /**
- * Tests whether the given mode is a FIFO.
- */
- public static boolean S_ISFIFO(int mode) { return (mode & S_IFMT) == S_IFIFO; }
-
- /**
- * Tests whether the given mode is a regular file.
- */
- public static boolean S_ISREG(int mode) { return (mode & S_IFMT) == S_IFREG; }
-
- /**
- * Tests whether the given mode is a symbolic link.
- */
- public static boolean S_ISLNK(int mode) { return (mode & S_IFMT) == S_IFLNK; }
-
- /**
- * Tests whether the given mode is a socket.
- */
- public static boolean S_ISSOCK(int mode) { return (mode & S_IFMT) == S_IFSOCK; }
-
- /**
- * Extracts the exit status of a child. Only valid if WIFEXITED returns true.
- */
- public static int WEXITSTATUS(int status) { return (status & 0xff00) >> 8; }
-
- /**
- * Tests whether the child dumped core. Only valid if WIFSIGNALED returns true.
- */
- public static boolean WCOREDUMP(int status) { return (status & 0x80) != 0; }
-
- /**
- * Returns the signal that caused the child to exit. Only valid if WIFSIGNALED returns true.
- */
- public static int WTERMSIG(int status) { return status & 0x7f; }
-
- /**
- * Returns the signal that cause the child to stop. Only valid if WIFSTOPPED returns true.
- */
- public static int WSTOPSIG(int status) { return WEXITSTATUS(status); }
-
- /**
- * Tests whether the child exited normally.
- */
- public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); }
-
- /**
- * Tests whether the child was stopped (not terminated) by a signal.
- */
- public static boolean WIFSTOPPED(int status) { return (WTERMSIG(status) == 0x7f); }
-
- /**
- * Tests whether the child was terminated by a signal.
- */
- public static boolean WIFSIGNALED(int status) { return (WTERMSIG(status + 1) >= 2); }
-
- public static final int AF_INET = placeholder();
- public static final int AF_INET6 = placeholder();
- public static final int AF_NETLINK = placeholder();
- public static final int AF_PACKET = placeholder();
- public static final int AF_UNIX = placeholder();
-
- /**
- * The virt-vsock address family, linux specific.
- * It is used with {@code struct sockaddr_vm} from uapi/linux/vm_sockets.h.
- *
- * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a>
- * @see VmSocketAddress
- */
- public static final int AF_VSOCK = placeholder();
- public static final int AF_UNSPEC = placeholder();
- public static final int AI_ADDRCONFIG = placeholder();
- public static final int AI_ALL = placeholder();
- public static final int AI_CANONNAME = placeholder();
- public static final int AI_NUMERICHOST = placeholder();
- public static final int AI_NUMERICSERV = placeholder();
- public static final int AI_PASSIVE = placeholder();
- public static final int AI_V4MAPPED = placeholder();
- public static final int ARPHRD_ETHER = placeholder();
-
- /**
- * The virtio-vsock {@code svmPort} value to bind for any available port.
- *
- * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a>
- * @see VmSocketAddress
- */
- public static final int VMADDR_PORT_ANY = placeholder();
-
- /**
- * The virtio-vsock {@code svmCid} value to listens for all CIDs.
- *
- * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a>
- * @see VmSocketAddress
- */
- public static final int VMADDR_CID_ANY = placeholder();
-
- /**
- * The virtio-vsock {@code svmCid} value for host communication.
- *
- * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a>
- * @see VmSocketAddress
- */
- public static final int VMADDR_CID_LOCAL = placeholder();
-
- /**
- * The virtio-vsock {@code svmCid} value for loopback communication.
- *
- * @see <a href="https://man7.org/linux/man-pages/man7/vsock.7.html">vsock(7)</a>
- * @see VmSocketAddress
- */
- public static final int VMADDR_CID_HOST = placeholder();
-
- /**
- * ARP protocol loopback device identifier.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int ARPHRD_LOOPBACK = placeholder();
- public static final int CAP_AUDIT_CONTROL = placeholder();
- public static final int CAP_AUDIT_WRITE = placeholder();
- public static final int CAP_BLOCK_SUSPEND = placeholder();
- public static final int CAP_CHOWN = placeholder();
- public static final int CAP_DAC_OVERRIDE = placeholder();
- public static final int CAP_DAC_READ_SEARCH = placeholder();
- public static final int CAP_FOWNER = placeholder();
- public static final int CAP_FSETID = placeholder();
- public static final int CAP_IPC_LOCK = placeholder();
- public static final int CAP_IPC_OWNER = placeholder();
- public static final int CAP_KILL = placeholder();
- public static final int CAP_LAST_CAP = placeholder();
- public static final int CAP_LEASE = placeholder();
- public static final int CAP_LINUX_IMMUTABLE = placeholder();
- public static final int CAP_MAC_ADMIN = placeholder();
- public static final int CAP_MAC_OVERRIDE = placeholder();
- public static final int CAP_MKNOD = placeholder();
- public static final int CAP_NET_ADMIN = placeholder();
- public static final int CAP_NET_BIND_SERVICE = placeholder();
- public static final int CAP_NET_BROADCAST = placeholder();
- public static final int CAP_NET_RAW = placeholder();
- public static final int CAP_SETFCAP = placeholder();
- public static final int CAP_SETGID = placeholder();
- public static final int CAP_SETPCAP = placeholder();
- public static final int CAP_SETUID = placeholder();
- public static final int CAP_SYS_ADMIN = placeholder();
- public static final int CAP_SYS_BOOT = placeholder();
- public static final int CAP_SYS_CHROOT = placeholder();
- public static final int CAP_SYSLOG = placeholder();
- public static final int CAP_SYS_MODULE = placeholder();
- public static final int CAP_SYS_NICE = placeholder();
- public static final int CAP_SYS_PACCT = placeholder();
- public static final int CAP_SYS_PTRACE = placeholder();
- public static final int CAP_SYS_RAWIO = placeholder();
- public static final int CAP_SYS_RESOURCE = placeholder();
- public static final int CAP_SYS_TIME = placeholder();
- public static final int CAP_SYS_TTY_CONFIG = placeholder();
- public static final int CAP_WAKE_ALARM = placeholder();
- public static final int E2BIG = placeholder();
- public static final int EACCES = placeholder();
- public static final int EADDRINUSE = placeholder();
- public static final int EADDRNOTAVAIL = placeholder();
- public static final int EAFNOSUPPORT = placeholder();
- public static final int EAGAIN = placeholder();
- public static final int EAI_AGAIN = placeholder();
- public static final int EAI_BADFLAGS = placeholder();
- public static final int EAI_FAIL = placeholder();
- public static final int EAI_FAMILY = placeholder();
- public static final int EAI_MEMORY = placeholder();
- public static final int EAI_NODATA = placeholder();
- public static final int EAI_NONAME = placeholder();
- public static final int EAI_OVERFLOW = placeholder();
- public static final int EAI_SERVICE = placeholder();
- public static final int EAI_SOCKTYPE = placeholder();
- public static final int EAI_SYSTEM = placeholder();
- public static final int EALREADY = placeholder();
- public static final int EBADF = placeholder();
- public static final int EBADMSG = placeholder();
- public static final int EBUSY = placeholder();
- public static final int ECANCELED = placeholder();
- public static final int ECHILD = placeholder();
- public static final int ECONNABORTED = placeholder();
- public static final int ECONNREFUSED = placeholder();
- public static final int ECONNRESET = placeholder();
- public static final int EDEADLK = placeholder();
- public static final int EDESTADDRREQ = placeholder();
- public static final int EDOM = placeholder();
- public static final int EDQUOT = placeholder();
- public static final int EEXIST = placeholder();
- public static final int EFAULT = placeholder();
- public static final int EFBIG = placeholder();
- public static final int EHOSTUNREACH = placeholder();
- public static final int EIDRM = placeholder();
- public static final int EILSEQ = placeholder();
- public static final int EINPROGRESS = placeholder();
- public static final int EINTR = placeholder();
- public static final int EINVAL = placeholder();
- public static final int EIO = placeholder();
- public static final int EISCONN = placeholder();
- public static final int EISDIR = placeholder();
- public static final int ELOOP = placeholder();
- public static final int EMFILE = placeholder();
- public static final int EMLINK = placeholder();
- public static final int EMSGSIZE = placeholder();
- public static final int EMULTIHOP = placeholder();
- public static final int ENAMETOOLONG = placeholder();
- public static final int ENETDOWN = placeholder();
- public static final int ENETRESET = placeholder();
- public static final int ENETUNREACH = placeholder();
- public static final int ENFILE = placeholder();
- public static final int ENOBUFS = placeholder();
- public static final int ENODATA = placeholder();
- public static final int ENODEV = placeholder();
- public static final int ENOENT = placeholder();
- public static final int ENOEXEC = placeholder();
- public static final int ENOLCK = placeholder();
- public static final int ENOLINK = placeholder();
- public static final int ENOMEM = placeholder();
- public static final int ENOMSG = placeholder();
- public static final int ENONET = placeholder();
- public static final int ENOPROTOOPT = placeholder();
- public static final int ENOSPC = placeholder();
- public static final int ENOSR = placeholder();
- public static final int ENOSTR = placeholder();
- public static final int ENOSYS = placeholder();
- public static final int ENOTCONN = placeholder();
- public static final int ENOTDIR = placeholder();
- public static final int ENOTEMPTY = placeholder();
- public static final int ENOTSOCK = placeholder();
- public static final int ENOTSUP = placeholder();
- public static final int ENOTTY = placeholder();
- public static final int ENXIO = placeholder();
- public static final int EOPNOTSUPP = placeholder();
- public static final int EOVERFLOW = placeholder();
- public static final int EPERM = placeholder();
- public static final int EPIPE = placeholder();
- public static final int EPROTO = placeholder();
- public static final int EPROTONOSUPPORT = placeholder();
- public static final int EPROTOTYPE = placeholder();
- public static final int ERANGE = placeholder();
- public static final int EROFS = placeholder();
- public static final int ESPIPE = placeholder();
- public static final int ESRCH = placeholder();
- public static final int ESTALE = placeholder();
- public static final int ETH_P_ALL = placeholder();
- public static final int ETH_P_ARP = placeholder();
- public static final int ETH_P_IP = placeholder();
- public static final int ETH_P_IPV6 = placeholder();
- public static final int ETIME = placeholder();
- public static final int ETIMEDOUT = placeholder();
- public static final int ETXTBSY = placeholder();
- /**
- * "Too many users" error.
- * See <a href="https://man7.org/linux/man-pages/man3/errno.3.html">errno(3)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int EUSERS = placeholder();
- // On Linux, EWOULDBLOCK == EAGAIN. Use EAGAIN instead, to reduce confusion.
- public static final int EXDEV = placeholder();
- public static final int EXIT_FAILURE = placeholder();
- public static final int EXIT_SUCCESS = placeholder();
- public static final int FD_CLOEXEC = placeholder();
- public static final int FIONREAD = placeholder();
- public static final int F_DUPFD = placeholder();
- public static final int F_DUPFD_CLOEXEC = placeholder();
- public static final int F_GETFD = placeholder();
- public static final int F_GETFL = placeholder();
- public static final int F_GETLK = placeholder();
- public static final int F_GETLK64 = placeholder();
- public static final int F_GETOWN = placeholder();
- public static final int F_OK = placeholder();
- public static final int F_RDLCK = placeholder();
- public static final int F_SETFD = placeholder();
- public static final int F_SETFL = placeholder();
- public static final int F_SETLK = placeholder();
- public static final int F_SETLK64 = placeholder();
- public static final int F_SETLKW = placeholder();
- public static final int F_SETLKW64 = placeholder();
- public static final int F_SETOWN = placeholder();
- public static final int F_UNLCK = placeholder();
- public static final int F_WRLCK = placeholder();
- public static final int ICMP_ECHO = placeholder();
- public static final int ICMP_ECHOREPLY = placeholder();
- public static final int ICMP6_ECHO_REQUEST = placeholder();
- public static final int ICMP6_ECHO_REPLY = placeholder();
- public static final int IFA_F_DADFAILED = placeholder();
- public static final int IFA_F_DEPRECATED = placeholder();
- public static final int IFA_F_HOMEADDRESS = placeholder();
- public static final int IFA_F_MANAGETEMPADDR = placeholder();
- public static final int IFA_F_NODAD = placeholder();
- public static final int IFA_F_NOPREFIXROUTE = placeholder();
- public static final int IFA_F_OPTIMISTIC = placeholder();
- public static final int IFA_F_PERMANENT = placeholder();
- public static final int IFA_F_SECONDARY = placeholder();
- public static final int IFA_F_TEMPORARY = placeholder();
- public static final int IFA_F_TENTATIVE = placeholder();
- public static final int IFF_ALLMULTI = placeholder();
- public static final int IFF_AUTOMEDIA = placeholder();
- public static final int IFF_BROADCAST = placeholder();
- public static final int IFF_DEBUG = placeholder();
- public static final int IFF_DYNAMIC = placeholder();
- public static final int IFF_LOOPBACK = placeholder();
- public static final int IFF_MASTER = placeholder();
- public static final int IFF_MULTICAST = placeholder();
- public static final int IFF_NOARP = placeholder();
- public static final int IFF_NOTRAILERS = placeholder();
- public static final int IFF_POINTOPOINT = placeholder();
- public static final int IFF_PORTSEL = placeholder();
- public static final int IFF_PROMISC = placeholder();
- public static final int IFF_RUNNING = placeholder();
- public static final int IFF_SLAVE = placeholder();
- public static final int IFF_UP = placeholder();
- public static final int IPPROTO_ICMP = placeholder();
- public static final int IPPROTO_ICMPV6 = placeholder();
- public static final int IPPROTO_IP = placeholder();
- public static final int IPPROTO_IPV6 = placeholder();
- public static final int IPPROTO_RAW = placeholder();
- public static final int IPPROTO_TCP = placeholder();
- public static final int IPPROTO_UDP = placeholder();
-
- /**
- * Encapsulation Security Payload protocol
- *
- * <p>Defined in /uapi/linux/in.h
- */
- public static final int IPPROTO_ESP = placeholder();
-
- public static final int IPV6_CHECKSUM = placeholder();
- public static final int IPV6_MULTICAST_HOPS = placeholder();
- public static final int IPV6_MULTICAST_IF = placeholder();
- public static final int IPV6_MULTICAST_LOOP = placeholder();
- public static final int IPV6_PKTINFO = placeholder();
- public static final int IPV6_RECVDSTOPTS = placeholder();
- public static final int IPV6_RECVHOPLIMIT = placeholder();
- public static final int IPV6_RECVHOPOPTS = placeholder();
- public static final int IPV6_RECVPKTINFO = placeholder();
- public static final int IPV6_RECVRTHDR = placeholder();
- public static final int IPV6_RECVTCLASS = placeholder();
- public static final int IPV6_TCLASS = placeholder();
- public static final int IPV6_UNICAST_HOPS = placeholder();
- public static final int IPV6_V6ONLY = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int IP_MULTICAST_ALL = placeholder();
- public static final int IP_MULTICAST_IF = placeholder();
- public static final int IP_MULTICAST_LOOP = placeholder();
- public static final int IP_MULTICAST_TTL = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int IP_RECVTOS = placeholder();
- public static final int IP_TOS = placeholder();
- public static final int IP_TTL = placeholder();
- /**
- * Version constant to be used in {@link StructCapUserHeader} with
- * {@link Os#capset(StructCapUserHeader, StructCapUserData[])} and
- * {@link Os#capget(StructCapUserHeader)}.
- *
- * See <a href="https://man7.org/linux/man-pages/man2/capget.2.html">capget(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int _LINUX_CAPABILITY_VERSION_3 = placeholder();
- public static final int MAP_FIXED = placeholder();
- public static final int MAP_ANONYMOUS = placeholder();
- /**
- * Flag argument for {@code mmap(long, long, int, int, FileDescriptor, long)}.
- *
- * See <a href="http://man7.org/linux/man-pages/man2/mmap.2.html">mmap(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int MAP_POPULATE = placeholder();
- public static final int MAP_PRIVATE = placeholder();
- public static final int MAP_SHARED = placeholder();
- public static final int MCAST_JOIN_GROUP = placeholder();
- public static final int MCAST_LEAVE_GROUP = placeholder();
- public static final int MCAST_JOIN_SOURCE_GROUP = placeholder();
- public static final int MCAST_LEAVE_SOURCE_GROUP = placeholder();
- public static final int MCAST_BLOCK_SOURCE = placeholder();
- public static final int MCAST_UNBLOCK_SOURCE = placeholder();
- public static final int MCL_CURRENT = placeholder();
- public static final int MCL_FUTURE = placeholder();
- public static final int MFD_CLOEXEC = placeholder();
- public static final int MSG_CTRUNC = placeholder();
- public static final int MSG_DONTROUTE = placeholder();
- public static final int MSG_EOR = placeholder();
- public static final int MSG_OOB = placeholder();
- public static final int MSG_PEEK = placeholder();
- public static final int MSG_TRUNC = placeholder();
- public static final int MSG_WAITALL = placeholder();
- public static final int MS_ASYNC = placeholder();
- public static final int MS_INVALIDATE = placeholder();
- public static final int MS_SYNC = placeholder();
- public static final int NETLINK_NETFILTER = placeholder();
- public static final int NETLINK_ROUTE = placeholder();
- /**
- * SELinux enforces that only system_server and netd may use this netlink socket type.
- */
- public static final int NETLINK_INET_DIAG = placeholder();
-
- /**
- * SELinux enforces that only system_server and netd may use this netlink socket type.
- *
- * @see <a href="https://man7.org/linux/man-pages/man7/netlink.7.html">netlink(7)</a>
- */
- public static final int NETLINK_XFRM = placeholder();
-
- public static final int NI_DGRAM = placeholder();
- public static final int NI_NAMEREQD = placeholder();
- public static final int NI_NOFQDN = placeholder();
- public static final int NI_NUMERICHOST = placeholder();
- public static final int NI_NUMERICSERV = placeholder();
- public static final int O_ACCMODE = placeholder();
- public static final int O_APPEND = placeholder();
- public static final int O_CLOEXEC = placeholder();
- public static final int O_CREAT = placeholder();
- /**
- * Flag for {@code Os#open(String, int, int)}.
- *
- * When enabled, tries to minimize cache effects of the I/O to and from this
- * file. In general this will degrade performance, but it is
- * useful in special situations, such as when applications do
- * their own caching. File I/O is done directly to/from
- * user-space buffers. The {@link O_DIRECT} flag on its own makes an
- * effort to transfer data synchronously, but does not give
- * the guarantees of the {@link O_SYNC} flag that data and necessary
- * metadata are transferred. To guarantee synchronous I/O,
- * {@link O_SYNC} must be used in addition to {@link O_DIRECT}.
- *
- * See <a href="https://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int O_DIRECT = placeholder();
- public static final int O_EXCL = placeholder();
- public static final int O_NOCTTY = placeholder();
- public static final int O_NOFOLLOW = placeholder();
- public static final int O_NONBLOCK = placeholder();
- public static final int O_RDONLY = placeholder();
- public static final int O_RDWR = placeholder();
- public static final int O_SYNC = placeholder();
- public static final int O_DSYNC = placeholder();
- public static final int O_TRUNC = placeholder();
- public static final int O_WRONLY = placeholder();
- public static final int POLLERR = placeholder();
- public static final int POLLHUP = placeholder();
- public static final int POLLIN = placeholder();
- public static final int POLLNVAL = placeholder();
- public static final int POLLOUT = placeholder();
- public static final int POLLPRI = placeholder();
- public static final int POLLRDBAND = placeholder();
- public static final int POLLRDNORM = placeholder();
- public static final int POLLWRBAND = placeholder();
- public static final int POLLWRNORM = placeholder();
- /**
- * Reads or changes the ambient capability set of the calling thread.
- * Has to be used as a first argument for {@link Os#prctl(int, long, long, long, long)}.
- *
- * See <a href="https://man7.org/linux/man-pages/man2/prctl.2.html">prctl(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int PR_CAP_AMBIENT = placeholder();
- /**
- * The capability specified in {@code arg3} of {@link Os#prctl(int, long, long, long, long)}
- * is added to the ambient set. The specified capability must already
- * be present in both the permitted and the inheritable sets of the process.
- * Has to be used as a second argument for {@link Os#prctl(int, long, long, long, long)}.
- *
- * See <a href="https://man7.org/linux/man-pages/man2/prctl.2.html">prctl(2)</a>.
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int PR_CAP_AMBIENT_RAISE = placeholder();
- public static final int PR_GET_DUMPABLE = placeholder();
- public static final int PR_SET_DUMPABLE = placeholder();
- public static final int PR_SET_NO_NEW_PRIVS = placeholder();
- public static final int PROT_EXEC = placeholder();
- public static final int PROT_NONE = placeholder();
- public static final int PROT_READ = placeholder();
- public static final int PROT_WRITE = placeholder();
- public static final int R_OK = placeholder();
- /**
- * Specifies a value one greater than the maximum file
- * descriptor number that can be opened by this process.
- *
- * <p>Attempts ({@link Os#open(String, int, int)}, {@link Os#pipe()},
- * {@link Os#dup(java.io.FileDescriptor)}, etc.) to exceed this
- * limit yield the error {@link EMFILE}.
- *
- * See <a href="https://man7.org/linux/man-pages/man3/vlimit.3.html">getrlimit(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int RLIMIT_NOFILE = placeholder();
- public static final int RT_SCOPE_HOST = placeholder();
- public static final int RT_SCOPE_LINK = placeholder();
- public static final int RT_SCOPE_NOWHERE = placeholder();
- public static final int RT_SCOPE_SITE = placeholder();
- public static final int RT_SCOPE_UNIVERSE = placeholder();
- /**
- * Bitmask for IPv4 addresses add/delete events multicast groups mask.
- * Used in {@link NetlinkSocketAddress}.
- *
- * See <a href="https://man7.org/linux/man-pages/man7/netlink.7.html">netlink(7)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int RTMGRP_IPV4_IFADDR = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV4_MROUTE = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV4_ROUTE = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV4_RULE = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV6_IFADDR = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV6_IFINFO = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV6_MROUTE = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV6_PREFIX = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_IPV6_ROUTE = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_LINK = placeholder();
- public static final int RTMGRP_NEIGH = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_NOTIFY = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int RTMGRP_TC = placeholder();
- public static final int SEEK_CUR = placeholder();
- public static final int SEEK_END = placeholder();
- public static final int SEEK_SET = placeholder();
- public static final int SHUT_RD = placeholder();
- public static final int SHUT_RDWR = placeholder();
- public static final int SHUT_WR = placeholder();
- public static final int SIGABRT = placeholder();
- public static final int SIGALRM = placeholder();
- public static final int SIGBUS = placeholder();
- public static final int SIGCHLD = placeholder();
- public static final int SIGCONT = placeholder();
- public static final int SIGFPE = placeholder();
- public static final int SIGHUP = placeholder();
- public static final int SIGILL = placeholder();
- public static final int SIGINT = placeholder();
- public static final int SIGIO = placeholder();
- public static final int SIGKILL = placeholder();
- public static final int SIGPIPE = placeholder();
- public static final int SIGPROF = placeholder();
- public static final int SIGPWR = placeholder();
- public static final int SIGQUIT = placeholder();
- public static final int SIGRTMAX = placeholder();
- public static final int SIGRTMIN = placeholder();
- public static final int SIGSEGV = placeholder();
- public static final int SIGSTKFLT = placeholder();
- public static final int SIGSTOP = placeholder();
- public static final int SIGSYS = placeholder();
- public static final int SIGTERM = placeholder();
- public static final int SIGTRAP = placeholder();
- public static final int SIGTSTP = placeholder();
- public static final int SIGTTIN = placeholder();
- public static final int SIGTTOU = placeholder();
- public static final int SIGURG = placeholder();
- public static final int SIGUSR1 = placeholder();
- public static final int SIGUSR2 = placeholder();
- public static final int SIGVTALRM = placeholder();
- public static final int SIGWINCH = placeholder();
- public static final int SIGXCPU = placeholder();
- public static final int SIGXFSZ = placeholder();
- public static final int SIOCGIFADDR = placeholder();
- public static final int SIOCGIFBRDADDR = placeholder();
- public static final int SIOCGIFDSTADDR = placeholder();
- public static final int SIOCGIFNETMASK = placeholder();
-
- /**
- * Set the close-on-exec ({@code FD_CLOEXEC}) flag on the new file
- * descriptor created by {@link Os#socket(int,int,int)} or
- * {@link Os#socketpair(int,int,int,java.io.FileDescriptor,java.io.FileDescriptor)}.
- * See the description of the O_CLOEXEC flag in
- * <a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>
- * for reasons why this may be useful.
- *
- * <p>Applications wishing to make use of this flag on older API versions
- * may use {@link #O_CLOEXEC} instead. On Android, {@code O_CLOEXEC} and
- * {@code SOCK_CLOEXEC} are the same value.
- */
- public static final int SOCK_CLOEXEC = placeholder();
- public static final int SOCK_DGRAM = placeholder();
-
- /**
- * Set the O_NONBLOCK file status flag on the file descriptor
- * created by {@link Os#socket(int,int,int)} or
- * {@link Os#socketpair(int,int,int,java.io.FileDescriptor,java.io.FileDescriptor)}.
- *
- * <p>Applications wishing to make use of this flag on older API versions
- * may use {@link #O_NONBLOCK} instead. On Android, {@code O_NONBLOCK}
- * and {@code SOCK_NONBLOCK} are the same value.
- */
- public static final int SOCK_NONBLOCK = placeholder();
- public static final int SOCK_RAW = placeholder();
- public static final int SOCK_SEQPACKET = placeholder();
- public static final int SOCK_STREAM = placeholder();
- public static final int SOL_SOCKET = placeholder();
- public static final int SOL_UDP = placeholder();
- public static final int SOL_PACKET = placeholder();
- public static final int SO_BINDTODEVICE = placeholder();
- public static final int SO_BROADCAST = placeholder();
- public static final int SO_DEBUG = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int SO_DOMAIN = placeholder();
- public static final int SO_DONTROUTE = placeholder();
- public static final int SO_ERROR = placeholder();
- public static final int SO_KEEPALIVE = placeholder();
- public static final int SO_LINGER = placeholder();
- public static final int SO_OOBINLINE = placeholder();
- public static final int SO_PASSCRED = placeholder();
- public static final int SO_PEERCRED = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int SO_PROTOCOL = placeholder();
- public static final int SO_RCVBUF = placeholder();
- public static final int SO_RCVLOWAT = placeholder();
- public static final int SO_RCVTIMEO = placeholder();
- public static final int SO_REUSEADDR = placeholder();
- public static final int SO_SNDBUF = placeholder();
- public static final int SO_SNDLOWAT = placeholder();
- public static final int SO_SNDTIMEO = placeholder();
- public static final int SO_TYPE = placeholder();
- public static final int PACKET_IGNORE_OUTGOING = placeholder();
- /**
- * Bitmask for flags argument of
- * {@link splice(java.io.FileDescriptor, Int64Ref , FileDescriptor, Int64Ref, long, int)}.
- *
- * Attempt to move pages instead of copying. This is only a
- * hint to the kernel: pages may still be copied if the
- * kernel cannot move the pages from the pipe, or if the pipe
- * buffers don't refer to full pages.
- *
- * See <a href="https://man7.org/linux/man-pages/man2/splice.2.html">splice(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int SPLICE_F_MOVE = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int SPLICE_F_NONBLOCK = placeholder();
- /**
- * Bitmask for flags argument of
- * {@link splice(java.io.FileDescriptor, Int64Ref, FileDescriptor, Int64Ref, long, int)}.
- *
- * <p>Indicates that more data will be coming in a subsequent splice. This is
- * a helpful hint when the {@code fdOut} refers to a socket.
- *
- * See <a href="https://man7.org/linux/man-pages/man2/splice.2.html">splice(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int SPLICE_F_MORE = placeholder();
- public static final int STDERR_FILENO = placeholder();
- public static final int STDIN_FILENO = placeholder();
- public static final int STDOUT_FILENO = placeholder();
- public static final int ST_MANDLOCK = placeholder();
- public static final int ST_NOATIME = placeholder();
- public static final int ST_NODEV = placeholder();
- public static final int ST_NODIRATIME = placeholder();
- public static final int ST_NOEXEC = placeholder();
- public static final int ST_NOSUID = placeholder();
- public static final int ST_RDONLY = placeholder();
- public static final int ST_RELATIME = placeholder();
- public static final int ST_SYNCHRONOUS = placeholder();
- public static final int S_IFBLK = placeholder();
- public static final int S_IFCHR = placeholder();
- public static final int S_IFDIR = placeholder();
- public static final int S_IFIFO = placeholder();
- public static final int S_IFLNK = placeholder();
- public static final int S_IFMT = placeholder();
- public static final int S_IFREG = placeholder();
- public static final int S_IFSOCK = placeholder();
- public static final int S_IRGRP = placeholder();
- public static final int S_IROTH = placeholder();
- public static final int S_IRUSR = placeholder();
- public static final int S_IRWXG = placeholder();
- public static final int S_IRWXO = placeholder();
- public static final int S_IRWXU = placeholder();
- public static final int S_ISGID = placeholder();
- public static final int S_ISUID = placeholder();
- public static final int S_ISVTX = placeholder();
- public static final int S_IWGRP = placeholder();
- public static final int S_IWOTH = placeholder();
- public static final int S_IWUSR = placeholder();
- public static final int S_IXGRP = placeholder();
- public static final int S_IXOTH = placeholder();
- public static final int S_IXUSR = placeholder();
- public static final int TCP_NODELAY = placeholder();
- public static final int TCP_USER_TIMEOUT = placeholder();
- public static final int UDP_GRO = placeholder();
- public static final int UDP_SEGMENT = placeholder();
- /**
- * Get the number of bytes in the output buffer.
- *
- * See <a href="https://man7.org/linux/man-pages/man2/ioctl.2.html">ioctl(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int TIOCOUTQ = placeholder();
- /**
- * Sockopt option to encapsulate ESP packets in UDP.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int UDP_ENCAP = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int UDP_ENCAP_ESPINUDP_NON_IKE = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int UDP_ENCAP_ESPINUDP = placeholder();
- /** @hide */
-// @UnsupportedAppUsage
- public static final int UNIX_PATH_MAX = placeholder();
- public static final int WCONTINUED = placeholder();
- public static final int WEXITED = placeholder();
- public static final int WNOHANG = placeholder();
- public static final int WNOWAIT = placeholder();
- public static final int WSTOPPED = placeholder();
- public static final int WUNTRACED = placeholder();
- public static final int W_OK = placeholder();
- /**
- * {@code flags} option for {@link Os#setxattr(String, String, byte[], int)}.
- *
- * <p>Performs a pure create, which fails if the named attribute exists already.
- *
- * See <a href="http://man7.org/linux/man-pages/man2/setxattr.2.html">setxattr(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int XATTR_CREATE = placeholder();
- /**
- * {@code flags} option for {@link Os#setxattr(String, String, byte[], int)}.
- *
- * <p>Perform a pure replace operation, which fails if the named attribute
- * does not already exist.
- *
- * See <a href="http://man7.org/linux/man-pages/man2/setxattr.2.html">setxattr(2)</a>.
- *
- * @hide
- */
-// @UnsupportedAppUsage
-// @SystemApi(client = MODULE_LIBRARIES)
- public static final int XATTR_REPLACE = placeholder();
- public static final int X_OK = placeholder();
- public static final int _SC_2_CHAR_TERM = placeholder();
- public static final int _SC_2_C_BIND = placeholder();
- public static final int _SC_2_C_DEV = placeholder();
- public static final int _SC_2_C_VERSION = placeholder();
- public static final int _SC_2_FORT_DEV = placeholder();
- public static final int _SC_2_FORT_RUN = placeholder();
- public static final int _SC_2_LOCALEDEF = placeholder();
- public static final int _SC_2_SW_DEV = placeholder();
- public static final int _SC_2_UPE = placeholder();
- public static final int _SC_2_VERSION = placeholder();
- public static final int _SC_AIO_LISTIO_MAX = placeholder();
- public static final int _SC_AIO_MAX = placeholder();
- public static final int _SC_AIO_PRIO_DELTA_MAX = placeholder();
- public static final int _SC_ARG_MAX = placeholder();
- public static final int _SC_ASYNCHRONOUS_IO = placeholder();
- public static final int _SC_ATEXIT_MAX = placeholder();
- public static final int _SC_AVPHYS_PAGES = placeholder();
- public static final int _SC_BC_BASE_MAX = placeholder();
- public static final int _SC_BC_DIM_MAX = placeholder();
- public static final int _SC_BC_SCALE_MAX = placeholder();
- public static final int _SC_BC_STRING_MAX = placeholder();
- public static final int _SC_CHILD_MAX = placeholder();
- public static final int _SC_CLK_TCK = placeholder();
- public static final int _SC_COLL_WEIGHTS_MAX = placeholder();
- public static final int _SC_DELAYTIMER_MAX = placeholder();
- public static final int _SC_EXPR_NEST_MAX = placeholder();
- public static final int _SC_FSYNC = placeholder();
- public static final int _SC_GETGR_R_SIZE_MAX = placeholder();
- public static final int _SC_GETPW_R_SIZE_MAX = placeholder();
- public static final int _SC_IOV_MAX = placeholder();
- public static final int _SC_JOB_CONTROL = placeholder();
- public static final int _SC_LINE_MAX = placeholder();
- public static final int _SC_LOGIN_NAME_MAX = placeholder();
- public static final int _SC_MAPPED_FILES = placeholder();
- public static final int _SC_MEMLOCK = placeholder();
- public static final int _SC_MEMLOCK_RANGE = placeholder();
- public static final int _SC_MEMORY_PROTECTION = placeholder();
- public static final int _SC_MESSAGE_PASSING = placeholder();
- public static final int _SC_MQ_OPEN_MAX = placeholder();
- public static final int _SC_MQ_PRIO_MAX = placeholder();
- public static final int _SC_NGROUPS_MAX = placeholder();
- public static final int _SC_NPROCESSORS_CONF = placeholder();
- public static final int _SC_NPROCESSORS_ONLN = placeholder();
- public static final int _SC_OPEN_MAX = placeholder();
- public static final int _SC_PAGESIZE = placeholder();
- public static final int _SC_PAGE_SIZE = placeholder();
- public static final int _SC_PASS_MAX = placeholder();
- public static final int _SC_PHYS_PAGES = placeholder();
- public static final int _SC_PRIORITIZED_IO = placeholder();
- public static final int _SC_PRIORITY_SCHEDULING = placeholder();
- public static final int _SC_REALTIME_SIGNALS = placeholder();
- public static final int _SC_RE_DUP_MAX = placeholder();
- public static final int _SC_RTSIG_MAX = placeholder();
- public static final int _SC_SAVED_IDS = placeholder();
- public static final int _SC_SEMAPHORES = placeholder();
- public static final int _SC_SEM_NSEMS_MAX = placeholder();
- public static final int _SC_SEM_VALUE_MAX = placeholder();
- public static final int _SC_SHARED_MEMORY_OBJECTS = placeholder();
- public static final int _SC_SIGQUEUE_MAX = placeholder();
- public static final int _SC_STREAM_MAX = placeholder();
- public static final int _SC_SYNCHRONIZED_IO = placeholder();
- public static final int _SC_THREADS = placeholder();
- public static final int _SC_THREAD_ATTR_STACKADDR = placeholder();
- public static final int _SC_THREAD_ATTR_STACKSIZE = placeholder();
- public static final int _SC_THREAD_DESTRUCTOR_ITERATIONS = placeholder();
- public static final int _SC_THREAD_KEYS_MAX = placeholder();
- public static final int _SC_THREAD_PRIORITY_SCHEDULING = placeholder();
- public static final int _SC_THREAD_PRIO_INHERIT = placeholder();
- public static final int _SC_THREAD_PRIO_PROTECT = placeholder();
- public static final int _SC_THREAD_SAFE_FUNCTIONS = placeholder();
- public static final int _SC_THREAD_STACK_MIN = placeholder();
- public static final int _SC_THREAD_THREADS_MAX = placeholder();
- public static final int _SC_TIMERS = placeholder();
- public static final int _SC_TIMER_MAX = placeholder();
- public static final int _SC_TTY_NAME_MAX = placeholder();
- public static final int _SC_TZNAME_MAX = placeholder();
- public static final int _SC_VERSION = placeholder();
- public static final int _SC_XBS5_ILP32_OFF32 = placeholder();
- public static final int _SC_XBS5_ILP32_OFFBIG = placeholder();
- public static final int _SC_XBS5_LP64_OFF64 = placeholder();
- public static final int _SC_XBS5_LPBIG_OFFBIG = placeholder();
- public static final int _SC_XOPEN_CRYPT = placeholder();
- public static final int _SC_XOPEN_ENH_I18N = placeholder();
- public static final int _SC_XOPEN_LEGACY = placeholder();
- public static final int _SC_XOPEN_REALTIME = placeholder();
- public static final int _SC_XOPEN_REALTIME_THREADS = placeholder();
- public static final int _SC_XOPEN_SHM = placeholder();
- public static final int _SC_XOPEN_UNIX = placeholder();
- public static final int _SC_XOPEN_VERSION = placeholder();
- public static final int _SC_XOPEN_XCU_VERSION = placeholder();
-
- /**
- * Returns the string name of a getaddrinfo(3) error value.
- * For example, "EAI_AGAIN".
- */
- public static String gaiName(int error) {
- if (error == EAI_AGAIN) {
- return "EAI_AGAIN";
- }
- if (error == EAI_BADFLAGS) {
- return "EAI_BADFLAGS";
- }
- if (error == EAI_FAIL) {
- return "EAI_FAIL";
- }
- if (error == EAI_FAMILY) {
- return "EAI_FAMILY";
- }
- if (error == EAI_MEMORY) {
- return "EAI_MEMORY";
- }
- if (error == EAI_NODATA) {
- return "EAI_NODATA";
- }
- if (error == EAI_NONAME) {
- return "EAI_NONAME";
- }
- if (error == EAI_OVERFLOW) {
- return "EAI_OVERFLOW";
- }
- if (error == EAI_SERVICE) {
- return "EAI_SERVICE";
- }
- if (error == EAI_SOCKTYPE) {
- return "EAI_SOCKTYPE";
- }
- if (error == EAI_SYSTEM) {
- return "EAI_SYSTEM";
- }
- return null;
- }
-
- /**
- * Returns the string name of an errno value.
- * For example, "EACCES". See {@link Os#strerror} for human-readable errno descriptions.
- */
- public static String errnoName(int errno) {
- if (errno == E2BIG) {
- return "E2BIG";
- }
- if (errno == EACCES) {
- return "EACCES";
- }
- if (errno == EADDRINUSE) {
- return "EADDRINUSE";
- }
- if (errno == EADDRNOTAVAIL) {
- return "EADDRNOTAVAIL";
- }
- if (errno == EAFNOSUPPORT) {
- return "EAFNOSUPPORT";
- }
- if (errno == EAGAIN) {
- return "EAGAIN";
- }
- if (errno == EALREADY) {
- return "EALREADY";
- }
- if (errno == EBADF) {
- return "EBADF";
- }
- if (errno == EBADMSG) {
- return "EBADMSG";
- }
- if (errno == EBUSY) {
- return "EBUSY";
- }
- if (errno == ECANCELED) {
- return "ECANCELED";
- }
- if (errno == ECHILD) {
- return "ECHILD";
- }
- if (errno == ECONNABORTED) {
- return "ECONNABORTED";
- }
- if (errno == ECONNREFUSED) {
- return "ECONNREFUSED";
- }
- if (errno == ECONNRESET) {
- return "ECONNRESET";
- }
- if (errno == EDEADLK) {
- return "EDEADLK";
- }
- if (errno == EDESTADDRREQ) {
- return "EDESTADDRREQ";
- }
- if (errno == EDOM) {
- return "EDOM";
- }
- if (errno == EDQUOT) {
- return "EDQUOT";
- }
- if (errno == EEXIST) {
- return "EEXIST";
- }
- if (errno == EFAULT) {
- return "EFAULT";
- }
- if (errno == EFBIG) {
- return "EFBIG";
- }
- if (errno == EHOSTUNREACH) {
- return "EHOSTUNREACH";
- }
- if (errno == EIDRM) {
- return "EIDRM";
- }
- if (errno == EILSEQ) {
- return "EILSEQ";
- }
- if (errno == EINPROGRESS) {
- return "EINPROGRESS";
- }
- if (errno == EINTR) {
- return "EINTR";
- }
- if (errno == EINVAL) {
- return "EINVAL";
- }
- if (errno == EIO) {
- return "EIO";
- }
- if (errno == EISCONN) {
- return "EISCONN";
- }
- if (errno == EISDIR) {
- return "EISDIR";
- }
- if (errno == ELOOP) {
- return "ELOOP";
- }
- if (errno == EMFILE) {
- return "EMFILE";
- }
- if (errno == EMLINK) {
- return "EMLINK";
- }
- if (errno == EMSGSIZE) {
- return "EMSGSIZE";
- }
- if (errno == EMULTIHOP) {
- return "EMULTIHOP";
- }
- if (errno == ENAMETOOLONG) {
- return "ENAMETOOLONG";
- }
- if (errno == ENETDOWN) {
- return "ENETDOWN";
- }
- if (errno == ENETRESET) {
- return "ENETRESET";
- }
- if (errno == ENETUNREACH) {
- return "ENETUNREACH";
- }
- if (errno == ENFILE) {
- return "ENFILE";
- }
- if (errno == ENOBUFS) {
- return "ENOBUFS";
- }
- if (errno == ENODATA) {
- return "ENODATA";
- }
- if (errno == ENODEV) {
- return "ENODEV";
- }
- if (errno == ENOENT) {
- return "ENOENT";
- }
- if (errno == ENOEXEC) {
- return "ENOEXEC";
- }
- if (errno == ENOLCK) {
- return "ENOLCK";
- }
- if (errno == ENOLINK) {
- return "ENOLINK";
- }
- if (errno == ENOMEM) {
- return "ENOMEM";
- }
- if (errno == ENOMSG) {
- return "ENOMSG";
- }
- if (errno == ENONET) {
- return "ENONET";
- }
- if (errno == ENOPROTOOPT) {
- return "ENOPROTOOPT";
- }
- if (errno == ENOSPC) {
- return "ENOSPC";
- }
- if (errno == ENOSR) {
- return "ENOSR";
- }
- if (errno == ENOSTR) {
- return "ENOSTR";
- }
- if (errno == ENOSYS) {
- return "ENOSYS";
- }
- if (errno == ENOTCONN) {
- return "ENOTCONN";
- }
- if (errno == ENOTDIR) {
- return "ENOTDIR";
- }
- if (errno == ENOTEMPTY) {
- return "ENOTEMPTY";
- }
- if (errno == ENOTSOCK) {
- return "ENOTSOCK";
- }
- if (errno == ENOTSUP) {
- return "ENOTSUP";
- }
- if (errno == ENOTTY) {
- return "ENOTTY";
- }
- if (errno == ENXIO) {
- return "ENXIO";
- }
- if (errno == EOPNOTSUPP) {
- return "EOPNOTSUPP";
- }
- if (errno == EOVERFLOW) {
- return "EOVERFLOW";
- }
- if (errno == EPERM) {
- return "EPERM";
- }
- if (errno == EPIPE) {
- return "EPIPE";
- }
- if (errno == EPROTO) {
- return "EPROTO";
- }
- if (errno == EPROTONOSUPPORT) {
- return "EPROTONOSUPPORT";
- }
- if (errno == EPROTOTYPE) {
- return "EPROTOTYPE";
- }
- if (errno == ERANGE) {
- return "ERANGE";
- }
- if (errno == EROFS) {
- return "EROFS";
- }
- if (errno == ESPIPE) {
- return "ESPIPE";
- }
- if (errno == ESRCH) {
- return "ESRCH";
- }
- if (errno == ESTALE) {
- return "ESTALE";
- }
- if (errno == ETIME) {
- return "ETIME";
- }
- if (errno == ETIMEDOUT) {
- return "ETIMEDOUT";
- }
- if (errno == ETXTBSY) {
- return "ETXTBSY";
- }
- if (errno == EXDEV) {
- return "EXDEV";
- }
- return null;
- }
-
- // [ravenwood-change] Moved to a nested class.
- // @UnsupportedAppUsage
- static class Native {
- private static native void initConstants();
- }
-
- // A hack to avoid these constants being inlined by javac...
-// @UnsupportedAppUsage
- private static int placeholder() { return 0; }
- // ...because we want to initialize them at runtime.
- static {
- // [ravenwood-change] Load the JNI lib.
- RavenwoodCommonUtils.loadRavenwoodNativeRuntime();
- Native.initConstants();
- }
-}
diff --git a/ravenwood/runtime-helper-src/libcore-fake/libcore/ravenwood/LibcoreRavenwoodUtils.java b/ravenwood/runtime-helper-src/libcore-fake/libcore/ravenwood/LibcoreRavenwoodUtils.java
new file mode 100644
index 0000000..839b62a
--- /dev/null
+++ b/ravenwood/runtime-helper-src/libcore-fake/libcore/ravenwood/LibcoreRavenwoodUtils.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package libcore.ravenwood;
+
+public class LibcoreRavenwoodUtils {
+ private LibcoreRavenwoodUtils() {
+ }
+
+ public static void loadRavenwoodNativeRuntime() {
+ // TODO Stop using reflections.
+ // We need to call RavenwoodUtils.loadRavenwoodNativeRuntime(), but due to the build
+ // structure complexity, we can't refer to to this method directly from here,
+ // so let's use reflections for now...
+ try {
+ final var clazz = Class.forName("android.platform.test.ravenwood.RavenwoodUtils");
+ final var method = clazz.getMethod("loadRavenwoodNativeRuntime");
+ method.invoke(null);
+ } catch (Throwable th) {
+ throw new IllegalStateException("Failed to load Ravenwood native runtime", th);
+ }
+ }
+}
diff --git a/ravenwood/runtime-helper-src/libcore-fake/libcore/util/NativeAllocationRegistry.java b/ravenwood/runtime-helper-src/libcore-fake/libcore/util/NativeAllocationRegistry.java
index 14b5a4f..93861e8 100644
--- a/ravenwood/runtime-helper-src/libcore-fake/libcore/util/NativeAllocationRegistry.java
+++ b/ravenwood/runtime-helper-src/libcore-fake/libcore/util/NativeAllocationRegistry.java
@@ -15,7 +15,7 @@
*/
package libcore.util;
-import com.android.ravenwood.common.RavenwoodRuntimeNative;
+import libcore.ravenwood.LibcoreRavenwoodUtils;
import java.lang.ref.Cleaner;
import java.lang.ref.Reference;
@@ -27,6 +27,11 @@
* (Should ART switch to java.lang.ref.Cleaner?)
*/
public class NativeAllocationRegistry {
+ static {
+ // Initialize the JNI method.
+ LibcoreRavenwoodUtils.loadRavenwoodNativeRuntime();
+ }
+
private final long mFreeFunction;
private static final Cleaner sCleaner = Cleaner.create();
@@ -66,7 +71,7 @@
}
final Runnable releaser = () -> {
- RavenwoodRuntimeNative.applyFreeFunction(mFreeFunction, nativePtr);
+ applyFreeFunction(mFreeFunction, nativePtr);
};
sCleaner.register(referent, releaser);
@@ -74,4 +79,10 @@
Reference.reachabilityFence(referent);
return releaser;
}
+
+ /**
+ * Calls {@code freeFunction}({@code nativePtr}).
+ */
+ public static native void applyFreeFunction(long freeFunction, long nativePtr);
}
+
diff --git a/ravenwood/runtime-jni/ravenwood_os_constants.cpp b/ravenwood/runtime-jni/ravenwood_os_constants.cpp
deleted file mode 100644
index ea6c9d4..0000000
--- a/ravenwood/runtime-jni/ravenwood_os_constants.cpp
+++ /dev/null
@@ -1,766 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Copied from libcore/luni/src/main/native/android_system_OsConstants.cpp,
-// changes annotated with [ravenwood-change].
-
-#define LOG_TAG "OsConstants"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <netinet/icmp6.h>
-#include <netinet/in.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/tcp.h>
-#include <poll.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <sys/resource.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <sys/xattr.h>
-#include <unistd.h>
-
-#include <net/if_arp.h>
-#include <linux/if_ether.h>
-
-// After the others because these are not necessarily self-contained in glibc.
-#include <linux/if_addr.h>
-#include <linux/rtnetlink.h>
-
-// Include linux socket constants for setting sockopts
-#include <linux/udp.h>
-
-#include <net/if.h> // After <sys/socket.h> to work around a Mac header file bug.
-
-// [ravenwood-change] always include it
-// #if defined(__BIONIC__)
-#include <linux/capability.h>
-// #endif
-
-#include <nativehelper/JNIHelp.h>
-#include <nativehelper/jni_macros.h>
-
-// [ravenwood-change] -- can't access "Portability.h", so just inline it here.
-// #include "Portability.h"
-#include <byteswap.h>
-#include <sys/sendfile.h>
-#include <sys/statvfs.h>
-#include <netdb.h>
-#include <linux/vm_sockets.h>
-
-// For LOG_ALWAYS_FATAL_IF
-#include "utils/Log.h"
-
-
-static void initConstant(JNIEnv* env, jclass c, const char* fieldName, int value) {
- jfieldID field = env->GetStaticFieldID(c, fieldName, "I");
- env->SetStaticIntField(c, field, value);
-}
-
-static void OsConstants_initConstants(JNIEnv* env, jclass) {
- // [ravenwood-change] -- the constants are in the outer class, but this JNI method is in the
- // nested class, so we need to get the outer class here.
- jclass c = env->FindClass("android/system/OsConstants");
- LOG_ALWAYS_FATAL_IF(c == NULL, "Unable to find class android/system/OsConstants");
-
- initConstant(env, c, "AF_INET", AF_INET);
- initConstant(env, c, "AF_INET6", AF_INET6);
- initConstant(env, c, "AF_PACKET", AF_PACKET);
- initConstant(env, c, "AF_NETLINK", AF_NETLINK);
- initConstant(env, c, "AF_UNIX", AF_UNIX);
- initConstant(env, c, "AF_VSOCK", AF_VSOCK);
- initConstant(env, c, "AF_UNSPEC", AF_UNSPEC);
- initConstant(env, c, "AI_ADDRCONFIG", AI_ADDRCONFIG);
- initConstant(env, c, "AI_ALL", AI_ALL);
- initConstant(env, c, "AI_CANONNAME", AI_CANONNAME);
- initConstant(env, c, "AI_NUMERICHOST", AI_NUMERICHOST);
-#if defined(AI_NUMERICSERV)
- initConstant(env, c, "AI_NUMERICSERV", AI_NUMERICSERV);
-#endif
- initConstant(env, c, "AI_PASSIVE", AI_PASSIVE);
- initConstant(env, c, "AI_V4MAPPED", AI_V4MAPPED);
- initConstant(env, c, "ARPHRD_ETHER", ARPHRD_ETHER);
- initConstant(env, c, "VMADDR_PORT_ANY", VMADDR_PORT_ANY);
- initConstant(env, c, "VMADDR_CID_ANY", VMADDR_CID_ANY);
- initConstant(env, c, "VMADDR_CID_LOCAL", VMADDR_CID_LOCAL);
- initConstant(env, c, "VMADDR_CID_HOST", VMADDR_CID_HOST);
- initConstant(env, c, "ARPHRD_LOOPBACK", ARPHRD_LOOPBACK);
-#if defined(CAP_LAST_CAP)
- initConstant(env, c, "CAP_AUDIT_CONTROL", CAP_AUDIT_CONTROL);
- initConstant(env, c, "CAP_AUDIT_WRITE", CAP_AUDIT_WRITE);
- initConstant(env, c, "CAP_BLOCK_SUSPEND", CAP_BLOCK_SUSPEND);
- initConstant(env, c, "CAP_CHOWN", CAP_CHOWN);
- initConstant(env, c, "CAP_DAC_OVERRIDE", CAP_DAC_OVERRIDE);
- initConstant(env, c, "CAP_DAC_READ_SEARCH", CAP_DAC_READ_SEARCH);
- initConstant(env, c, "CAP_FOWNER", CAP_FOWNER);
- initConstant(env, c, "CAP_FSETID", CAP_FSETID);
- initConstant(env, c, "CAP_IPC_LOCK", CAP_IPC_LOCK);
- initConstant(env, c, "CAP_IPC_OWNER", CAP_IPC_OWNER);
- initConstant(env, c, "CAP_KILL", CAP_KILL);
- initConstant(env, c, "CAP_LAST_CAP", CAP_LAST_CAP);
- initConstant(env, c, "CAP_LEASE", CAP_LEASE);
- initConstant(env, c, "CAP_LINUX_IMMUTABLE", CAP_LINUX_IMMUTABLE);
- initConstant(env, c, "CAP_MAC_ADMIN", CAP_MAC_ADMIN);
- initConstant(env, c, "CAP_MAC_OVERRIDE", CAP_MAC_OVERRIDE);
- initConstant(env, c, "CAP_MKNOD", CAP_MKNOD);
- initConstant(env, c, "CAP_NET_ADMIN", CAP_NET_ADMIN);
- initConstant(env, c, "CAP_NET_BIND_SERVICE", CAP_NET_BIND_SERVICE);
- initConstant(env, c, "CAP_NET_BROADCAST", CAP_NET_BROADCAST);
- initConstant(env, c, "CAP_NET_RAW", CAP_NET_RAW);
- initConstant(env, c, "CAP_SETFCAP", CAP_SETFCAP);
- initConstant(env, c, "CAP_SETGID", CAP_SETGID);
- initConstant(env, c, "CAP_SETPCAP", CAP_SETPCAP);
- initConstant(env, c, "CAP_SETUID", CAP_SETUID);
- initConstant(env, c, "CAP_SYS_ADMIN", CAP_SYS_ADMIN);
- initConstant(env, c, "CAP_SYS_BOOT", CAP_SYS_BOOT);
- initConstant(env, c, "CAP_SYS_CHROOT", CAP_SYS_CHROOT);
- initConstant(env, c, "CAP_SYSLOG", CAP_SYSLOG);
- initConstant(env, c, "CAP_SYS_MODULE", CAP_SYS_MODULE);
- initConstant(env, c, "CAP_SYS_NICE", CAP_SYS_NICE);
- initConstant(env, c, "CAP_SYS_PACCT", CAP_SYS_PACCT);
- initConstant(env, c, "CAP_SYS_PTRACE", CAP_SYS_PTRACE);
- initConstant(env, c, "CAP_SYS_RAWIO", CAP_SYS_RAWIO);
- initConstant(env, c, "CAP_SYS_RESOURCE", CAP_SYS_RESOURCE);
- initConstant(env, c, "CAP_SYS_TIME", CAP_SYS_TIME);
- initConstant(env, c, "CAP_SYS_TTY_CONFIG", CAP_SYS_TTY_CONFIG);
- initConstant(env, c, "CAP_WAKE_ALARM", CAP_WAKE_ALARM);
-#endif
- initConstant(env, c, "E2BIG", E2BIG);
- initConstant(env, c, "EACCES", EACCES);
- initConstant(env, c, "EADDRINUSE", EADDRINUSE);
- initConstant(env, c, "EADDRNOTAVAIL", EADDRNOTAVAIL);
- initConstant(env, c, "EAFNOSUPPORT", EAFNOSUPPORT);
- initConstant(env, c, "EAGAIN", EAGAIN);
- initConstant(env, c, "EAI_AGAIN", EAI_AGAIN);
- initConstant(env, c, "EAI_BADFLAGS", EAI_BADFLAGS);
- initConstant(env, c, "EAI_FAIL", EAI_FAIL);
- initConstant(env, c, "EAI_FAMILY", EAI_FAMILY);
- initConstant(env, c, "EAI_MEMORY", EAI_MEMORY);
- initConstant(env, c, "EAI_NODATA", EAI_NODATA);
- initConstant(env, c, "EAI_NONAME", EAI_NONAME);
-#if defined(EAI_OVERFLOW)
- initConstant(env, c, "EAI_OVERFLOW", EAI_OVERFLOW);
-#endif
- initConstant(env, c, "EAI_SERVICE", EAI_SERVICE);
- initConstant(env, c, "EAI_SOCKTYPE", EAI_SOCKTYPE);
- initConstant(env, c, "EAI_SYSTEM", EAI_SYSTEM);
- initConstant(env, c, "EALREADY", EALREADY);
- initConstant(env, c, "EBADF", EBADF);
- initConstant(env, c, "EBADMSG", EBADMSG);
- initConstant(env, c, "EBUSY", EBUSY);
- initConstant(env, c, "ECANCELED", ECANCELED);
- initConstant(env, c, "ECHILD", ECHILD);
- initConstant(env, c, "ECONNABORTED", ECONNABORTED);
- initConstant(env, c, "ECONNREFUSED", ECONNREFUSED);
- initConstant(env, c, "ECONNRESET", ECONNRESET);
- initConstant(env, c, "EDEADLK", EDEADLK);
- initConstant(env, c, "EDESTADDRREQ", EDESTADDRREQ);
- initConstant(env, c, "EDOM", EDOM);
- initConstant(env, c, "EDQUOT", EDQUOT);
- initConstant(env, c, "EEXIST", EEXIST);
- initConstant(env, c, "EFAULT", EFAULT);
- initConstant(env, c, "EFBIG", EFBIG);
- initConstant(env, c, "EHOSTUNREACH", EHOSTUNREACH);
- initConstant(env, c, "EIDRM", EIDRM);
- initConstant(env, c, "EILSEQ", EILSEQ);
- initConstant(env, c, "EINPROGRESS", EINPROGRESS);
- initConstant(env, c, "EINTR", EINTR);
- initConstant(env, c, "EINVAL", EINVAL);
- initConstant(env, c, "EIO", EIO);
- initConstant(env, c, "EISCONN", EISCONN);
- initConstant(env, c, "EISDIR", EISDIR);
- initConstant(env, c, "ELOOP", ELOOP);
- initConstant(env, c, "EMFILE", EMFILE);
- initConstant(env, c, "EMLINK", EMLINK);
- initConstant(env, c, "EMSGSIZE", EMSGSIZE);
- initConstant(env, c, "EMULTIHOP", EMULTIHOP);
- initConstant(env, c, "ENAMETOOLONG", ENAMETOOLONG);
- initConstant(env, c, "ENETDOWN", ENETDOWN);
- initConstant(env, c, "ENETRESET", ENETRESET);
- initConstant(env, c, "ENETUNREACH", ENETUNREACH);
- initConstant(env, c, "ENFILE", ENFILE);
- initConstant(env, c, "ENOBUFS", ENOBUFS);
- initConstant(env, c, "ENODATA", ENODATA);
- initConstant(env, c, "ENODEV", ENODEV);
- initConstant(env, c, "ENOENT", ENOENT);
- initConstant(env, c, "ENOEXEC", ENOEXEC);
- initConstant(env, c, "ENOLCK", ENOLCK);
- initConstant(env, c, "ENOLINK", ENOLINK);
- initConstant(env, c, "ENOMEM", ENOMEM);
- initConstant(env, c, "ENOMSG", ENOMSG);
- initConstant(env, c, "ENONET", ENONET);
- initConstant(env, c, "ENOPROTOOPT", ENOPROTOOPT);
- initConstant(env, c, "ENOSPC", ENOSPC);
- initConstant(env, c, "ENOSR", ENOSR);
- initConstant(env, c, "ENOSTR", ENOSTR);
- initConstant(env, c, "ENOSYS", ENOSYS);
- initConstant(env, c, "ENOTCONN", ENOTCONN);
- initConstant(env, c, "ENOTDIR", ENOTDIR);
- initConstant(env, c, "ENOTEMPTY", ENOTEMPTY);
- initConstant(env, c, "ENOTSOCK", ENOTSOCK);
- initConstant(env, c, "ENOTSUP", ENOTSUP);
- initConstant(env, c, "ENOTTY", ENOTTY);
- initConstant(env, c, "ENXIO", ENXIO);
- initConstant(env, c, "EOPNOTSUPP", EOPNOTSUPP);
- initConstant(env, c, "EOVERFLOW", EOVERFLOW);
- initConstant(env, c, "EPERM", EPERM);
- initConstant(env, c, "EPIPE", EPIPE);
- initConstant(env, c, "EPROTO", EPROTO);
- initConstant(env, c, "EPROTONOSUPPORT", EPROTONOSUPPORT);
- initConstant(env, c, "EPROTOTYPE", EPROTOTYPE);
- initConstant(env, c, "ERANGE", ERANGE);
- initConstant(env, c, "EROFS", EROFS);
- initConstant(env, c, "ESPIPE", ESPIPE);
- initConstant(env, c, "ESRCH", ESRCH);
- initConstant(env, c, "ESTALE", ESTALE);
- initConstant(env, c, "ETH_P_ALL", ETH_P_ALL);
- initConstant(env, c, "ETH_P_ARP", ETH_P_ARP);
- initConstant(env, c, "ETH_P_IP", ETH_P_IP);
- initConstant(env, c, "ETH_P_IPV6", ETH_P_IPV6);
- initConstant(env, c, "ETIME", ETIME);
- initConstant(env, c, "ETIMEDOUT", ETIMEDOUT);
- initConstant(env, c, "ETXTBSY", ETXTBSY);
- initConstant(env, c, "EUSERS", EUSERS);
-#if EWOULDBLOCK != EAGAIN
-#error EWOULDBLOCK != EAGAIN
-#endif
- initConstant(env, c, "EXDEV", EXDEV);
- initConstant(env, c, "EXIT_FAILURE", EXIT_FAILURE);
- initConstant(env, c, "EXIT_SUCCESS", EXIT_SUCCESS);
- initConstant(env, c, "FD_CLOEXEC", FD_CLOEXEC);
- initConstant(env, c, "FIONREAD", FIONREAD);
- initConstant(env, c, "F_DUPFD", F_DUPFD);
- initConstant(env, c, "F_DUPFD_CLOEXEC", F_DUPFD_CLOEXEC);
- initConstant(env, c, "F_GETFD", F_GETFD);
- initConstant(env, c, "F_GETFL", F_GETFL);
- initConstant(env, c, "F_GETLK", F_GETLK);
-#if defined(F_GETLK64)
- initConstant(env, c, "F_GETLK64", F_GETLK64);
-#endif
- initConstant(env, c, "F_GETOWN", F_GETOWN);
- initConstant(env, c, "F_OK", F_OK);
- initConstant(env, c, "F_RDLCK", F_RDLCK);
- initConstant(env, c, "F_SETFD", F_SETFD);
- initConstant(env, c, "F_SETFL", F_SETFL);
- initConstant(env, c, "F_SETLK", F_SETLK);
-#if defined(F_SETLK64)
- initConstant(env, c, "F_SETLK64", F_SETLK64);
-#endif
- initConstant(env, c, "F_SETLKW", F_SETLKW);
-#if defined(F_SETLKW64)
- initConstant(env, c, "F_SETLKW64", F_SETLKW64);
-#endif
- initConstant(env, c, "F_SETOWN", F_SETOWN);
- initConstant(env, c, "F_UNLCK", F_UNLCK);
- initConstant(env, c, "F_WRLCK", F_WRLCK);
- initConstant(env, c, "ICMP_ECHO", ICMP_ECHO);
- initConstant(env, c, "ICMP_ECHOREPLY", ICMP_ECHOREPLY);
- initConstant(env, c, "ICMP6_ECHO_REQUEST", ICMP6_ECHO_REQUEST);
- initConstant(env, c, "ICMP6_ECHO_REPLY", ICMP6_ECHO_REPLY);
-#if defined(IFA_F_DADFAILED)
- initConstant(env, c, "IFA_F_DADFAILED", IFA_F_DADFAILED);
-#endif
-#if defined(IFA_F_DEPRECATED)
- initConstant(env, c, "IFA_F_DEPRECATED", IFA_F_DEPRECATED);
-#endif
-#if defined(IFA_F_HOMEADDRESS)
- initConstant(env, c, "IFA_F_HOMEADDRESS", IFA_F_HOMEADDRESS);
-#endif
-#if defined(IFA_F_MANAGETEMPADDR)
- initConstant(env, c, "IFA_F_MANAGETEMPADDR", IFA_F_MANAGETEMPADDR);
-#endif
-#if defined(IFA_F_NODAD)
- initConstant(env, c, "IFA_F_NODAD", IFA_F_NODAD);
-#endif
-#if defined(IFA_F_NOPREFIXROUTE)
- initConstant(env, c, "IFA_F_NOPREFIXROUTE", IFA_F_NOPREFIXROUTE);
-#endif
-#if defined(IFA_F_OPTIMISTIC)
- initConstant(env, c, "IFA_F_OPTIMISTIC", IFA_F_OPTIMISTIC);
-#endif
-#if defined(IFA_F_PERMANENT)
- initConstant(env, c, "IFA_F_PERMANENT", IFA_F_PERMANENT);
-#endif
-#if defined(IFA_F_SECONDARY)
- initConstant(env, c, "IFA_F_SECONDARY", IFA_F_SECONDARY);
-#endif
-#if defined(IFA_F_TEMPORARY)
- initConstant(env, c, "IFA_F_TEMPORARY", IFA_F_TEMPORARY);
-#endif
-#if defined(IFA_F_TENTATIVE)
- initConstant(env, c, "IFA_F_TENTATIVE", IFA_F_TENTATIVE);
-#endif
- initConstant(env, c, "IFF_ALLMULTI", IFF_ALLMULTI);
-#if defined(IFF_AUTOMEDIA)
- initConstant(env, c, "IFF_AUTOMEDIA", IFF_AUTOMEDIA);
-#endif
- initConstant(env, c, "IFF_BROADCAST", IFF_BROADCAST);
- initConstant(env, c, "IFF_DEBUG", IFF_DEBUG);
-#if defined(IFF_DYNAMIC)
- initConstant(env, c, "IFF_DYNAMIC", IFF_DYNAMIC);
-#endif
- initConstant(env, c, "IFF_LOOPBACK", IFF_LOOPBACK);
-#if defined(IFF_MASTER)
- initConstant(env, c, "IFF_MASTER", IFF_MASTER);
-#endif
- initConstant(env, c, "IFF_MULTICAST", IFF_MULTICAST);
- initConstant(env, c, "IFF_NOARP", IFF_NOARP);
- initConstant(env, c, "IFF_NOTRAILERS", IFF_NOTRAILERS);
- initConstant(env, c, "IFF_POINTOPOINT", IFF_POINTOPOINT);
-#if defined(IFF_PORTSEL)
- initConstant(env, c, "IFF_PORTSEL", IFF_PORTSEL);
-#endif
- initConstant(env, c, "IFF_PROMISC", IFF_PROMISC);
- initConstant(env, c, "IFF_RUNNING", IFF_RUNNING);
-#if defined(IFF_SLAVE)
- initConstant(env, c, "IFF_SLAVE", IFF_SLAVE);
-#endif
- initConstant(env, c, "IFF_UP", IFF_UP);
- initConstant(env, c, "IPPROTO_ICMP", IPPROTO_ICMP);
- initConstant(env, c, "IPPROTO_ICMPV6", IPPROTO_ICMPV6);
- initConstant(env, c, "IPPROTO_IP", IPPROTO_IP);
- initConstant(env, c, "IPPROTO_IPV6", IPPROTO_IPV6);
- initConstant(env, c, "IPPROTO_RAW", IPPROTO_RAW);
- initConstant(env, c, "IPPROTO_TCP", IPPROTO_TCP);
- initConstant(env, c, "IPPROTO_UDP", IPPROTO_UDP);
- initConstant(env, c, "IPPROTO_ESP", IPPROTO_ESP);
- initConstant(env, c, "IPV6_CHECKSUM", IPV6_CHECKSUM);
- initConstant(env, c, "IPV6_MULTICAST_HOPS", IPV6_MULTICAST_HOPS);
- initConstant(env, c, "IPV6_MULTICAST_IF", IPV6_MULTICAST_IF);
- initConstant(env, c, "IPV6_MULTICAST_LOOP", IPV6_MULTICAST_LOOP);
-#if defined(IPV6_PKTINFO)
- initConstant(env, c, "IPV6_PKTINFO", IPV6_PKTINFO);
-#endif
-#if defined(IPV6_RECVDSTOPTS)
- initConstant(env, c, "IPV6_RECVDSTOPTS", IPV6_RECVDSTOPTS);
-#endif
-#if defined(IPV6_RECVHOPLIMIT)
- initConstant(env, c, "IPV6_RECVHOPLIMIT", IPV6_RECVHOPLIMIT);
-#endif
-#if defined(IPV6_RECVHOPOPTS)
- initConstant(env, c, "IPV6_RECVHOPOPTS", IPV6_RECVHOPOPTS);
-#endif
-#if defined(IPV6_RECVPKTINFO)
- initConstant(env, c, "IPV6_RECVPKTINFO", IPV6_RECVPKTINFO);
-#endif
-#if defined(IPV6_RECVRTHDR)
- initConstant(env, c, "IPV6_RECVRTHDR", IPV6_RECVRTHDR);
-#endif
-#if defined(IPV6_RECVTCLASS)
- initConstant(env, c, "IPV6_RECVTCLASS", IPV6_RECVTCLASS);
-#endif
-#if defined(IPV6_TCLASS)
- initConstant(env, c, "IPV6_TCLASS", IPV6_TCLASS);
-#endif
- initConstant(env, c, "IPV6_UNICAST_HOPS", IPV6_UNICAST_HOPS);
- initConstant(env, c, "IPV6_V6ONLY", IPV6_V6ONLY);
- initConstant(env, c, "IP_MULTICAST_ALL", IP_MULTICAST_ALL);
- initConstant(env, c, "IP_MULTICAST_IF", IP_MULTICAST_IF);
- initConstant(env, c, "IP_MULTICAST_LOOP", IP_MULTICAST_LOOP);
- initConstant(env, c, "IP_MULTICAST_TTL", IP_MULTICAST_TTL);
- initConstant(env, c, "IP_RECVTOS", IP_RECVTOS);
- initConstant(env, c, "IP_TOS", IP_TOS);
- initConstant(env, c, "IP_TTL", IP_TTL);
-#if defined(_LINUX_CAPABILITY_VERSION_3)
- initConstant(env, c, "_LINUX_CAPABILITY_VERSION_3", _LINUX_CAPABILITY_VERSION_3);
-#endif
- initConstant(env, c, "MAP_FIXED", MAP_FIXED);
- initConstant(env, c, "MAP_ANONYMOUS", MAP_ANONYMOUS);
- initConstant(env, c, "MAP_POPULATE", MAP_POPULATE);
- initConstant(env, c, "MAP_PRIVATE", MAP_PRIVATE);
- initConstant(env, c, "MAP_SHARED", MAP_SHARED);
-#if defined(MCAST_JOIN_GROUP)
- initConstant(env, c, "MCAST_JOIN_GROUP", MCAST_JOIN_GROUP);
-#endif
-#if defined(MCAST_LEAVE_GROUP)
- initConstant(env, c, "MCAST_LEAVE_GROUP", MCAST_LEAVE_GROUP);
-#endif
-#if defined(MCAST_JOIN_SOURCE_GROUP)
- initConstant(env, c, "MCAST_JOIN_SOURCE_GROUP", MCAST_JOIN_SOURCE_GROUP);
-#endif
-#if defined(MCAST_LEAVE_SOURCE_GROUP)
- initConstant(env, c, "MCAST_LEAVE_SOURCE_GROUP", MCAST_LEAVE_SOURCE_GROUP);
-#endif
-#if defined(MCAST_BLOCK_SOURCE)
- initConstant(env, c, "MCAST_BLOCK_SOURCE", MCAST_BLOCK_SOURCE);
-#endif
-#if defined(MCAST_UNBLOCK_SOURCE)
- initConstant(env, c, "MCAST_UNBLOCK_SOURCE", MCAST_UNBLOCK_SOURCE);
-#endif
- initConstant(env, c, "MCL_CURRENT", MCL_CURRENT);
- initConstant(env, c, "MCL_FUTURE", MCL_FUTURE);
-#if defined(MFD_CLOEXEC)
- initConstant(env, c, "MFD_CLOEXEC", MFD_CLOEXEC);
-#endif
- initConstant(env, c, "MSG_CTRUNC", MSG_CTRUNC);
- initConstant(env, c, "MSG_DONTROUTE", MSG_DONTROUTE);
- initConstant(env, c, "MSG_EOR", MSG_EOR);
- initConstant(env, c, "MSG_OOB", MSG_OOB);
- initConstant(env, c, "MSG_PEEK", MSG_PEEK);
- initConstant(env, c, "MSG_TRUNC", MSG_TRUNC);
- initConstant(env, c, "MSG_WAITALL", MSG_WAITALL);
- initConstant(env, c, "MS_ASYNC", MS_ASYNC);
- initConstant(env, c, "MS_INVALIDATE", MS_INVALIDATE);
- initConstant(env, c, "MS_SYNC", MS_SYNC);
- initConstant(env, c, "NETLINK_NETFILTER", NETLINK_NETFILTER);
- initConstant(env, c, "NETLINK_ROUTE", NETLINK_ROUTE);
- initConstant(env, c, "NETLINK_INET_DIAG", NETLINK_INET_DIAG);
- initConstant(env, c, "NETLINK_XFRM", NETLINK_XFRM);
- initConstant(env, c, "NI_DGRAM", NI_DGRAM);
- initConstant(env, c, "NI_NAMEREQD", NI_NAMEREQD);
- initConstant(env, c, "NI_NOFQDN", NI_NOFQDN);
- initConstant(env, c, "NI_NUMERICHOST", NI_NUMERICHOST);
- initConstant(env, c, "NI_NUMERICSERV", NI_NUMERICSERV);
- initConstant(env, c, "O_ACCMODE", O_ACCMODE);
- initConstant(env, c, "O_APPEND", O_APPEND);
- initConstant(env, c, "O_CLOEXEC", O_CLOEXEC);
- initConstant(env, c, "O_CREAT", O_CREAT);
- initConstant(env, c, "O_DIRECT", O_DIRECT);
- initConstant(env, c, "O_EXCL", O_EXCL);
- initConstant(env, c, "O_NOCTTY", O_NOCTTY);
- initConstant(env, c, "O_NOFOLLOW", O_NOFOLLOW);
- initConstant(env, c, "O_NONBLOCK", O_NONBLOCK);
- initConstant(env, c, "O_RDONLY", O_RDONLY);
- initConstant(env, c, "O_RDWR", O_RDWR);
- initConstant(env, c, "O_SYNC", O_SYNC);
- initConstant(env, c, "O_DSYNC", O_DSYNC);
- initConstant(env, c, "O_TRUNC", O_TRUNC);
- initConstant(env, c, "O_WRONLY", O_WRONLY);
- initConstant(env, c, "POLLERR", POLLERR);
- initConstant(env, c, "POLLHUP", POLLHUP);
- initConstant(env, c, "POLLIN", POLLIN);
- initConstant(env, c, "POLLNVAL", POLLNVAL);
- initConstant(env, c, "POLLOUT", POLLOUT);
- initConstant(env, c, "POLLPRI", POLLPRI);
- initConstant(env, c, "POLLRDBAND", POLLRDBAND);
- initConstant(env, c, "POLLRDNORM", POLLRDNORM);
- initConstant(env, c, "POLLWRBAND", POLLWRBAND);
- initConstant(env, c, "POLLWRNORM", POLLWRNORM);
-#if defined(PR_CAP_AMBIENT)
- initConstant(env, c, "PR_CAP_AMBIENT", PR_CAP_AMBIENT);
-#endif
-#if defined(PR_CAP_AMBIENT_RAISE)
- initConstant(env, c, "PR_CAP_AMBIENT_RAISE", PR_CAP_AMBIENT_RAISE);
-#endif
-#if defined(PR_GET_DUMPABLE)
- initConstant(env, c, "PR_GET_DUMPABLE", PR_GET_DUMPABLE);
-#endif
-#if defined(PR_SET_DUMPABLE)
- initConstant(env, c, "PR_SET_DUMPABLE", PR_SET_DUMPABLE);
-#endif
-#if defined(PR_SET_NO_NEW_PRIVS)
- initConstant(env, c, "PR_SET_NO_NEW_PRIVS", PR_SET_NO_NEW_PRIVS);
-#endif
- initConstant(env, c, "PROT_EXEC", PROT_EXEC);
- initConstant(env, c, "PROT_NONE", PROT_NONE);
- initConstant(env, c, "PROT_READ", PROT_READ);
- initConstant(env, c, "PROT_WRITE", PROT_WRITE);
- initConstant(env, c, "R_OK", R_OK);
- initConstant(env, c, "RLIMIT_NOFILE", RLIMIT_NOFILE);
-// NOTE: The RT_* constants are not preprocessor defines, they're enum
-// members. The best we can do (barring UAPI / kernel version checks) is
-// to hope they exist on all host linuxes we're building on. These
-// constants have been around since 2.6.35 at least, so we should be ok.
- initConstant(env, c, "RT_SCOPE_HOST", RT_SCOPE_HOST);
- initConstant(env, c, "RT_SCOPE_LINK", RT_SCOPE_LINK);
- initConstant(env, c, "RT_SCOPE_NOWHERE", RT_SCOPE_NOWHERE);
- initConstant(env, c, "RT_SCOPE_SITE", RT_SCOPE_SITE);
- initConstant(env, c, "RT_SCOPE_UNIVERSE", RT_SCOPE_UNIVERSE);
- initConstant(env, c, "RTMGRP_IPV4_IFADDR", RTMGRP_IPV4_IFADDR);
- initConstant(env, c, "RTMGRP_IPV4_MROUTE", RTMGRP_IPV4_MROUTE);
- initConstant(env, c, "RTMGRP_IPV4_ROUTE", RTMGRP_IPV4_ROUTE);
- initConstant(env, c, "RTMGRP_IPV4_RULE", RTMGRP_IPV4_RULE);
- initConstant(env, c, "RTMGRP_IPV6_IFADDR", RTMGRP_IPV6_IFADDR);
- initConstant(env, c, "RTMGRP_IPV6_IFINFO", RTMGRP_IPV6_IFINFO);
- initConstant(env, c, "RTMGRP_IPV6_MROUTE", RTMGRP_IPV6_MROUTE);
- initConstant(env, c, "RTMGRP_IPV6_PREFIX", RTMGRP_IPV6_PREFIX);
- initConstant(env, c, "RTMGRP_IPV6_ROUTE", RTMGRP_IPV6_ROUTE);
- initConstant(env, c, "RTMGRP_LINK", RTMGRP_LINK);
- initConstant(env, c, "RTMGRP_NEIGH", RTMGRP_NEIGH);
- initConstant(env, c, "RTMGRP_NOTIFY", RTMGRP_NOTIFY);
- initConstant(env, c, "RTMGRP_TC", RTMGRP_TC);
- initConstant(env, c, "SEEK_CUR", SEEK_CUR);
- initConstant(env, c, "SEEK_END", SEEK_END);
- initConstant(env, c, "SEEK_SET", SEEK_SET);
- initConstant(env, c, "SHUT_RD", SHUT_RD);
- initConstant(env, c, "SHUT_RDWR", SHUT_RDWR);
- initConstant(env, c, "SHUT_WR", SHUT_WR);
- initConstant(env, c, "SIGABRT", SIGABRT);
- initConstant(env, c, "SIGALRM", SIGALRM);
- initConstant(env, c, "SIGBUS", SIGBUS);
- initConstant(env, c, "SIGCHLD", SIGCHLD);
- initConstant(env, c, "SIGCONT", SIGCONT);
- initConstant(env, c, "SIGFPE", SIGFPE);
- initConstant(env, c, "SIGHUP", SIGHUP);
- initConstant(env, c, "SIGILL", SIGILL);
- initConstant(env, c, "SIGINT", SIGINT);
- initConstant(env, c, "SIGIO", SIGIO);
- initConstant(env, c, "SIGKILL", SIGKILL);
- initConstant(env, c, "SIGPIPE", SIGPIPE);
- initConstant(env, c, "SIGPROF", SIGPROF);
-#if defined(SIGPWR)
- initConstant(env, c, "SIGPWR", SIGPWR);
-#endif
- initConstant(env, c, "SIGQUIT", SIGQUIT);
-#if defined(SIGRTMAX)
- initConstant(env, c, "SIGRTMAX", SIGRTMAX);
-#endif
-#if defined(SIGRTMIN)
- initConstant(env, c, "SIGRTMIN", SIGRTMIN);
-#endif
- initConstant(env, c, "SIGSEGV", SIGSEGV);
-#if defined(SIGSTKFLT)
- initConstant(env, c, "SIGSTKFLT", SIGSTKFLT);
-#endif
- initConstant(env, c, "SIGSTOP", SIGSTOP);
- initConstant(env, c, "SIGSYS", SIGSYS);
- initConstant(env, c, "SIGTERM", SIGTERM);
- initConstant(env, c, "SIGTRAP", SIGTRAP);
- initConstant(env, c, "SIGTSTP", SIGTSTP);
- initConstant(env, c, "SIGTTIN", SIGTTIN);
- initConstant(env, c, "SIGTTOU", SIGTTOU);
- initConstant(env, c, "SIGURG", SIGURG);
- initConstant(env, c, "SIGUSR1", SIGUSR1);
- initConstant(env, c, "SIGUSR2", SIGUSR2);
- initConstant(env, c, "SIGVTALRM", SIGVTALRM);
- initConstant(env, c, "SIGWINCH", SIGWINCH);
- initConstant(env, c, "SIGXCPU", SIGXCPU);
- initConstant(env, c, "SIGXFSZ", SIGXFSZ);
- initConstant(env, c, "SIOCGIFADDR", SIOCGIFADDR);
- initConstant(env, c, "SIOCGIFBRDADDR", SIOCGIFBRDADDR);
- initConstant(env, c, "SIOCGIFDSTADDR", SIOCGIFDSTADDR);
- initConstant(env, c, "SIOCGIFNETMASK", SIOCGIFNETMASK);
- initConstant(env, c, "SOCK_CLOEXEC", SOCK_CLOEXEC);
- initConstant(env, c, "SOCK_DGRAM", SOCK_DGRAM);
- initConstant(env, c, "SOCK_NONBLOCK", SOCK_NONBLOCK);
- initConstant(env, c, "SOCK_RAW", SOCK_RAW);
- initConstant(env, c, "SOCK_SEQPACKET", SOCK_SEQPACKET);
- initConstant(env, c, "SOCK_STREAM", SOCK_STREAM);
- initConstant(env, c, "SOL_SOCKET", SOL_SOCKET);
-#if defined(SOL_UDP)
- initConstant(env, c, "SOL_UDP", SOL_UDP);
-#endif
- initConstant(env, c, "SOL_PACKET", SOL_PACKET);
-#if defined(SO_BINDTODEVICE)
- initConstant(env, c, "SO_BINDTODEVICE", SO_BINDTODEVICE);
-#endif
- initConstant(env, c, "SO_BROADCAST", SO_BROADCAST);
- initConstant(env, c, "SO_DEBUG", SO_DEBUG);
-#if defined(SO_DOMAIN)
- initConstant(env, c, "SO_DOMAIN", SO_DOMAIN);
-#endif
- initConstant(env, c, "SO_DONTROUTE", SO_DONTROUTE);
- initConstant(env, c, "SO_ERROR", SO_ERROR);
- initConstant(env, c, "SO_KEEPALIVE", SO_KEEPALIVE);
- initConstant(env, c, "SO_LINGER", SO_LINGER);
- initConstant(env, c, "SO_OOBINLINE", SO_OOBINLINE);
-#if defined(SO_PASSCRED)
- initConstant(env, c, "SO_PASSCRED", SO_PASSCRED);
-#endif
-#if defined(SO_PEERCRED)
- initConstant(env, c, "SO_PEERCRED", SO_PEERCRED);
-#endif
-#if defined(SO_PROTOCOL)
- initConstant(env, c, "SO_PROTOCOL", SO_PROTOCOL);
-#endif
- initConstant(env, c, "SO_RCVBUF", SO_RCVBUF);
- initConstant(env, c, "SO_RCVLOWAT", SO_RCVLOWAT);
- initConstant(env, c, "SO_RCVTIMEO", SO_RCVTIMEO);
- initConstant(env, c, "SO_REUSEADDR", SO_REUSEADDR);
- initConstant(env, c, "SO_SNDBUF", SO_SNDBUF);
- initConstant(env, c, "SO_SNDLOWAT", SO_SNDLOWAT);
- initConstant(env, c, "SO_SNDTIMEO", SO_SNDTIMEO);
- initConstant(env, c, "SO_TYPE", SO_TYPE);
-#if defined(PACKET_IGNORE_OUTGOING)
- initConstant(env, c, "PACKET_IGNORE_OUTGOING", PACKET_IGNORE_OUTGOING);
-#endif
- initConstant(env, c, "SPLICE_F_MOVE", SPLICE_F_MOVE);
- initConstant(env, c, "SPLICE_F_NONBLOCK", SPLICE_F_NONBLOCK);
- initConstant(env, c, "SPLICE_F_MORE", SPLICE_F_MORE);
- initConstant(env, c, "STDERR_FILENO", STDERR_FILENO);
- initConstant(env, c, "STDIN_FILENO", STDIN_FILENO);
- initConstant(env, c, "STDOUT_FILENO", STDOUT_FILENO);
- initConstant(env, c, "ST_MANDLOCK", ST_MANDLOCK);
- initConstant(env, c, "ST_NOATIME", ST_NOATIME);
- initConstant(env, c, "ST_NODEV", ST_NODEV);
- initConstant(env, c, "ST_NODIRATIME", ST_NODIRATIME);
- initConstant(env, c, "ST_NOEXEC", ST_NOEXEC);
- initConstant(env, c, "ST_NOSUID", ST_NOSUID);
- initConstant(env, c, "ST_RDONLY", ST_RDONLY);
- initConstant(env, c, "ST_RELATIME", ST_RELATIME);
- initConstant(env, c, "ST_SYNCHRONOUS", ST_SYNCHRONOUS);
- initConstant(env, c, "S_IFBLK", S_IFBLK);
- initConstant(env, c, "S_IFCHR", S_IFCHR);
- initConstant(env, c, "S_IFDIR", S_IFDIR);
- initConstant(env, c, "S_IFIFO", S_IFIFO);
- initConstant(env, c, "S_IFLNK", S_IFLNK);
- initConstant(env, c, "S_IFMT", S_IFMT);
- initConstant(env, c, "S_IFREG", S_IFREG);
- initConstant(env, c, "S_IFSOCK", S_IFSOCK);
- initConstant(env, c, "S_IRGRP", S_IRGRP);
- initConstant(env, c, "S_IROTH", S_IROTH);
- initConstant(env, c, "S_IRUSR", S_IRUSR);
- initConstant(env, c, "S_IRWXG", S_IRWXG);
- initConstant(env, c, "S_IRWXO", S_IRWXO);
- initConstant(env, c, "S_IRWXU", S_IRWXU);
- initConstant(env, c, "S_ISGID", S_ISGID);
- initConstant(env, c, "S_ISUID", S_ISUID);
- initConstant(env, c, "S_ISVTX", S_ISVTX);
- initConstant(env, c, "S_IWGRP", S_IWGRP);
- initConstant(env, c, "S_IWOTH", S_IWOTH);
- initConstant(env, c, "S_IWUSR", S_IWUSR);
- initConstant(env, c, "S_IXGRP", S_IXGRP);
- initConstant(env, c, "S_IXOTH", S_IXOTH);
- initConstant(env, c, "S_IXUSR", S_IXUSR);
- initConstant(env, c, "TCP_NODELAY", TCP_NODELAY);
-#if defined(TCP_USER_TIMEOUT)
- initConstant(env, c, "TCP_USER_TIMEOUT", TCP_USER_TIMEOUT);
-#endif
- initConstant(env, c, "TIOCOUTQ", TIOCOUTQ);
- initConstant(env, c, "UDP_ENCAP", UDP_ENCAP);
- initConstant(env, c, "UDP_ENCAP_ESPINUDP_NON_IKE", UDP_ENCAP_ESPINUDP_NON_IKE);
- initConstant(env, c, "UDP_ENCAP_ESPINUDP", UDP_ENCAP_ESPINUDP);
-#if defined(UDP_GRO)
- initConstant(env, c, "UDP_GRO", UDP_GRO);
-#endif
-#if defined(UDP_SEGMENT)
- initConstant(env, c, "UDP_SEGMENT", UDP_SEGMENT);
-#endif
- // UNIX_PATH_MAX is mentioned in some versions of unix(7), but not actually declared.
- initConstant(env, c, "UNIX_PATH_MAX", sizeof(sockaddr_un::sun_path));
- initConstant(env, c, "WCONTINUED", WCONTINUED);
- initConstant(env, c, "WEXITED", WEXITED);
- initConstant(env, c, "WNOHANG", WNOHANG);
- initConstant(env, c, "WNOWAIT", WNOWAIT);
- initConstant(env, c, "WSTOPPED", WSTOPPED);
- initConstant(env, c, "WUNTRACED", WUNTRACED);
- initConstant(env, c, "W_OK", W_OK);
- initConstant(env, c, "XATTR_CREATE", XATTR_CREATE);
- initConstant(env, c, "XATTR_REPLACE", XATTR_REPLACE);
- initConstant(env, c, "X_OK", X_OK);
- initConstant(env, c, "_SC_2_CHAR_TERM", _SC_2_CHAR_TERM);
- initConstant(env, c, "_SC_2_C_BIND", _SC_2_C_BIND);
- initConstant(env, c, "_SC_2_C_DEV", _SC_2_C_DEV);
-#if defined(_SC_2_C_VERSION)
- initConstant(env, c, "_SC_2_C_VERSION", _SC_2_C_VERSION);
-#endif
- initConstant(env, c, "_SC_2_FORT_DEV", _SC_2_FORT_DEV);
- initConstant(env, c, "_SC_2_FORT_RUN", _SC_2_FORT_RUN);
- initConstant(env, c, "_SC_2_LOCALEDEF", _SC_2_LOCALEDEF);
- initConstant(env, c, "_SC_2_SW_DEV", _SC_2_SW_DEV);
- initConstant(env, c, "_SC_2_UPE", _SC_2_UPE);
- initConstant(env, c, "_SC_2_VERSION", _SC_2_VERSION);
- initConstant(env, c, "_SC_AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX);
- initConstant(env, c, "_SC_AIO_MAX", _SC_AIO_MAX);
- initConstant(env, c, "_SC_AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX);
- initConstant(env, c, "_SC_ARG_MAX", _SC_ARG_MAX);
- initConstant(env, c, "_SC_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO);
- initConstant(env, c, "_SC_ATEXIT_MAX", _SC_ATEXIT_MAX);
-#if defined(_SC_AVPHYS_PAGES)
- initConstant(env, c, "_SC_AVPHYS_PAGES", _SC_AVPHYS_PAGES);
-#endif
- initConstant(env, c, "_SC_BC_BASE_MAX", _SC_BC_BASE_MAX);
- initConstant(env, c, "_SC_BC_DIM_MAX", _SC_BC_DIM_MAX);
- initConstant(env, c, "_SC_BC_SCALE_MAX", _SC_BC_SCALE_MAX);
- initConstant(env, c, "_SC_BC_STRING_MAX", _SC_BC_STRING_MAX);
- initConstant(env, c, "_SC_CHILD_MAX", _SC_CHILD_MAX);
- initConstant(env, c, "_SC_CLK_TCK", _SC_CLK_TCK);
- initConstant(env, c, "_SC_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX);
- initConstant(env, c, "_SC_DELAYTIMER_MAX", _SC_DELAYTIMER_MAX);
- initConstant(env, c, "_SC_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX);
- initConstant(env, c, "_SC_FSYNC", _SC_FSYNC);
- initConstant(env, c, "_SC_GETGR_R_SIZE_MAX", _SC_GETGR_R_SIZE_MAX);
- initConstant(env, c, "_SC_GETPW_R_SIZE_MAX", _SC_GETPW_R_SIZE_MAX);
- initConstant(env, c, "_SC_IOV_MAX", _SC_IOV_MAX);
- initConstant(env, c, "_SC_JOB_CONTROL", _SC_JOB_CONTROL);
- initConstant(env, c, "_SC_LINE_MAX", _SC_LINE_MAX);
- initConstant(env, c, "_SC_LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX);
- initConstant(env, c, "_SC_MAPPED_FILES", _SC_MAPPED_FILES);
- initConstant(env, c, "_SC_MEMLOCK", _SC_MEMLOCK);
- initConstant(env, c, "_SC_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE);
- initConstant(env, c, "_SC_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION);
- initConstant(env, c, "_SC_MESSAGE_PASSING", _SC_MESSAGE_PASSING);
- initConstant(env, c, "_SC_MQ_OPEN_MAX", _SC_MQ_OPEN_MAX);
- initConstant(env, c, "_SC_MQ_PRIO_MAX", _SC_MQ_PRIO_MAX);
- initConstant(env, c, "_SC_NGROUPS_MAX", _SC_NGROUPS_MAX);
- initConstant(env, c, "_SC_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF);
- initConstant(env, c, "_SC_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN);
- initConstant(env, c, "_SC_OPEN_MAX", _SC_OPEN_MAX);
- initConstant(env, c, "_SC_PAGESIZE", _SC_PAGESIZE);
- initConstant(env, c, "_SC_PAGE_SIZE", _SC_PAGE_SIZE);
- initConstant(env, c, "_SC_PASS_MAX", _SC_PASS_MAX);
-#if defined(_SC_PHYS_PAGES)
- initConstant(env, c, "_SC_PHYS_PAGES", _SC_PHYS_PAGES);
-#endif
- initConstant(env, c, "_SC_PRIORITIZED_IO", _SC_PRIORITIZED_IO);
- initConstant(env, c, "_SC_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING);
- initConstant(env, c, "_SC_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS);
- initConstant(env, c, "_SC_RE_DUP_MAX", _SC_RE_DUP_MAX);
- initConstant(env, c, "_SC_RTSIG_MAX", _SC_RTSIG_MAX);
- initConstant(env, c, "_SC_SAVED_IDS", _SC_SAVED_IDS);
- initConstant(env, c, "_SC_SEMAPHORES", _SC_SEMAPHORES);
- initConstant(env, c, "_SC_SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX);
- initConstant(env, c, "_SC_SEM_VALUE_MAX", _SC_SEM_VALUE_MAX);
- initConstant(env, c, "_SC_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS);
- initConstant(env, c, "_SC_SIGQUEUE_MAX", _SC_SIGQUEUE_MAX);
- initConstant(env, c, "_SC_STREAM_MAX", _SC_STREAM_MAX);
- initConstant(env, c, "_SC_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO);
- initConstant(env, c, "_SC_THREADS", _SC_THREADS);
- initConstant(env, c, "_SC_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR);
- initConstant(env, c, "_SC_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE);
- initConstant(env, c, "_SC_THREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS);
- initConstant(env, c, "_SC_THREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX);
- initConstant(env, c, "_SC_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING);
- initConstant(env, c, "_SC_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT);
- initConstant(env, c, "_SC_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT);
- initConstant(env, c, "_SC_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS);
- initConstant(env, c, "_SC_THREAD_STACK_MIN", _SC_THREAD_STACK_MIN);
- initConstant(env, c, "_SC_THREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX);
- initConstant(env, c, "_SC_TIMERS", _SC_TIMERS);
- initConstant(env, c, "_SC_TIMER_MAX", _SC_TIMER_MAX);
- initConstant(env, c, "_SC_TTY_NAME_MAX", _SC_TTY_NAME_MAX);
- initConstant(env, c, "_SC_TZNAME_MAX", _SC_TZNAME_MAX);
- initConstant(env, c, "_SC_VERSION", _SC_VERSION);
- initConstant(env, c, "_SC_XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32);
- initConstant(env, c, "_SC_XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG);
- initConstant(env, c, "_SC_XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64);
- initConstant(env, c, "_SC_XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG);
- initConstant(env, c, "_SC_XOPEN_CRYPT", _SC_XOPEN_CRYPT);
- initConstant(env, c, "_SC_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N);
- initConstant(env, c, "_SC_XOPEN_LEGACY", _SC_XOPEN_LEGACY);
- initConstant(env, c, "_SC_XOPEN_REALTIME", _SC_XOPEN_REALTIME);
- initConstant(env, c, "_SC_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS);
- initConstant(env, c, "_SC_XOPEN_SHM", _SC_XOPEN_SHM);
- initConstant(env, c, "_SC_XOPEN_UNIX", _SC_XOPEN_UNIX);
- initConstant(env, c, "_SC_XOPEN_VERSION", _SC_XOPEN_VERSION);
- initConstant(env, c, "_SC_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION);
-}
-
-static JNINativeMethod gMethods[] = {
- NATIVE_METHOD(OsConstants, initConstants, "()V"),
-};
-
-void register_android_system_OsConstants(JNIEnv* env) {
- // [ravenwood-change] -- method moved to the nested class
- jniRegisterNativeMethods(env, "android/system/OsConstants$Native", gMethods, NELEM(gMethods));
-}
diff --git a/ravenwood/runtime-jni/ravenwood_runtime.cpp b/ravenwood/runtime-jni/ravenwood_runtime.cpp
deleted file mode 100644
index 34cf9f9..0000000
--- a/ravenwood/runtime-jni/ravenwood_runtime.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <unistd.h>
-#include <nativehelper/JNIHelp.h>
-#include "jni.h"
-#include "utils/Log.h"
-#include "utils/misc.h"
-
-// Defined in ravenwood_os_constants.cpp
-void register_android_system_OsConstants(JNIEnv* env);
-
-// ---- Exception related ----
-
-static void throwErrnoException(JNIEnv* env, const char* functionName) {
- int error = errno;
- jniThrowErrnoException(env, functionName, error);
-}
-
-template <typename rc_t>
-static rc_t throwIfMinusOne(JNIEnv* env, const char* name, rc_t rc) {
- if (rc == rc_t(-1)) {
- throwErrnoException(env, name);
- }
- return rc;
-}
-
-// ---- JNI methods ----
-
-typedef void (*FreeFunction)(void*);
-
-static void nApplyFreeFunction(JNIEnv*, jclass, jlong freeFunction, jlong ptr) {
- void* nativePtr = reinterpret_cast<void*>(static_cast<uintptr_t>(ptr));
- FreeFunction nativeFreeFunction
- = reinterpret_cast<FreeFunction>(static_cast<uintptr_t>(freeFunction));
- nativeFreeFunction(nativePtr);
-}
-
-static jint nFcntlInt(JNIEnv* env, jclass, jint fd, jint cmd, jint arg) {
- return throwIfMinusOne(env, "fcntl", TEMP_FAILURE_RETRY(fcntl(fd, cmd, arg)));
-}
-
-static jlong nLseek(JNIEnv* env, jclass, jint fd, jlong offset, jint whence) {
- return throwIfMinusOne(env, "lseek", TEMP_FAILURE_RETRY(lseek(fd, offset, whence)));
-}
-
-static jintArray nPipe2(JNIEnv* env, jclass, jint flags) {
- int fds[2];
- throwIfMinusOne(env, "pipe2", TEMP_FAILURE_RETRY(pipe2(fds, flags)));
-
- jintArray result;
- result = env->NewIntArray(2);
- if (result == NULL) {
- return NULL; /* out of memory error thrown */
- }
- env->SetIntArrayRegion(result, 0, 2, fds);
- return result;
-}
-
-static jlong nDup(JNIEnv* env, jclass, jint fd) {
- return throwIfMinusOne(env, "fcntl", TEMP_FAILURE_RETRY(fcntl(fd, F_DUPFD_CLOEXEC, 0)));
-}
-
-// ---- Registration ----
-
-static const JNINativeMethod sMethods[] =
-{
- { "applyFreeFunction", "(JJ)V", (void*)nApplyFreeFunction },
- { "nFcntlInt", "(III)I", (void*)nFcntlInt },
- { "nLseek", "(IJI)J", (void*)nLseek },
- { "nPipe2", "(I)[I", (void*)nPipe2 },
- { "nDup", "(I)I", (void*)nDup },
-};
-
-extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
-{
- JNIEnv* env = NULL;
- jint result = -1;
-
- if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
- ALOGE("GetEnv failed!");
- return result;
- }
- ALOG_ASSERT(env, "Could not retrieve the env!");
-
- ALOGI("%s: JNI_OnLoad", __FILE__);
-
- jint res = jniRegisterNativeMethods(env, "com/android/ravenwood/common/RavenwoodRuntimeNative",
- sMethods, NELEM(sMethods));
- if (res < 0) {
- return res;
- }
-
- register_android_system_OsConstants(env);
-
- return JNI_VERSION_1_4;
-}
diff --git a/ravenwood/runtime-test/Android.bp b/ravenwood/runtime-test/Android.bp
deleted file mode 100644
index 4102920..0000000
--- a/ravenwood/runtime-test/Android.bp
+++ /dev/null
@@ -1,23 +0,0 @@
-package {
- // See: http://go/android-license-faq
- // A large-scale-change added 'default_applicable_licenses' to import
- // all of the 'license_kinds' from "frameworks_base_license"
- // to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
- default_applicable_licenses: ["frameworks_base_license"],
-}
-
-android_ravenwood_test {
- name: "RavenwoodRuntimeTest",
-
- static_libs: [
- "androidx.annotation_annotation",
- "androidx.test.ext.junit",
- "androidx.test.rules",
- ],
- srcs: [
- "test/**/*.java",
- ],
- // sdk_version: "module_current",
- auto_gen_config: true,
-}
diff --git a/ravenwood/runtime-test/test/com/android/ravenwood/runtimetest/OsConstantsTest.java b/ravenwood/runtime-test/test/com/android/ravenwood/runtimetest/OsConstantsTest.java
deleted file mode 100644
index 3332e24..0000000
--- a/ravenwood/runtime-test/test/com/android/ravenwood/runtimetest/OsConstantsTest.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ravenwood.runtimetest;
-
-// Copied from libcore/luni/src/test/java/libcore/android/system/OsConstantsTest.java
-
-import static android.system.OsConstants.CAP_TO_INDEX;
-import static android.system.OsConstants.CAP_TO_MASK;
-import static android.system.OsConstants.S_ISBLK;
-import static android.system.OsConstants.S_ISCHR;
-import static android.system.OsConstants.S_ISDIR;
-import static android.system.OsConstants.S_ISFIFO;
-import static android.system.OsConstants.S_ISLNK;
-import static android.system.OsConstants.S_ISREG;
-import static android.system.OsConstants.S_ISSOCK;
-import static android.system.OsConstants.WCOREDUMP;
-import static android.system.OsConstants.WEXITSTATUS;
-import static android.system.OsConstants.WIFEXITED;
-import static android.system.OsConstants.WIFSIGNALED;
-import static android.system.OsConstants.WIFSTOPPED;
-import static android.system.OsConstants.WSTOPSIG;
-import static android.system.OsConstants.WTERMSIG;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import android.system.OsConstants;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class OsConstantsTest {
-
- // http://b/15602893
- @Test
- public void testBug15602893() {
- assertTrue(OsConstants.RT_SCOPE_HOST > 0);
- assertTrue(OsConstants.RT_SCOPE_LINK > 0);
- assertTrue(OsConstants.RT_SCOPE_SITE > 0);
-
- assertTrue(OsConstants.IFA_F_TENTATIVE > 0);
- }
-
- // introduced for http://b/30402085
- @Test
- public void testTcpUserTimeoutIsDefined() {
- assertTrue(OsConstants.TCP_USER_TIMEOUT > 0);
- }
-
- /**
- * Verifies equality assertions given in the documentation for
- * {@link OsConstants#SOCK_CLOEXEC} and {@link OsConstants#SOCK_NONBLOCK}.
- */
- @Test
- public void testConstantsEqual() {
- assertEquals(OsConstants.O_CLOEXEC, OsConstants.SOCK_CLOEXEC);
- assertEquals(OsConstants.O_NONBLOCK, OsConstants.SOCK_NONBLOCK);
- }
-
- @Test
- public void test_CAP_constants() {
- assertEquals(0, OsConstants.CAP_CHOWN);
- assertEquals(1, OsConstants.CAP_DAC_OVERRIDE);
- assertEquals(2, OsConstants.CAP_DAC_READ_SEARCH);
- assertEquals(3, OsConstants.CAP_FOWNER);
- assertEquals(4, OsConstants.CAP_FSETID);
- assertEquals(5, OsConstants.CAP_KILL);
- assertEquals(6, OsConstants.CAP_SETGID);
- assertEquals(7, OsConstants.CAP_SETUID);
- assertEquals(8, OsConstants.CAP_SETPCAP);
- assertEquals(9, OsConstants.CAP_LINUX_IMMUTABLE);
- assertEquals(10, OsConstants.CAP_NET_BIND_SERVICE);
- assertEquals(11, OsConstants.CAP_NET_BROADCAST);
- assertEquals(12, OsConstants.CAP_NET_ADMIN);
- assertEquals(13, OsConstants.CAP_NET_RAW);
- assertEquals(14, OsConstants.CAP_IPC_LOCK);
- assertEquals(15, OsConstants.CAP_IPC_OWNER);
- assertEquals(16, OsConstants.CAP_SYS_MODULE);
- assertEquals(17, OsConstants.CAP_SYS_RAWIO);
- assertEquals(18, OsConstants.CAP_SYS_CHROOT);
- assertEquals(19, OsConstants.CAP_SYS_PTRACE);
- assertEquals(20, OsConstants.CAP_SYS_PACCT);
- assertEquals(21, OsConstants.CAP_SYS_ADMIN);
- assertEquals(22, OsConstants.CAP_SYS_BOOT);
- assertEquals(23, OsConstants.CAP_SYS_NICE);
- assertEquals(24, OsConstants.CAP_SYS_RESOURCE);
- assertEquals(25, OsConstants.CAP_SYS_TIME);
- assertEquals(26, OsConstants.CAP_SYS_TTY_CONFIG);
- assertEquals(27, OsConstants.CAP_MKNOD);
- assertEquals(28, OsConstants.CAP_LEASE);
- assertEquals(29, OsConstants.CAP_AUDIT_WRITE);
- assertEquals(30, OsConstants.CAP_AUDIT_CONTROL);
- assertEquals(31, OsConstants.CAP_SETFCAP);
- assertEquals(32, OsConstants.CAP_MAC_OVERRIDE);
- assertEquals(33, OsConstants.CAP_MAC_ADMIN);
- assertEquals(34, OsConstants.CAP_SYSLOG);
- assertEquals(35, OsConstants.CAP_WAKE_ALARM);
- assertEquals(36, OsConstants.CAP_BLOCK_SUSPEND);
- // last constant
- assertEquals(40, OsConstants.CAP_LAST_CAP);
- }
-
- @Test
- public void test_CAP_TO_INDEX() {
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_CHOWN));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_DAC_OVERRIDE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_DAC_READ_SEARCH));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_FOWNER));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_FSETID));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_KILL));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SETGID));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SETUID));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SETPCAP));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_LINUX_IMMUTABLE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_NET_BIND_SERVICE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_NET_BROADCAST));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_NET_ADMIN));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_NET_RAW));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_IPC_LOCK));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_IPC_OWNER));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_MODULE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_RAWIO));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_CHROOT));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_PTRACE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_PACCT));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_ADMIN));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_BOOT));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_NICE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_RESOURCE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_TIME));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SYS_TTY_CONFIG));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_MKNOD));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_LEASE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_AUDIT_WRITE));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_AUDIT_CONTROL));
- assertEquals(0, CAP_TO_INDEX(OsConstants.CAP_SETFCAP));
- assertEquals(1, CAP_TO_INDEX(OsConstants.CAP_MAC_OVERRIDE));
- assertEquals(1, CAP_TO_INDEX(OsConstants.CAP_MAC_ADMIN));
- assertEquals(1, CAP_TO_INDEX(OsConstants.CAP_SYSLOG));
- assertEquals(1, CAP_TO_INDEX(OsConstants.CAP_WAKE_ALARM));
- assertEquals(1, CAP_TO_INDEX(OsConstants.CAP_BLOCK_SUSPEND));
- }
-
- @Test
- public void test_CAP_TO_MASK() {
- assertEquals(1 << 0, CAP_TO_MASK(OsConstants.CAP_CHOWN));
- assertEquals(1 << 1, CAP_TO_MASK(OsConstants.CAP_DAC_OVERRIDE));
- assertEquals(1 << 2, CAP_TO_MASK(OsConstants.CAP_DAC_READ_SEARCH));
- assertEquals(1 << 3, CAP_TO_MASK(OsConstants.CAP_FOWNER));
- assertEquals(1 << 4, CAP_TO_MASK(OsConstants.CAP_FSETID));
- assertEquals(1 << 5, CAP_TO_MASK(OsConstants.CAP_KILL));
- assertEquals(1 << 6, CAP_TO_MASK(OsConstants.CAP_SETGID));
- assertEquals(1 << 7, CAP_TO_MASK(OsConstants.CAP_SETUID));
- assertEquals(1 << 8, CAP_TO_MASK(OsConstants.CAP_SETPCAP));
- assertEquals(1 << 9, CAP_TO_MASK(OsConstants.CAP_LINUX_IMMUTABLE));
- assertEquals(1 << 10, CAP_TO_MASK(OsConstants.CAP_NET_BIND_SERVICE));
- assertEquals(1 << 11, CAP_TO_MASK(OsConstants.CAP_NET_BROADCAST));
- assertEquals(1 << 12, CAP_TO_MASK(OsConstants.CAP_NET_ADMIN));
- assertEquals(1 << 13, CAP_TO_MASK(OsConstants.CAP_NET_RAW));
- assertEquals(1 << 14, CAP_TO_MASK(OsConstants.CAP_IPC_LOCK));
- assertEquals(1 << 15, CAP_TO_MASK(OsConstants.CAP_IPC_OWNER));
- assertEquals(1 << 16, CAP_TO_MASK(OsConstants.CAP_SYS_MODULE));
- assertEquals(1 << 17, CAP_TO_MASK(OsConstants.CAP_SYS_RAWIO));
- assertEquals(1 << 18, CAP_TO_MASK(OsConstants.CAP_SYS_CHROOT));
- assertEquals(1 << 19, CAP_TO_MASK(OsConstants.CAP_SYS_PTRACE));
- assertEquals(1 << 20, CAP_TO_MASK(OsConstants.CAP_SYS_PACCT));
- assertEquals(1 << 21, CAP_TO_MASK(OsConstants.CAP_SYS_ADMIN));
- assertEquals(1 << 22, CAP_TO_MASK(OsConstants.CAP_SYS_BOOT));
- assertEquals(1 << 23, CAP_TO_MASK(OsConstants.CAP_SYS_NICE));
- assertEquals(1 << 24, CAP_TO_MASK(OsConstants.CAP_SYS_RESOURCE));
- assertEquals(1 << 25, CAP_TO_MASK(OsConstants.CAP_SYS_TIME));
- assertEquals(1 << 26, CAP_TO_MASK(OsConstants.CAP_SYS_TTY_CONFIG));
- assertEquals(1 << 27, CAP_TO_MASK(OsConstants.CAP_MKNOD));
- assertEquals(1 << 28, CAP_TO_MASK(OsConstants.CAP_LEASE));
- assertEquals(1 << 29, CAP_TO_MASK(OsConstants.CAP_AUDIT_WRITE));
- assertEquals(1 << 30, CAP_TO_MASK(OsConstants.CAP_AUDIT_CONTROL));
- assertEquals(1 << 31, CAP_TO_MASK(OsConstants.CAP_SETFCAP));
- assertEquals(1 << 0, CAP_TO_MASK(OsConstants.CAP_MAC_OVERRIDE));
- assertEquals(1 << 1, CAP_TO_MASK(OsConstants.CAP_MAC_ADMIN));
- assertEquals(1 << 2, CAP_TO_MASK(OsConstants.CAP_SYSLOG));
- assertEquals(1 << 3, CAP_TO_MASK(OsConstants.CAP_WAKE_ALARM));
- assertEquals(1 << 4, CAP_TO_MASK(OsConstants.CAP_BLOCK_SUSPEND));
- }
-
- @Test
- public void test_S_ISLNK() {
- assertTrue(S_ISLNK(OsConstants.S_IFLNK));
-
- assertFalse(S_ISLNK(OsConstants.S_IFBLK));
- assertFalse(S_ISLNK(OsConstants.S_IFCHR));
- assertFalse(S_ISLNK(OsConstants.S_IFDIR));
- assertFalse(S_ISLNK(OsConstants.S_IFIFO));
- assertFalse(S_ISLNK(OsConstants.S_IFMT));
- assertFalse(S_ISLNK(OsConstants.S_IFREG));
- assertFalse(S_ISLNK(OsConstants.S_IFSOCK));
- assertFalse(S_ISLNK(OsConstants.S_IRGRP));
- assertFalse(S_ISLNK(OsConstants.S_IROTH));
- assertFalse(S_ISLNK(OsConstants.S_IRUSR));
- assertFalse(S_ISLNK(OsConstants.S_IRWXG));
- assertFalse(S_ISLNK(OsConstants.S_IRWXO));
- assertFalse(S_ISLNK(OsConstants.S_IRWXU));
- assertFalse(S_ISLNK(OsConstants.S_ISGID));
- assertFalse(S_ISLNK(OsConstants.S_ISUID));
- assertFalse(S_ISLNK(OsConstants.S_ISVTX));
- assertFalse(S_ISLNK(OsConstants.S_IWGRP));
- assertFalse(S_ISLNK(OsConstants.S_IWOTH));
- assertFalse(S_ISLNK(OsConstants.S_IWUSR));
- assertFalse(S_ISLNK(OsConstants.S_IXGRP));
- assertFalse(S_ISLNK(OsConstants.S_IXOTH));
- assertFalse(S_ISLNK(OsConstants.S_IXUSR));
- }
-
- @Test
- public void test_S_ISREG() {
- assertTrue(S_ISREG(OsConstants.S_IFREG));
-
- assertFalse(S_ISREG(OsConstants.S_IFBLK));
- assertFalse(S_ISREG(OsConstants.S_IFCHR));
- assertFalse(S_ISREG(OsConstants.S_IFDIR));
- assertFalse(S_ISREG(OsConstants.S_IFIFO));
- assertFalse(S_ISREG(OsConstants.S_IFLNK));
- assertFalse(S_ISREG(OsConstants.S_IFMT));
- assertFalse(S_ISREG(OsConstants.S_IFSOCK));
- assertFalse(S_ISREG(OsConstants.S_IRGRP));
- assertFalse(S_ISREG(OsConstants.S_IROTH));
- assertFalse(S_ISREG(OsConstants.S_IRUSR));
- assertFalse(S_ISREG(OsConstants.S_IRWXG));
- assertFalse(S_ISREG(OsConstants.S_IRWXO));
- assertFalse(S_ISREG(OsConstants.S_IRWXU));
- assertFalse(S_ISREG(OsConstants.S_ISGID));
- assertFalse(S_ISREG(OsConstants.S_ISUID));
- assertFalse(S_ISREG(OsConstants.S_ISVTX));
- assertFalse(S_ISREG(OsConstants.S_IWGRP));
- assertFalse(S_ISREG(OsConstants.S_IWOTH));
- assertFalse(S_ISREG(OsConstants.S_IWUSR));
- assertFalse(S_ISREG(OsConstants.S_IXGRP));
- assertFalse(S_ISREG(OsConstants.S_IXOTH));
- assertFalse(S_ISREG(OsConstants.S_IXUSR));
- }
-
- @Test
- public void test_S_ISDIR() {
- assertTrue(S_ISDIR(OsConstants.S_IFDIR));
-
- assertFalse(S_ISDIR(OsConstants.S_IFBLK));
- assertFalse(S_ISDIR(OsConstants.S_IFCHR));
- assertFalse(S_ISDIR(OsConstants.S_IFIFO));
- assertFalse(S_ISDIR(OsConstants.S_IFLNK));
- assertFalse(S_ISDIR(OsConstants.S_IFMT));
- assertFalse(S_ISDIR(OsConstants.S_IFREG));
- assertFalse(S_ISDIR(OsConstants.S_IFSOCK));
- assertFalse(S_ISDIR(OsConstants.S_IRGRP));
- assertFalse(S_ISDIR(OsConstants.S_IROTH));
- assertFalse(S_ISDIR(OsConstants.S_IRUSR));
- assertFalse(S_ISDIR(OsConstants.S_IRWXG));
- assertFalse(S_ISDIR(OsConstants.S_IRWXO));
- assertFalse(S_ISDIR(OsConstants.S_IRWXU));
- assertFalse(S_ISDIR(OsConstants.S_ISGID));
- assertFalse(S_ISDIR(OsConstants.S_ISUID));
- assertFalse(S_ISDIR(OsConstants.S_ISVTX));
- assertFalse(S_ISDIR(OsConstants.S_IWGRP));
- assertFalse(S_ISDIR(OsConstants.S_IWOTH));
- assertFalse(S_ISDIR(OsConstants.S_IWUSR));
- assertFalse(S_ISDIR(OsConstants.S_IXGRP));
- assertFalse(S_ISDIR(OsConstants.S_IXOTH));
- assertFalse(S_ISDIR(OsConstants.S_IXUSR));
- }
-
- @Test
- public void test_S_ISCHR() {
- assertTrue(S_ISCHR(OsConstants.S_IFCHR));
-
- assertFalse(S_ISCHR(OsConstants.S_IFBLK));
- assertFalse(S_ISCHR(OsConstants.S_IFDIR));
- assertFalse(S_ISCHR(OsConstants.S_IFIFO));
- assertFalse(S_ISCHR(OsConstants.S_IFLNK));
- assertFalse(S_ISCHR(OsConstants.S_IFMT));
- assertFalse(S_ISCHR(OsConstants.S_IFREG));
- assertFalse(S_ISCHR(OsConstants.S_IFSOCK));
- assertFalse(S_ISCHR(OsConstants.S_IRGRP));
- assertFalse(S_ISCHR(OsConstants.S_IROTH));
- assertFalse(S_ISCHR(OsConstants.S_IRUSR));
- assertFalse(S_ISCHR(OsConstants.S_IRWXG));
- assertFalse(S_ISCHR(OsConstants.S_IRWXO));
- assertFalse(S_ISCHR(OsConstants.S_IRWXU));
- assertFalse(S_ISCHR(OsConstants.S_ISGID));
- assertFalse(S_ISCHR(OsConstants.S_ISUID));
- assertFalse(S_ISCHR(OsConstants.S_ISVTX));
- assertFalse(S_ISCHR(OsConstants.S_IWGRP));
- assertFalse(S_ISCHR(OsConstants.S_IWOTH));
- assertFalse(S_ISCHR(OsConstants.S_IWUSR));
- assertFalse(S_ISCHR(OsConstants.S_IXGRP));
- assertFalse(S_ISCHR(OsConstants.S_IXOTH));
- assertFalse(S_ISCHR(OsConstants.S_IXUSR));
- }
-
- @Test
- public void test_S_ISBLK() {
- assertTrue (S_ISBLK(OsConstants.S_IFBLK));
-
- assertFalse(S_ISBLK(OsConstants.S_IFCHR));
- assertFalse(S_ISBLK(OsConstants.S_IFDIR));
- assertFalse(S_ISBLK(OsConstants.S_IFIFO));
- assertFalse(S_ISBLK(OsConstants.S_IFLNK));
- assertFalse(S_ISBLK(OsConstants.S_IFMT));
- assertFalse(S_ISBLK(OsConstants.S_IFREG));
- assertFalse(S_ISBLK(OsConstants.S_IFSOCK));
- assertFalse(S_ISBLK(OsConstants.S_IRGRP));
- assertFalse(S_ISBLK(OsConstants.S_IROTH));
- assertFalse(S_ISBLK(OsConstants.S_IRUSR));
- assertFalse(S_ISBLK(OsConstants.S_IRWXG));
- assertFalse(S_ISBLK(OsConstants.S_IRWXO));
- assertFalse(S_ISBLK(OsConstants.S_IRWXU));
- assertFalse(S_ISBLK(OsConstants.S_ISGID));
- assertFalse(S_ISBLK(OsConstants.S_ISUID));
- assertFalse(S_ISBLK(OsConstants.S_ISVTX));
- assertFalse(S_ISBLK(OsConstants.S_IWGRP));
- assertFalse(S_ISBLK(OsConstants.S_IWOTH));
- assertFalse(S_ISBLK(OsConstants.S_IWUSR));
- assertFalse(S_ISBLK(OsConstants.S_IXGRP));
- assertFalse(S_ISBLK(OsConstants.S_IXOTH));
- assertFalse(S_ISBLK(OsConstants.S_IXUSR));
- }
-
- @Test
- public void test_S_ISFIFO() {
- assertTrue(S_ISFIFO(OsConstants.S_IFIFO));
-
- assertFalse(S_ISFIFO(OsConstants.S_IFBLK));
- assertFalse(S_ISFIFO(OsConstants.S_IFCHR));
- assertFalse(S_ISFIFO(OsConstants.S_IFDIR));
- assertFalse(S_ISFIFO(OsConstants.S_IFLNK));
- assertFalse(S_ISFIFO(OsConstants.S_IFMT));
- assertFalse(S_ISFIFO(OsConstants.S_IFREG));
- assertFalse(S_ISFIFO(OsConstants.S_IFSOCK));
- assertFalse(S_ISFIFO(OsConstants.S_IRGRP));
- assertFalse(S_ISFIFO(OsConstants.S_IROTH));
- assertFalse(S_ISFIFO(OsConstants.S_IRUSR));
- assertFalse(S_ISFIFO(OsConstants.S_IRWXG));
- assertFalse(S_ISFIFO(OsConstants.S_IRWXO));
- assertFalse(S_ISFIFO(OsConstants.S_IRWXU));
- assertFalse(S_ISFIFO(OsConstants.S_ISGID));
- assertFalse(S_ISFIFO(OsConstants.S_ISUID));
- assertFalse(S_ISFIFO(OsConstants.S_ISVTX));
- assertFalse(S_ISFIFO(OsConstants.S_IWGRP));
- assertFalse(S_ISFIFO(OsConstants.S_IWOTH));
- assertFalse(S_ISFIFO(OsConstants.S_IWUSR));
- assertFalse(S_ISFIFO(OsConstants.S_IXGRP));
- assertFalse(S_ISFIFO(OsConstants.S_IXOTH));
- assertFalse(S_ISFIFO(OsConstants.S_IXUSR));
- }
-
- @Test
- public void test_S_ISSOCK() {
- assertTrue(S_ISSOCK(OsConstants.S_IFSOCK));
-
- assertFalse(S_ISSOCK(OsConstants.S_IFBLK));
- assertFalse(S_ISSOCK(OsConstants.S_IFCHR));
- assertFalse(S_ISSOCK(OsConstants.S_IFDIR));
- assertFalse(S_ISSOCK(OsConstants.S_IFIFO));
- assertFalse(S_ISSOCK(OsConstants.S_IFLNK));
- assertFalse(S_ISSOCK(OsConstants.S_IFMT));
- assertFalse(S_ISSOCK(OsConstants.S_IFREG));
- assertFalse(S_ISSOCK(OsConstants.S_IRGRP));
- assertFalse(S_ISSOCK(OsConstants.S_IROTH));
- assertFalse(S_ISSOCK(OsConstants.S_IRUSR));
- assertFalse(S_ISSOCK(OsConstants.S_IRWXG));
- assertFalse(S_ISSOCK(OsConstants.S_IRWXO));
- assertFalse(S_ISSOCK(OsConstants.S_IRWXU));
- assertFalse(S_ISSOCK(OsConstants.S_ISGID));
- assertFalse(S_ISSOCK(OsConstants.S_ISUID));
- assertFalse(S_ISSOCK(OsConstants.S_ISVTX));
- assertFalse(S_ISSOCK(OsConstants.S_IWGRP));
- assertFalse(S_ISSOCK(OsConstants.S_IWOTH));
- assertFalse(S_ISSOCK(OsConstants.S_IWUSR));
- assertFalse(S_ISSOCK(OsConstants.S_IXGRP));
- assertFalse(S_ISSOCK(OsConstants.S_IXOTH));
- assertFalse(S_ISSOCK(OsConstants.S_IXUSR));
- }
-
- @Test
- public void test_WEXITSTATUS() {
- assertEquals(0, WEXITSTATUS(0x0000));
- assertEquals(0, WEXITSTATUS(0x00DE));
- assertEquals(0xF0, WEXITSTATUS(0xF000));
- assertEquals(0xAB, WEXITSTATUS(0xAB12));
- }
-
- @Test
- public void test_WCOREDUMP() {
- assertFalse(WCOREDUMP(0));
- assertTrue(WCOREDUMP(0x80));
- }
-
- @Test
- public void test_WTERMSIG() {
- assertEquals(0, WTERMSIG(0));
- assertEquals(0x7f, WTERMSIG(0x7f));
- }
-
- @Test
- public void test_WSTOPSIG() {
- assertEquals(0, WSTOPSIG(0x0000));
- assertEquals(0, WSTOPSIG(0x00DE));
- assertEquals(0xF0, WSTOPSIG(0xF000));
- assertEquals(0xAB, WSTOPSIG(0xAB12));
- }
-
-
- @Test
- public void test_WIFEXITED() {
- assertTrue(WIFEXITED(0));
- assertFalse(WIFEXITED(0x7f));
- }
-
- @Test
- public void test_WIFSTOPPED() {
- assertFalse(WIFSTOPPED(0));
- assertTrue(WIFSTOPPED(0x7f));
- }
-
- @Test
- public void test_WIFSIGNALED() {
- assertFalse(WIFSIGNALED(0));
- assertTrue(WIFSIGNALED(1));
- }
-}
diff --git a/ravenwood/runtime-test/test/com/android/ravenwood/runtimetest/OsTest.java b/ravenwood/runtime-test/test/com/android/ravenwood/runtimetest/OsTest.java
deleted file mode 100644
index b5038e6..0000000
--- a/ravenwood/runtime-test/test/com/android/ravenwood/runtimetest/OsTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ravenwood.runtimetest;
-
-import static org.junit.Assert.assertEquals;
-
-import android.system.Os;
-import android.system.OsConstants;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.ravenwood.common.JvmWorkaround;
-import com.android.ravenwood.common.RavenwoodRuntimeNative;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-@RunWith(AndroidJUnit4.class)
-public class OsTest {
- public interface ConsumerWithThrow<T> {
- void accept(T var1) throws Exception;
- }
-
- private void withTestFile(ConsumerWithThrow<FileDescriptor> consumer) throws Exception {
- File file = File.createTempFile("osTest", "bin");
- try (var raf = new RandomAccessFile(file, "rw")) {
- var fd = raf.getFD();
-
- try (var os = new FileOutputStream(fd)) {
- os.write(1);
- os.write(2);
- os.write(3);
- os.write(4);
-
- consumer.accept(fd);
- }
- }
- }
-
- @Test
- public void testLseek() throws Exception {
- withTestFile((fd) -> {
- assertEquals(4, Os.lseek(fd, 4, OsConstants.SEEK_SET));
- assertEquals(4, Os.lseek(fd, 0, OsConstants.SEEK_CUR));
- assertEquals(6, Os.lseek(fd, 2, OsConstants.SEEK_CUR));
- });
- }
-
- @Test
- public void testDup() throws Exception {
- withTestFile((fd) -> {
- var dup = Os.dup(fd);
-
- checkAreDup(fd, dup);
- });
- }
-
- @Test
- public void testPipe2() throws Exception {
- var fds = Os.pipe2(0);
-
- write(fds[1], 123);
- assertEquals(123, read(fds[0]));
- }
-
- @Test
- public void testFcntlInt() throws Exception {
- withTestFile((fd) -> {
- var dupInt = Os.fcntlInt(fd, 0, 0);
-
- var dup = new FileDescriptor();
- JvmWorkaround.getInstance().setFdInt(dup, dupInt);
-
- checkAreDup(fd, dup);
- });
- }
-
- private static void write(FileDescriptor fd, int oneByte) throws IOException {
- // Create a dup to avoid closing the FD.
- try (var dup = new FileOutputStream(RavenwoodRuntimeNative.dup(fd))) {
- dup.write(oneByte);
- }
- }
-
- private static int read(FileDescriptor fd) throws IOException {
- // Create a dup to avoid closing the FD.
- try (var dup = new FileInputStream(RavenwoodRuntimeNative.dup(fd))) {
- return dup.read();
- }
- }
-
- private static void checkAreDup(FileDescriptor fd1, FileDescriptor fd2) throws Exception {
- assertEquals(4, Os.lseek(fd1, 4, OsConstants.SEEK_SET));
- assertEquals(4, Os.lseek(fd1, 0, OsConstants.SEEK_CUR));
-
- // Dup'ed FD shares the same position.
- assertEquals(4, Os.lseek(fd2, 0, OsConstants.SEEK_CUR));
-
- assertEquals(6, Os.lseek(fd1, 2, OsConstants.SEEK_CUR));
- assertEquals(6, Os.lseek(fd2, 0, OsConstants.SEEK_CUR));
- }
-}