Merge "Clean up some dead code."
diff --git a/luni/src/main/native/AsynchronousCloseMonitor.cpp b/luni/src/main/native/AsynchronousCloseMonitor.cpp
index 31cde00..6c9b2e5 100644
--- a/luni/src/main/native/AsynchronousCloseMonitor.cpp
+++ b/luni/src/main/native/AsynchronousCloseMonitor.cpp
@@ -38,11 +38,7 @@
* The specific signal chosen here is arbitrary, but bionic needs to know so that SIGRTMIN
* starts at a higher value.
*/
-#if defined(__APPLE__)
-static const int BLOCKED_THREAD_SIGNAL = SIGUSR2;
-#else
static const int BLOCKED_THREAD_SIGNAL = __SIGRTMIN + 2;
-#endif
static void blockedThreadSignalHandler(int /*signal*/) {
// Do nothing. We only sent this signal for its side-effect of interrupting syscalls.
diff --git a/luni/src/main/native/Portability.h b/luni/src/main/native/Portability.h
index 5900cb0..4df3353 100644
--- a/luni/src/main/native/Portability.h
+++ b/luni/src/main/native/Portability.h
@@ -17,64 +17,10 @@
#ifndef PORTABILITY_H_included
#define PORTABILITY_H_included
-#if defined(__APPLE__)
-
-// Mac OS.
-#include <AvailabilityMacros.h> // For MAC_OS_X_VERSION_MAX_ALLOWED
-
-#include <libkern/OSByteOrder.h>
-#define bswap_16 OSSwapInt16
-#define bswap_32 OSSwapInt32
-#define bswap_64 OSSwapInt64
-
-#include <crt_externs.h>
-#define environ (*_NSGetEnviron())
-
-// Mac OS has a 64-bit off_t and no 32-bit compatibility cruft.
-#define flock64 flock
-#define ftruncate64 ftruncate
-#define isnanf __inline_isnanf
-#define lseek64 lseek
-#define pread64 pread
-#define pwrite64 pwrite
-
-// TODO: Darwin appears to have an fdatasync syscall.
-static inline int fdatasync(int fd) { return fsync(fd); }
-
-// For Linux-compatible sendfile(3).
-#include <sys/socket.h>
-#include <sys/types.h>
-static inline ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) {
- off_t in_out_count = count;
- int result = sendfile(in_fd, out_fd, *offset, &in_out_count, NULL, 0);
- if (result == -1) {
- return -1;
- }
- return in_out_count;
-}
-
-// For mincore(3).
-#define _DARWIN_C_SOURCE
-#include <sys/mman.h>
-#undef _DARWIN_C_SOURCE
-static inline int mincore(void* addr, size_t length, unsigned char* vec) {
- return mincore(addr, length, reinterpret_cast<char*>(vec));
-}
-
-// For statfs(3).
-#include <sys/param.h>
-#include <sys/mount.h>
-
-#else
-
-// Bionic or glibc.
-
#include <byteswap.h>
#include <sys/sendfile.h>
#include <sys/statvfs.h>
-#endif
-
#include <netdb.h>
#if defined(__BIONIC__)
extern "C" int android_getaddrinfofornet(const char*, const char*, const struct addrinfo*, unsigned, unsigned, struct addrinfo**);
diff --git a/luni/src/main/native/android_system_OsConstants.cpp b/luni/src/main/native/android_system_OsConstants.cpp
index c064130..074bbef 100644
--- a/luni/src/main/native/android_system_OsConstants.cpp
+++ b/luni/src/main/native/android_system_OsConstants.cpp
@@ -30,9 +30,7 @@
#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/un.h>
@@ -44,10 +42,8 @@
#include <linux/if_ether.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.
@@ -417,7 +413,6 @@
// 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.
-#if !defined(__APPLE__)
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);
@@ -436,7 +431,6 @@
initConstant(env, c, "RTMGRP_NEIGH", RTMGRP_NEIGH);
initConstant(env, c, "RTMGRP_NOTIFY", RTMGRP_NOTIFY);
initConstant(env, c, "RTMGRP_TC", RTMGRP_TC);
-#endif
initConstant(env, c, "SEEK_CUR", SEEK_CUR);
initConstant(env, c, "SEEK_END", SEEK_END);
initConstant(env, c, "SEEK_SET", SEEK_SET);
diff --git a/luni/src/main/native/cbigint.cpp b/luni/src/main/native/cbigint.cpp
index 6943ca2..c202ed7 100644
--- a/luni/src/main/native/cbigint.cpp
+++ b/luni/src/main/native/cbigint.cpp
@@ -18,31 +18,9 @@
#include <string.h>
#include "cbigint.h"
-#if defined(__linux__) || defined(__APPLE__)
-#define USE_LL
-#endif
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define at(i) (i)
-#else
-#define at(i) ((i)^1)
-/* the sequence for halfAt is -1, 2, 1, 4, 3, 6, 5, 8... */
-/* and it should correspond to 0, 1, 2, 3, 4, 5, 6, 7... */
-#define halfAt(i) (-((-(i)) ^ 1))
-#endif
-
#define HIGH_IN_U64(u64) ((u64) >> 32)
-#if defined(USE_LL)
#define LOW_IN_U64(u64) ((u64) & 0x00000000FFFFFFFFLL)
-#else
-#if defined(USE_L)
-#define LOW_IN_U64(u64) ((u64) & 0x00000000FFFFFFFFL)
-#else
-#define LOW_IN_U64(u64) ((u64) & 0x00000000FFFFFFFF)
-#endif /* USE_L */
-#endif /* USE_LL */
-#if defined(USE_LL)
#define TEN_E1 (0xALL)
#define TEN_E2 (0x64LL)
#define TEN_E3 (0x3E8LL)
@@ -53,54 +31,15 @@
#define TEN_E8 (0x5F5E100LL)
#define TEN_E9 (0x3B9ACA00LL)
#define TEN_E19 (0x8AC7230489E80000LL)
-#else
-#if defined(USE_L)
-#define TEN_E1 (0xAL)
-#define TEN_E2 (0x64L)
-#define TEN_E3 (0x3E8L)
-#define TEN_E4 (0x2710L)
-#define TEN_E5 (0x186A0L)
-#define TEN_E6 (0xF4240L)
-#define TEN_E7 (0x989680L)
-#define TEN_E8 (0x5F5E100L)
-#define TEN_E9 (0x3B9ACA00L)
-#define TEN_E19 (0x8AC7230489E80000L)
-#else
-#define TEN_E1 (0xA)
-#define TEN_E2 (0x64)
-#define TEN_E3 (0x3E8)
-#define TEN_E4 (0x2710)
-#define TEN_E5 (0x186A0)
-#define TEN_E6 (0xF4240)
-#define TEN_E7 (0x989680)
-#define TEN_E8 (0x5F5E100)
-#define TEN_E9 (0x3B9ACA00)
-#define TEN_E19 (0x8AC7230489E80000)
-#endif /* USE_L */
-#endif /* USE_LL */
#define TIMES_TEN(x) (((x) << 3) + ((x) << 1))
#define bitSection(x, mask, shift) (((x) & (mask)) >> (shift))
#define CREATE_DOUBLE_BITS(normalizedM, e) (((normalizedM) & MANTISSA_MASK) | ((static_cast<uint64_t>((e) + E_OFFSET)) << 52))
-#if defined(USE_LL)
#define MANTISSA_MASK (0x000FFFFFFFFFFFFFLL)
#define EXPONENT_MASK (0x7FF0000000000000LL)
#define NORMAL_MASK (0x0010000000000000LL)
#define SIGN_MASK (0x8000000000000000LL)
-#else
-#if defined(USE_L)
-#define MANTISSA_MASK (0x000FFFFFFFFFFFFFL)
-#define EXPONENT_MASK (0x7FF0000000000000L)
-#define NORMAL_MASK (0x0010000000000000L)
-#define SIGN_MASK (0x8000000000000000L)
-#else
-#define MANTISSA_MASK (0x000FFFFFFFFFFFFF)
-#define EXPONENT_MASK (0x7FF0000000000000)
-#define NORMAL_MASK (0x0010000000000000)
-#define SIGN_MASK (0x8000000000000000)
-#endif /* USE_L */
-#endif /* USE_LL */
#define E_OFFSET (1075)
@@ -229,53 +168,28 @@
do
{
product =
- HIGH_IN_U64 (product) + result[at (resultIndex)] +
+ HIGH_IN_U64 (product) + result[resultIndex] +
arg2 * LOW_U32_FROM_PTR (arg1 + index);
- result[at (resultIndex)] = LOW_U32_FROM_VAR (product);
+ result[resultIndex] = LOW_U32_FROM_VAR (product);
++resultIndex;
product =
- HIGH_IN_U64 (product) + result[at (resultIndex)] +
+ HIGH_IN_U64 (product) + result[resultIndex] +
arg2 * HIGH_U32_FROM_PTR (arg1 + index);
- result[at (resultIndex)] = LOW_U32_FROM_VAR (product);
+ result[resultIndex] = LOW_U32_FROM_VAR (product);
++resultIndex;
}
while (++index < length);
- result[at (resultIndex)] += HIGH_U32_FROM_VAR (product);
- if (result[at (resultIndex)] < HIGH_U32_FROM_VAR (product))
+ result[resultIndex] += HIGH_U32_FROM_VAR (product);
+ if (result[resultIndex] < HIGH_U32_FROM_VAR (product))
{
/* must be careful with ++ operator and macro expansion */
++resultIndex;
- while (++result[at (resultIndex)] == 0)
+ while (++result[resultIndex] == 0)
++resultIndex;
}
}
-#if __BYTE_ORDER != __LITTLE_ENDIAN
-void simpleMultiplyAddHighPrecisionBigEndianFix(uint64_t* arg1, int32_t length, uint64_t arg2, uint32_t* result) {
- /* Assumes result can hold the product and arg2 only holds 32 bits of information */
- int32_t index = 0;
- int32_t resultIndex = 0;
- uint64_t product = 0;
-
- do {
- product = HIGH_IN_U64(product) + result[halfAt(resultIndex)] + arg2 * LOW_U32_FROM_PTR(arg1 + index);
- result[halfAt(resultIndex)] = LOW_U32_FROM_VAR(product);
- ++resultIndex;
- product = HIGH_IN_U64(product) + result[halfAt(resultIndex)] + arg2 * HIGH_U32_FROM_PTR(arg1 + index);
- result[halfAt(resultIndex)] = LOW_U32_FROM_VAR(product);
- ++resultIndex;
- } while (++index < length);
-
- result[halfAt(resultIndex)] += HIGH_U32_FROM_VAR(product);
- if (result[halfAt(resultIndex)] < HIGH_U32_FROM_VAR(product)) {
- /* must be careful with ++ operator and macro expansion */
- ++resultIndex;
- while (++result[halfAt(resultIndex)] == 0) ++resultIndex;
- }
-}
-#endif
-
void
multiplyHighPrecision (uint64_t * arg1, int32_t length1, uint64_t * arg2, int32_t length2,
uint64_t * result, int32_t length)
@@ -304,11 +218,7 @@
{
simpleMultiplyAddHighPrecision (arg1, length1, LOW_IN_U64 (arg2[count]),
resultIn32 + (++index));
-#if __BYTE_ORDER == __LITTLE_ENDIAN
simpleMultiplyAddHighPrecision(arg1, length1, HIGH_IN_U64(arg2[count]), resultIn32 + (++index));
-#else
- simpleMultiplyAddHighPrecisionBigEndianFix(arg1, length1, HIGH_IN_U64(arg2[count]), resultIn32 + (++index));
-#endif
}
}
@@ -374,7 +284,6 @@
if (*y == 0)
return 0;
-#if defined(USE_LL)
if (*y & 0xFFFFFFFF00000000LL)
{
x = HIGH_U32_FROM_PTR (y);
@@ -385,31 +294,6 @@
x = LOW_U32_FROM_PTR (y);
result = 0;
}
-#else
-#if defined(USE_L)
- if (*y & 0xFFFFFFFF00000000L)
- {
- x = HIGH_U32_FROM_PTR (y);
- result = 32;
- }
- else
- {
- x = LOW_U32_FROM_PTR (y);
- result = 0;
- }
-#else
- if (*y & 0xFFFFFFFF00000000)
- {
- x = HIGH_U32_FROM_PTR (y);
- result = 32;
- }
- else
- {
- x = LOW_U32_FROM_PTR (y);
- result = 0;
- }
-#endif /* USE_L */
-#endif /* USE_LL */
if (x & 0xFFFF0000)
{
@@ -445,7 +329,6 @@
if (*y == 0)
return 0;
-#if defined(USE_LL)
if (*y & 0x00000000FFFFFFFFLL)
{
x = LOW_U32_FROM_PTR (y);
@@ -456,31 +339,6 @@
x = HIGH_U32_FROM_PTR (y);
result = 32;
}
-#else
-#if defined(USE_L)
- if (*y & 0x00000000FFFFFFFFL)
- {
- x = LOW_U32_FROM_PTR (y);
- result = 0;
- }
- else
- {
- x = HIGH_U32_FROM_PTR (y);
- result = 32;
- }
-#else
- if (*y & 0x00000000FFFFFFFF)
- {
- x = LOW_U32_FROM_PTR (y);
- result = 0;
- }
- else
- {
- x = HIGH_U32_FROM_PTR (y);
- result = 32;
- }
-#endif /* USE_L */
-#endif /* USE_LL */
if (!(x & 0xFFFF))
{
diff --git a/luni/src/main/native/java_lang_ProcessManager.cpp b/luni/src/main/native/java_lang_ProcessManager.cpp
index 3a97ac6..efa5e77 100644
--- a/luni/src/main/native/java_lang_ProcessManager.cpp
+++ b/luni/src/main/native/java_lang_ProcessManager.cpp
@@ -38,11 +38,6 @@
static void CloseNonStandardFds(int status_pipe_fd) {
// On Cygwin, Linux, and Solaris, the best way to close iterates over "/proc/self/fd/".
const char* fd_path = "/proc/self/fd";
-#if defined(__APPLE__)
- // On Mac OS, there's "/dev/fd/" which Linux seems to link to "/proc/self/fd/",
- // but which on Solaris appears to be something quite different.
- fd_path = "/dev/fd";
-#endif
// Keep track of the system properties fd so we don't close it.
int properties_fd = -1;
diff --git a/luni/src/main/native/java_lang_System.cpp b/luni/src/main/native/java_lang_System.cpp
index a552cfd..1ba230a 100644
--- a/luni/src/main/native/java_lang_System.cpp
+++ b/luni/src/main/native/java_lang_System.cpp
@@ -113,15 +113,9 @@
}
static jlong System_nanoTime(JNIEnv*, jclass) {
-#if defined(__linux__)
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_sec * 1000000000LL + now.tv_nsec;
-#else // __APPLE__
- timeval now;
- gettimeofday(&now, NULL);
- return static_cast<jlong>(now.tv_sec) * 1000000000LL + now.tv_usec * 1000LL;
-#endif
}
static JNINativeMethod gMethods[] = {
diff --git a/luni/src/main/native/libcore_io_Posix.cpp b/luni/src/main/native/libcore_io_Posix.cpp
index 1f2f008..783a1bb 100644
--- a/luni/src/main/native/libcore_io_Posix.cpp
+++ b/luni/src/main/native/libcore_io_Posix.cpp
@@ -45,14 +45,9 @@
#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>
@@ -423,13 +418,6 @@
}
static jobject makeStructStatVfs(JNIEnv* env, const struct statvfs& sb) {
-#if defined(__APPLE__)
- // Mac OS has no f_namelen field in struct statfs.
- jlong max_name_length = 255; // __DARWIN_MAXNAMLEN
-#else
- jlong max_name_length = static_cast<jlong>(sb.f_namemax);
-#endif
-
static jmethodID ctor = env->GetMethodID(JniConstants::structStatVfsClass, "<init>",
"(JJJJJJJJJJJ)V");
return env->NewObject(JniConstants::structStatVfsClass, ctor,
@@ -443,7 +431,7 @@
static_cast<jlong>(sb.f_favail),
static_cast<jlong>(sb.f_fsid),
static_cast<jlong>(sb.f_flag),
- max_name_length);
+ static_cast<jlong>(sb.f_namemax));
}
static jobject makeStructLinger(JNIEnv* env, const struct linger& l) {
@@ -458,13 +446,8 @@
}
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) {
@@ -1146,15 +1129,7 @@
}
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 0;
- }
- return static_cast<jint>(owner);
-#elif defined(__BIONIC__)
+#if defined(__BIONIC__)
return TEMP_FAILURE_RETRY(gettid());
#else
return syscall(__NR_gettid);
@@ -1346,10 +1321,6 @@
}
static jobjectArray Posix_pipe2(JNIEnv* env, jobject, jint flags __unused) {
-#ifdef __APPLE__
- jniThrowException(env, "java/lang/UnsupportedOperationException", "no pipe2 on Mac OS");
- return NULL;
-#else
int fds[2];
throwIfMinusOne(env, "pipe2", TEMP_FAILURE_RETRY(pipe2(&fds[0], flags)));
jobjectArray result = env->NewObjectArray(2, JniConstants::fileDescriptorClass, NULL);
@@ -1367,7 +1338,6 @@
}
}
return result;
-#endif
}
static jint Posix_poll(JNIEnv* env, jobject, jobjectArray javaStructs, jint timeoutMs) {
@@ -1453,32 +1423,22 @@
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);
while ((errno = posix_fallocate64(fd, offset, length)) == EINTR) {
}
if (errno != 0) {
throwErrnoException(env, "posix_fallocate");
}
-#endif
}
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 = TEMP_FAILURE_RETRY(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) {
@@ -1695,12 +1655,6 @@
throwIfMinusOne(env, "setsockopt", TEMP_FAILURE_RETRY(setsockopt(fd, level, option, &value, sizeof(value))));
}
-#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED < 1070
-// Mac OS didn't support modern multicast APIs until 10.7.
-static void Posix_setsockoptIpMreqn(JNIEnv*, jobject, jobject, jint, jint, jint) { abort(); }
-static void Posix_setsockoptGroupReq(JNIEnv*, jobject, jobject, jint, jint, jobject) { abort(); }
-static void Posix_setsockoptGroupSourceReq(JNIEnv*, jobject, jobject, jint, jint, jobject) { abort(); }
-#else
static void Posix_setsockoptIpMreqn(JNIEnv* env, jobject, jobject javaFd, jint level, jint option, jint value) {
ip_mreqn req;
memset(&req, 0, sizeof(req));
@@ -1783,7 +1737,6 @@
}
throwIfMinusOne(env, "setsockopt", rc);
}
-#endif
static void Posix_setsockoptLinger(JNIEnv* env, jobject, jobject javaFd, jint level, jint option, jobject javaLinger) {
static jfieldID lOnoffFid = env->GetFieldID(JniConstants::structLingerClass, "l_onoff", "I");