summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2015-07-30 10:47:35 -0500
committerElliott Hughes2015-07-30 11:33:43 -0500
commit9b828adfad09200f3f1bd3602187fe3dd5335774 (patch)
treedbea9a10676206346b39e428e74ee630a1a71219
parentdcf890914c7571d3068046b9df1f672e9f45b4d2 (diff)
downloadplatform-system-core-9b828adfad09200f3f1bd3602187fe3dd5335774.tar.gz
platform-system-core-9b828adfad09200f3f1bd3602187fe3dd5335774.tar.xz
platform-system-core-9b828adfad09200f3f1bd3602187fe3dd5335774.zip
Use __ANDROID__ instead of HAVE_ANDROID_OS.
Change-Id: I9967f3fd758c2a5b40be5b60ae72be7e2fb75136
-rw-r--r--include/private/android_filesystem_config.h2
-rw-r--r--include/utils/AndroidThreads.h2
-rw-r--r--include/utils/Mutex.h4
-rw-r--r--include/utils/Thread.h4
-rw-r--r--include/utils/Trace.h6
-rw-r--r--libcutils/iosched_policy.c6
-rw-r--r--libcutils/process_name.c8
-rw-r--r--libcutils/sched_policy.c4
-rw-r--r--libcutils/sockets.c4
-rw-r--r--libnativebridge/native_bridge.cc4
-rw-r--r--libnativebridge/tests/PreInitializeNativeBridge_test.cpp4
-rw-r--r--libnetutils/ifc_utils.c4
-rw-r--r--libutils/SystemClock.cpp4
-rw-r--r--libutils/Threads.cpp21
-rw-r--r--libutils/Timers.cpp2
15 files changed, 36 insertions, 43 deletions
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index 0c071ca53..9046fbe65 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -26,7 +26,7 @@
26#include <sys/types.h> 26#include <sys/types.h>
27#include <stdint.h> 27#include <stdint.h>
28 28
29#ifdef HAVE_ANDROID_OS 29#if defined(__ANDROID__)
30#include <linux/capability.h> 30#include <linux/capability.h>
31#else 31#else
32#include "android_filesystem_capability.h" 32#include "android_filesystem_capability.h"
diff --git a/include/utils/AndroidThreads.h b/include/utils/AndroidThreads.h
index aad1e82cb..4c2dd49f6 100644
--- a/include/utils/AndroidThreads.h
+++ b/include/utils/AndroidThreads.h
@@ -73,7 +73,7 @@ extern void androidSetCreateThreadFunc(android_create_thread_fn func);
73// ------------------------------------------------------------------ 73// ------------------------------------------------------------------
74// Extra functions working with raw pids. 74// Extra functions working with raw pids.
75 75
76#ifdef HAVE_ANDROID_OS 76#if defined(__ANDROID__)
77// Change the priority AND scheduling group of a particular thread. The priority 77// Change the priority AND scheduling group of a particular thread. The priority
78// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION 78// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION
79// if the priority set failed, else another value if just the group set failed; 79// if the priority set failed, else another value if just the group set failed;
diff --git a/include/utils/Mutex.h b/include/utils/Mutex.h
index 757519b08..f027c799f 100644
--- a/include/utils/Mutex.h
+++ b/include/utils/Mutex.h
@@ -59,7 +59,7 @@ public:
59 // lock if possible; returns 0 on success, error otherwise 59 // lock if possible; returns 0 on success, error otherwise
60 status_t tryLock(); 60 status_t tryLock();
61 61
62#if HAVE_ANDROID_OS 62#if defined(__ANDROID__)
63 // lock the mutex, but don't wait longer than timeoutMilliseconds. 63 // lock the mutex, but don't wait longer than timeoutMilliseconds.
64 // Returns 0 on success, TIMED_OUT for failure due to timeout expiration. 64 // Returns 0 on success, TIMED_OUT for failure due to timeout expiration.
65 // 65 //
@@ -128,7 +128,7 @@ inline void Mutex::unlock() {
128inline status_t Mutex::tryLock() { 128inline status_t Mutex::tryLock() {
129 return -pthread_mutex_trylock(&mMutex); 129 return -pthread_mutex_trylock(&mMutex);
130} 130}
131#if HAVE_ANDROID_OS 131#if defined(__ANDROID__)
132inline status_t Mutex::timedLock(nsecs_t timeoutNs) { 132inline status_t Mutex::timedLock(nsecs_t timeoutNs) {
133 const struct timespec ts = { 133 const struct timespec ts = {
134 /* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000), 134 /* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
diff --git a/include/utils/Thread.h b/include/utils/Thread.h
index 28839fded..1532b7e0c 100644
--- a/include/utils/Thread.h
+++ b/include/utils/Thread.h
@@ -70,7 +70,7 @@ public:
70 // Indicates whether this thread is running or not. 70 // Indicates whether this thread is running or not.
71 bool isRunning() const; 71 bool isRunning() const;
72 72
73#ifdef HAVE_ANDROID_OS 73#if defined(__ANDROID__)
74 // Return the thread's kernel ID, same as the thread itself calling gettid(), 74 // Return the thread's kernel ID, same as the thread itself calling gettid(),
75 // or -1 if the thread is not running. 75 // or -1 if the thread is not running.
76 pid_t getTid() const; 76 pid_t getTid() const;
@@ -101,7 +101,7 @@ private:
101 volatile bool mExitPending; 101 volatile bool mExitPending;
102 volatile bool mRunning; 102 volatile bool mRunning;
103 sp<Thread> mHoldSelf; 103 sp<Thread> mHoldSelf;
104#ifdef HAVE_ANDROID_OS 104#if defined(__ANDROID__)
105 // legacy for debugging, not used by getTid() as it is set by the child thread 105 // legacy for debugging, not used by getTid() as it is set by the child thread
106 // and so is not initialized until the child reaches that point 106 // and so is not initialized until the child reaches that point
107 pid_t mTid; 107 pid_t mTid;
diff --git a/include/utils/Trace.h b/include/utils/Trace.h
index 6ee343d79..6ba68f61c 100644
--- a/include/utils/Trace.h
+++ b/include/utils/Trace.h
@@ -17,7 +17,7 @@
17#ifndef ANDROID_TRACE_H 17#ifndef ANDROID_TRACE_H
18#define ANDROID_TRACE_H 18#define ANDROID_TRACE_H
19 19
20#ifdef HAVE_ANDROID_OS 20#if defined(__ANDROID__)
21 21
22#include <fcntl.h> 22#include <fcntl.h>
23#include <stdint.h> 23#include <stdint.h>
@@ -59,11 +59,11 @@ private:
59 59
60}; // namespace android 60}; // namespace android
61 61
62#else // HAVE_ANDROID_OS 62#else // !__ANDROID__
63 63
64#define ATRACE_NAME(...) 64#define ATRACE_NAME(...)
65#define ATRACE_CALL() 65#define ATRACE_CALL()
66 66
67#endif // HAVE_ANDROID_OS 67#endif // __ANDROID__
68 68
69#endif // ANDROID_TRACE_H 69#endif // ANDROID_TRACE_H
diff --git a/libcutils/iosched_policy.c b/libcutils/iosched_policy.c
index 8946d3c14..71bc94b25 100644
--- a/libcutils/iosched_policy.c
+++ b/libcutils/iosched_policy.c
@@ -23,7 +23,7 @@
23 23
24#include <cutils/iosched_policy.h> 24#include <cutils/iosched_policy.h>
25 25
26#ifdef HAVE_ANDROID_OS 26#if defined(__ANDROID__)
27#include <linux/ioprio.h> 27#include <linux/ioprio.h>
28#include <sys/syscall.h> 28#include <sys/syscall.h>
29#define __android_unused 29#define __android_unused
@@ -32,7 +32,7 @@
32#endif 32#endif
33 33
34int android_set_ioprio(int pid __android_unused, IoSchedClass clazz __android_unused, int ioprio __android_unused) { 34int android_set_ioprio(int pid __android_unused, IoSchedClass clazz __android_unused, int ioprio __android_unused) {
35#ifdef HAVE_ANDROID_OS 35#if defined(__ANDROID__)
36 if (syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, pid, ioprio | (clazz << IOPRIO_CLASS_SHIFT))) { 36 if (syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, pid, ioprio | (clazz << IOPRIO_CLASS_SHIFT))) {
37 return -1; 37 return -1;
38 } 38 }
@@ -41,7 +41,7 @@ int android_set_ioprio(int pid __android_unused, IoSchedClass clazz __android_un
41} 41}
42 42
43int android_get_ioprio(int pid __android_unused, IoSchedClass *clazz, int *ioprio) { 43int android_get_ioprio(int pid __android_unused, IoSchedClass *clazz, int *ioprio) {
44#ifdef HAVE_ANDROID_OS 44#if defined(__ANDROID__)
45 int rc; 45 int rc;
46 46
47 if ((rc = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, pid)) < 0) { 47 if ((rc = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, pid)) < 0) {
diff --git a/libcutils/process_name.c b/libcutils/process_name.c
index cc931ebaf..5d28b6ff2 100644
--- a/libcutils/process_name.c
+++ b/libcutils/process_name.c
@@ -25,19 +25,19 @@
25#include <unistd.h> 25#include <unistd.h>
26 26
27#include <cutils/process_name.h> 27#include <cutils/process_name.h>
28#ifdef HAVE_ANDROID_OS 28#if defined(__ANDROID__)
29#include <cutils/properties.h> 29#include <cutils/properties.h>
30#endif 30#endif
31 31
32#define PROCESS_NAME_DEVICE "/sys/qemu_trace/process_name" 32#define PROCESS_NAME_DEVICE "/sys/qemu_trace/process_name"
33 33
34static const char* process_name = "unknown"; 34static const char* process_name = "unknown";
35#ifdef HAVE_ANDROID_OS 35#if defined(__ANDROID__)
36static int running_in_emulator = -1; 36static int running_in_emulator = -1;
37#endif 37#endif
38 38
39void set_process_name(const char* new_name) { 39void set_process_name(const char* new_name) {
40#ifdef HAVE_ANDROID_OS 40#if defined(__ANDROID__)
41 char propBuf[PROPERTY_VALUE_MAX]; 41 char propBuf[PROPERTY_VALUE_MAX];
42#endif 42#endif
43 43
@@ -59,7 +59,7 @@ void set_process_name(const char* new_name) {
59 } 59 }
60#endif 60#endif
61 61
62#ifdef HAVE_ANDROID_OS 62#if defined(__ANDROID__)
63 // If we know we are not running in the emulator, then return. 63 // If we know we are not running in the emulator, then return.
64 if (running_in_emulator == 0) { 64 if (running_in_emulator == 0) {
65 return; 65 return;
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index dfc877752..103ff66b3 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -37,7 +37,7 @@ static inline SchedPolicy _policy(SchedPolicy p)
37 return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p; 37 return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
38} 38}
39 39
40#if defined(HAVE_ANDROID_OS) 40#if defined(__ANDROID__)
41 41
42#include <pthread.h> 42#include <pthread.h>
43#include <sched.h> 43#include <sched.h>
@@ -142,7 +142,7 @@ static void __initialize(void) {
142 */ 142 */
143static int getSchedulerGroup(int tid, char* buf, size_t bufLen) 143static int getSchedulerGroup(int tid, char* buf, size_t bufLen)
144{ 144{
145#ifdef HAVE_ANDROID_OS 145#if defined(__ANDROID__)
146 char pathBuf[32]; 146 char pathBuf[32];
147 char lineBuf[256]; 147 char lineBuf[256];
148 FILE *fp; 148 FILE *fp;
diff --git a/libcutils/sockets.c b/libcutils/sockets.c
index 15ede2b5b..d43878258 100644
--- a/libcutils/sockets.c
+++ b/libcutils/sockets.c
@@ -17,7 +17,7 @@
17#include <cutils/sockets.h> 17#include <cutils/sockets.h>
18#include <log/log.h> 18#include <log/log.h>
19 19
20#ifdef HAVE_ANDROID_OS 20#if defined(__ANDROID__)
21/* For the socket trust (credentials) check */ 21/* For the socket trust (credentials) check */
22#include <private/android_filesystem_config.h> 22#include <private/android_filesystem_config.h>
23#define __android_unused 23#define __android_unused
@@ -27,7 +27,7 @@
27 27
28bool socket_peer_is_trusted(int fd __android_unused) 28bool socket_peer_is_trusted(int fd __android_unused)
29{ 29{
30#ifdef HAVE_ANDROID_OS 30#if defined(__ANDROID__)
31 struct ucred cr; 31 struct ucred cr;
32 socklen_t len = sizeof(cr); 32 socklen_t len = sizeof(cr);
33 int n = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &len); 33 int n = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &len);
diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc
index a9671a97a..32a65ea04 100644
--- a/libnativebridge/native_bridge.cc
+++ b/libnativebridge/native_bridge.cc
@@ -295,13 +295,13 @@ bool PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct
295 // so we save the extra file existence check. 295 // so we save the extra file existence check.
296 char cpuinfo_path[1024]; 296 char cpuinfo_path[1024];
297 297
298#ifdef HAVE_ANDROID_OS 298#if defined(__ANDROID__)
299 snprintf(cpuinfo_path, sizeof(cpuinfo_path), "/system/lib" 299 snprintf(cpuinfo_path, sizeof(cpuinfo_path), "/system/lib"
300#ifdef __LP64__ 300#ifdef __LP64__
301 "64" 301 "64"
302#endif // __LP64__ 302#endif // __LP64__
303 "/%s/cpuinfo", instruction_set); 303 "/%s/cpuinfo", instruction_set);
304#else // !HAVE_ANDROID_OS 304#else // !__ANDROID__
305 // To be able to test on the host, we hardwire a relative path. 305 // To be able to test on the host, we hardwire a relative path.
306 snprintf(cpuinfo_path, sizeof(cpuinfo_path), "./cpuinfo"); 306 snprintf(cpuinfo_path, sizeof(cpuinfo_path), "./cpuinfo");
307#endif 307#endif
diff --git a/libnativebridge/tests/PreInitializeNativeBridge_test.cpp b/libnativebridge/tests/PreInitializeNativeBridge_test.cpp
index cec26ce50..d3bbebefd 100644
--- a/libnativebridge/tests/PreInitializeNativeBridge_test.cpp
+++ b/libnativebridge/tests/PreInitializeNativeBridge_test.cpp
@@ -32,8 +32,8 @@ static constexpr const char* kTestData = "PreInitializeNativeBridge test.";
32 32
33TEST_F(NativeBridgeTest, PreInitializeNativeBridge) { 33TEST_F(NativeBridgeTest, PreInitializeNativeBridge) {
34 ASSERT_TRUE(LoadNativeBridge(kNativeBridgeLibrary, nullptr)); 34 ASSERT_TRUE(LoadNativeBridge(kNativeBridgeLibrary, nullptr));
35#ifndef __APPLE__ // Mac OS does not support bind-mount. 35#if !defined(__APPLE__) // Mac OS does not support bind-mount.
36#ifndef HAVE_ANDROID_OS // Cannot write into the hard-wired location. 36#if !defined(__ANDROID__) // Cannot write into the hard-wired location.
37 // Try to create our mount namespace. 37 // Try to create our mount namespace.
38 if (unshare(CLONE_NEWNS) != -1) { 38 if (unshare(CLONE_NEWNS) != -1) {
39 // Create a dummy file. 39 // Create a dummy file.
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c
index 7d2a5fbf2..956ed30c3 100644
--- a/libnetutils/ifc_utils.c
+++ b/libnetutils/ifc_utils.c
@@ -50,7 +50,7 @@
50#define ALOGW printf 50#define ALOGW printf
51#endif 51#endif
52 52
53#ifdef HAVE_ANDROID_OS 53#if defined(__ANDROID__)
54/* SIOCKILLADDR is an Android extension. */ 54/* SIOCKILLADDR is an Android extension. */
55#define SIOCKILLADDR 0x8939 55#define SIOCKILLADDR 0x8939
56#endif 56#endif
@@ -596,7 +596,7 @@ int ifc_disable(const char *ifname)
596 596
597int ifc_reset_connections(const char *ifname, const int reset_mask) 597int ifc_reset_connections(const char *ifname, const int reset_mask)
598{ 598{
599#ifdef HAVE_ANDROID_OS 599#if defined(__ANDROID__)
600 int result, success; 600 int result, success;
601 in_addr_t myaddr = 0; 601 in_addr_t myaddr = 0;
602 struct ifreq ifr; 602 struct ifreq ifr;
diff --git a/libutils/SystemClock.cpp b/libutils/SystemClock.cpp
index 64204a8e8..1fca2b293 100644
--- a/libutils/SystemClock.cpp
+++ b/libutils/SystemClock.cpp
@@ -19,7 +19,7 @@
19 * System clock functions. 19 * System clock functions.
20 */ 20 */
21 21
22#ifdef HAVE_ANDROID_OS 22#if defined(__ANDROID__)
23#include <linux/ioctl.h> 23#include <linux/ioctl.h>
24#include <linux/rtc.h> 24#include <linux/rtc.h>
25#include <utils/Atomic.h> 25#include <utils/Atomic.h>
@@ -107,7 +107,7 @@ static inline void checkTimeStamps(int64_t timestamp,
107 */ 107 */
108int64_t elapsedRealtimeNano() 108int64_t elapsedRealtimeNano()
109{ 109{
110#ifdef HAVE_ANDROID_OS 110#if defined(__ANDROID__)
111 struct timespec ts; 111 struct timespec ts;
112 int result; 112 int result;
113 int64_t timestamp; 113 int64_t timestamp;
diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp
index c3666e4b4..6dda6b573 100644
--- a/libutils/Threads.cpp
+++ b/libutils/Threads.cpp
@@ -45,7 +45,7 @@
45 45
46#include <cutils/sched_policy.h> 46#include <cutils/sched_policy.h>
47 47
48#ifdef HAVE_ANDROID_OS 48#if defined(__ANDROID__)
49# define __android_unused 49# define __android_unused
50#else 50#else
51# define __android_unused __attribute__((__unused__)) 51# define __android_unused __attribute__((__unused__))
@@ -132,7 +132,7 @@ int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
132 pthread_attr_init(&attr); 132 pthread_attr_init(&attr);
133 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 133 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
134 134
135#ifdef HAVE_ANDROID_OS /* valgrind is rejecting RT-priority create reqs */ 135#if defined(__ANDROID__) /* valgrind is rejecting RT-priority create reqs */
136 if (threadPriority != PRIORITY_DEFAULT || threadName != NULL) { 136 if (threadPriority != PRIORITY_DEFAULT || threadName != NULL) {
137 // Now that the pthread_t has a method to find the associated 137 // Now that the pthread_t has a method to find the associated
138 // android_thread_id_t (pid) from pthread_t, it would be possible to avoid 138 // 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,
176 return 1; 176 return 1;
177} 177}
178 178
179#ifdef HAVE_ANDROID_OS 179#if defined(__ANDROID__)
180static pthread_t android_thread_id_t_to_pthread(android_thread_id_t thread) 180static pthread_t android_thread_id_t_to_pthread(android_thread_id_t thread)
181{ 181{
182 return (pthread_t) thread; 182 return (pthread_t) thread;
@@ -302,12 +302,10 @@ void androidSetCreateThreadFunc(android_create_thread_fn func)
302 gCreateThreadFn = func; 302 gCreateThreadFn = func;
303} 303}
304 304
305#ifdef HAVE_ANDROID_OS 305#if defined(__ANDROID__)
306int androidSetThreadPriority(pid_t tid, int pri) 306int androidSetThreadPriority(pid_t tid, int pri)
307{ 307{
308 int rc = 0; 308 int rc = 0;
309
310#if !defined(_WIN32)
311 int lasterr = 0; 309 int lasterr = 0;
312 310
313 if (pri >= ANDROID_PRIORITY_BACKGROUND) { 311 if (pri >= ANDROID_PRIORITY_BACKGROUND) {
@@ -325,17 +323,12 @@ int androidSetThreadPriority(pid_t tid, int pri)
325 } else { 323 } else {
326 errno = lasterr; 324 errno = lasterr;
327 } 325 }
328#endif
329 326
330 return rc; 327 return rc;
331} 328}
332 329
333int androidGetThreadPriority(pid_t tid) { 330int androidGetThreadPriority(pid_t tid) {
334#if !defined(_WIN32)
335 return getpriority(PRIO_PROCESS, tid); 331 return getpriority(PRIO_PROCESS, tid);
336#else
337 return ANDROID_PRIORITY_NORMAL;
338#endif
339} 332}
340 333
341#endif 334#endif
@@ -658,7 +651,7 @@ Thread::Thread(bool canCallJava)
658 mLock("Thread::mLock"), 651 mLock("Thread::mLock"),
659 mStatus(NO_ERROR), 652 mStatus(NO_ERROR),
660 mExitPending(false), mRunning(false) 653 mExitPending(false), mRunning(false)
661#ifdef HAVE_ANDROID_OS 654#if defined(__ANDROID__)
662 , mTid(-1) 655 , mTid(-1)
663#endif 656#endif
664{ 657{
@@ -728,7 +721,7 @@ int Thread::_threadLoop(void* user)
728 wp<Thread> weak(strong); 721 wp<Thread> weak(strong);
729 self->mHoldSelf.clear(); 722 self->mHoldSelf.clear();
730 723
731#ifdef HAVE_ANDROID_OS 724#if defined(__ANDROID__)
732 // this is very useful for debugging with gdb 725 // this is very useful for debugging with gdb
733 self->mTid = gettid(); 726 self->mTid = gettid();
734#endif 727#endif
@@ -839,7 +832,7 @@ bool Thread::isRunning() const {
839 return mRunning; 832 return mRunning;
840} 833}
841 834
842#ifdef HAVE_ANDROID_OS 835#if defined(__ANDROID__)
843pid_t Thread::getTid() const 836pid_t Thread::getTid() const
844{ 837{
845 // mTid is not defined until the child initializes it, and the caller may need it earlier 838 // mTid is not defined until the child initializes it, and the caller may need it earlier
diff --git a/libutils/Timers.cpp b/libutils/Timers.cpp
index fb70e1588..201bc412c 100644
--- a/libutils/Timers.cpp
+++ b/libutils/Timers.cpp
@@ -23,7 +23,7 @@
23#include <sys/time.h> 23#include <sys/time.h>
24#include <time.h> 24#include <time.h>
25 25
26#if defined(HAVE_ANDROID_OS) 26#if defined(__ANDROID__)
27nsecs_t systemTime(int clock) 27nsecs_t systemTime(int clock)
28{ 28{
29 static const clockid_t clocks[] = { 29 static const clockid_t clocks[] = {