am e6e71608: Merge "Use __ANDROID__ instead of HAVE_ANDROID_OS."

* commit 'e6e71608bd60b4745b048ec466b5ea1301020b32':
  Use __ANDROID__ instead of HAVE_ANDROID_OS.
This commit is contained in:
Elliott Hughes 2015-07-30 16:42:50 +00:00 committed by Android Git Automerger
commit fb1ecbc55e
15 changed files with 36 additions and 43 deletions

View File

@ -26,7 +26,7 @@
#include <sys/types.h>
#include <stdint.h>
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
#include <linux/capability.h>
#else
#include "android_filesystem_capability.h"

View File

@ -73,7 +73,7 @@ extern void androidSetCreateThreadFunc(android_create_thread_fn func);
// ------------------------------------------------------------------
// Extra functions working with raw pids.
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
// Change the priority AND scheduling group of a particular thread. The priority
// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION
// if the priority set failed, else another value if just the group set failed;

View File

@ -59,7 +59,7 @@ public:
// lock if possible; returns 0 on success, error otherwise
status_t tryLock();
#if HAVE_ANDROID_OS
#if defined(__ANDROID__)
// lock the mutex, but don't wait longer than timeoutMilliseconds.
// Returns 0 on success, TIMED_OUT for failure due to timeout expiration.
//
@ -128,7 +128,7 @@ inline void Mutex::unlock() {
inline status_t Mutex::tryLock() {
return -pthread_mutex_trylock(&mMutex);
}
#if HAVE_ANDROID_OS
#if defined(__ANDROID__)
inline status_t Mutex::timedLock(nsecs_t timeoutNs) {
const struct timespec ts = {
/* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),

View File

@ -70,7 +70,7 @@ public:
// Indicates whether this thread is running or not.
bool isRunning() const;
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
// Return the thread's kernel ID, same as the thread itself calling gettid(),
// or -1 if the thread is not running.
pid_t getTid() const;
@ -101,7 +101,7 @@ private:
volatile bool mExitPending;
volatile bool mRunning;
sp<Thread> mHoldSelf;
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
// legacy for debugging, not used by getTid() as it is set by the child thread
// and so is not initialized until the child reaches that point
pid_t mTid;

View File

@ -17,7 +17,7 @@
#ifndef ANDROID_TRACE_H
#define ANDROID_TRACE_H
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
#include <fcntl.h>
#include <stdint.h>
@ -59,11 +59,11 @@ private:
}; // namespace android
#else // HAVE_ANDROID_OS
#else // !__ANDROID__
#define ATRACE_NAME(...)
#define ATRACE_CALL()
#endif // HAVE_ANDROID_OS
#endif // __ANDROID__
#endif // ANDROID_TRACE_H

View File

@ -23,7 +23,7 @@
#include <cutils/iosched_policy.h>
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
#include <linux/ioprio.h>
#include <sys/syscall.h>
#define __android_unused
@ -32,7 +32,7 @@
#endif
int android_set_ioprio(int pid __android_unused, IoSchedClass clazz __android_unused, int ioprio __android_unused) {
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
if (syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, pid, ioprio | (clazz << IOPRIO_CLASS_SHIFT))) {
return -1;
}
@ -41,7 +41,7 @@ int android_set_ioprio(int pid __android_unused, IoSchedClass clazz __android_un
}
int android_get_ioprio(int pid __android_unused, IoSchedClass *clazz, int *ioprio) {
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
int rc;
if ((rc = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, pid)) < 0) {

View File

@ -25,19 +25,19 @@
#include <unistd.h>
#include <cutils/process_name.h>
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
#include <cutils/properties.h>
#endif
#define PROCESS_NAME_DEVICE "/sys/qemu_trace/process_name"
static const char* process_name = "unknown";
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
static int running_in_emulator = -1;
#endif
void set_process_name(const char* new_name) {
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
char propBuf[PROPERTY_VALUE_MAX];
#endif
@ -59,7 +59,7 @@ void set_process_name(const char* new_name) {
}
#endif
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
// If we know we are not running in the emulator, then return.
if (running_in_emulator == 0) {
return;

View File

@ -37,7 +37,7 @@ static inline SchedPolicy _policy(SchedPolicy p)
return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
}
#if defined(HAVE_ANDROID_OS)
#if defined(__ANDROID__)
#include <pthread.h>
#include <sched.h>
@ -142,7 +142,7 @@ static void __initialize(void) {
*/
static int getSchedulerGroup(int tid, char* buf, size_t bufLen)
{
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
char pathBuf[32];
char lineBuf[256];
FILE *fp;

View File

@ -17,7 +17,7 @@
#include <cutils/sockets.h>
#include <log/log.h>
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
/* For the socket trust (credentials) check */
#include <private/android_filesystem_config.h>
#define __android_unused
@ -27,7 +27,7 @@
bool socket_peer_is_trusted(int fd __android_unused)
{
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
struct ucred cr;
socklen_t len = sizeof(cr);
int n = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &len);

View File

@ -295,13 +295,13 @@ bool PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct
// so we save the extra file existence check.
char cpuinfo_path[1024];
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
snprintf(cpuinfo_path, sizeof(cpuinfo_path), "/system/lib"
#ifdef __LP64__
"64"
#endif // __LP64__
"/%s/cpuinfo", instruction_set);
#else // !HAVE_ANDROID_OS
#else // !__ANDROID__
// To be able to test on the host, we hardwire a relative path.
snprintf(cpuinfo_path, sizeof(cpuinfo_path), "./cpuinfo");
#endif

View File

@ -32,8 +32,8 @@ static constexpr const char* kTestData = "PreInitializeNativeBridge test.";
TEST_F(NativeBridgeTest, PreInitializeNativeBridge) {
ASSERT_TRUE(LoadNativeBridge(kNativeBridgeLibrary, nullptr));
#ifndef __APPLE__ // Mac OS does not support bind-mount.
#ifndef HAVE_ANDROID_OS // Cannot write into the hard-wired location.
#if !defined(__APPLE__) // Mac OS does not support bind-mount.
#if !defined(__ANDROID__) // Cannot write into the hard-wired location.
// Try to create our mount namespace.
if (unshare(CLONE_NEWNS) != -1) {
// Create a dummy file.

View File

@ -50,7 +50,7 @@
#define ALOGW printf
#endif
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
/* SIOCKILLADDR is an Android extension. */
#define SIOCKILLADDR 0x8939
#endif
@ -596,7 +596,7 @@ int ifc_disable(const char *ifname)
int ifc_reset_connections(const char *ifname, const int reset_mask)
{
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
int result, success;
in_addr_t myaddr = 0;
struct ifreq ifr;

View File

@ -19,7 +19,7 @@
* System clock functions.
*/
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
#include <linux/ioctl.h>
#include <linux/rtc.h>
#include <utils/Atomic.h>
@ -107,7 +107,7 @@ static inline void checkTimeStamps(int64_t timestamp,
*/
int64_t elapsedRealtimeNano()
{
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
struct timespec ts;
int result;
int64_t timestamp;

View File

@ -45,7 +45,7 @@
#include <cutils/sched_policy.h>
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
# define __android_unused
#else
# define __android_unused __attribute__((__unused__))
@ -132,7 +132,7 @@ int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
#ifdef HAVE_ANDROID_OS /* valgrind is rejecting RT-priority create reqs */
#if defined(__ANDROID__) /* valgrind is rejecting RT-priority create reqs */
if (threadPriority != PRIORITY_DEFAULT || threadName != NULL) {
// Now that the pthread_t has a method to find the associated
// android_thread_id_t (pid) from pthread_t, it would be possible to avoid
@ -176,7 +176,7 @@ int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
return 1;
}
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
static pthread_t android_thread_id_t_to_pthread(android_thread_id_t thread)
{
return (pthread_t) thread;
@ -302,12 +302,10 @@ void androidSetCreateThreadFunc(android_create_thread_fn func)
gCreateThreadFn = func;
}
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
int androidSetThreadPriority(pid_t tid, int pri)
{
int rc = 0;
#if !defined(_WIN32)
int lasterr = 0;
if (pri >= ANDROID_PRIORITY_BACKGROUND) {
@ -325,17 +323,12 @@ int androidSetThreadPriority(pid_t tid, int pri)
} else {
errno = lasterr;
}
#endif
return rc;
}
int androidGetThreadPriority(pid_t tid) {
#if !defined(_WIN32)
return getpriority(PRIO_PROCESS, tid);
#else
return ANDROID_PRIORITY_NORMAL;
#endif
}
#endif
@ -658,7 +651,7 @@ Thread::Thread(bool canCallJava)
mLock("Thread::mLock"),
mStatus(NO_ERROR),
mExitPending(false), mRunning(false)
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
, mTid(-1)
#endif
{
@ -728,7 +721,7 @@ int Thread::_threadLoop(void* user)
wp<Thread> weak(strong);
self->mHoldSelf.clear();
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
// this is very useful for debugging with gdb
self->mTid = gettid();
#endif
@ -839,7 +832,7 @@ bool Thread::isRunning() const {
return mRunning;
}
#ifdef HAVE_ANDROID_OS
#if defined(__ANDROID__)
pid_t Thread::getTid() const
{
// mTid is not defined until the child initializes it, and the caller may need it earlier

View File

@ -23,7 +23,7 @@
#include <sys/time.h>
#include <time.h>
#if defined(HAVE_ANDROID_OS)
#if defined(__ANDROID__)
nsecs_t systemTime(int clock)
{
static const clockid_t clocks[] = {