diff options
author | Ian Rogers <irogers@google.com> | 2014-05-23 15:12:42 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-06-09 20:39:00 -0700 |
commit | 3deabd220cf7b1ca0824987e90b8ecc07087f05a (patch) | |
tree | a737476c6d4125cdef0e99dba94bb992b076acb9 /luni/src/main/native | |
parent | d6e67fd7082cf8c6ef5544dc740f9052add21538 (diff) | |
download | libcore-3deabd220cf7b1ca0824987e90b8ecc07087f05a.zip libcore-3deabd220cf7b1ca0824987e90b8ecc07087f05a.tar.gz libcore-3deabd220cf7b1ca0824987e90b8ecc07087f05a.tar.bz2 |
Remove deprecated WITH_HOST_DALVIK.
Bug: 13751317
Fix the Mac host build:
- conditionally define constants using pre-existing pattern,
- make Posix calls that the Mac doesn't support throw
UnsupportedOperationException.
Change-Id: Ib68887cbe36ab167d042eb96c7834bce0651b078
Diffstat (limited to 'luni/src/main/native')
-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 |
3 files changed, 70 insertions, 5 deletions
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) { |