summaryrefslogtreecommitdiffstats
path: root/luni/src/main/native
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-06-10 03:40:22 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-06-10 03:40:22 +0000
commita3f1cb6819f5e2b7f8a478c4ddcf70d67b4e2b53 (patch)
treea546430284f992c2ab9789671afb162c77c1760a /luni/src/main/native
parent7450e1e23f96732b33f0cc04a235357a5ceadf89 (diff)
parent3deabd220cf7b1ca0824987e90b8ecc07087f05a (diff)
downloadlibcore-a3f1cb6819f5e2b7f8a478c4ddcf70d67b4e2b53.zip
libcore-a3f1cb6819f5e2b7f8a478c4ddcf70d67b4e2b53.tar.gz
libcore-a3f1cb6819f5e2b7f8a478c4ddcf70d67b4e2b53.tar.bz2
Merge "Remove deprecated WITH_HOST_DALVIK."
Diffstat (limited to 'luni/src/main/native')
-rw-r--r--luni/src/main/native/Portability.h1
-rw-r--r--luni/src/main/native/android_system_OsConstants.cpp34
-rw-r--r--luni/src/main/native/libcore_io_Posix.cpp40
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) {