diff options
Diffstat (limited to 'libcutils')
-rw-r--r-- | libcutils/threads.c | 34 |
1 files changed, 16 insertions, 18 deletions
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) */ |