diff options
-rw-r--r-- | Android.mk | 34 | ||||
-rw-r--r-- | CaCerts.mk | 3 | ||||
-rw-r--r-- | JavaLibrary.mk | 65 | ||||
-rw-r--r-- | NativeCode.mk | 32 | ||||
-rw-r--r-- | luni/src/main/native/Portability.h | 1 | ||||
-rw-r--r-- | luni/src/main/native/android_system_OsConstants.cpp | 34 | ||||
-rw-r--r-- | luni/src/main/native/libcore_io_Posix.cpp | 40 |
7 files changed, 133 insertions, 76 deletions
@@ -55,23 +55,21 @@ endif # "m dalvik-host" for quick minimal host build # -ifeq ($(WITH_HOST_DALVIK),true) - .PHONY: dalvik-host - dalvik-host: \ - dalvik \ - $(HOST_OUT)/bin/dalvikvm \ - $(HOST_OUT)/bin/dexopt \ - $(HOST_OUT)/lib/libjavacore.so \ - $(HOST_OUT)/lib/libjavacrypto.so \ - $(HOST_OUT)/lib/libjavacoretests.so \ - cacerts-host \ - core-hostdex \ - conscrypt-hostdex \ - okhttp-hostdex \ - bouncycastle-hostdex \ - apache-xml-hostdex \ - apache-harmony-tests-hostdex \ - $(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)/classes.jar -endif +.PHONY: dalvik-host +dalvik-host: \ + dalvik \ + $(HOST_OUT)/bin/dalvikvm \ + $(HOST_OUT)/bin/dexopt \ + $(HOST_OUT)/lib/libjavacore.so \ + $(HOST_OUT)/lib/libjavacrypto.so \ + $(HOST_OUT)/lib/libjavacoretests.so \ + cacerts-host \ + core-hostdex \ + conscrypt-hostdex \ + okhttp-hostdex \ + bouncycastle-hostdex \ + apache-xml-hostdex \ + apache-harmony-tests-hostdex \ + $(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)/classes.jar include $(subdir_makefiles) @@ -50,10 +50,9 @@ cacerts: $(cacerts_target) # This is so that build/target/product/core.mk can use cacerts in PRODUCT_PACKAGES ALL_MODULES.cacerts.INSTALLED := $(cacerts_target) -ifeq ($(WITH_HOST_DALVIK),true) cacerts_host_directory := $(HOST_OUT)/etc/security/cacerts $(foreach cacert, $(cacerts), $(eval $(call include-prebuilt-with-destination-directory,host-cacert-$(notdir $(cacert)),$(cacert),$(cacerts_host_directory)))) -endif + cacerts_host := $(addprefix $(cacerts_host_directory)/,$(foreach cacert,$(cacerts),$(notdir $(cacert)))) .PHONY: cacerts-host cacerts-host: $(cacerts_host) diff --git a/JavaLibrary.mk b/JavaLibrary.mk index d97f453..8935b9a 100644 --- a/JavaLibrary.mk +++ b/JavaLibrary.mk @@ -167,38 +167,36 @@ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := dex-host include $(BUILD_HOST_JAVA_LIBRARY) -ifeq ($(WITH_HOST_DALVIK),true) - - # Definitions to make the core library. - include $(CLEAR_VARS) - LOCAL_SRC_FILES := $(libdvm_core_src_files) - LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) - LOCAL_NO_STANDARD_LIBRARIES := true - LOCAL_JAVACFLAGS := $(local_javac_flags) - LOCAL_DX_FLAGS := --core-library - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE := core-hostdex - LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk - LOCAL_REQUIRED_MODULES := tzdata-host - include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) +# Definitions to make the core library. +include $(CLEAR_VARS) +LOCAL_SRC_FILES := $(libdvm_core_src_files) +LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) +LOCAL_NO_STANDARD_LIBRARIES := true +LOCAL_JAVACFLAGS := $(local_javac_flags) +LOCAL_DX_FLAGS := --core-library +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := core-hostdex +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk +LOCAL_REQUIRED_MODULES := tzdata-host +include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) - include $(CLEAR_VARS) - LOCAL_SRC_FILES := $(libart_core_src_files) - LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) - LOCAL_NO_STANDARD_LIBRARIES := true - LOCAL_JAVACFLAGS := $(local_javac_flags) - LOCAL_DX_FLAGS := --core-library - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE := core-libart-hostdex - LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk - LOCAL_REQUIRED_MODULES := tzdata-host - # Should not be dex-preopted as it isn't really a Dalvik boot jar or a - # regular java library, but part of the image for ART. - LOCAL_DEX_PREOPT := false - include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) +include $(CLEAR_VARS) +LOCAL_SRC_FILES := $(libart_core_src_files) +LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) +LOCAL_NO_STANDARD_LIBRARIES := true +LOCAL_JAVACFLAGS := $(local_javac_flags) +LOCAL_DX_FLAGS := --core-library +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := core-libart-hostdex +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk +LOCAL_REQUIRED_MODULES := tzdata-host +# Should not be dex-preopted as it isn't really a Dalvik boot jar or a +# regular java library, but part of the image for ART. +LOCAL_DEX_PREOPT := false +include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) - # Make the core-tests library. - ifeq ($(LIBCORE_SKIP_TESTS),) +# Make the core-tests library. +ifeq ($(LIBCORE_SKIP_TESTS),) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(test_src_files) LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) @@ -209,10 +207,10 @@ ifeq ($(WITH_HOST_DALVIK),true) LOCAL_MODULE := core-tests-hostdex LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) - endif +endif - # Make the core-tests-support library. - ifeq ($(LIBCORE_SKIP_TESTS),) +# Make the core-tests-support library. +ifeq ($(LIBCORE_SKIP_TESTS),) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-test-java-files-under,support) LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) @@ -222,7 +220,6 @@ ifeq ($(WITH_HOST_DALVIK),true) LOCAL_MODULE := core-tests-support-hostdex LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) - endif endif # diff --git a/NativeCode.mk b/NativeCode.mk index 2a16598..5e149fd 100644 --- a/NativeCode.mk +++ b/NativeCode.mk @@ -112,22 +112,21 @@ endif # LIBCORE_SKIP_TESTS # Build for the host. # -ifeq ($(WITH_HOST_DALVIK),true) - include $(CLEAR_VARS) - LOCAL_CLANG := true - LOCAL_SRC_FILES += $(core_src_files) - LOCAL_CFLAGS += $(core_cflags) - LOCAL_C_INCLUDES += $(core_c_includes) - LOCAL_CPPFLAGS += $(core_cppflags) - LOCAL_LDLIBS += -ldl -lpthread -lrt - LOCAL_MODULE_TAGS := optional - LOCAL_MODULE := libjavacore - LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk - LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat-host libicuuc-host libicui18n-host libcrypto-host libz-host - LOCAL_STATIC_LIBRARIES += $(core_static_libraries) libziparchive-host libutils - include $(BUILD_HOST_SHARED_LIBRARY) +include $(CLEAR_VARS) +LOCAL_CLANG := true +LOCAL_SRC_FILES += $(core_src_files) +LOCAL_CFLAGS += $(core_cflags) +LOCAL_C_INCLUDES += $(core_c_includes) +LOCAL_CPPFLAGS += $(core_cppflags) +LOCAL_LDLIBS += -ldl -lpthread +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libjavacore +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk +LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat-host libicuuc-host libicui18n-host libcrypto-host libz-host +LOCAL_STATIC_LIBRARIES += $(core_static_libraries) libziparchive-host libutils +include $(BUILD_HOST_SHARED_LIBRARY) - ifeq ($(LIBCORE_SKIP_TESTS),) +ifeq ($(LIBCORE_SKIP_TESTS),) include $(CLEAR_VARS) LOCAL_CLANG := true LOCAL_SRC_FILES += $(core_test_files) @@ -140,5 +139,4 @@ ifeq ($(WITH_HOST_DALVIK),true) LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk LOCAL_SHARED_LIBRARIES := libcrypto-host include $(BUILD_HOST_SHARED_LIBRARY) - endif # LIBCORE_SKIP_TESTS -endif +endif # LIBCORE_SKIP_TESTS diff --git a/luni/src/main/native/Portability.h b/luni/src/main/native/Portability.h index 60b7062..fb60ed4 100644 --- a/luni/src/main/native/Portability.h +++ b/luni/src/main/native/Portability.h @@ -64,7 +64,6 @@ static inline int mincore(void* addr, size_t length, unsigned char* vec) { // For statfs(3). #include <sys/param.h> #include <sys/mount.h> -#define f_frsize f_bsize // TODO: close enough? #else diff --git a/luni/src/main/native/android_system_OsConstants.cpp b/luni/src/main/native/android_system_OsConstants.cpp index cc3054a..13a0b1c 100644 --- a/luni/src/main/native/android_system_OsConstants.cpp +++ b/luni/src/main/native/android_system_OsConstants.cpp @@ -30,15 +30,19 @@ #include <stdlib.h> #include <sys/ioctl.h> #include <sys/mman.h> +#ifndef __APPLE__ #include <sys/prctl.h> +#endif #include <sys/socket.h> #include <sys/stat.h> #include <sys/wait.h> #include <unistd.h> // After the others because these are not necessarily self-contained in glibc. +#ifndef __APPLE__ #include <linux/if_addr.h> #include <linux/rtnetlink.h> +#endif #include <net/if.h> // After <sys/socket.h> to work around a Mac header file bug. @@ -229,14 +233,30 @@ static void OsConstants_initConstants(JNIEnv* env, jclass c) { #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_NODAD) initConstant(env, c, "IFA_F_NODAD", IFA_F_NODAD); +#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(IDA_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); @@ -370,11 +390,21 @@ static void OsConstants_initConstants(JNIEnv* env, jclass c) { initConstant(env, c, "PROT_READ", PROT_READ); initConstant(env, c, "PROT_WRITE", PROT_WRITE); initConstant(env, c, "R_OK", R_OK); +#if defined(RT_SCOPE_HOST) initConstant(env, c, "RT_SCOPE_HOST", RT_SCOPE_HOST); +#endif +#if defined(RT_SCOPE_LINK) initConstant(env, c, "RT_SCOPE_LINK", RT_SCOPE_LINK); +#endif +#if defined(RT_SCOPE_NOWHERE) initConstant(env, c, "RT_SCOPE_NOWHERE", RT_SCOPE_NOWHERE); +#endif +#if defined(RT_SCOPE_SITE) initConstant(env, c, "RT_SCOPE_SITE", RT_SCOPE_SITE); +#endif +#if defined(RT_SCOPE_UNIVERSE) initConstant(env, c, "RT_SCOPE_UNIVERSE", RT_SCOPE_UNIVERSE); +#endif initConstant(env, c, "SEEK_CUR", SEEK_CUR); initConstant(env, c, "SEEK_END", SEEK_END); initConstant(env, c, "SEEK_SET", SEEK_SET); @@ -441,8 +471,12 @@ static void OsConstants_initConstants(JNIEnv* env, jclass c) { 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 initConstant(env, c, "SO_RCVBUF", SO_RCVBUF); initConstant(env, c, "SO_RCVLOWAT", SO_RCVLOWAT); initConstant(env, c, "SO_RCVTIMEO", SO_RCVTIMEO); diff --git a/luni/src/main/native/libcore_io_Posix.cpp b/luni/src/main/native/libcore_io_Posix.cpp index c04f73e..aee3933 100644 --- a/luni/src/main/native/libcore_io_Posix.cpp +++ b/luni/src/main/native/libcore_io_Posix.cpp @@ -44,9 +44,14 @@ #include <stdlib.h> #include <sys/ioctl.h> #include <sys/mman.h> +#ifndef __APPLE__ #include <sys/prctl.h> +#endif #include <sys/socket.h> #include <sys/stat.h> +#ifdef __APPLE__ +#include <sys/statvfs.h> +#endif #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> @@ -330,9 +335,14 @@ static jobject makeStructTimeval(JNIEnv* env, const struct timeval& tv) { static_cast<jlong>(tv.tv_sec), static_cast<jlong>(tv.tv_usec)); } -static jobject makeStructUcred(JNIEnv* env, const struct ucred& u) { +static jobject makeStructUcred(JNIEnv* env, const struct ucred& u __unused) { +#ifdef __APPLE__ + jniThrowException(env, "java/lang/UnsupportedOperationException", "unimplemented support for ucred on a Mac"); + return NULL; +#else static jmethodID ctor = env->GetMethodID(JniConstants::structUcredClass, "<init>", "(III)V"); return env->NewObject(JniConstants::structUcredClass, ctor, u.pid, u.uid, u.gid); +#endif } static jobject makeStructUtsname(JNIEnv* env, const struct utsname& buf) { @@ -847,9 +857,19 @@ static jobject Posix_getsockoptUcred(JNIEnv* env, jobject, jobject javaFd, jint return makeStructUcred(env, u); } -static jint Posix_gettid(JNIEnv*, jobject) { +static jint Posix_gettid(JNIEnv* env __unused, jobject) { +#if defined(__APPLE__) + uint64_t owner; + int rc = pthread_threadid_np(NULL, &owner); // Requires Mac OS 10.6 + if (rc != 0) { + throwErrnoException(env, "gettid"); + return NULL; + } + return static_cast<jint>(owner); +#else // Neither bionic nor glibc exposes gettid(2). return syscall(__NR_gettid); +#endif } static jint Posix_getuid(JNIEnv*, jobject) { @@ -1082,19 +1102,31 @@ static jint Posix_poll(JNIEnv* env, jobject, jobjectArray javaStructs, jint time return rc; } -static void Posix_posix_fallocate(JNIEnv* env, jobject, jobject javaFd, jlong offset, jlong length) { +static void Posix_posix_fallocate(JNIEnv* env, jobject, jobject javaFd __unused, + jlong offset __unused, jlong length __unused) { +#ifdef __APPLE__ + jniThrowException(env, "java/lang/UnsupportedOperationException", + "fallocate doesn't exist on a Mac"); +#else int fd = jniGetFDFromFileDescriptor(env, javaFd); errno = TEMP_FAILURE_RETRY(posix_fallocate64(fd, offset, length)); if (errno != 0) { throwErrnoException(env, "posix_fallocate"); } +#endif } -static jint Posix_prctl(JNIEnv* env, jobject, jint option, jlong arg2, jlong arg3, jlong arg4, jlong arg5) { +static jint Posix_prctl(JNIEnv* env, jobject, jint option __unused, jlong arg2 __unused, + jlong arg3 __unused, jlong arg4 __unused, jlong arg5 __unused) { +#ifdef __APPLE__ + jniThrowException(env, "java/lang/UnsupportedOperationException", "prctl doesn't exist on a Mac"); + return 0; +#else int result = prctl(static_cast<int>(option), static_cast<unsigned long>(arg2), static_cast<unsigned long>(arg3), static_cast<unsigned long>(arg4), static_cast<unsigned long>(arg5)); return throwIfMinusOne(env, "prctl", result); +#endif } static jint Posix_preadBytes(JNIEnv* env, jobject, jobject javaFd, jobject javaBytes, jint byteOffset, jint byteCount, jlong offset) { |