Ticket #4885: 4885.patch

File 4885.patch, 2.1 KB (added by viboes, 11 years ago)

win32/pthread.cpp

  • thread.cpp

     
    2727    namespace
    2828    {
    2929        boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT;
    30         DWORD current_thread_tls_key=0;
     30        #if defined(UNDER_CE)
     31        // Windows CE does not define the TLS_OUT_OF_INDEXES constant.
     32        DWORD tls_out_of_index=0xFFFFFFFF;
     33        #else
     34        DWORD tls_out_of_index=TLS_OUT_OF_INDEXES;
     35        #endif
     36        DWORD current_thread_tls_key=tls_out_of_index;
    3137
    3238        void create_current_thread_tls_key()
    3339        {
    3440            tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in
    3541            current_thread_tls_key=TlsAlloc();
    36                         #if defined(UNDER_CE)
    37                                 // Windows CE does not define the TLS_OUT_OF_INDEXES constant.
    38                                 BOOST_ASSERT(current_thread_tls_key!=0xFFFFFFFF);
    39                         #else
    40                                 BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES);
    41                         #endif
     42            BOOST_ASSERT(current_thread_tls_key!=tls_out_of_index);
    4243        }
    4344
    4445        void cleanup_tls_key()
    4546        {
    46             if(current_thread_tls_key)
     47            if(current_thread_tls_key!=tls_out_of_index)
    4748            {
    4849                TlsFree(current_thread_tls_key);
    49                 current_thread_tls_key=0;
     50                current_thread_tls_key=tls_out_of_index;
    5051            }
    5152        }
    5253
    5354        detail::thread_data_base* get_current_thread_data()
    5455        {
    55             if(!current_thread_tls_key)
     56            if(current_thread_tls_key==tls_out_of_index)
    5657            {
    5758                return 0;
    5859            }
     
    6263        void set_current_thread_data(detail::thread_data_base* new_data)
    6364        {
    6465            boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
    65             if(current_thread_tls_key)
     66            if(current_thread_tls_key!=tls_out_of_index)
    6667                BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data));
    6768            else
    6869                boost::throw_exception(thread_resource_error());