Skip to content

Commit f5bf095

Browse files
committed
Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.
1 parent 1fceaeb commit f5bf095

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

include/boost/thread/detail/thread.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@ namespace boost
601601
class BOOST_SYMBOL_VISIBLE thread::id
602602
{
603603
private:
604+
605+
#if !defined(BOOST_EMBTC)
606+
604607
friend inline
605608
std::size_t
606609
hash_value(const thread::id &v)
@@ -612,6 +615,14 @@ namespace boost
612615
#endif
613616
}
614617

618+
#else
619+
620+
friend
621+
std::size_t
622+
hash_value(const thread::id &v);
623+
624+
#endif
625+
615626
#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
616627
#if defined(BOOST_THREAD_PLATFORM_WIN32)
617628
typedef unsigned int data;
@@ -704,6 +715,21 @@ namespace boost
704715
#endif
705716
#endif
706717
};
718+
719+
#if defined(BOOST_EMBTC)
720+
721+
inline
722+
std::size_t
723+
hash_value(const thread::id &v)
724+
{
725+
#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
726+
return hash_value(v.thread_data);
727+
#else
728+
return hash_value(v.thread_data.get());
729+
#endif
730+
}
731+
732+
#endif
707733

708734
#ifdef BOOST_THREAD_PLATFORM_PTHREAD
709735
inline thread::id thread::get_id() const BOOST_NOEXCEPT

include/boost/thread/win32/thread_data.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ namespace boost
145145
{}
146146
virtual ~thread_data_base();
147147

148+
#if !defined(BOOST_EMBTC)
149+
148150
friend void intrusive_ptr_add_ref(thread_data_base * p)
149151
{
150152
BOOST_INTERLOCKED_INCREMENT(&p->count);
@@ -158,6 +160,13 @@ namespace boost
158160
}
159161
}
160162

163+
#else
164+
165+
friend void intrusive_ptr_add_ref(thread_data_base * p);
166+
friend void intrusive_ptr_release(thread_data_base * p);
167+
168+
#endif
169+
161170
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
162171
void interrupt()
163172
{
@@ -180,6 +189,24 @@ namespace boost
180189
}
181190
//#endif
182191
};
192+
193+
#if defined(BOOST_EMBTC)
194+
195+
inline void intrusive_ptr_add_ref(thread_data_base * p)
196+
{
197+
BOOST_INTERLOCKED_INCREMENT(&p->count);
198+
}
199+
200+
inline void intrusive_ptr_release(thread_data_base * p)
201+
{
202+
if(!BOOST_INTERLOCKED_DECREMENT(&p->count))
203+
{
204+
detail::heap_delete(p);
205+
}
206+
}
207+
208+
#endif
209+
183210
BOOST_THREAD_DECL thread_data_base* get_current_thread_data();
184211

185212
typedef boost::intrusive_ptr<detail::thread_data_base> thread_data_ptr;

0 commit comments

Comments
 (0)