diff options
author | Yabin Cui <yabinc@google.com> | 2015-01-26 19:48:54 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-01-27 14:23:22 -0800 |
commit | 4a6e5a3b641dd99b658c4c336490371a3a5ae180 (patch) | |
tree | 3048f441498f5d5aed8bb218ecaca5e9a80cbf40 | |
parent | fb538fb13d930a7398695d1044ceaaf854949018 (diff) | |
download | system_core-4a6e5a3b641dd99b658c4c336490371a3a5ae180.zip system_core-4a6e5a3b641dd99b658c4c336490371a3a5ae180.tar.gz system_core-4a6e5a3b641dd99b658c4c336490371a3a5ae180.tar.bz2 |
Kill HAVE_PTHREADS.
Bug: 19083585
Change-Id: Ic09eb3dd250bc5c5b63cac7998f99f5fa007f407
-rw-r--r-- | include/cutils/threads.h | 22 | ||||
-rw-r--r-- | include/log/log.h | 6 | ||||
-rw-r--r-- | include/log/logd.h | 15 | ||||
-rw-r--r-- | include/utils/AndroidThreads.h | 2 | ||||
-rw-r--r-- | include/utils/Condition.h | 8 | ||||
-rw-r--r-- | include/utils/Mutex.h | 8 | ||||
-rw-r--r-- | include/utils/RWLock.h | 6 | ||||
-rw-r--r-- | include/utils/Thread.h | 2 | ||||
-rw-r--r-- | libcutils/threads.c | 34 | ||||
-rw-r--r-- | liblog/fake_log_device.c | 8 | ||||
-rw-r--r-- | liblog/logd_write.c | 14 | ||||
-rw-r--r-- | liblog/logd_write_kern.c | 21 | ||||
-rw-r--r-- | libutils/Threads.cpp | 80 | ||||
-rw-r--r-- | libutils/Timers.cpp | 11 | ||||
-rw-r--r-- | libutils/misc.cpp | 8 |
15 files changed, 103 insertions, 142 deletions
diff --git a/include/cutils/threads.h b/include/cutils/threads.h index acf8f48..ade9a0c 100644 --- a/include/cutils/threads.h +++ b/include/cutils/threads.h @@ -29,7 +29,7 @@ extern "C" { /***********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) #include <pthread.h> @@ -42,7 +42,7 @@ typedef struct { #define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } -#elif defined HAVE_WIN32_THREADS +#else // !defined(_WIN32) #include <windows.h> @@ -56,15 +56,13 @@ typedef struct { #define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } -#else -# error "no thread_store_t implementation for your platform !!" -#endif +#endif // !defined(_WIN32) typedef void (*thread_store_destruct_t)(void* value); extern void* thread_store_get(thread_store_t* store); -extern void thread_store_set(thread_store_t* store, +extern void thread_store_set(thread_store_t* store, void* value, thread_store_destruct_t destroy); @@ -76,7 +74,7 @@ extern void thread_store_set(thread_store_t* store, /***********************************************************************/ /***********************************************************************/ -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) typedef pthread_mutex_t mutex_t; @@ -98,10 +96,10 @@ static __inline__ void mutex_destroy(mutex_t* lock) { pthread_mutex_destroy(lock); } -#endif -#ifdef HAVE_WIN32_THREADS -typedef struct { +#else // !defined(_WIN32) + +typedef struct { int init; CRITICAL_SECTION lock[1]; } mutex_t; @@ -134,10 +132,10 @@ static __inline__ void mutex_destroy(mutex_t* lock) { if (lock->init) { lock->init = 0; - DeleteCriticalSection(lock->lock); + DeleteCriticalSection(lock->lock); } } -#endif +#endif // !defined(_WIN32) #ifdef __cplusplus } diff --git a/include/log/log.h b/include/log/log.h index ace12d6..3d86533 100644 --- a/include/log/log.h +++ b/include/log/log.h @@ -28,14 +28,12 @@ #ifndef _LIBS_LOG_LOG_H #define _LIBS_LOG_LOG_H -#include <sys/types.h> -#ifdef HAVE_PTHREADS -#include <pthread.h> -#endif #include <stdarg.h> #include <stdio.h> +#include <sys/types.h> #include <time.h> #include <unistd.h> + #include <log/logd.h> #include <log/uio.h> diff --git a/include/log/logd.h b/include/log/logd.h index 2e6f220..0fe515f 100644 --- a/include/log/logd.h +++ b/include/log/logd.h @@ -23,16 +23,17 @@ #include <android/log.h> /* the rest is only used internally by the system */ -#include <time.h> -#include <stdio.h> -#include <unistd.h> -#include <stdint.h> -#include <sys/types.h> -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) #include <pthread.h> #endif -#include <log/uio.h> #include <stdarg.h> +#include <stdint.h> +#include <stdio.h> +#include <sys/types.h> +#include <time.h> +#include <unistd.h> + +#include <log/uio.h> #ifdef __cplusplus extern "C" { diff --git a/include/utils/AndroidThreads.h b/include/utils/AndroidThreads.h index 3c640b6..aad1e82 100644 --- a/include/utils/AndroidThreads.h +++ b/include/utils/AndroidThreads.h @@ -20,7 +20,7 @@ #include <stdint.h> #include <sys/types.h> -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) # include <pthread.h> #endif diff --git a/include/utils/Condition.h b/include/utils/Condition.h index db9be59..5a72519 100644 --- a/include/utils/Condition.h +++ b/include/utils/Condition.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <time.h> -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) # include <pthread.h> #endif @@ -74,7 +74,7 @@ public: void broadcast(); private: -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) pthread_cond_t mCond; #else void* mState; @@ -83,7 +83,7 @@ private: // --------------------------------------------------------------------------- -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) inline Condition::Condition() { pthread_cond_init(&mCond, NULL); @@ -149,7 +149,7 @@ inline void Condition::broadcast() { pthread_cond_broadcast(&mCond); } -#endif // HAVE_PTHREADS +#endif // !defined(_WIN32) // --------------------------------------------------------------------------- }; // namespace android diff --git a/include/utils/Mutex.h b/include/utils/Mutex.h index a3b594d..757519b 100644 --- a/include/utils/Mutex.h +++ b/include/utils/Mutex.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <time.h> -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) # include <pthread.h> #endif @@ -87,7 +87,7 @@ private: Mutex(const Mutex&); Mutex& operator = (const Mutex&); -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) pthread_mutex_t mMutex; #else void _init(); @@ -97,7 +97,7 @@ private: // --------------------------------------------------------------------------- -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) inline Mutex::Mutex() { pthread_mutex_init(&mMutex, NULL); @@ -138,7 +138,7 @@ inline status_t Mutex::timedLock(nsecs_t timeoutNs) { } #endif -#endif // HAVE_PTHREADS +#endif // !defined(_WIN32) // --------------------------------------------------------------------------- diff --git a/include/utils/RWLock.h b/include/utils/RWLock.h index 90beb5f..e743b1c 100644 --- a/include/utils/RWLock.h +++ b/include/utils/RWLock.h @@ -20,7 +20,7 @@ #include <stdint.h> #include <sys/types.h> -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) # include <pthread.h> #endif @@ -31,7 +31,7 @@ namespace android { // --------------------------------------------------------------------------- -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) /* * Simple mutex class. The implementation is system-dependent. @@ -117,7 +117,7 @@ inline void RWLock::unlock() { pthread_rwlock_unlock(&mRWLock); } -#endif // HAVE_PTHREADS +#endif // !defined(_WIN32) // --------------------------------------------------------------------------- }; // namespace android diff --git a/include/utils/Thread.h b/include/utils/Thread.h index c867e95..28839fd 100644 --- a/include/utils/Thread.h +++ b/include/utils/Thread.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <time.h> -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) # include <pthread.h> #endif diff --git a/libcutils/threads.c b/libcutils/threads.c index bf182f0..ca600b3 100644 --- a/libcutils/threads.c +++ b/libcutils/threads.c @@ -1,22 +1,22 @@ /* ** Copyright (C) 2007, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ #include <cutils/threads.h> -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) void* thread_store_get( thread_store_t* store ) { if (!store->has_tls) @@ -24,8 +24,8 @@ void* thread_store_get( thread_store_t* store ) return pthread_getspecific( store->tls ); } - -extern void thread_store_set( thread_store_t* store, + +extern void thread_store_set( thread_store_t* store, void* value, thread_store_destruct_t destroy) { @@ -42,14 +42,12 @@ extern void thread_store_set( thread_store_t* store, pthread_setspecific( store->tls, value ); } -#endif - -#ifdef HAVE_WIN32_THREADS +#else /* !defined(_WIN32) */ void* thread_store_get( thread_store_t* store ) { if (!store->has_tls) return NULL; - + return (void*) TlsGetValue( store->tls ); } @@ -65,7 +63,7 @@ void thread_store_set( thread_store_t* store, } else while (store->lock_init != -2) { Sleep(10); /* 10ms */ } - + EnterCriticalSection( &store->lock ); if (!store->has_tls) { store->tls = TlsAlloc(); @@ -76,7 +74,7 @@ void thread_store_set( thread_store_t* store, store->has_tls = 1; } LeaveCriticalSection( &store->lock ); - + TlsSetValue( store->tls, value ); } -#endif +#endif /* !defined(_WIN32) */ diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c index 117e154..cf3dc50 100644 --- a/liblog/fake_log_device.c +++ b/liblog/fake_log_device.c @@ -29,7 +29,7 @@ #include <log/logd.h> -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) #include <pthread.h> #endif @@ -88,7 +88,7 @@ typedef struct LogState { } LogState; -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) /* * Locking. Since we're emulating a device, we need to be prepared * to have multiple callers at the same time. This lock is used @@ -106,10 +106,10 @@ static void unlock() { pthread_mutex_unlock(&fakeLogDeviceLock); } -#else // !HAVE_PTHREADS +#else // !defined(_WIN32) #define lock() ((void)0) #define unlock() ((void)0) -#endif // !HAVE_PTHREADS +#endif // !defined(_WIN32) /* diff --git a/liblog/logd_write.c b/liblog/logd_write.c index 1e9b591..aaec619 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -15,7 +15,7 @@ */ #include <errno.h> #include <fcntl.h> -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) #include <pthread.h> #endif #include <stdarg.h> @@ -50,7 +50,7 @@ static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr); static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init; -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; #endif @@ -259,11 +259,11 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr) if (ret < 0) { ret = -errno; if (ret == -ENOTCONN) { -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) pthread_mutex_lock(&log_init_lock); #endif ret = __write_to_log_initialize(); -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) pthread_mutex_unlock(&log_init_lock); #endif @@ -306,7 +306,7 @@ const char *android_log_id_to_name(log_id_t log_id) static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) { -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) pthread_mutex_lock(&log_init_lock); #endif @@ -315,7 +315,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) ret = __write_to_log_initialize(); if (ret < 0) { -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) pthread_mutex_unlock(&log_init_lock); #endif return ret; @@ -324,7 +324,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) write_to_log = __write_to_log_kernel; } -#ifdef HAVE_PTHREADS +#if !defined(_WIN32) pthread_mutex_unlock(&log_init_lock); #endif diff --git a/liblog/logd_write_kern.c b/liblog/logd_write_kern.c index ae621cb..2ca3c94 100644 --- a/liblog/logd_write_kern.c +++ b/liblog/logd_write_kern.c @@ -16,9 +16,7 @@ #include <errno.h> #include <fcntl.h> -#ifdef HAVE_PTHREADS #include <pthread.h> -#endif #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -28,9 +26,7 @@ #include <time.h> #include <unistd.h> -#ifdef __BIONIC__ #include <android/set_abort_message.h> -#endif #include <log/log.h> #include <log/logd.h> @@ -43,23 +39,14 @@ #define LOG_BUF_SIZE 1024 -#if FAKE_LOG_DEVICE -/* This will be defined when building for the host. */ -#include "fake_log_device.h" -#define log_open(pathname, flags) fakeLogOpen(pathname, flags) -#define log_writev(filedes, vector, count) fakeLogWritev(filedes, vector, count) -#define log_close(filedes) fakeLogClose(filedes) -#else #define log_open(pathname, flags) open(pathname, (flags) | O_CLOEXEC) #define log_writev(filedes, vector, count) writev(filedes, vector, count) #define log_close(filedes) close(filedes) -#endif static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr); static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init; -#ifdef HAVE_PTHREADS + static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; -#endif #ifndef __unused #define __unused __attribute__((__unused__)) @@ -119,9 +106,7 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr) static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) { -#ifdef HAVE_PTHREADS pthread_mutex_lock(&log_init_lock); -#endif if (write_to_log == __write_to_log_init) { log_fds[LOG_ID_MAIN] = log_open("/dev/"LOGGER_LOG_MAIN, O_WRONLY); @@ -147,9 +132,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) } } -#ifdef HAVE_PTHREADS pthread_mutex_unlock(&log_init_lock); -#endif return write_to_log(log_id, vec, nr); } @@ -179,11 +162,9 @@ int __android_log_write(int prio, const char *tag, const char *msg) tag = tmp_tag; } -#if __BIONIC__ if (prio == ANDROID_LOG_FATAL) { android_set_abort_message(msg); } -#endif vec[0].iov_base = (unsigned char *) &prio; vec[0].iov_len = 1; diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp index b2c6903..1e014c6 100644 --- a/libutils/Threads.cpp +++ b/libutils/Threads.cpp @@ -24,11 +24,11 @@ #include <stdlib.h> #include <unistd.h> -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) # include <pthread.h> # include <sched.h> # include <sys/resource.h> -#elif defined(HAVE_WIN32_THREADS) +#else # include <windows.h> # include <stdint.h> # include <process.h> @@ -59,7 +59,7 @@ using namespace android; // ---------------------------------------------------------------------------- -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) // ---------------------------------------------------------------------------- /* @@ -90,7 +90,7 @@ struct thread_data_t { } else { set_sched_policy(0, SP_FOREGROUND); } - + if (name) { androidSetThreadName(name); free(name); @@ -127,7 +127,7 @@ int androidCreateRawThreadEtc(android_thread_func_t entryFunction, size_t threadStackSize, android_thread_id_t *threadId) { - pthread_attr_t attr; + pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); @@ -146,14 +146,14 @@ int androidCreateRawThreadEtc(android_thread_func_t entryFunction, t->entryFunction = entryFunction; t->userData = userData; entryFunction = (android_thread_func_t)&thread_data_t::trampoline; - userData = t; + userData = t; } #endif if (threadStackSize) { pthread_attr_setstacksize(&attr, threadStackSize); } - + errno = 0; pthread_t thread; int result = pthread_create(&thread, &attr, @@ -188,7 +188,7 @@ android_thread_id_t androidGetThreadId() } // ---------------------------------------------------------------------------- -#elif defined(HAVE_WIN32_THREADS) +#else // !defined(_WIN32) // ---------------------------------------------------------------------------- /* @@ -268,9 +268,7 @@ android_thread_id_t androidGetThreadId() } // ---------------------------------------------------------------------------- -#else -#error "Threads not supported" -#endif +#endif // !defined(_WIN32) // ---------------------------------------------------------------------------- @@ -307,8 +305,8 @@ void androidSetCreateThreadFunc(android_create_thread_fn func) int androidSetThreadPriority(pid_t tid, int pri) { int rc = 0; - -#if defined(HAVE_PTHREADS) + +#if !defined(_WIN32) int lasterr = 0; if (pri >= ANDROID_PRIORITY_BACKGROUND) { @@ -327,12 +325,12 @@ int androidSetThreadPriority(pid_t tid, int pri) errno = lasterr; } #endif - + return rc; } int androidGetThreadPriority(pid_t tid) { -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) return getpriority(PRIO_PROCESS, tid); #else return ANDROID_PRIORITY_NORMAL; @@ -349,9 +347,9 @@ namespace android { * =========================================================================== */ -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) // implemented as inlines in threads.h -#elif defined(HAVE_WIN32_THREADS) +#else Mutex::Mutex() { @@ -413,9 +411,7 @@ status_t Mutex::tryLock() return (dwWaitResult == WAIT_OBJECT_0) ? 0 : -1; } -#else -#error "Somebody forgot to implement threads for this platform." -#endif +#endif // !defined(_WIN32) /* @@ -424,9 +420,9 @@ status_t Mutex::tryLock() * =========================================================================== */ -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) // implemented as inlines in threads.h -#elif defined(HAVE_WIN32_THREADS) +#else /* * Windows doesn't have a condition variable solution. It's possible @@ -474,7 +470,7 @@ typedef struct WinCondition { //printf("+++ wait: incr waitersCount to %d (tid=%ld)\n", // condState->waitersCount, getThreadId()); LeaveCriticalSection(&condState->waitersCountLock); - + DWORD timeout = INFINITE; if (abstime) { nsecs_t reltime = *abstime - systemTime(); @@ -482,27 +478,27 @@ typedef struct WinCondition { reltime = 0; timeout = reltime/1000000; } - + // Atomically release the external mutex and wait on the semaphore. DWORD res = SignalObjectAndWait(hMutex, condState->sema, timeout, FALSE); - + //printf("+++ wait: awake (tid=%ld)\n", getThreadId()); - + // Reacquire lock to avoid race conditions. EnterCriticalSection(&condState->waitersCountLock); - + // No longer waiting. condState->waitersCount--; - + // Check to see if we're the last waiter after a broadcast. bool lastWaiter = (condState->wasBroadcast && condState->waitersCount == 0); - + //printf("+++ wait: lastWaiter=%d (wasBc=%d wc=%d)\n", // lastWaiter, condState->wasBroadcast, condState->waitersCount); - + LeaveCriticalSection(&condState->waitersCountLock); - + // If we're the last waiter thread during this particular broadcast // then signal broadcast() that we're all awake. It'll drop the // internal mutex. @@ -518,11 +514,11 @@ typedef struct WinCondition { // Grab the internal mutex. WaitForSingleObject(condState->internalMutex, INFINITE); } - + // Release the internal and grab the external. ReleaseMutex(condState->internalMutex); WaitForSingleObject(hMutex, INFINITE); - + return res == WAIT_OBJECT_0 ? NO_ERROR : -1; } } WinCondition; @@ -565,7 +561,7 @@ status_t Condition::wait(Mutex& mutex) { WinCondition* condState = (WinCondition*) mState; HANDLE hMutex = (HANDLE) mutex.mState; - + return ((WinCondition*)mState)->wait(condState, hMutex, NULL); } @@ -647,9 +643,7 @@ void Condition::broadcast() ReleaseMutex(condState->internalMutex); } -#else -#error "condition variables not supported on this platform" -#endif +#endif // !defined(_WIN32) // ---------------------------------------------------------------------------- @@ -692,7 +686,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack) mStatus = NO_ERROR; mExitPending = false; mThread = thread_id_t(-1); - + // hold a strong reference on ourself mHoldSelf = this; @@ -706,7 +700,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack) res = androidCreateRawThreadEtc(_threadLoop, this, name, priority, stack, &mThread); } - + if (res == false) { mStatus = UNKNOWN_ERROR; // something happened! mRunning = false; @@ -715,7 +709,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack) return UNKNOWN_ERROR; } - + // Do not refer to mStatus here: The thread is already running (may, in fact // already have exited with a valid mStatus result). The NO_ERROR indication // here merely indicates successfully starting the thread and does not @@ -779,14 +773,14 @@ int Thread::_threadLoop(void* user) break; } } - + // Release our strong reference, to let a chance to the thread // to die a peaceful death. strong.clear(); // And immediately, re-acquire a strong reference for the next loop strong = weak.promote(); } while(strong != 0); - + return 0; } @@ -807,7 +801,7 @@ status_t Thread::requestExitAndWait() return WOULD_BLOCK; } - + mExitPending = true; while (mRunning == true) { diff --git a/libutils/Timers.cpp b/libutils/Timers.cpp index 4687d4d..fb70e15 100644 --- a/libutils/Timers.cpp +++ b/libutils/Timers.cpp @@ -18,19 +18,10 @@ // Timer functions. // #include <utils/Timers.h> -#include <utils/Log.h> -#include <stdlib.h> -#include <stdio.h> -#include <unistd.h> +#include <limits.h> #include <sys/time.h> #include <time.h> -#include <errno.h> -#include <limits.h> - -#ifdef HAVE_WIN32_THREADS -#include <windows.h> -#endif #if defined(HAVE_ANDROID_OS) nsecs_t systemTime(int clock) diff --git a/libutils/misc.cpp b/libutils/misc.cpp index 58eb499..ed1ba23 100644 --- a/libutils/misc.cpp +++ b/libutils/misc.cpp @@ -27,7 +27,7 @@ #include <errno.h> #include <stdio.h> -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) # include <pthread.h> #endif @@ -42,13 +42,13 @@ struct sysprop_change_callback_info { int priority; }; -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) static pthread_mutex_t gSyspropMutex = PTHREAD_MUTEX_INITIALIZER; static Vector<sysprop_change_callback_info>* gSyspropList = NULL; #endif void add_sysprop_change_callback(sysprop_change_callback cb, int priority) { -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) pthread_mutex_lock(&gSyspropMutex); if (gSyspropList == NULL) { gSyspropList = new Vector<sysprop_change_callback_info>(); @@ -72,7 +72,7 @@ void add_sysprop_change_callback(sysprop_change_callback cb, int priority) { } void report_sysprop_change() { -#if defined(HAVE_PTHREADS) +#if !defined(_WIN32) pthread_mutex_lock(&gSyspropMutex); Vector<sysprop_change_callback_info> listeners; if (gSyspropList != NULL) { |