1 /*
2     Copyright (c) 2005-2017 Intel Corporation
3 
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7 
8         http://www.apache.org/licenses/LICENSE-2.0
9 
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15 
16 
17 
18 
19 */
20 
21 #if !defined(__TBB_machine_H) || defined(__TBB_machine_windows_intel64_H)
22 #error Do not #include this internal file directly; use public TBB headers instead.
23 #endif
24 
25 #define __TBB_machine_windows_intel64_H
26 
27 #define __TBB_WORDSIZE 8
28 #define __TBB_ENDIANNESS __TBB_ENDIAN_LITTLE
29 
30 #include "msvc_ia32_common.h"
31 
32 #ifndef __TBB_ATOMIC_PRIMITIVES_DEFINED
33 
34 #include <intrin.h>
35 #pragma intrinsic(_InterlockedCompareExchange,_InterlockedExchangeAdd,_InterlockedExchange)
36 #pragma intrinsic(_InterlockedCompareExchange64,_InterlockedExchangeAdd64,_InterlockedExchange64)
37 
38 // ATTENTION: if you ever change argument types in machine-specific primitives,
39 // please take care of atomic_word<> specializations in tbb/atomic.h
40 extern "C" {
41     __int8 __TBB_EXPORTED_FUNC __TBB_machine_cmpswp1 (volatile void *ptr, __int8 value, __int8 comparand );
42     __int8 __TBB_EXPORTED_FUNC __TBB_machine_fetchadd1 (volatile void *ptr, __int8 addend );
43     __int8 __TBB_EXPORTED_FUNC __TBB_machine_fetchstore1 (volatile void *ptr, __int8 value );
44     __int16 __TBB_EXPORTED_FUNC __TBB_machine_cmpswp2 (volatile void *ptr, __int16 value, __int16 comparand );
45     __int16 __TBB_EXPORTED_FUNC __TBB_machine_fetchadd2 (volatile void *ptr, __int16 addend );
46     __int16 __TBB_EXPORTED_FUNC __TBB_machine_fetchstore2 (volatile void *ptr, __int16 value );
47 }
48 
__TBB_machine_cmpswp4(volatile void * ptr,__int32 value,__int32 comparand)49 inline long __TBB_machine_cmpswp4 (volatile void *ptr, __int32 value, __int32 comparand ) {
50     return _InterlockedCompareExchange( (long*)ptr, value, comparand );
51 }
__TBB_machine_fetchadd4(volatile void * ptr,__int32 addend)52 inline long __TBB_machine_fetchadd4 (volatile void *ptr, __int32 addend ) {
53     return _InterlockedExchangeAdd( (long*)ptr, addend );
54 }
__TBB_machine_fetchstore4(volatile void * ptr,__int32 value)55 inline long __TBB_machine_fetchstore4 (volatile void *ptr, __int32 value ) {
56     return _InterlockedExchange( (long*)ptr, value );
57 }
58 
__TBB_machine_cmpswp8(volatile void * ptr,__int64 value,__int64 comparand)59 inline __int64 __TBB_machine_cmpswp8 (volatile void *ptr, __int64 value, __int64 comparand ) {
60     return _InterlockedCompareExchange64( (__int64*)ptr, value, comparand );
61 }
__TBB_machine_fetchadd8(volatile void * ptr,__int64 addend)62 inline __int64 __TBB_machine_fetchadd8 (volatile void *ptr, __int64 addend ) {
63     return _InterlockedExchangeAdd64( (__int64*)ptr, addend );
64 }
__TBB_machine_fetchstore8(volatile void * ptr,__int64 value)65 inline __int64 __TBB_machine_fetchstore8 (volatile void *ptr, __int64 value ) {
66     return _InterlockedExchange64( (__int64*)ptr, value );
67 }
68 
69 #endif /*__TBB_ATOMIC_PRIMITIVES_DEFINED*/
70 
71 #define __TBB_USE_FETCHSTORE_AS_FULL_FENCED_STORE           1
72 #define __TBB_USE_GENERIC_HALF_FENCED_LOAD_STORE            1
73 #define __TBB_USE_GENERIC_RELAXED_LOAD_STORE                1
74 #define __TBB_USE_GENERIC_SEQUENTIAL_CONSISTENCY_LOAD_STORE 1
75