| flow_graph.h | | flow_graph.h | |
| | | | |
| skipping to change at line 1959 | | skipping to change at line 1959 | |
| // template for tag_matching join_node | | // template for tag_matching join_node | |
| template<typename OutputTuple> | | template<typename OutputTuple> | |
| class join_node<OutputTuple, tag_matching> : public internal::unfolded_join
_node<tbb::flow::tuple_size<OutputTuple>::value, | | class join_node<OutputTuple, tag_matching> : public internal::unfolded_join
_node<tbb::flow::tuple_size<OutputTuple>::value, | |
| tag_matching_port, OutputTuple, tag_matching> { | | tag_matching_port, OutputTuple, tag_matching> { | |
| private: | | private: | |
| static const int N = tbb::flow::tuple_size<OutputTuple>::value; | | static const int N = tbb::flow::tuple_size<OutputTuple>::value; | |
| typedef typename internal::unfolded_join_node<N, tag_matching_port, Out
putTuple, tag_matching> unfolded_type; | | typedef typename internal::unfolded_join_node<N, tag_matching_port, Out
putTuple, tag_matching> unfolded_type; | |
| public: | | public: | |
| typedef OutputTuple output_type; | | typedef OutputTuple output_type; | |
| typedef typename unfolded_type::input_ports_type input_ports_type; | | typedef typename unfolded_type::input_ports_type input_ports_type; | |
|
| template<typename B0, typename B1> | | template<typename __TBB_B0, typename __TBB_B1> | |
| join_node(graph &g, B0 b0, B1 b1) : unfolded_type(g, b0, b1) { } | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1) : unfolded_type(g, b0, b1 | |
| template<typename B0, typename B1, typename B2> | | ) { } | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2) : unfolded_type(g, b0, b1, b2) | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2> | |
| { } | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2) : unfolded_t | |
| template<typename B0, typename B1, typename B2, typename B3> | | ype(g, b0, b1, b2) { } | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2, B3 b3) : unfolded_type(g, b0, | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2, typen | |
| b1, b2, b3) { } | | ame __TBB_B3> | |
| template<typename B0, typename B1, typename B2, typename B3, typename B | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3) | |
| 4> | | : unfolded_type(g, b0, b1, b2, b3) { } | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) : unfolded_type( | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2, typen | |
| g, b0, b1, b2, b3, b4) { } | | ame __TBB_B3, typename __TBB_B4> | |
| | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, | |
| | | __TBB_B4 b4) : | |
| | | unfolded_type(g, b0, b1, b2, b3, b4) { } | |
| #if __TBB_VARIADIC_MAX >= 6 | | #if __TBB_VARIADIC_MAX >= 6 | |
|
| template<typename B0, typename B1, typename B2, typename B3, typename B | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2, typen | |
| 4, typename B5> | | ame __TBB_B3, typename __TBB_B4, | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4, B5 b5) : unfolde | | typename __TBB_B5> | |
| d_type(g, b0, b1, b2, b3, b4, b5) { } | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, | |
| | | __TBB_B4 b4, __TBB_B5 b5) : | |
| | | unfolded_type(g, b0, b1, b2, b3, b4, b5) { } | |
| #endif | | #endif | |
| #if __TBB_VARIADIC_MAX >= 7 | | #if __TBB_VARIADIC_MAX >= 7 | |
|
| template<typename B0, typename B1, typename B2, typename B3, typename B | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2, typen | |
| 4, typename B5, typename B6> | | ame __TBB_B3, typename __TBB_B4, | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6) : | | typename __TBB_B5, typename __TBB_B6> | |
| unfolded_type(g, b0, b1, b2, b3, b4, b5, b6) { } | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, | |
| | | __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6) : | |
| | | unfolded_type(g, b0, b1, b2, b3, b4, b5, b6) { } | |
| #endif | | #endif | |
| #if __TBB_VARIADIC_MAX >= 8 | | #if __TBB_VARIADIC_MAX >= 8 | |
|
| template<typename B0, typename B1, typename B2, typename B3, typename B | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2, typen | |
| 4, typename B5, typename B6, typename B7> | | ame __TBB_B3, typename __TBB_B4, | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6, B7 | | typename __TBB_B5, typename __TBB_B6, typename __TBB_B7> | |
| b7) : unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7) { } | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, | |
| | | __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6, | |
| | | __TBB_B7 b7) : unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7) | |
| | | { } | |
| #endif | | #endif | |
| #if __TBB_VARIADIC_MAX >= 9 | | #if __TBB_VARIADIC_MAX >= 9 | |
|
| template<typename B0, typename B1, typename B2, typename B3, typename B | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2, typen | |
| 4, typename B5, typename B6, typename B7, typename B8> | | ame __TBB_B3, typename __TBB_B4, | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6, B7 | | typename __TBB_B5, typename __TBB_B6, typename __TBB_B7, typename _ | |
| b7, B8 b8) : unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7, b8) { } | | _TBB_B8> | |
| | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, | |
| | | __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6, | |
| | | __TBB_B7 b7, __TBB_B8 b8) : unfolded_type(g, b0, b1, b2, b3, b4 | |
| | | , b5, b6, b7, b8) { } | |
| #endif | | #endif | |
| #if __TBB_VARIADIC_MAX >= 10 | | #if __TBB_VARIADIC_MAX >= 10 | |
|
| template<typename B0, typename B1, typename B2, typename B3, typename B | | template<typename __TBB_B0, typename __TBB_B1, typename __TBB_B2, typen | |
| 4, typename B5, typename B6, typename B7, typename B8, typename B9> | | ame __TBB_B3, typename __TBB_B4, | |
| join_node(graph &g, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4, B5 b5, B6 b6, B7 | | typename __TBB_B5, typename __TBB_B6, typename __TBB_B7, typename _ | |
| b7, B8 b8, B9 b9) : unfolded_type(g, b0, b1, b2, b3, b4, b5, b6, b7, b8, b | | _TBB_B8, typename __TBB_B9> | |
| 9) { } | | join_node(graph &g, __TBB_B0 b0, __TBB_B1 b1, __TBB_B2 b2, __TBB_B3 b3, | |
| | | __TBB_B4 b4, __TBB_B5 b5, __TBB_B6 b6, | |
| | | __TBB_B7 b7, __TBB_B8 b8, __TBB_B9 b9) : unfolded_type(g, b0, b | |
| | | 1, b2, b3, b4, b5, b6, b7, b8, b9) { } | |
| #endif | | #endif | |
| join_node(const join_node &other) : unfolded_type(other) {} | | join_node(const join_node &other) : unfolded_type(other) {} | |
| }; | | }; | |
| | | | |
| #if TBB_PREVIEW_GRAPH_NODES | | #if TBB_PREVIEW_GRAPH_NODES | |
| // or node | | // or node | |
| #include "internal/_flow_graph_or_impl.h" | | #include "internal/_flow_graph_or_impl.h" | |
| | | | |
| template<typename InputTuple> | | template<typename InputTuple> | |
| class or_node : public internal::unfolded_or_node<InputTuple> { | | class or_node : public internal::unfolded_or_node<InputTuple> { | |
| | | | |
End of changes. 6 change blocks. |
| 33 lines changed or deleted | | 50 lines changed or added | |
|
| tbb_machine.h | | tbb_machine.h | |
| | | | |
| skipping to change at line 108 | | skipping to change at line 108 | |
| | | | |
| __TBB_machine_<op><S><fence>(...), where | | __TBB_machine_<op><S><fence>(...), where | |
| <op> = {cmpswp, fetchadd, fetchstore} | | <op> = {cmpswp, fetchadd, fetchstore} | |
| <S> = {1, 2, 4, 8} | | <S> = {1, 2, 4, 8} | |
| <fence> = {full_fence, acquire, release, relaxed} | | <fence> = {full_fence, acquire, release, relaxed} | |
| Must be provided if __TBB_USE_FENCED_ATOMICS is set. | | Must be provided if __TBB_USE_FENCED_ATOMICS is set. | |
| | | | |
| __TBB_control_consistency_helper() | | __TBB_control_consistency_helper() | |
| Bridges the memory-semantics gap between architectures providing on
ly | | Bridges the memory-semantics gap between architectures providing on
ly | |
| implicit C++0x "consume" semantics (like Power Architecture) and th
ose | | implicit C++0x "consume" semantics (like Power Architecture) and th
ose | |
|
| also implicitly obeying control dependencies (like IA-64). | | also implicitly obeying control dependencies (like IA-64 architectu
re). | |
| It must be used only in conditional code where the condition is its
elf | | It must be used only in conditional code where the condition is its
elf | |
| data-dependent, and will then make subsequent code behave as if the | | data-dependent, and will then make subsequent code behave as if the | |
| original data dependency were acquired. | | original data dependency were acquired. | |
| It needs only a compiler fence where implied by the architecture | | It needs only a compiler fence where implied by the architecture | |
|
| either specifically (like IA-64) or because generally stronger "acq | | either specifically (like IA-64 architecture) or because generally | |
| uire" | | stronger | |
| semantics are enforced (like x86). | | "acquire" semantics are enforced (like x86). | |
| It is always valid, though potentially suboptimal, to replace | | It is always valid, though potentially suboptimal, to replace | |
| control with acquire on the load and then remove the helper. | | control with acquire on the load and then remove the helper. | |
| | | | |
| __TBB_acquire_consistency_helper(), __TBB_release_consistency_helper() | | __TBB_acquire_consistency_helper(), __TBB_release_consistency_helper() | |
| Must be provided if __TBB_USE_GENERIC_HALF_FENCED_LOAD_STORE is set
. | | Must be provided if __TBB_USE_GENERIC_HALF_FENCED_LOAD_STORE is set
. | |
| Enforce acquire and release semantics in generic implementations of
fenced | | Enforce acquire and release semantics in generic implementations of
fenced | |
| store and load operations. Depending on the particular architecture
/compiler | | store and load operations. Depending on the particular architecture
/compiler | |
| combination they may be a hardware fence, a compiler fence, both or
nothing. | | combination they may be a hardware fence, a compiler fence, both or
nothing. | |
| **/ | | **/ | |
| | | | |
| | | | |
| skipping to change at line 363 | | skipping to change at line 363 | |
| | | | |
| //! Class that implements exponential backoff. | | //! Class that implements exponential backoff. | |
| /** See implementation of spin_wait_while_eq for an example. */ | | /** See implementation of spin_wait_while_eq for an example. */ | |
| class atomic_backoff : no_copy { | | class atomic_backoff : no_copy { | |
| //! Time delay, in units of "pause" instructions. | | //! Time delay, in units of "pause" instructions. | |
| /** Should be equal to approximately the number of "pause" instructions | | /** Should be equal to approximately the number of "pause" instructions | |
| that take the same time as an context switch. */ | | that take the same time as an context switch. */ | |
| static const int32_t LOOPS_BEFORE_YIELD = 16; | | static const int32_t LOOPS_BEFORE_YIELD = 16; | |
| int32_t count; | | int32_t count; | |
| public: | | public: | |
|
| | | // In many cases, an object of this type is initialized eagerly on hot | |
| | | path, | |
| | | // as in for(atomic_backoff b; ; b.pause()) { /*loop body*/ } | |
| | | // For this reason, the construction cost must be very small! | |
| atomic_backoff() : count(1) {} | | atomic_backoff() : count(1) {} | |
|
| | | // This constructor pauses immediately; do not use on hot paths! | |
| | | atomic_backoff( bool ) : count(1) { pause(); } | |
| | | | |
| //! Pause for a while. | | //! Pause for a while. | |
| void pause() { | | void pause() { | |
| if( count<=LOOPS_BEFORE_YIELD ) { | | if( count<=LOOPS_BEFORE_YIELD ) { | |
| __TBB_Pause(count); | | __TBB_Pause(count); | |
| // Pause twice as long the next time. | | // Pause twice as long the next time. | |
| count*=2; | | count*=2; | |
| } else { | | } else { | |
| // Pause is so long that we might as well yield CPU to schedule
r. | | // Pause is so long that we might as well yield CPU to schedule
r. | |
| __TBB_Yield(); | | __TBB_Yield(); | |
| | | | |
| skipping to change at line 454 | | skipping to change at line 459 | |
| const uint32_t byte_offset = (uint32_t) ((uintptr_t)ptr & 0x
3); | | const uint32_t byte_offset = (uint32_t) ((uintptr_t)ptr & 0x
3); | |
| volatile uint32_t * const aligned_ptr = (uint32_t*)((uintptr_t)ptr - by
te_offset ); | | volatile uint32_t * const aligned_ptr = (uint32_t*)((uintptr_t)ptr - by
te_offset ); | |
| | | | |
| // location of T within uint32_t for a C++ shift operation | | // location of T within uint32_t for a C++ shift operation | |
| const uint32_t bits_to_shift = 8*(endianness::is_big_endian() ? (4
- sizeof(T) - (byte_offset)) : byte_offset); | | const uint32_t bits_to_shift = 8*(endianness::is_big_endian() ? (4
- sizeof(T) - (byte_offset)) : byte_offset); | |
| const uint32_t mask = (((uint32_t)1<<(sizeof(T)*8)) - 1 )<
<bits_to_shift; | | const uint32_t mask = (((uint32_t)1<<(sizeof(T)*8)) - 1 )<
<bits_to_shift; | |
| // for signed T, any sign extension bits in cast value/comparand are im
mediately clipped by mask | | // for signed T, any sign extension bits in cast value/comparand are im
mediately clipped by mask | |
| const uint32_t shifted_comparand = ((uint32_t)comparand << bits_to_shif
t)&mask; | | const uint32_t shifted_comparand = ((uint32_t)comparand << bits_to_shif
t)&mask; | |
| const uint32_t shifted_value = ((uint32_t)value << bits_to_shif
t)&mask; | | const uint32_t shifted_value = ((uint32_t)value << bits_to_shif
t)&mask; | |
| | | | |
|
| for(atomic_backoff b;;b.pause()) { | | for( atomic_backoff b;;b.pause() ) { | |
| const uint32_t surroundings = *aligned_ptr & ~mask ; // may have c
hanged during the pause | | const uint32_t surroundings = *aligned_ptr & ~mask ; // may have c
hanged during the pause | |
| const uint32_t big_comparand = surroundings | shifted_comparand ; | | const uint32_t big_comparand = surroundings | shifted_comparand ; | |
| const uint32_t big_value = surroundings | shifted_value ; | | const uint32_t big_value = surroundings | shifted_value ; | |
| // __TBB_machine_cmpswp4 presumed to have full fence. | | // __TBB_machine_cmpswp4 presumed to have full fence. | |
| // Cast shuts up /Wp64 warning | | // Cast shuts up /Wp64 warning | |
| const uint32_t big_result = (uint32_t)__TBB_machine_cmpswp4( aligne
d_ptr, big_value, big_comparand ); | | const uint32_t big_result = (uint32_t)__TBB_machine_cmpswp4( aligne
d_ptr, big_value, big_comparand ); | |
| if( big_result == big_comparand // CAS succeeded | | if( big_result == big_comparand // CAS succeeded | |
| || ((big_result ^ big_comparand) & mask) != 0) // CAS failed an
d the bits of interest have changed | | || ((big_result ^ big_comparand) & mask) != 0) // CAS failed an
d the bits of interest have changed | |
| { | | { | |
| return T((big_result & mask) >> bits_to_shift); | | return T((big_result & mask) >> bits_to_shift); | |
| | | | |
| skipping to change at line 508 | | skipping to change at line 513 | |
| | | | |
| #if __TBB_64BIT_ATOMICS | | #if __TBB_64BIT_ATOMICS | |
| template<> | | template<> | |
| inline uint64_t __TBB_CompareAndSwapGeneric <8,uint64_t> (volatile void *pt
r, uint64_t value, uint64_t comparand ) { | | inline uint64_t __TBB_CompareAndSwapGeneric <8,uint64_t> (volatile void *pt
r, uint64_t value, uint64_t comparand ) { | |
| return __TBB_machine_cmpswp8(ptr,value,comparand); | | return __TBB_machine_cmpswp8(ptr,value,comparand); | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| template<size_t S, typename T> | | template<size_t S, typename T> | |
| inline T __TBB_FetchAndAddGeneric (volatile void *ptr, T addend) { | | inline T __TBB_FetchAndAddGeneric (volatile void *ptr, T addend) { | |
|
| atomic_backoff b; | | | |
| T result; | | T result; | |
|
| for(;;) { | | for( atomic_backoff b;;b.pause() ) { | |
| result = *reinterpret_cast<volatile T *>(ptr); | | result = *reinterpret_cast<volatile T *>(ptr); | |
| // __TBB_CompareAndSwapGeneric presumed to have full fence. | | // __TBB_CompareAndSwapGeneric presumed to have full fence. | |
| if( __TBB_CompareAndSwapGeneric<S,T> ( ptr, result+addend, result )
==result ) | | if( __TBB_CompareAndSwapGeneric<S,T> ( ptr, result+addend, result )
==result ) | |
| break; | | break; | |
|
| b.pause(); | | | |
| } | | } | |
| return result; | | return result; | |
| } | | } | |
| | | | |
| template<size_t S, typename T> | | template<size_t S, typename T> | |
| inline T __TBB_FetchAndStoreGeneric (volatile void *ptr, T value) { | | inline T __TBB_FetchAndStoreGeneric (volatile void *ptr, T value) { | |
|
| atomic_backoff b; | | | |
| T result; | | T result; | |
|
| for(;;) { | | for( atomic_backoff b;;b.pause() ) { | |
| result = *reinterpret_cast<volatile T *>(ptr); | | result = *reinterpret_cast<volatile T *>(ptr); | |
| // __TBB_CompareAndSwapGeneric presumed to have full fence. | | // __TBB_CompareAndSwapGeneric presumed to have full fence. | |
| if( __TBB_CompareAndSwapGeneric<S,T> ( ptr, value, result )==result
) | | if( __TBB_CompareAndSwapGeneric<S,T> ( ptr, value, result )==result
) | |
| break; | | break; | |
|
| b.pause(); | | | |
| } | | } | |
| return result; | | return result; | |
| } | | } | |
| | | | |
| #if __TBB_USE_GENERIC_PART_WORD_CAS | | #if __TBB_USE_GENERIC_PART_WORD_CAS | |
| #define __TBB_machine_cmpswp1 tbb::internal::__TBB_CompareAndSwapGeneric<1,
uint8_t> | | #define __TBB_machine_cmpswp1 tbb::internal::__TBB_CompareAndSwapGeneric<1,
uint8_t> | |
| #define __TBB_machine_cmpswp2 tbb::internal::__TBB_CompareAndSwapGeneric<2,
uint16_t> | | #define __TBB_machine_cmpswp2 tbb::internal::__TBB_CompareAndSwapGeneric<2,
uint16_t> | |
| #endif | | #endif | |
| | | | |
| #if __TBB_USE_GENERIC_FETCH_ADD || __TBB_USE_GENERIC_PART_WORD_FETCH_ADD | | #if __TBB_USE_GENERIC_FETCH_ADD || __TBB_USE_GENERIC_PART_WORD_FETCH_ADD | |
| | | | |
| skipping to change at line 866 | | skipping to change at line 867 | |
| if( uintptr_t tmp = x>>8 ) { x=tmp; result += 8; } | | if( uintptr_t tmp = x>>8 ) { x=tmp; result += 8; } | |
| if( uintptr_t tmp = x>>4 ) { x=tmp; result += 4; } | | if( uintptr_t tmp = x>>4 ) { x=tmp; result += 4; } | |
| if( uintptr_t tmp = x>>2 ) { x=tmp; result += 2; } | | if( uintptr_t tmp = x>>2 ) { x=tmp; result += 2; } | |
| | | | |
| return (x&2)? result+1: result; | | return (x&2)? result+1: result; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #ifndef __TBB_AtomicOR | | #ifndef __TBB_AtomicOR | |
| inline void __TBB_AtomicOR( volatile void *operand, uintptr_t addend ) { | | inline void __TBB_AtomicOR( volatile void *operand, uintptr_t addend ) { | |
|
| tbb::internal::atomic_backoff b; | | for( tbb::internal::atomic_backoff b;;b.pause() ) { | |
| for(;;) { | | | |
| uintptr_t tmp = *(volatile uintptr_t *)operand; | | uintptr_t tmp = *(volatile uintptr_t *)operand; | |
| uintptr_t result = __TBB_CompareAndSwapW(operand, tmp|addend, tmp); | | uintptr_t result = __TBB_CompareAndSwapW(operand, tmp|addend, tmp); | |
| if( result==tmp ) break; | | if( result==tmp ) break; | |
|
| b.pause(); | | | |
| } | | } | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #ifndef __TBB_AtomicAND | | #ifndef __TBB_AtomicAND | |
| inline void __TBB_AtomicAND( volatile void *operand, uintptr_t addend ) { | | inline void __TBB_AtomicAND( volatile void *operand, uintptr_t addend ) { | |
|
| tbb::internal::atomic_backoff b; | | for( tbb::internal::atomic_backoff b;;b.pause() ) { | |
| for(;;) { | | | |
| uintptr_t tmp = *(volatile uintptr_t *)operand; | | uintptr_t tmp = *(volatile uintptr_t *)operand; | |
| uintptr_t result = __TBB_CompareAndSwapW(operand, tmp&addend, tmp); | | uintptr_t result = __TBB_CompareAndSwapW(operand, tmp&addend, tmp); | |
| if( result==tmp ) break; | | if( result==tmp ) break; | |
|
| b.pause(); | | | |
| } | | } | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #if __TBB_PREFETCHING | | #if __TBB_PREFETCHING | |
| #ifndef __TBB_cl_prefetch | | #ifndef __TBB_cl_prefetch | |
| #error This platform does not define cache management primitives required f
or __TBB_PREFETCHING | | #error This platform does not define cache management primitives required f
or __TBB_PREFETCHING | |
| #endif | | #endif | |
| | | | |
| #ifndef __TBB_cl_evict | | #ifndef __TBB_cl_evict | |
| | | | |
| skipping to change at line 911 | | skipping to change at line 908 | |
| typedef __TBB_atomic __TBB_Flag __TBB_atomic_flag; | | typedef __TBB_atomic __TBB_Flag __TBB_atomic_flag; | |
| | | | |
| #ifndef __TBB_TryLockByte | | #ifndef __TBB_TryLockByte | |
| inline bool __TBB_TryLockByte( __TBB_atomic_flag &flag ) { | | inline bool __TBB_TryLockByte( __TBB_atomic_flag &flag ) { | |
| return __TBB_machine_cmpswp1(&flag,1,0)==0; | | return __TBB_machine_cmpswp1(&flag,1,0)==0; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #ifndef __TBB_LockByte | | #ifndef __TBB_LockByte | |
| inline __TBB_Flag __TBB_LockByte( __TBB_atomic_flag& flag ) { | | inline __TBB_Flag __TBB_LockByte( __TBB_atomic_flag& flag ) { | |
|
| if ( !__TBB_TryLockByte(flag) ) { | | tbb::internal::atomic_backoff backoff; | |
| tbb::internal::atomic_backoff b; | | while( !__TBB_TryLockByte(flag) ) backoff.pause(); | |
| do { | | | |
| b.pause(); | | | |
| } while ( !__TBB_TryLockByte(flag) ); | | | |
| } | | | |
| return 0; | | return 0; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #ifndef __TBB_UnlockByte | | #ifndef __TBB_UnlockByte | |
| #define __TBB_UnlockByte(addr) __TBB_store_with_release((addr),0) | | #define __TBB_UnlockByte(addr) __TBB_store_with_release((addr),0) | |
| #endif | | #endif | |
| | | | |
| #ifndef __TBB_ReverseByte | | #ifndef __TBB_ReverseByte | |
| inline unsigned char __TBB_ReverseByte(unsigned char src) { | | inline unsigned char __TBB_ReverseByte(unsigned char src) { | |
| | | | |
End of changes. 16 change blocks. |
| 23 lines changed or deleted | | 17 lines changed or added | |
|
| tuple | | tuple | |
| | | | |
| skipping to change at line 49 | | skipping to change at line 49 | |
| #define __TBB_U_PACK | | #define __TBB_U_PACK | |
| #define __TBB_TYPENAME_T_PACK | | #define __TBB_TYPENAME_T_PACK | |
| #define __TBB_TYPENAME_U_PACK | | #define __TBB_TYPENAME_U_PACK | |
| #define __TBB_NULL_TYPE_PACK | | #define __TBB_NULL_TYPE_PACK | |
| #define __TBB_REF_T_PARAM_PACK | | #define __TBB_REF_T_PARAM_PACK | |
| #define __TBB_CONST_REF_T_PARAM_PACK | | #define __TBB_CONST_REF_T_PARAM_PACK | |
| #define __TBB_T_PARAM_LIST_PACK | | #define __TBB_T_PARAM_LIST_PACK | |
| #define __TBB_CONST_NULL_REF_PACK | | #define __TBB_CONST_NULL_REF_PACK | |
| // | | // | |
| #elif __TBB_VARIADIC_MAX == 6 | | #elif __TBB_VARIADIC_MAX == 6 | |
|
| #define __TBB_T_PACK ,T5 | | #define __TBB_T_PACK ,__T5 | |
| #define __TBB_U_PACK ,U5 | | #define __TBB_U_PACK ,__U5 | |
| #define __TBB_TYPENAME_T_PACK , typename T5 | | #define __TBB_TYPENAME_T_PACK , typename __T5 | |
| #define __TBB_TYPENAME_U_PACK , typename U5 | | #define __TBB_TYPENAME_U_PACK , typename __U5 | |
| #define __TBB_NULL_TYPE_PACK , null_type | | #define __TBB_NULL_TYPE_PACK , null_type | |
|
| #define __TBB_REF_T_PARAM_PACK ,T5& t5 | | #define __TBB_REF_T_PARAM_PACK ,__T5& t5 | |
| #define __TBB_CONST_REF_T_PARAM_PACK ,const T5& t5 | | #define __TBB_CONST_REF_T_PARAM_PACK ,const __T5& t5 | |
| #define __TBB_T_PARAM_LIST_PACK ,t5 | | #define __TBB_T_PARAM_LIST_PACK ,t5 | |
| #define __TBB_CONST_NULL_REF_PACK , const null_type& | | #define __TBB_CONST_NULL_REF_PACK , const null_type& | |
| // | | // | |
| #elif __TBB_VARIADIC_MAX == 7 | | #elif __TBB_VARIADIC_MAX == 7 | |
|
| #define __TBB_T_PACK ,T5, T6 | | #define __TBB_T_PACK ,__T5, __T6 | |
| #define __TBB_U_PACK ,U5, U6 | | #define __TBB_U_PACK ,__U5, __U6 | |
| #define __TBB_TYPENAME_T_PACK , typename T5 , typename T6 | | #define __TBB_TYPENAME_T_PACK , typename __T5 , typename __T6 | |
| #define __TBB_TYPENAME_U_PACK , typename U5 , typename U6 | | #define __TBB_TYPENAME_U_PACK , typename __U5 , typename __U6 | |
| #define __TBB_NULL_TYPE_PACK , null_type, null_type | | #define __TBB_NULL_TYPE_PACK , null_type, null_type | |
|
| #define __TBB_REF_T_PARAM_PACK ,T5& t5, T6& t6 | | #define __TBB_REF_T_PARAM_PACK ,__T5& t5, __T6& t6 | |
| #define __TBB_CONST_REF_T_PARAM_PACK ,const T5& t5, const T6& t6 | | #define __TBB_CONST_REF_T_PARAM_PACK ,const __T5& t5, const __T6& t6 | |
| #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 | | #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 | |
| #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type& | | #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type& | |
| // | | // | |
| #elif __TBB_VARIADIC_MAX == 8 | | #elif __TBB_VARIADIC_MAX == 8 | |
|
| #define __TBB_T_PACK ,T5, T6, T7 | | #define __TBB_T_PACK ,__T5, __T6, __T7 | |
| #define __TBB_U_PACK ,U5, U6, U7 | | #define __TBB_U_PACK ,__U5, __U6, __U7 | |
| #define __TBB_TYPENAME_T_PACK , typename T5 , typename T6, typename T7 | | #define __TBB_TYPENAME_T_PACK , typename __T5 , typename __T6, typename __T | |
| #define __TBB_TYPENAME_U_PACK , typename U5 , typename U6, typename U7 | | 7 | |
| | | #define __TBB_TYPENAME_U_PACK , typename __U5 , typename __U6, typename __U | |
| | | 7 | |
| #define __TBB_NULL_TYPE_PACK , null_type, null_type, null_type | | #define __TBB_NULL_TYPE_PACK , null_type, null_type, null_type | |
|
| #define __TBB_REF_T_PARAM_PACK ,T5& t5, T6& t6, T7& t7 | | #define __TBB_REF_T_PARAM_PACK ,__T5& t5, __T6& t6, __T7& t7 | |
| #define __TBB_CONST_REF_T_PARAM_PACK , const T5& t5, const T6& t6, const T7 | | #define __TBB_CONST_REF_T_PARAM_PACK , const __T5& t5, const __T6& t6, cons | |
| & t7 | | t __T7& t7 | |
| #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 ,t7 | | #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 ,t7 | |
| #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type&, con
st null_type& | | #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type&, con
st null_type& | |
| // | | // | |
| #elif __TBB_VARIADIC_MAX == 9 | | #elif __TBB_VARIADIC_MAX == 9 | |
|
| #define __TBB_T_PACK ,T5, T6, T7, T8 | | #define __TBB_T_PACK ,__T5, __T6, __T7, __T8 | |
| #define __TBB_U_PACK ,U5, U6, U7, U8 | | #define __TBB_U_PACK ,__U5, __U6, __U7, __U8 | |
| #define __TBB_TYPENAME_T_PACK , typename T5, typename T6, typename T7, type | | #define __TBB_TYPENAME_T_PACK , typename __T5, typename __T6, typename __T7 | |
| name T8 | | , typename __T8 | |
| #define __TBB_TYPENAME_U_PACK , typename U5, typename U6, typename U7, type | | #define __TBB_TYPENAME_U_PACK , typename __U5, typename __U6, typename __U7 | |
| name U8 | | , typename __U8 | |
| #define __TBB_NULL_TYPE_PACK , null_type, null_type, null_type, null_type | | #define __TBB_NULL_TYPE_PACK , null_type, null_type, null_type, null_type | |
|
| #define __TBB_REF_T_PARAM_PACK ,T5& t5, T6& t6, T7& t7, T8& t8 | | #define __TBB_REF_T_PARAM_PACK ,__T5& t5, __T6& t6, __T7& t7, __T8& t8 | |
| #define __TBB_CONST_REF_T_PARAM_PACK , const T5& t5, const T6& t6, const T7 | | #define __TBB_CONST_REF_T_PARAM_PACK , const __T5& t5, const __T6& t6, cons | |
| & t7, const T8& t8 | | t __T7& t7, const __T8& t8 | |
| #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 ,t7 ,t8 | | #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 ,t7 ,t8 | |
| #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type&, con
st null_type&, const null_type& | | #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type&, con
st null_type&, const null_type& | |
| // | | // | |
| #elif __TBB_VARIADIC_MAX >= 10 | | #elif __TBB_VARIADIC_MAX >= 10 | |
|
| #define __TBB_T_PACK ,T5, T6, T7, T8, T9 | | #define __TBB_T_PACK ,__T5, __T6, __T7, __T8, __T9 | |
| #define __TBB_U_PACK ,U5, U6, U7, U8, U9 | | #define __TBB_U_PACK ,__U5, __U6, __U7, __U8, __U9 | |
| #define __TBB_TYPENAME_T_PACK , typename T5, typename T6, typename T7, type | | #define __TBB_TYPENAME_T_PACK , typename __T5, typename __T6, typename __T7 | |
| name T8, typename T9 | | , typename __T8, typename __T9 | |
| #define __TBB_TYPENAME_U_PACK , typename U5, typename U6, typename U7, type | | #define __TBB_TYPENAME_U_PACK , typename __U5, typename __U6, typename __U7 | |
| name U8, typename U9 | | , typename __U8, typename __U9 | |
| #define __TBB_NULL_TYPE_PACK , null_type, null_type, null_type, null_type,
null_type | | #define __TBB_NULL_TYPE_PACK , null_type, null_type, null_type, null_type,
null_type | |
|
| #define __TBB_REF_T_PARAM_PACK ,T5& t5, T6& t6, T7& t7, T8& t8, T9& t9 | | #define __TBB_REF_T_PARAM_PACK ,__T5& t5, __T6& t6, __T7& t7, __T8& t8, __T | |
| #define __TBB_CONST_REF_T_PARAM_PACK , const T5& t5, const T6& t6, const T7 | | 9& t9 | |
| & t7, const T8& t8, const T9& t9 | | #define __TBB_CONST_REF_T_PARAM_PACK , const __T5& t5, const __T6& t6, cons | |
| | | t __T7& t7, const __T8& t8, const __T9& t9 | |
| #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 ,t7 ,t8 ,t9 | | #define __TBB_T_PARAM_LIST_PACK ,t5 ,t6 ,t7 ,t8 ,t9 | |
| #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type&, con
st null_type&, const null_type&, const null_type& | | #define __TBB_CONST_NULL_REF_PACK , const null_type&, const null_type&, con
st null_type&, const null_type&, const null_type& | |
| #endif | | #endif | |
| | | | |
| namespace tbb { | | namespace tbb { | |
| namespace interface5 { | | namespace interface5 { | |
| | | | |
| namespace internal { | | namespace internal { | |
| struct null_type { }; | | struct null_type { }; | |
| } | | } | |
| using internal::null_type; | | using internal::null_type; | |
| | | | |
| // tuple forward declaration | | // tuple forward declaration | |
|
| template <typename T0=null_type, typename T1=null_type, typename T2=null_ty | | template <typename __T0=null_type, typename __T1=null_type, typename __T2=n | |
| pe, | | ull_type, | |
| typename T3=null_type, typename T4=null_type | | typename __T3=null_type, typename __T4=null_type | |
| #if __TBB_VARIADIC_MAX >= 6 | | #if __TBB_VARIADIC_MAX >= 6 | |
|
| , typename T5=null_type | | , typename __T5=null_type | |
| #if __TBB_VARIADIC_MAX >= 7 | | #if __TBB_VARIADIC_MAX >= 7 | |
|
| , typename T6=null_type | | , typename __T6=null_type | |
| #if __TBB_VARIADIC_MAX >= 8 | | #if __TBB_VARIADIC_MAX >= 8 | |
|
| , typename T7=null_type | | , typename __T7=null_type | |
| #if __TBB_VARIADIC_MAX >= 9 | | #if __TBB_VARIADIC_MAX >= 9 | |
|
| , typename T8=null_type | | , typename __T8=null_type | |
| #if __TBB_VARIADIC_MAX >= 10 | | #if __TBB_VARIADIC_MAX >= 10 | |
|
| , typename T9=null_type | | , typename __T9=null_type | |
| #endif | | #endif | |
| #endif | | #endif | |
| #endif | | #endif | |
| #endif | | #endif | |
| #endif | | #endif | |
| > | | > | |
| class tuple; | | class tuple; | |
| | | | |
| namespace internal { | | namespace internal { | |
| | | | |
| // const null_type temp | | // const null_type temp | |
| inline const null_type cnull() { return null_type(); } | | inline const null_type cnull() { return null_type(); } | |
| | | | |
| // cons forward declaration | | // cons forward declaration | |
|
| template <typename HT, typename TT> struct cons; | | template <typename __HT, typename __TT> struct cons; | |
| | | | |
| // type of a component of the cons | | // type of a component of the cons | |
|
| template<int N, typename T> | | template<int __N, typename __T> | |
| struct component { | | struct component { | |
|
| typedef typename T::tail_type next; | | typedef typename __T::tail_type next; | |
| typedef typename component<N-1,next>::type type; | | typedef typename component<__N-1,next>::type type; | |
| }; | | }; | |
| | | | |
|
| template<typename T> | | template<typename __T> | |
| struct component<0,T> { | | struct component<0,__T> { | |
| typedef typename T::head_type type; | | typedef typename __T::head_type type; | |
| }; | | }; | |
| | | | |
| template<> | | template<> | |
| struct component<0,null_type> { | | struct component<0,null_type> { | |
| typedef null_type type; | | typedef null_type type; | |
| }; | | }; | |
| | | | |
| // const version of component | | // const version of component | |
| | | | |
|
| template<int N, typename T> | | template<int __N, typename __T> | |
| struct component<N, const T> | | struct component<__N, const __T> | |
| { | | { | |
|
| typedef typename T::tail_type next; | | typedef typename __T::tail_type next; | |
| typedef const typename component<N-1,next>::type type; | | typedef const typename component<__N-1,next>::type type; | |
| }; | | }; | |
| | | | |
|
| template<typename T> | | template<typename __T> | |
| struct component<0, const T> | | struct component<0, const __T> | |
| { | | { | |
|
| typedef const typename T::head_type type; | | typedef const typename __T::head_type type; | |
| }; | | }; | |
| | | | |
| // helper class for getting components of cons | | // helper class for getting components of cons | |
|
| template< int N> | | template< int __N> | |
| struct get_helper { | | struct get_helper { | |
|
| template<typename HT, typename TT> | | template<typename __HT, typename __TT> | |
| inline static typename component<N, cons<HT,TT> >::type& get(cons<HT,TT>& t | | inline static typename component<__N, cons<__HT,__TT> >::type& get(cons<__H | |
| i) { | | T,__TT>& ti) { | |
| return get_helper<N-1>::get(ti.tail); | | return get_helper<__N-1>::get(ti.tail); | |
| } | | } | |
|
| template<typename HT, typename TT> | | template<typename __HT, typename __TT> | |
| inline static typename component<N, cons<HT,TT> >::type const& get(const co | | inline static typename component<__N, cons<__HT,__TT> >::type const& get(co | |
| ns<HT,TT>& ti) { | | nst cons<__HT,__TT>& ti) { | |
| return get_helper<N-1>::get(ti.tail); | | return get_helper<__N-1>::get(ti.tail); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template<> | | template<> | |
| struct get_helper<0> { | | struct get_helper<0> { | |
|
| template<typename HT, typename TT> | | template<typename __HT, typename __TT> | |
| inline static typename component<0, cons<HT,TT> >::type& get(cons<HT,TT>& t | | inline static typename component<0, cons<__HT,__TT> >::type& get(cons<__HT, | |
| i) { | | __TT>& ti) { | |
| return ti.head; | | return ti.head; | |
| } | | } | |
|
| template<typename HT, typename TT> | | template<typename __HT, typename __TT> | |
| inline static typename component<0, cons<HT,TT> >::type const& get(const co | | inline static typename component<0, cons<__HT,__TT> >::type const& get(cons | |
| ns<HT,TT>& ti) { | | t cons<__HT,__TT>& ti) { | |
| return ti.head; | | return ti.head; | |
| } | | } | |
| }; | | }; | |
| | | | |
| // traits adaptor | | // traits adaptor | |
|
| template <typename T0, typename T1, typename T2, typename T3, typename T4 _
_TBB_TYPENAME_T_PACK> | | template <typename __T0, typename __T1, typename __T2, typename __T3, typen
ame __T4 __TBB_TYPENAME_T_PACK> | |
| struct tuple_traits { | | struct tuple_traits { | |
|
| typedef cons <T0, typename tuple_traits<T1, T2, T3, T4 __TBB_T_PACK , n
ull_type>::U > U; | | typedef cons <__T0, typename tuple_traits<__T1, __T2, __T3, __T4 __TBB_
T_PACK , null_type>::U > U; | |
| }; | | }; | |
| | | | |
|
| template <typename T0> | | template <typename __T0> | |
| struct tuple_traits<T0, null_type, null_type, null_type, null_type __TBB_NU | | struct tuple_traits<__T0, null_type, null_type, null_type, null_type __TBB_ | |
| LL_TYPE_PACK > { | | NULL_TYPE_PACK > { | |
| typedef cons<T0, null_type> U; | | typedef cons<__T0, null_type> U; | |
| }; | | }; | |
| | | | |
| template<> | | template<> | |
| struct tuple_traits<null_type, null_type, null_type, null_type, null_type _
_TBB_NULL_TYPE_PACK > { | | struct tuple_traits<null_type, null_type, null_type, null_type, null_type _
_TBB_NULL_TYPE_PACK > { | |
| typedef null_type U; | | typedef null_type U; | |
| }; | | }; | |
| | | | |
| // core cons defs | | // core cons defs | |
|
| template <typename HT, typename TT> | | template <typename __HT, typename __TT> | |
| struct cons{ | | struct cons{ | |
| | | | |
|
| typedef HT head_type; | | typedef __HT head_type; | |
| typedef TT tail_type; | | typedef __TT tail_type; | |
| | | | |
| head_type head; | | head_type head; | |
| tail_type tail; | | tail_type tail; | |
| | | | |
| static const int length = 1 + tail_type::length; | | static const int length = 1 + tail_type::length; | |
| | | | |
| // default constructors | | // default constructors | |
| explicit cons() : head(), tail() { } | | explicit cons() : head(), tail() { } | |
| | | | |
| // non-default constructors | | // non-default constructors | |
| cons(head_type& h, const tail_type& t) : head(h), tail(t) { } | | cons(head_type& h, const tail_type& t) : head(h), tail(t) { } | |
| | | | |
|
| template <typename T0, typename T1, typename T2, typename T3, typename | | template <typename __T0, typename __T1, typename __T2, typename __T3, t | |
| T4 __TBB_TYPENAME_T_PACK > | | ypename __T4 __TBB_TYPENAME_T_PACK > | |
| cons(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& | | cons(const __T0& t0, const __T1& t1, const __T2& t2, const __T3& t3, co | |
| t4 __TBB_CONST_REF_T_PARAM_PACK) : | | nst __T4& t4 __TBB_CONST_REF_T_PARAM_PACK) : | |
| head(t0), tail(t1, t2, t3, t4 __TBB_T_PARAM_LIST_PACK, cnull()) { } | | head(t0), tail(t1, t2, t3, t4 __TBB_T_PARAM_LIST_PACK, cnull()) { } | |
| | | | |
|
| template <typename T0, typename T1, typename T2, typename T3, typename | | template <typename __T0, typename __T1, typename __T2, typename __T3, t | |
| T4 __TBB_TYPENAME_T_PACK > | | ypename __T4 __TBB_TYPENAME_T_PACK > | |
| cons(T0& t0, T1& t1, T2& t2, T3& t3, T4& t4 __TBB_REF_T_PARAM_PACK) : | | cons(__T0& t0, __T1& t1, __T2& t2, __T3& t3, __T4& t4 __TBB_REF_T_PARAM | |
| | | _PACK) : | |
| head(t0), tail(t1, t2, t3, t4 __TBB_T_PARAM_LIST_PACK , cnull()) {
} | | head(t0), tail(t1, t2, t3, t4 __TBB_T_PARAM_LIST_PACK , cnull()) {
} | |
| | | | |
|
| template <typename HT1, typename TT1> | | template <typename __HT1, typename __TT1> | |
| cons(const cons<HT1,TT1>& other) : head(other.head), tail(other.tail) { | | cons(const cons<__HT1,__TT1>& other) : head(other.head), tail(other.tai | |
| } | | l) { } | |
| | | | |
| cons& operator=(const cons& other) { head = other.head; tail = other.ta
il; return *this; } | | cons& operator=(const cons& other) { head = other.head; tail = other.ta
il; return *this; } | |
| | | | |
| friend bool operator==(const cons& me, const cons& other) { | | friend bool operator==(const cons& me, const cons& other) { | |
| return me.head == other.head && me.tail == other.tail; | | return me.head == other.head && me.tail == other.tail; | |
| } | | } | |
| friend bool operator<(const cons& me, const cons& other) { | | friend bool operator<(const cons& me, const cons& other) { | |
| return me.head < other.head || (!(other.head < me.head) && me.tail
< other.tail); | | return me.head < other.head || (!(other.head < me.head) && me.tail
< other.tail); | |
| } | | } | |
| friend bool operator>(const cons& me, const cons& other) { return othe
r<me; } | | friend bool operator>(const cons& me, const cons& other) { return othe
r<me; } | |
| friend bool operator!=(const cons& me, const cons& other) { return !(me
==other); } | | friend bool operator!=(const cons& me, const cons& other) { return !(me
==other); } | |
| friend bool operator>=(const cons& me, const cons& other) { return !(me
<other); } | | friend bool operator>=(const cons& me, const cons& other) { return !(me
<other); } | |
| friend bool operator<=(const cons& me, const cons& other) { return !(me
>other); } | | friend bool operator<=(const cons& me, const cons& other) { return !(me
>other); } | |
| | | | |
|
| template<typename HT1, typename TT1> | | template<typename __HT1, typename __TT1> | |
| friend bool operator==(const cons<HT,TT>& me, const cons<HT1,TT1>& othe | | friend bool operator==(const cons<__HT,__TT>& me, const cons<__HT1,__TT | |
| r) { | | 1>& other) { | |
| return me.head == other.head && me.tail == other.tail; | | return me.head == other.head && me.tail == other.tail; | |
| } | | } | |
| | | | |
|
| template<typename HT1, typename TT1> | | template<typename __HT1, typename __TT1> | |
| friend bool operator<(const cons<HT,TT>& me, const cons<HT1,TT1>& other | | friend bool operator<(const cons<__HT,__TT>& me, const cons<__HT1,__TT1 | |
| ) { | | >& other) { | |
| return me.head < other.head || (!(other.head < me.head) && me.tail
< other.tail); | | return me.head < other.head || (!(other.head < me.head) && me.tail
< other.tail); | |
| } | | } | |
| | | | |
|
| template<typename HT1, typename TT1> | | template<typename __HT1, typename __TT1> | |
| friend bool operator>(const cons<HT,TT>& me, const cons<HT1,TT1>& other | | friend bool operator>(const cons<__HT,__TT>& me, const cons<__HT1,__TT1 | |
| ) { return other<me; } | | >& other) { return other<me; } | |
| | | | |
|
| template<typename HT1, typename TT1> | | template<typename __HT1, typename __TT1> | |
| friend bool operator!=(const cons<HT,TT>& me, const cons<HT1,TT1>& othe | | friend bool operator!=(const cons<__HT,__TT>& me, const cons<__HT1,__TT | |
| r) { return !(me==other); } | | 1>& other) { return !(me==other); } | |
| | | | |
|
| template<typename HT1, typename TT1> | | template<typename __HT1, typename __TT1> | |
| friend bool operator>=(const cons<HT,TT>& me, const cons<HT1,TT1>& othe | | friend bool operator>=(const cons<__HT,__TT>& me, const cons<__HT1,__TT | |
| r) { return !(me<other); } | | 1>& other) { return !(me<other); } | |
| | | | |
|
| template<typename HT1, typename TT1> | | template<typename __HT1, typename __TT1> | |
| friend bool operator<=(const cons<HT,TT>& me, const cons<HT1,TT1>& othe | | friend bool operator<=(const cons<__HT,__TT>& me, const cons<__HT1,__TT | |
| r) { return !(me>other); } | | 1>& other) { return !(me>other); } | |
| | | | |
| }; // cons | | }; // cons | |
| | | | |
|
| template <typename HT> | | template <typename __HT> | |
| struct cons<HT,null_type> { | | struct cons<__HT,null_type> { | |
| | | | |
|
| typedef HT head_type; | | typedef __HT head_type; | |
| typedef null_type tail_type; | | typedef null_type tail_type; | |
| | | | |
| head_type head; | | head_type head; | |
| | | | |
| static const int length = 1; | | static const int length = 1; | |
| | | | |
| // default constructor | | // default constructor | |
| cons() : head() { /*std::cout << "default constructor 1\n";*/ } | | cons() : head() { /*std::cout << "default constructor 1\n";*/ } | |
| | | | |
| cons(const null_type&, const null_type&, const null_type&, const null_t
ype&, const null_type& __TBB_CONST_NULL_REF_PACK) : head() { /*std::cout <<
"default constructor 2\n";*/ } | | cons(const null_type&, const null_type&, const null_type&, const null_t
ype&, const null_type& __TBB_CONST_NULL_REF_PACK) : head() { /*std::cout <<
"default constructor 2\n";*/ } | |
| | | | |
| // non-default constructor | | // non-default constructor | |
|
| template<typename T1> | | template<typename __T1> | |
| cons(T1& t1, const null_type&, const null_type&, const null_type&, cons | | cons(__T1& t1, const null_type&, const null_type&, const null_type&, co | |
| t null_type& __TBB_CONST_NULL_REF_PACK) : head(t1) { /*std::cout << "non-de | | nst null_type& __TBB_CONST_NULL_REF_PACK) : head(t1) { /*std::cout << "non- | |
| fault a1, t1== " << t1 << "\n";*/} | | default a1, t1== " << t1 << "\n";*/} | |
| | | | |
| cons(head_type& h, const null_type& = null_type() ) : head(h) { } | | cons(head_type& h, const null_type& = null_type() ) : head(h) { } | |
| cons(const head_type& t0, const null_type&, const null_type&, const nul
l_type&, const null_type& __TBB_CONST_NULL_REF_PACK) : head(t0) { } | | cons(const head_type& t0, const null_type&, const null_type&, const nul
l_type&, const null_type& __TBB_CONST_NULL_REF_PACK) : head(t0) { } | |
| | | | |
| // converting constructor | | // converting constructor | |
|
| template<typename HT1> | | template<typename __HT1> | |
| cons(HT1 h1, const null_type&, const null_type&, const null_type&, cons | | cons(__HT1 h1, const null_type&, const null_type&, const null_type&, co | |
| t null_type& __TBB_CONST_NULL_REF_PACK) : head(h1) { } | | nst null_type& __TBB_CONST_NULL_REF_PACK) : head(h1) { } | |
| | | | |
| // copy constructor | | // copy constructor | |
|
| template<typename HT1> | | template<typename __HT1> | |
| cons( const cons<HT1, null_type>& other) : head(other.head) { } | | cons( const cons<__HT1, null_type>& other) : head(other.head) { } | |
| | | | |
| // assignment operator | | // assignment operator | |
| cons& operator=(const cons& other) { head = other.head; return *this; } | | cons& operator=(const cons& other) { head = other.head; return *this; } | |
| | | | |
| friend bool operator==(const cons& me, const cons& other) { return me.h
ead == other.head; } | | friend bool operator==(const cons& me, const cons& other) { return me.h
ead == other.head; } | |
| friend bool operator<(const cons& me, const cons& other) { return me.he
ad < other.head; } | | friend bool operator<(const cons& me, const cons& other) { return me.he
ad < other.head; } | |
| friend bool operator>(const cons& me, const cons& other) { return other
<me; } | | friend bool operator>(const cons& me, const cons& other) { return other
<me; } | |
| friend bool operator!=(const cons& me, const cons& other) {return !(me=
=other); } | | friend bool operator!=(const cons& me, const cons& other) {return !(me=
=other); } | |
| friend bool operator<=(const cons& me, const cons& other) {return !(me>
other); } | | friend bool operator<=(const cons& me, const cons& other) {return !(me>
other); } | |
| friend bool operator>=(const cons& me, const cons& other) {return !(me<
other); } | | friend bool operator>=(const cons& me, const cons& other) {return !(me<
other); } | |
| | | | |
|
| template<typename HT1> | | template<typename __HT1> | |
| friend bool operator==(const cons<HT,null_type>& me, const cons<HT1,nul | | friend bool operator==(const cons<__HT,null_type>& me, const cons<__HT1 | |
| l_type>& other) { | | ,null_type>& other) { | |
| return me.head == other.head; | | return me.head == other.head; | |
| } | | } | |
| | | | |
|
| template<typename HT1> | | template<typename __HT1> | |
| friend bool operator<(const cons<HT,null_type>& me, const cons<HT1,null | | friend bool operator<(const cons<__HT,null_type>& me, const cons<__HT1, | |
| _type>& other) { | | null_type>& other) { | |
| return me.head < other.head; | | return me.head < other.head; | |
| } | | } | |
| | | | |
|
| template<typename HT1> | | template<typename __HT1> | |
| friend bool operator>(const cons<HT,null_type>& me, const cons<HT1,null | | friend bool operator>(const cons<__HT,null_type>& me, const cons<__HT1, | |
| _type>& other) { return other<me; } | | null_type>& other) { return other<me; } | |
| | | | |
|
| template<typename HT1> | | template<typename __HT1> | |
| friend bool operator!=(const cons<HT,null_type>& me, const cons<HT1,nul | | friend bool operator!=(const cons<__HT,null_type>& me, const cons<__HT1 | |
| l_type>& other) { return !(me==other); } | | ,null_type>& other) { return !(me==other); } | |
| | | | |
|
| template<typename HT1> | | template<typename __HT1> | |
| friend bool operator<=(const cons<HT,null_type>& me, const cons<HT1,nul | | friend bool operator<=(const cons<__HT,null_type>& me, const cons<__HT1 | |
| l_type>& other) { return !(me>other); } | | ,null_type>& other) { return !(me>other); } | |
| | | | |
|
| template<typename HT1> | | template<typename __HT1> | |
| friend bool operator>=(const cons<HT,null_type>& me, const cons<HT1,nul | | friend bool operator>=(const cons<__HT,null_type>& me, const cons<__HT1 | |
| l_type>& other) { return !(me<other); } | | ,null_type>& other) { return !(me<other); } | |
| | | | |
| }; // cons | | }; // cons | |
| | | | |
| template <> | | template <> | |
| struct cons<null_type,null_type> { typedef null_type tail_type; static cons
t int length = 0; }; | | struct cons<null_type,null_type> { typedef null_type tail_type; static cons
t int length = 0; }; | |
| | | | |
| // wrapper for default constructor | | // wrapper for default constructor | |
|
| template<typename T> | | template<typename __T> | |
| inline const T wrap_dcons(T*) { return T(); } | | inline const __T wrap_dcons(__T*) { return __T(); } | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| // tuple definition | | // tuple definition | |
|
| template<typename T0, typename T1, typename T2, typename T3, typename T4 __ | | template<typename __T0, typename __T1, typename __T2, typename __T3, typena | |
| TBB_TYPENAME_T_PACK > | | me __T4 __TBB_TYPENAME_T_PACK > | |
| class tuple : public internal::tuple_traits<T0, T1, T2, T3, T4 __TBB_T_PACK | | class tuple : public internal::tuple_traits<__T0, __T1, __T2, __T3, __T4 __ | |
| >::U { | | TBB_T_PACK >::U { | |
| // friends | | // friends | |
|
| template <typename T> friend class tuple_size; | | template <typename __T> friend class tuple_size; | |
| template<int N, typename T> friend struct tuple_element; | | template<int __N, typename __T> friend struct tuple_element; | |
| | | | |
| // stl components | | // stl components | |
|
| typedef tuple<T0,T1,T2,T3,T4 __TBB_T_PACK > value_type; | | typedef tuple<__T0,__T1,__T2,__T3,__T4 __TBB_T_PACK > value_type; | |
| typedef value_type *pointer; | | typedef value_type *pointer; | |
| typedef const value_type *const_pointer; | | typedef const value_type *const_pointer; | |
| typedef value_type &reference; | | typedef value_type &reference; | |
| typedef const value_type &const_reference; | | typedef const value_type &const_reference; | |
| typedef size_t size_type; | | typedef size_t size_type; | |
| | | | |
|
| typedef typename internal::tuple_traits<T0,T1,T2,T3, T4 __TBB_T_PACK >:
:U my_cons; | | typedef typename internal::tuple_traits<__T0,__T1,__T2,__T3, __T4 __TBB
_T_PACK >::U my_cons; | |
| | | | |
| public: | | public: | |
|
| tuple(const T0& t0=internal::wrap_dcons((T0*)NULL) | | tuple(const __T0& t0=internal::wrap_dcons((__T0*)NULL) | |
| ,const T1& t1=internal::wrap_dcons((T1*)NULL) | | ,const __T1& t1=internal::wrap_dcons((__T1*)NULL) | |
| ,const T2& t2=internal::wrap_dcons((T2*)NULL) | | ,const __T2& t2=internal::wrap_dcons((__T2*)NULL) | |
| ,const T3& t3=internal::wrap_dcons((T3*)NULL) | | ,const __T3& t3=internal::wrap_dcons((__T3*)NULL) | |
| ,const T4& t4=internal::wrap_dcons((T4*)NULL) | | ,const __T4& t4=internal::wrap_dcons((__T4*)NULL) | |
| #if __TBB_VARIADIC_MAX >= 6 | | #if __TBB_VARIADIC_MAX >= 6 | |
|
| ,const T5& t5=internal::wrap_dcons((T5*)NULL) | | ,const __T5& t5=internal::wrap_dcons((__T5*)NULL) | |
| #if __TBB_VARIADIC_MAX >= 7 | | #if __TBB_VARIADIC_MAX >= 7 | |
|
| ,const T6& t6=internal::wrap_dcons((T6*)NULL) | | ,const __T6& t6=internal::wrap_dcons((__T6*)NULL) | |
| #if __TBB_VARIADIC_MAX >= 8 | | #if __TBB_VARIADIC_MAX >= 8 | |
|
| ,const T7& t7=internal::wrap_dcons((T7*)NULL) | | ,const __T7& t7=internal::wrap_dcons((__T7*)NULL) | |
| #if __TBB_VARIADIC_MAX >= 9 | | #if __TBB_VARIADIC_MAX >= 9 | |
|
| ,const T8& t8=internal::wrap_dcons((T8*)NULL) | | ,const __T8& t8=internal::wrap_dcons((__T8*)NULL) | |
| #if __TBB_VARIADIC_MAX >= 10 | | #if __TBB_VARIADIC_MAX >= 10 | |
|
| ,const T9& t9=internal::wrap_dcons((T9*)NULL) | | ,const __T9& t9=internal::wrap_dcons((__T9*)NULL) | |
| #endif | | #endif | |
| #endif | | #endif | |
| #endif | | #endif | |
| #endif | | #endif | |
| #endif | | #endif | |
| ) : | | ) : | |
| my_cons(t0,t1,t2,t3,t4 __TBB_T_PARAM_LIST_PACK) { } | | my_cons(t0,t1,t2,t3,t4 __TBB_T_PARAM_LIST_PACK) { } | |
| | | | |
|
| template<int N> | | template<int __N> | |
| struct internal_tuple_element { | | struct internal_tuple_element { | |
|
| typedef typename internal::component<N,my_cons>::type type; | | typedef typename internal::component<__N,my_cons>::type type; | |
| }; | | }; | |
| | | | |
|
| template<int N> | | template<int __N> | |
| typename internal_tuple_element<N>::type& get() { return internal::get_ | | typename internal_tuple_element<__N>::type& get() { return internal::ge | |
| helper<N>::get(*this); } | | t_helper<__N>::get(*this); } | |
| | | | |
|
| template<int N> | | template<int __N> | |
| typename internal_tuple_element<N>::type const& get() const { return in | | typename internal_tuple_element<__N>::type const& get() const { return | |
| ternal::get_helper<N>::get(*this); } | | internal::get_helper<__N>::get(*this); } | |
| | | | |
|
| template<typename U1, typename U2> | | template<typename __U1, typename __U2> | |
| tuple& operator=(const internal::cons<U1,U2>& other) { | | tuple& operator=(const internal::cons<__U1,__U2>& other) { | |
| my_cons::operator=(other); | | my_cons::operator=(other); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
|
| template<typename U1, typename U2> | | template<typename __U1, typename __U2> | |
| tuple& operator=(const std::pair<U1,U2>& other) { | | tuple& operator=(const std::pair<__U1,__U2>& other) { | |
| // __TBB_ASSERT(tuple_size<value_type>::value == 2, "Invalid size f
or pair to tuple assignment"); | | // __TBB_ASSERT(tuple_size<value_type>::value == 2, "Invalid size f
or pair to tuple assignment"); | |
| this->head = other.first; | | this->head = other.first; | |
| this->tail.head = other.second; | | this->tail.head = other.second; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| friend bool operator==(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)==(other);} | | friend bool operator==(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)==(other);} | |
| friend bool operator<(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)<(other);} | | friend bool operator<(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)<(other);} | |
| friend bool operator>(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)>(other);} | | friend bool operator>(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)>(other);} | |
| friend bool operator!=(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)!=(other);} | | friend bool operator!=(const tuple& me, const tuple& other) {return sta
tic_cast<const my_cons &>(me)!=(other);} | |
| | | | |
| skipping to change at line 435 | | skipping to change at line 435 | |
| | | | |
| }; // tuple | | }; // tuple | |
| | | | |
| // empty tuple | | // empty tuple | |
| template<> | | template<> | |
| class tuple<null_type, null_type, null_type, null_type, null_type __TBB_NUL
L_TYPE_PACK > : public null_type { | | class tuple<null_type, null_type, null_type, null_type, null_type __TBB_NUL
L_TYPE_PACK > : public null_type { | |
| }; | | }; | |
| | | | |
| // helper classes | | // helper classes | |
| | | | |
|
| template < typename T> | | template < typename __T> | |
| class tuple_size { | | class tuple_size { | |
| public: | | public: | |
|
| static const size_t value = 1 + tuple_size<typename T::tail_type>::valu
e; | | static const size_t value = 1 + tuple_size<typename __T::tail_type>::va
lue; | |
| }; | | }; | |
| | | | |
| template <> | | template <> | |
| class tuple_size<tuple<> > { | | class tuple_size<tuple<> > { | |
| public: | | public: | |
| static const size_t value = 0; | | static const size_t value = 0; | |
| }; | | }; | |
| | | | |
| template <> | | template <> | |
| class tuple_size<null_type> { | | class tuple_size<null_type> { | |
| public: | | public: | |
| static const size_t value = 0; | | static const size_t value = 0; | |
| }; | | }; | |
| | | | |
|
| template<int N, typename T> | | template<int __N, typename __T> | |
| struct tuple_element { | | struct tuple_element { | |
|
| typedef typename internal::component<N, typename T::my_cons>::type type
; | | typedef typename internal::component<__N, typename __T::my_cons>::type
type; | |
| }; | | }; | |
| | | | |
|
| template<int N, typename T0, typename T1, typename T2, typename T3, typenam | | template<int __N, typename __T0, typename __T1, typename __T2, typename __T | |
| e T4 __TBB_TYPENAME_T_PACK > | | 3, typename __T4 __TBB_TYPENAME_T_PACK > | |
| inline static typename tuple_element<N,tuple<T0,T1,T2,T3,T4 __TBB_T_PACK > | | inline static typename tuple_element<__N,tuple<__T0,__T1,__T2,__T3,__T4 __T | |
| >::type& | | BB_T_PACK > >::type& | |
| get(tuple<T0,T1,T2,T3,T4 __TBB_T_PACK >& t) { return internal::get_help | | get(tuple<__T0,__T1,__T2,__T3,__T4 __TBB_T_PACK >& t) { return internal | |
| er<N>::get(t); } | | ::get_helper<__N>::get(t); } | |
| | | | |
|
| template<int N, typename T0, typename T1, typename T2, typename T3, typenam | | template<int __N, typename __T0, typename __T1, typename __T2, typename __T | |
| e T4 __TBB_TYPENAME_T_PACK > | | 3, typename __T4 __TBB_TYPENAME_T_PACK > | |
| inline static typename tuple_element<N,tuple<T0,T1,T2,T3,T4 __TBB_T_PACK > | | inline static typename tuple_element<__N,tuple<__T0,__T1,__T2,__T3,__T4 __T | |
| >::type const& | | BB_T_PACK > >::type const& | |
| get(const tuple<T0,T1,T2,T3,T4 __TBB_T_PACK >& t) { return internal::ge | | get(const tuple<__T0,__T1,__T2,__T3,__T4 __TBB_T_PACK >& t) { return in | |
| t_helper<N>::get(t); } | | ternal::get_helper<__N>::get(t); } | |
| | | | |
| } // interface5 | | } // interface5 | |
| } // tbb | | } // tbb | |
| | | | |
| #if !__TBB_CPP11_TUPLE_PRESENT | | #if !__TBB_CPP11_TUPLE_PRESENT | |
| namespace tbb { | | namespace tbb { | |
| namespace flow { | | namespace flow { | |
| using tbb::interface5::tuple; | | using tbb::interface5::tuple; | |
| using tbb::interface5::tuple_size; | | using tbb::interface5::tuple_size; | |
| using tbb::interface5::tuple_element; | | using tbb::interface5::tuple_element; | |
| | | | |
End of changes. 77 change blocks. |
| 189 lines changed or deleted | | 193 lines changed or added | |
|