Ticket #4885: boost thread ticket4885.patch

File boost thread ticket4885.patch, 2.4 KB (added by Ulrich Eckhardt <ulrich.eckhardt@…>, 11 years ago)

patch

  • thread.cpp

     
    1010#include <boost/thread/thread.hpp>
    1111#include <algorithm>
    1212#ifndef UNDER_CE
    13 #include <process.h>
     13#  include <process.h>
     14   /* Several CE SDKs don't define this constant, and some only define it in
     15   kfuncs.h. Just define it here if it wasn't defined before. */
     16#  ifndef TLS_OUT_OF_INDEXES
     17#    define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
     18#  endif
    1419#endif
    1520#include <stdio.h>
    1621#include <boost/thread/once.hpp>
     
    2732    namespace
    2833    {
    2934        boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT;
    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;
     35        DWORD current_thread_tls_key=TLS_OUT_OF_INDEXES;
    3736
    3837        void create_current_thread_tls_key()
    3938        {
    4039            tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in
    4140            current_thread_tls_key=TlsAlloc();
    42             BOOST_ASSERT(current_thread_tls_key!=tls_out_of_index);
     41            BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES);
    4342        }
    4443
    4544        void cleanup_tls_key()
    4645        {
    47             if(current_thread_tls_key!=tls_out_of_index)
     46            if(current_thread_tls_key!=TLS_OUT_OF_INDEXES)
    4847            {
    4948                TlsFree(current_thread_tls_key);
    50                 current_thread_tls_key=tls_out_of_index;
     49                current_thread_tls_key=TLS_OUT_OF_INDEXES;
    5150            }
    5251        }
    5352
    5453        detail::thread_data_base* get_current_thread_data()
    5554        {
    56             if(current_thread_tls_key==tls_out_of_index)
     55            if(current_thread_tls_key==TLS_OUT_OF_INDEXES)
    5756            {
    5857                return 0;
    5958            }
     
    6362        void set_current_thread_data(detail::thread_data_base* new_data)
    6463        {
    6564            boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
    66             if(current_thread_tls_key!=tls_out_of_index)
     65            if(current_thread_tls_key!=TLS_OUT_OF_INDEXES)
    6766                BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data));
    6867            else
    6968                boost::throw_exception(thread_resource_error());