summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adb/adb.c5
-rw-r--r--adb/commandline.c4
-rw-r--r--adb/sysdeps.h22
-rw-r--r--adb/sysdeps_win32.c16
-rw-r--r--adb/transport.c8
-rw-r--r--include/cutils/threads.h22
-rw-r--r--include/log/log.h6
-rw-r--r--include/log/logd.h15
-rw-r--r--include/utils/AndroidThreads.h2
-rw-r--r--include/utils/Condition.h8
-rw-r--r--include/utils/Mutex.h8
-rw-r--r--include/utils/RWLock.h6
-rw-r--r--include/utils/Thread.h2
-rw-r--r--libcutils/threads.c34
-rw-r--r--liblog/fake_log_device.c8
-rw-r--r--liblog/logd_write.c14
-rw-r--r--liblog/logd_write_kern.c21
-rw-r--r--libutils/Threads.cpp80
-rw-r--r--libutils/Timers.cpp11
-rw-r--r--libutils/misc.cpp8
20 files changed, 143 insertions, 157 deletions
diff --git a/adb/adb.c b/adb/adb.c
index 1834472fe..c939ef028 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -1125,10 +1125,11 @@ int launch_server(int server_port)
1125 1125
1126 /* get path of current program */ 1126 /* get path of current program */
1127 GetModuleFileName( NULL, program_path, sizeof(program_path) ); 1127 GetModuleFileName( NULL, program_path, sizeof(program_path) );
1128 1128 char args[64];
1129 snprintf(args, sizeof(args), "adb -P %d fork-server server", server_port);
1129 ret = CreateProcess( 1130 ret = CreateProcess(
1130 program_path, /* program path */ 1131 program_path, /* program path */
1131 "adb fork-server server", 1132 args,
1132 /* the fork-server argument will set the 1133 /* the fork-server argument will set the
1133 debug = 2 in the child */ 1134 debug = 2 in the child */
1134 NULL, /* process handle is not inheritable */ 1135 NULL, /* process handle is not inheritable */
diff --git a/adb/commandline.c b/adb/commandline.c
index 44541b7cc..a06885b3c 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -472,7 +472,7 @@ int adb_download_buffer(const char *service, const char *fn, const void* data, i
472 } 472 }
473 473
474 int opt = CHUNK_SIZE; 474 int opt = CHUNK_SIZE;
475 opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt)); 475 opt = adb_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt));
476 476
477 total = sz; 477 total = sz;
478 ptr = data; 478 ptr = data;
@@ -581,7 +581,7 @@ int adb_sideload_host(const char* fn) {
581 } 581 }
582 582
583 int opt = SIDELOAD_HOST_BLOCK_SIZE; 583 int opt = SIDELOAD_HOST_BLOCK_SIZE;
584 opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt)); 584 opt = adb_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt));
585 585
586 int last_percent = -1; 586 int last_percent = -1;
587 for (;;) { 587 for (;;) {
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index 304a61327..086dd61e9 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -89,8 +89,6 @@ static __inline__ void close_on_exec(int fd)
89 /* nothing really */ 89 /* nothing really */
90} 90}
91 91
92extern void disable_tcp_nagle(int fd);
93
94#define lstat stat /* no symlinks on Win32 */ 92#define lstat stat /* no symlinks on Win32 */
95 93
96#define S_ISLNK(m) 0 /* no symlinks on Win32 */ 94#define S_ISLNK(m) 0 /* no symlinks on Win32 */
@@ -210,10 +208,21 @@ extern int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t
210#undef accept 208#undef accept
211#define accept ___xxx_accept 209#define accept ___xxx_accept
212 210
211extern int adb_setsockopt(int fd, int level, int optname, const void* optval, socklen_t optlen);
212
213#undef setsockopt
214#define setsockopt ___xxx_setsockopt
215
213static __inline__ int adb_socket_setbufsize( int fd, int bufsize ) 216static __inline__ int adb_socket_setbufsize( int fd, int bufsize )
214{ 217{
215 int opt = bufsize; 218 int opt = bufsize;
216 return setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char*)&opt, sizeof(opt)); 219 return adb_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const void*)&opt, sizeof(opt));
220}
221
222static __inline__ void disable_tcp_nagle( int fd )
223{
224 int on = 1;
225 adb_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void*)&on, sizeof(on));
217} 226}
218 227
219extern int adb_socketpair( int sv[2] ); 228extern int adb_socketpair( int sv[2] );
@@ -450,6 +459,13 @@ static __inline__ void disable_tcp_nagle(int fd)
450 setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) ); 459 setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on) );
451} 460}
452 461
462static __inline__ int adb_setsockopt( int fd, int level, int optname, const void* optval, socklen_t optlen )
463{
464 return setsockopt( fd, level, optname, optval, optlen );
465}
466
467#undef setsockopt
468#define setsockopt ___xxx_setsockopt
453 469
454static __inline__ int unix_socketpair( int d, int type, int protocol, int sv[2] ) 470static __inline__ int unix_socketpair( int d, int type, int protocol, int sv[2] )
455{ 471{
diff --git a/adb/sysdeps_win32.c b/adb/sysdeps_win32.c
index e69ec2bbd..f132b8c6a 100644
--- a/adb/sysdeps_win32.c
+++ b/adb/sysdeps_win32.c
@@ -440,7 +440,8 @@ int adb_shutdown(int fd)
440{ 440{
441 FH f = _fh_from_int(fd); 441 FH f = _fh_from_int(fd);
442 442
443 if (!f) { 443 if (!f || f->clazz != &_fh_socket_class) {
444 D("adb_shutdown: invalid fd %d\n", fd);
444 return -1; 445 return -1;
445 } 446 }
446 447
@@ -471,6 +472,8 @@ int adb_close(int fd)
471/**************************************************************************/ 472/**************************************************************************/
472/**************************************************************************/ 473/**************************************************************************/
473 474
475#undef setsockopt
476
474static void 477static void
475_socket_set_errno( void ) 478_socket_set_errno( void )
476{ 479{
@@ -786,15 +789,16 @@ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrle
786} 789}
787 790
788 791
789void disable_tcp_nagle(int fd) 792int adb_setsockopt( int fd, int level, int optname, const void* optval, socklen_t optlen )
790{ 793{
791 FH fh = _fh_from_int(fd); 794 FH fh = _fh_from_int(fd);
792 int on = 1;
793 795
794 if ( !fh || fh->clazz != &_fh_socket_class ) 796 if ( !fh || fh->clazz != &_fh_socket_class ) {
795 return; 797 D("adb_setsockopt: invalid fd %d\n", fd);
798 return -1;
799 }
796 800
797 setsockopt( fh->fh_socket, IPPROTO_TCP, TCP_NODELAY, (const char*)&on, sizeof(on) ); 801 return setsockopt( fh->fh_socket, level, optname, optval, optlen );
798} 802}
799 803
800/**************************************************************************/ 804/**************************************************************************/
diff --git a/adb/transport.c b/adb/transport.c
index 7db6a4783..ffe59da22 100644
--- a/adb/transport.c
+++ b/adb/transport.c
@@ -1165,7 +1165,9 @@ int readx(int fd, void *ptr, size_t len)
1165 1165
1166#if ADB_TRACE 1166#if ADB_TRACE
1167 D("readx: fd=%d wanted=%zu got=%zu\n", fd, len0, len0 - len); 1167 D("readx: fd=%d wanted=%zu got=%zu\n", fd, len0, len0 - len);
1168 dump_hex( ptr, len0 ); 1168 if (ADB_TRACING) {
1169 dump_hex( ptr, len0 );
1170 }
1169#endif 1171#endif
1170 return 0; 1172 return 0;
1171} 1173}
@@ -1177,7 +1179,9 @@ int writex(int fd, const void *ptr, size_t len)
1177 1179
1178#if ADB_TRACE 1180#if ADB_TRACE
1179 D("writex: fd=%d len=%d: ", fd, (int)len); 1181 D("writex: fd=%d len=%d: ", fd, (int)len);
1180 dump_hex( ptr, len ); 1182 if (ADB_TRACING) {
1183 dump_hex( ptr, len );
1184 }
1181#endif 1185#endif
1182 while(len > 0) { 1186 while(len > 0) {
1183 r = adb_write(fd, p, len); 1187 r = adb_write(fd, p, len);
diff --git a/include/cutils/threads.h b/include/cutils/threads.h
index acf8f4843..ade9a0ce9 100644
--- a/include/cutils/threads.h
+++ b/include/cutils/threads.h
@@ -29,7 +29,7 @@ extern "C" {
29/***********************************************************************/ 29/***********************************************************************/
30/***********************************************************************/ 30/***********************************************************************/
31 31
32#ifdef HAVE_PTHREADS 32#if !defined(_WIN32)
33 33
34#include <pthread.h> 34#include <pthread.h>
35 35
@@ -42,7 +42,7 @@ typedef struct {
42 42
43#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } 43#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 }
44 44
45#elif defined HAVE_WIN32_THREADS 45#else // !defined(_WIN32)
46 46
47#include <windows.h> 47#include <windows.h>
48 48
@@ -56,15 +56,13 @@ typedef struct {
56 56
57#define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } 57#define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} }
58 58
59#else 59#endif // !defined(_WIN32)
60# error "no thread_store_t implementation for your platform !!"
61#endif
62 60
63typedef void (*thread_store_destruct_t)(void* value); 61typedef void (*thread_store_destruct_t)(void* value);
64 62
65extern void* thread_store_get(thread_store_t* store); 63extern void* thread_store_get(thread_store_t* store);
66 64
67extern void thread_store_set(thread_store_t* store, 65extern void thread_store_set(thread_store_t* store,
68 void* value, 66 void* value,
69 thread_store_destruct_t destroy); 67 thread_store_destruct_t destroy);
70 68
@@ -76,7 +74,7 @@ extern void thread_store_set(thread_store_t* store,
76/***********************************************************************/ 74/***********************************************************************/
77/***********************************************************************/ 75/***********************************************************************/
78 76
79#ifdef HAVE_PTHREADS 77#if !defined(_WIN32)
80 78
81typedef pthread_mutex_t mutex_t; 79typedef pthread_mutex_t mutex_t;
82 80
@@ -98,10 +96,10 @@ static __inline__ void mutex_destroy(mutex_t* lock)
98{ 96{
99 pthread_mutex_destroy(lock); 97 pthread_mutex_destroy(lock);
100} 98}
101#endif
102 99
103#ifdef HAVE_WIN32_THREADS 100#else // !defined(_WIN32)
104typedef struct { 101
102typedef struct {
105 int init; 103 int init;
106 CRITICAL_SECTION lock[1]; 104 CRITICAL_SECTION lock[1];
107} mutex_t; 105} mutex_t;
@@ -134,10 +132,10 @@ static __inline__ void mutex_destroy(mutex_t* lock)
134{ 132{
135 if (lock->init) { 133 if (lock->init) {
136 lock->init = 0; 134 lock->init = 0;
137 DeleteCriticalSection(lock->lock); 135 DeleteCriticalSection(lock->lock);
138 } 136 }
139} 137}
140#endif 138#endif // !defined(_WIN32)
141 139
142#ifdef __cplusplus 140#ifdef __cplusplus
143} 141}
diff --git a/include/log/log.h b/include/log/log.h
index ace12d631..3d8653336 100644
--- a/include/log/log.h
+++ b/include/log/log.h
@@ -28,14 +28,12 @@
28#ifndef _LIBS_LOG_LOG_H 28#ifndef _LIBS_LOG_LOG_H
29#define _LIBS_LOG_LOG_H 29#define _LIBS_LOG_LOG_H
30 30
31#include <sys/types.h>
32#ifdef HAVE_PTHREADS
33#include <pthread.h>
34#endif
35#include <stdarg.h> 31#include <stdarg.h>
36#include <stdio.h> 32#include <stdio.h>
33#include <sys/types.h>
37#include <time.h> 34#include <time.h>
38#include <unistd.h> 35#include <unistd.h>
36
39#include <log/logd.h> 37#include <log/logd.h>
40#include <log/uio.h> 38#include <log/uio.h>
41 39
diff --git a/include/log/logd.h b/include/log/logd.h
index 2e6f22005..0fe515f2a 100644
--- a/include/log/logd.h
+++ b/include/log/logd.h
@@ -23,16 +23,17 @@
23#include <android/log.h> 23#include <android/log.h>
24 24
25/* the rest is only used internally by the system */ 25/* the rest is only used internally by the system */
26#include <time.h> 26#if !defined(_WIN32)
27#include <stdio.h>
28#include <unistd.h>
29#include <stdint.h>
30#include <sys/types.h>
31#ifdef HAVE_PTHREADS
32#include <pthread.h> 27#include <pthread.h>
33#endif 28#endif
34#include <log/uio.h>
35#include <stdarg.h> 29#include <stdarg.h>
30#include <stdint.h>
31#include <stdio.h>
32#include <sys/types.h>
33#include <time.h>
34#include <unistd.h>
35
36#include <log/uio.h>
36 37
37#ifdef __cplusplus 38#ifdef __cplusplus
38extern "C" { 39extern "C" {
diff --git a/include/utils/AndroidThreads.h b/include/utils/AndroidThreads.h
index 3c640b6b6..aad1e82cb 100644
--- a/include/utils/AndroidThreads.h
+++ b/include/utils/AndroidThreads.h
@@ -20,7 +20,7 @@
20#include <stdint.h> 20#include <stdint.h>
21#include <sys/types.h> 21#include <sys/types.h>
22 22
23#if defined(HAVE_PTHREADS) 23#if !defined(_WIN32)
24# include <pthread.h> 24# include <pthread.h>
25#endif 25#endif
26 26
diff --git a/include/utils/Condition.h b/include/utils/Condition.h
index db9be595f..5a7251982 100644
--- a/include/utils/Condition.h
+++ b/include/utils/Condition.h
@@ -21,7 +21,7 @@
21#include <sys/types.h> 21#include <sys/types.h>
22#include <time.h> 22#include <time.h>
23 23
24#if defined(HAVE_PTHREADS) 24#if !defined(_WIN32)
25# include <pthread.h> 25# include <pthread.h>
26#endif 26#endif
27 27
@@ -74,7 +74,7 @@ public:
74 void broadcast(); 74 void broadcast();
75 75
76private: 76private:
77#if defined(HAVE_PTHREADS) 77#if !defined(_WIN32)
78 pthread_cond_t mCond; 78 pthread_cond_t mCond;
79#else 79#else
80 void* mState; 80 void* mState;
@@ -83,7 +83,7 @@ private:
83 83
84// --------------------------------------------------------------------------- 84// ---------------------------------------------------------------------------
85 85
86#if defined(HAVE_PTHREADS) 86#if !defined(_WIN32)
87 87
88inline Condition::Condition() { 88inline Condition::Condition() {
89 pthread_cond_init(&mCond, NULL); 89 pthread_cond_init(&mCond, NULL);
@@ -149,7 +149,7 @@ inline void Condition::broadcast() {
149 pthread_cond_broadcast(&mCond); 149 pthread_cond_broadcast(&mCond);
150} 150}
151 151
152#endif // HAVE_PTHREADS 152#endif // !defined(_WIN32)
153 153
154// --------------------------------------------------------------------------- 154// ---------------------------------------------------------------------------
155}; // namespace android 155}; // namespace android
diff --git a/include/utils/Mutex.h b/include/utils/Mutex.h
index a3b594d4c..757519b08 100644
--- a/include/utils/Mutex.h
+++ b/include/utils/Mutex.h
@@ -21,7 +21,7 @@
21#include <sys/types.h> 21#include <sys/types.h>
22#include <time.h> 22#include <time.h>
23 23
24#if defined(HAVE_PTHREADS) 24#if !defined(_WIN32)
25# include <pthread.h> 25# include <pthread.h>
26#endif 26#endif
27 27
@@ -87,7 +87,7 @@ private:
87 Mutex(const Mutex&); 87 Mutex(const Mutex&);
88 Mutex& operator = (const Mutex&); 88 Mutex& operator = (const Mutex&);
89 89
90#if defined(HAVE_PTHREADS) 90#if !defined(_WIN32)
91 pthread_mutex_t mMutex; 91 pthread_mutex_t mMutex;
92#else 92#else
93 void _init(); 93 void _init();
@@ -97,7 +97,7 @@ private:
97 97
98// --------------------------------------------------------------------------- 98// ---------------------------------------------------------------------------
99 99
100#if defined(HAVE_PTHREADS) 100#if !defined(_WIN32)
101 101
102inline Mutex::Mutex() { 102inline Mutex::Mutex() {
103 pthread_mutex_init(&mMutex, NULL); 103 pthread_mutex_init(&mMutex, NULL);
@@ -138,7 +138,7 @@ inline status_t Mutex::timedLock(nsecs_t timeoutNs) {
138} 138}
139#endif 139#endif
140 140
141#endif // HAVE_PTHREADS 141#endif // !defined(_WIN32)
142 142
143// --------------------------------------------------------------------------- 143// ---------------------------------------------------------------------------
144 144
diff --git a/include/utils/RWLock.h b/include/utils/RWLock.h
index 90beb5f4a..e743b1c8c 100644
--- a/include/utils/RWLock.h
+++ b/include/utils/RWLock.h
@@ -20,7 +20,7 @@
20#include <stdint.h> 20#include <stdint.h>
21#include <sys/types.h> 21#include <sys/types.h>
22 22
23#if defined(HAVE_PTHREADS) 23#if !defined(_WIN32)
24# include <pthread.h> 24# include <pthread.h>
25#endif 25#endif
26 26
@@ -31,7 +31,7 @@
31namespace android { 31namespace android {
32// --------------------------------------------------------------------------- 32// ---------------------------------------------------------------------------
33 33
34#if defined(HAVE_PTHREADS) 34#if !defined(_WIN32)
35 35
36/* 36/*
37 * Simple mutex class. The implementation is system-dependent. 37 * Simple mutex class. The implementation is system-dependent.
@@ -117,7 +117,7 @@ inline void RWLock::unlock() {
117 pthread_rwlock_unlock(&mRWLock); 117 pthread_rwlock_unlock(&mRWLock);
118} 118}
119 119
120#endif // HAVE_PTHREADS 120#endif // !defined(_WIN32)
121 121
122// --------------------------------------------------------------------------- 122// ---------------------------------------------------------------------------
123}; // namespace android 123}; // namespace android
diff --git a/include/utils/Thread.h b/include/utils/Thread.h
index c867e95a4..28839fded 100644
--- a/include/utils/Thread.h
+++ b/include/utils/Thread.h
@@ -21,7 +21,7 @@
21#include <sys/types.h> 21#include <sys/types.h>
22#include <time.h> 22#include <time.h>
23 23
24#if defined(HAVE_PTHREADS) 24#if !defined(_WIN32)
25# include <pthread.h> 25# include <pthread.h>
26#endif 26#endif
27 27
diff --git a/libcutils/threads.c b/libcutils/threads.c
index bf182f081..ca600b3b1 100644
--- a/libcutils/threads.c
+++ b/libcutils/threads.c
@@ -1,22 +1,22 @@
1/* 1/*
2** Copyright (C) 2007, The Android Open Source Project 2** Copyright (C) 2007, The Android Open Source Project
3** 3**
4** Licensed under the Apache License, Version 2.0 (the "License"); 4** Licensed under the Apache License, Version 2.0 (the "License");
5** you may not use this file except in compliance with the License. 5** you may not use this file except in compliance with the License.
6** You may obtain a copy of the License at 6** You may obtain a copy of the License at
7** 7**
8** http://www.apache.org/licenses/LICENSE-2.0 8** http://www.apache.org/licenses/LICENSE-2.0
9** 9**
10** Unless required by applicable law or agreed to in writing, software 10** Unless required by applicable law or agreed to in writing, software
11** distributed under the License is distributed on an "AS IS" BASIS, 11** distributed under the License is distributed on an "AS IS" BASIS,
12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** See the License for the specific language governing permissions and 13** See the License for the specific language governing permissions and
14** limitations under the License. 14** limitations under the License.
15*/ 15*/
16 16
17#include <cutils/threads.h> 17#include <cutils/threads.h>
18 18
19#ifdef HAVE_PTHREADS 19#if !defined(_WIN32)
20void* thread_store_get( thread_store_t* store ) 20void* thread_store_get( thread_store_t* store )
21{ 21{
22 if (!store->has_tls) 22 if (!store->has_tls)
@@ -24,8 +24,8 @@ void* thread_store_get( thread_store_t* store )
24 24
25 return pthread_getspecific( store->tls ); 25 return pthread_getspecific( store->tls );
26} 26}
27 27
28extern void thread_store_set( thread_store_t* store, 28extern void thread_store_set( thread_store_t* store,
29 void* value, 29 void* value,
30 thread_store_destruct_t destroy) 30 thread_store_destruct_t destroy)
31{ 31{
@@ -42,14 +42,12 @@ extern void thread_store_set( thread_store_t* store,
42 pthread_setspecific( store->tls, value ); 42 pthread_setspecific( store->tls, value );
43} 43}
44 44
45#endif 45#else /* !defined(_WIN32) */
46
47#ifdef HAVE_WIN32_THREADS
48void* thread_store_get( thread_store_t* store ) 46void* thread_store_get( thread_store_t* store )
49{ 47{
50 if (!store->has_tls) 48 if (!store->has_tls)
51 return NULL; 49 return NULL;
52 50
53 return (void*) TlsGetValue( store->tls ); 51 return (void*) TlsGetValue( store->tls );
54} 52}
55 53
@@ -65,7 +63,7 @@ void thread_store_set( thread_store_t* store,
65 } else while (store->lock_init != -2) { 63 } else while (store->lock_init != -2) {
66 Sleep(10); /* 10ms */ 64 Sleep(10); /* 10ms */
67 } 65 }
68 66
69 EnterCriticalSection( &store->lock ); 67 EnterCriticalSection( &store->lock );
70 if (!store->has_tls) { 68 if (!store->has_tls) {
71 store->tls = TlsAlloc(); 69 store->tls = TlsAlloc();
@@ -76,7 +74,7 @@ void thread_store_set( thread_store_t* store,
76 store->has_tls = 1; 74 store->has_tls = 1;
77 } 75 }
78 LeaveCriticalSection( &store->lock ); 76 LeaveCriticalSection( &store->lock );
79 77
80 TlsSetValue( store->tls, value ); 78 TlsSetValue( store->tls, value );
81} 79}
82#endif 80#endif /* !defined(_WIN32) */
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index 117e1547a..cf3dc500c 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -29,7 +29,7 @@
29 29
30#include <log/logd.h> 30#include <log/logd.h>
31 31
32#ifdef HAVE_PTHREADS 32#if !defined(_WIN32)
33#include <pthread.h> 33#include <pthread.h>
34#endif 34#endif
35 35
@@ -88,7 +88,7 @@ typedef struct LogState {
88} LogState; 88} LogState;
89 89
90 90
91#ifdef HAVE_PTHREADS 91#if !defined(_WIN32)
92/* 92/*
93 * Locking. Since we're emulating a device, we need to be prepared 93 * Locking. Since we're emulating a device, we need to be prepared
94 * to have multiple callers at the same time. This lock is used 94 * to have multiple callers at the same time. This lock is used
@@ -106,10 +106,10 @@ static void unlock()
106{ 106{
107 pthread_mutex_unlock(&fakeLogDeviceLock); 107 pthread_mutex_unlock(&fakeLogDeviceLock);
108} 108}
109#else // !HAVE_PTHREADS 109#else // !defined(_WIN32)
110#define lock() ((void)0) 110#define lock() ((void)0)
111#define unlock() ((void)0) 111#define unlock() ((void)0)
112#endif // !HAVE_PTHREADS 112#endif // !defined(_WIN32)
113 113
114 114
115/* 115/*
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index 1e9b59147..aaec619f3 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -15,7 +15,7 @@
15 */ 15 */
16#include <errno.h> 16#include <errno.h>
17#include <fcntl.h> 17#include <fcntl.h>
18#ifdef HAVE_PTHREADS 18#if !defined(_WIN32)
19#include <pthread.h> 19#include <pthread.h>
20#endif 20#endif
21#include <stdarg.h> 21#include <stdarg.h>
@@ -50,7 +50,7 @@
50 50
51static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr); 51static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr);
52static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init; 52static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init;
53#ifdef HAVE_PTHREADS 53#if !defined(_WIN32)
54static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; 54static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
55#endif 55#endif
56 56
@@ -259,11 +259,11 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr)
259 if (ret < 0) { 259 if (ret < 0) {
260 ret = -errno; 260 ret = -errno;
261 if (ret == -ENOTCONN) { 261 if (ret == -ENOTCONN) {
262#ifdef HAVE_PTHREADS 262#if !defined(_WIN32)
263 pthread_mutex_lock(&log_init_lock); 263 pthread_mutex_lock(&log_init_lock);
264#endif 264#endif
265 ret = __write_to_log_initialize(); 265 ret = __write_to_log_initialize();
266#ifdef HAVE_PTHREADS 266#if !defined(_WIN32)
267 pthread_mutex_unlock(&log_init_lock); 267 pthread_mutex_unlock(&log_init_lock);
268#endif 268#endif
269 269
@@ -306,7 +306,7 @@ const char *android_log_id_to_name(log_id_t log_id)
306 306
307static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) 307static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr)
308{ 308{
309#ifdef HAVE_PTHREADS 309#if !defined(_WIN32)
310 pthread_mutex_lock(&log_init_lock); 310 pthread_mutex_lock(&log_init_lock);
311#endif 311#endif
312 312
@@ -315,7 +315,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr)
315 315
316 ret = __write_to_log_initialize(); 316 ret = __write_to_log_initialize();
317 if (ret < 0) { 317 if (ret < 0) {
318#ifdef HAVE_PTHREADS 318#if !defined(_WIN32)
319 pthread_mutex_unlock(&log_init_lock); 319 pthread_mutex_unlock(&log_init_lock);
320#endif 320#endif
321 return ret; 321 return ret;
@@ -324,7 +324,7 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr)
324 write_to_log = __write_to_log_kernel; 324 write_to_log = __write_to_log_kernel;
325 } 325 }
326 326
327#ifdef HAVE_PTHREADS 327#if !defined(_WIN32)
328 pthread_mutex_unlock(&log_init_lock); 328 pthread_mutex_unlock(&log_init_lock);
329#endif 329#endif
330 330
diff --git a/liblog/logd_write_kern.c b/liblog/logd_write_kern.c
index ae621cb13..2ca3c94e7 100644
--- a/liblog/logd_write_kern.c
+++ b/liblog/logd_write_kern.c
@@ -16,9 +16,7 @@
16 16
17#include <errno.h> 17#include <errno.h>
18#include <fcntl.h> 18#include <fcntl.h>
19#ifdef HAVE_PTHREADS
20#include <pthread.h> 19#include <pthread.h>
21#endif
22#include <stdarg.h> 20#include <stdarg.h>
23#include <stdio.h> 21#include <stdio.h>
24#include <stdlib.h> 22#include <stdlib.h>
@@ -28,9 +26,7 @@
28#include <time.h> 26#include <time.h>
29#include <unistd.h> 27#include <unistd.h>
30 28
31#ifdef __BIONIC__
32#include <android/set_abort_message.h> 29#include <android/set_abort_message.h>
33#endif
34 30
35#include <log/log.h> 31#include <log/log.h>
36#include <log/logd.h> 32#include <log/logd.h>
@@ -43,23 +39,14 @@
43 39
44#define LOG_BUF_SIZE 1024 40#define LOG_BUF_SIZE 1024
45 41
46#if FAKE_LOG_DEVICE
47/* This will be defined when building for the host. */
48#include "fake_log_device.h"
49#define log_open(pathname, flags) fakeLogOpen(pathname, flags)
50#define log_writev(filedes, vector, count) fakeLogWritev(filedes, vector, count)
51#define log_close(filedes) fakeLogClose(filedes)
52#else
53#define log_open(pathname, flags) open(pathname, (flags) | O_CLOEXEC) 42#define log_open(pathname, flags) open(pathname, (flags) | O_CLOEXEC)
54#define log_writev(filedes, vector, count) writev(filedes, vector, count) 43#define log_writev(filedes, vector, count) writev(filedes, vector, count)
55#define log_close(filedes) close(filedes) 44#define log_close(filedes) close(filedes)
56#endif
57 45
58static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr); 46static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr);
59static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init; 47static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init;
60#ifdef HAVE_PTHREADS 48
61static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; 49static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
62#endif
63 50
64#ifndef __unused 51#ifndef __unused
65#define __unused __attribute__((__unused__)) 52#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)
119 106
120static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr) 107static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr)
121{ 108{
122#ifdef HAVE_PTHREADS
123 pthread_mutex_lock(&log_init_lock); 109 pthread_mutex_lock(&log_init_lock);
124#endif
125 110
126 if (write_to_log == __write_to_log_init) { 111 if (write_to_log == __write_to_log_init) {
127 log_fds[LOG_ID_MAIN] = log_open("/dev/"LOGGER_LOG_MAIN, O_WRONLY); 112 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)
147 } 132 }
148 } 133 }
149 134
150#ifdef HAVE_PTHREADS
151 pthread_mutex_unlock(&log_init_lock); 135 pthread_mutex_unlock(&log_init_lock);
152#endif
153 136
154 return write_to_log(log_id, vec, nr); 137 return write_to_log(log_id, vec, nr);
155} 138}
@@ -179,11 +162,9 @@ int __android_log_write(int prio, const char *tag, const char *msg)
179 tag = tmp_tag; 162 tag = tmp_tag;
180 } 163 }
181 164
182#if __BIONIC__
183 if (prio == ANDROID_LOG_FATAL) { 165 if (prio == ANDROID_LOG_FATAL) {
184 android_set_abort_message(msg); 166 android_set_abort_message(msg);
185 } 167 }
186#endif
187 168
188 vec[0].iov_base = (unsigned char *) &prio; 169 vec[0].iov_base = (unsigned char *) &prio;
189 vec[0].iov_len = 1; 170 vec[0].iov_len = 1;
diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp
index b2c690397..1e014c64e 100644
--- a/libutils/Threads.cpp
+++ b/libutils/Threads.cpp
@@ -24,11 +24,11 @@
24#include <stdlib.h> 24#include <stdlib.h>
25#include <unistd.h> 25#include <unistd.h>
26 26
27#if defined(HAVE_PTHREADS) 27#if !defined(_WIN32)
28# include <pthread.h> 28# include <pthread.h>
29# include <sched.h> 29# include <sched.h>
30# include <sys/resource.h> 30# include <sys/resource.h>
31#elif defined(HAVE_WIN32_THREADS) 31#else
32# include <windows.h> 32# include <windows.h>
33# include <stdint.h> 33# include <stdint.h>
34# include <process.h> 34# include <process.h>
@@ -59,7 +59,7 @@
59using namespace android; 59using namespace android;
60 60
61// ---------------------------------------------------------------------------- 61// ----------------------------------------------------------------------------
62#if defined(HAVE_PTHREADS) 62#if !defined(_WIN32)
63// ---------------------------------------------------------------------------- 63// ----------------------------------------------------------------------------
64 64
65/* 65/*
@@ -90,7 +90,7 @@ struct thread_data_t {
90 } else { 90 } else {
91 set_sched_policy(0, SP_FOREGROUND); 91 set_sched_policy(0, SP_FOREGROUND);
92 } 92 }
93 93
94 if (name) { 94 if (name) {
95 androidSetThreadName(name); 95 androidSetThreadName(name);
96 free(name); 96 free(name);
@@ -127,7 +127,7 @@ int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
127 size_t threadStackSize, 127 size_t threadStackSize,
128 android_thread_id_t *threadId) 128 android_thread_id_t *threadId)
129{ 129{
130 pthread_attr_t attr; 130 pthread_attr_t attr;
131 pthread_attr_init(&attr); 131 pthread_attr_init(&attr);
132 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 132 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
133 133
@@ -146,14 +146,14 @@ int androidCreateRawThreadEtc(android_thread_func_t entryFunction,
146 t->entryFunction = entryFunction; 146 t->entryFunction = entryFunction;
147 t->userData = userData; 147 t->userData = userData;
148 entryFunction = (android_thread_func_t)&thread_data_t::trampoline; 148 entryFunction = (android_thread_func_t)&thread_data_t::trampoline;
149 userData = t; 149 userData = t;
150 } 150 }
151#endif 151#endif
152 152
153 if (threadStackSize) { 153 if (threadStackSize) {
154 pthread_attr_setstacksize(&attr, threadStackSize); 154 pthread_attr_setstacksize(&attr, threadStackSize);
155 } 155 }
156 156
157 errno = 0; 157 errno = 0;
158 pthread_t thread; 158 pthread_t thread;
159 int result = pthread_create(&thread, &attr, 159 int result = pthread_create(&thread, &attr,
@@ -188,7 +188,7 @@ android_thread_id_t androidGetThreadId()
188} 188}
189 189
190// ---------------------------------------------------------------------------- 190// ----------------------------------------------------------------------------
191#elif defined(HAVE_WIN32_THREADS) 191#else // !defined(_WIN32)
192// ---------------------------------------------------------------------------- 192// ----------------------------------------------------------------------------
193 193
194/* 194/*
@@ -268,9 +268,7 @@ android_thread_id_t androidGetThreadId()
268} 268}
269 269
270// ---------------------------------------------------------------------------- 270// ----------------------------------------------------------------------------
271#else 271#endif // !defined(_WIN32)
272#error "Threads not supported"
273#endif
274 272
275// ---------------------------------------------------------------------------- 273// ----------------------------------------------------------------------------
276 274
@@ -307,8 +305,8 @@ void androidSetCreateThreadFunc(android_create_thread_fn func)
307int androidSetThreadPriority(pid_t tid, int pri) 305int androidSetThreadPriority(pid_t tid, int pri)
308{ 306{
309 int rc = 0; 307 int rc = 0;
310 308
311#if defined(HAVE_PTHREADS) 309#if !defined(_WIN32)
312 int lasterr = 0; 310 int lasterr = 0;
313 311
314 if (pri >= ANDROID_PRIORITY_BACKGROUND) { 312 if (pri >= ANDROID_PRIORITY_BACKGROUND) {
@@ -327,12 +325,12 @@ int androidSetThreadPriority(pid_t tid, int pri)
327 errno = lasterr; 325 errno = lasterr;
328 } 326 }
329#endif 327#endif
330 328
331 return rc; 329 return rc;
332} 330}
333 331
334int androidGetThreadPriority(pid_t tid) { 332int androidGetThreadPriority(pid_t tid) {
335#if defined(HAVE_PTHREADS) 333#if !defined(_WIN32)
336 return getpriority(PRIO_PROCESS, tid); 334 return getpriority(PRIO_PROCESS, tid);
337#else 335#else
338 return ANDROID_PRIORITY_NORMAL; 336 return ANDROID_PRIORITY_NORMAL;
@@ -349,9 +347,9 @@ namespace android {
349 * =========================================================================== 347 * ===========================================================================
350 */ 348 */
351 349
352#if defined(HAVE_PTHREADS) 350#if !defined(_WIN32)
353// implemented as inlines in threads.h 351// implemented as inlines in threads.h
354#elif defined(HAVE_WIN32_THREADS) 352#else
355 353
356Mutex::Mutex() 354Mutex::Mutex()
357{ 355{
@@ -413,9 +411,7 @@ status_t Mutex::tryLock()
413 return (dwWaitResult == WAIT_OBJECT_0) ? 0 : -1; 411 return (dwWaitResult == WAIT_OBJECT_0) ? 0 : -1;
414} 412}
415 413
416#else 414#endif // !defined(_WIN32)
417#error "Somebody forgot to implement threads for this platform."
418#endif
419 415
420 416
421/* 417/*
@@ -424,9 +420,9 @@ status_t Mutex::tryLock()
424 * =========================================================================== 420 * ===========================================================================
425 */ 421 */
426 422
427#if defined(HAVE_PTHREADS) 423#if !defined(_WIN32)
428// implemented as inlines in threads.h 424// implemented as inlines in threads.h
429#elif defined(HAVE_WIN32_THREADS) 425#else
430 426
431/* 427/*
432 * Windows doesn't have a condition variable solution. It's possible 428 * Windows doesn't have a condition variable solution. It's possible
@@ -474,7 +470,7 @@ typedef struct WinCondition {
474 //printf("+++ wait: incr waitersCount to %d (tid=%ld)\n", 470 //printf("+++ wait: incr waitersCount to %d (tid=%ld)\n",
475 // condState->waitersCount, getThreadId()); 471 // condState->waitersCount, getThreadId());
476 LeaveCriticalSection(&condState->waitersCountLock); 472 LeaveCriticalSection(&condState->waitersCountLock);
477 473
478 DWORD timeout = INFINITE; 474 DWORD timeout = INFINITE;
479 if (abstime) { 475 if (abstime) {
480 nsecs_t reltime = *abstime - systemTime(); 476 nsecs_t reltime = *abstime - systemTime();
@@ -482,27 +478,27 @@ typedef struct WinCondition {
482 reltime = 0; 478 reltime = 0;
483 timeout = reltime/1000000; 479 timeout = reltime/1000000;
484 } 480 }
485 481
486 // Atomically release the external mutex and wait on the semaphore. 482 // Atomically release the external mutex and wait on the semaphore.
487 DWORD res = 483 DWORD res =
488 SignalObjectAndWait(hMutex, condState->sema, timeout, FALSE); 484 SignalObjectAndWait(hMutex, condState->sema, timeout, FALSE);
489 485
490 //printf("+++ wait: awake (tid=%ld)\n", getThreadId()); 486 //printf("+++ wait: awake (tid=%ld)\n", getThreadId());
491 487
492 // Reacquire lock to avoid race conditions. 488 // Reacquire lock to avoid race conditions.
493 EnterCriticalSection(&condState->waitersCountLock); 489 EnterCriticalSection(&condState->waitersCountLock);
494 490
495 // No longer waiting. 491 // No longer waiting.
496 condState->waitersCount--; 492 condState->waitersCount--;
497 493
498 // Check to see if we're the last waiter after a broadcast. 494 // Check to see if we're the last waiter after a broadcast.
499 bool lastWaiter = (condState->wasBroadcast && condState->waitersCount == 0); 495 bool lastWaiter = (condState->wasBroadcast && condState->waitersCount == 0);
500 496
501 //printf("+++ wait: lastWaiter=%d (wasBc=%d wc=%d)\n", 497 //printf("+++ wait: lastWaiter=%d (wasBc=%d wc=%d)\n",
502 // lastWaiter, condState->wasBroadcast, condState->waitersCount); 498 // lastWaiter, condState->wasBroadcast, condState->waitersCount);
503 499
504 LeaveCriticalSection(&condState->waitersCountLock); 500 LeaveCriticalSection(&condState->waitersCountLock);
505 501
506 // If we're the last waiter thread during this particular broadcast 502 // If we're the last waiter thread during this particular broadcast
507 // then signal broadcast() that we're all awake. It'll drop the 503 // then signal broadcast() that we're all awake. It'll drop the
508 // internal mutex. 504 // internal mutex.
@@ -518,11 +514,11 @@ typedef struct WinCondition {
518 // Grab the internal mutex. 514 // Grab the internal mutex.
519 WaitForSingleObject(condState->internalMutex, INFINITE); 515 WaitForSingleObject(condState->internalMutex, INFINITE);
520 } 516 }
521 517
522 // Release the internal and grab the external. 518 // Release the internal and grab the external.
523 ReleaseMutex(condState->internalMutex); 519 ReleaseMutex(condState->internalMutex);
524 WaitForSingleObject(hMutex, INFINITE); 520 WaitForSingleObject(hMutex, INFINITE);
525 521
526 return res == WAIT_OBJECT_0 ? NO_ERROR : -1; 522 return res == WAIT_OBJECT_0 ? NO_ERROR : -1;
527 } 523 }
528} WinCondition; 524} WinCondition;
@@ -565,7 +561,7 @@ status_t Condition::wait(Mutex& mutex)
565{ 561{
566 WinCondition* condState = (WinCondition*) mState; 562 WinCondition* condState = (WinCondition*) mState;
567 HANDLE hMutex = (HANDLE) mutex.mState; 563 HANDLE hMutex = (HANDLE) mutex.mState;
568 564
569 return ((WinCondition*)mState)->wait(condState, hMutex, NULL); 565 return ((WinCondition*)mState)->wait(condState, hMutex, NULL);
570} 566}
571 567
@@ -647,9 +643,7 @@ void Condition::broadcast()
647 ReleaseMutex(condState->internalMutex); 643 ReleaseMutex(condState->internalMutex);
648} 644}
649 645
650#else 646#endif // !defined(_WIN32)
651#error "condition variables not supported on this platform"
652#endif
653 647
654// ---------------------------------------------------------------------------- 648// ----------------------------------------------------------------------------
655 649
@@ -692,7 +686,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack)
692 mStatus = NO_ERROR; 686 mStatus = NO_ERROR;
693 mExitPending = false; 687 mExitPending = false;
694 mThread = thread_id_t(-1); 688 mThread = thread_id_t(-1);
695 689
696 // hold a strong reference on ourself 690 // hold a strong reference on ourself
697 mHoldSelf = this; 691 mHoldSelf = this;
698 692
@@ -706,7 +700,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack)
706 res = androidCreateRawThreadEtc(_threadLoop, 700 res = androidCreateRawThreadEtc(_threadLoop,
707 this, name, priority, stack, &mThread); 701 this, name, priority, stack, &mThread);
708 } 702 }
709 703
710 if (res == false) { 704 if (res == false) {
711 mStatus = UNKNOWN_ERROR; // something happened! 705 mStatus = UNKNOWN_ERROR; // something happened!
712 mRunning = false; 706 mRunning = false;
@@ -715,7 +709,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack)
715 709
716 return UNKNOWN_ERROR; 710 return UNKNOWN_ERROR;
717 } 711 }
718 712
719 // Do not refer to mStatus here: The thread is already running (may, in fact 713 // Do not refer to mStatus here: The thread is already running (may, in fact
720 // already have exited with a valid mStatus result). The NO_ERROR indication 714 // already have exited with a valid mStatus result). The NO_ERROR indication
721 // here merely indicates successfully starting the thread and does not 715 // here merely indicates successfully starting the thread and does not
@@ -779,14 +773,14 @@ int Thread::_threadLoop(void* user)
779 break; 773 break;
780 } 774 }
781 } 775 }
782 776
783 // Release our strong reference, to let a chance to the thread 777 // Release our strong reference, to let a chance to the thread
784 // to die a peaceful death. 778 // to die a peaceful death.
785 strong.clear(); 779 strong.clear();
786 // And immediately, re-acquire a strong reference for the next loop 780 // And immediately, re-acquire a strong reference for the next loop
787 strong = weak.promote(); 781 strong = weak.promote();
788 } while(strong != 0); 782 } while(strong != 0);
789 783
790 return 0; 784 return 0;
791} 785}
792 786
@@ -807,7 +801,7 @@ status_t Thread::requestExitAndWait()
807 801
808 return WOULD_BLOCK; 802 return WOULD_BLOCK;
809 } 803 }
810 804
811 mExitPending = true; 805 mExitPending = true;
812 806
813 while (mRunning == true) { 807 while (mRunning == true) {
diff --git a/libutils/Timers.cpp b/libutils/Timers.cpp
index 4687d4d59..fb70e1588 100644
--- a/libutils/Timers.cpp
+++ b/libutils/Timers.cpp
@@ -18,19 +18,10 @@
18// Timer functions. 18// Timer functions.
19// 19//
20#include <utils/Timers.h> 20#include <utils/Timers.h>
21#include <utils/Log.h>
22 21
23#include <stdlib.h> 22#include <limits.h>
24#include <stdio.h>
25#include <unistd.h>
26#include <sys/time.h> 23#include <sys/time.h>
27#include <time.h> 24#include <time.h>
28#include <errno.h>
29#include <limits.h>
30
31#ifdef HAVE_WIN32_THREADS
32#include <windows.h>
33#endif
34 25
35#if defined(HAVE_ANDROID_OS) 26#if defined(HAVE_ANDROID_OS)
36nsecs_t systemTime(int clock) 27nsecs_t systemTime(int clock)
diff --git a/libutils/misc.cpp b/libutils/misc.cpp
index 58eb49901..ed1ba2392 100644
--- a/libutils/misc.cpp
+++ b/libutils/misc.cpp
@@ -27,7 +27,7 @@
27#include <errno.h> 27#include <errno.h>
28#include <stdio.h> 28#include <stdio.h>
29 29
30#if defined(HAVE_PTHREADS) 30#if !defined(_WIN32)
31# include <pthread.h> 31# include <pthread.h>
32#endif 32#endif
33 33
@@ -42,13 +42,13 @@ struct sysprop_change_callback_info {
42 int priority; 42 int priority;
43}; 43};
44 44
45#if defined(HAVE_PTHREADS) 45#if !defined(_WIN32)
46static pthread_mutex_t gSyspropMutex = PTHREAD_MUTEX_INITIALIZER; 46static pthread_mutex_t gSyspropMutex = PTHREAD_MUTEX_INITIALIZER;
47static Vector<sysprop_change_callback_info>* gSyspropList = NULL; 47static Vector<sysprop_change_callback_info>* gSyspropList = NULL;
48#endif 48#endif
49 49
50void add_sysprop_change_callback(sysprop_change_callback cb, int priority) { 50void add_sysprop_change_callback(sysprop_change_callback cb, int priority) {
51#if defined(HAVE_PTHREADS) 51#if !defined(_WIN32)
52 pthread_mutex_lock(&gSyspropMutex); 52 pthread_mutex_lock(&gSyspropMutex);
53 if (gSyspropList == NULL) { 53 if (gSyspropList == NULL) {
54 gSyspropList = new Vector<sysprop_change_callback_info>(); 54 gSyspropList = new Vector<sysprop_change_callback_info>();
@@ -72,7 +72,7 @@ void add_sysprop_change_callback(sysprop_change_callback cb, int priority) {
72} 72}
73 73
74void report_sysprop_change() { 74void report_sysprop_change() {
75#if defined(HAVE_PTHREADS) 75#if !defined(_WIN32)
76 pthread_mutex_lock(&gSyspropMutex); 76 pthread_mutex_lock(&gSyspropMutex);
77 Vector<sysprop_change_callback_info> listeners; 77 Vector<sysprop_change_callback_info> listeners;
78 if (gSyspropList != NULL) { 78 if (gSyspropList != NULL) {