Index: thread.cpp =================================================================== --- thread.cpp (revision 76602) +++ thread.cpp (working copy) @@ -27,32 +27,33 @@ namespace { boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; - DWORD current_thread_tls_key=0; + #if defined(UNDER_CE) + // Windows CE does not define the TLS_OUT_OF_INDEXES constant. + DWORD tls_out_of_index=0xFFFFFFFF; + #else + DWORD tls_out_of_index=TLS_OUT_OF_INDEXES; + #endif + DWORD current_thread_tls_key=tls_out_of_index; void create_current_thread_tls_key() { tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in current_thread_tls_key=TlsAlloc(); - #if defined(UNDER_CE) - // Windows CE does not define the TLS_OUT_OF_INDEXES constant. - BOOST_ASSERT(current_thread_tls_key!=0xFFFFFFFF); - #else - BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES); - #endif + BOOST_ASSERT(current_thread_tls_key!=tls_out_of_index); } void cleanup_tls_key() { - if(current_thread_tls_key) + if(current_thread_tls_key!=tls_out_of_index) { TlsFree(current_thread_tls_key); - current_thread_tls_key=0; + current_thread_tls_key=tls_out_of_index; } } detail::thread_data_base* get_current_thread_data() { - if(!current_thread_tls_key) + if(current_thread_tls_key==tls_out_of_index) { return 0; } @@ -62,7 +63,7 @@ void set_current_thread_data(detail::thread_data_base* new_data) { boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); - if(current_thread_tls_key) + if(current_thread_tls_key!=tls_out_of_index) BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); else boost::throw_exception(thread_resource_error());