]> git.sesse.net Git - casparcg/blob - tbb30_20100406oss/include/tbb/machine/linux_ia64.h
cd788fecfb1c4953c34a939c3c5afd879f7b59e7
[casparcg] / tbb30_20100406oss / include / tbb / machine / linux_ia64.h
1 /*
2     Copyright 2005-2010 Intel Corporation.  All Rights Reserved.
3
4     This file is part of Threading Building Blocks.
5
6     Threading Building Blocks is free software; you can redistribute it
7     and/or modify it under the terms of the GNU General Public License
8     version 2 as published by the Free Software Foundation.
9
10     Threading Building Blocks is distributed in the hope that it will be
11     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with Threading Building Blocks; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19     As a special exception, you may use this file as part of a free software
20     library without restriction.  Specifically, if other files instantiate
21     templates or use macros or inline functions from this file, or you compile
22     this file and link it with other files to produce an executable, this
23     file does not by itself cause the resulting executable to be covered by
24     the GNU General Public License.  This exception does not however
25     invalidate any other reasons why the executable file might be covered by
26     the GNU General Public License.
27 */
28
29 #ifndef __TBB_machine_H
30 #error Do not include this file directly; include tbb_machine.h instead
31 #endif
32
33 #include "linux_common.h"
34 #include <ia64intrin.h>
35
36 #define __TBB_WORDSIZE 8
37 #define __TBB_BIG_ENDIAN 0
38 #define __TBB_DECL_FENCED_ATOMICS 1
39
40 // Most of the functions will be in a .s file
41
42 extern "C" {
43     int8_t __TBB_machine_cmpswp1__TBB_full_fence (volatile void *ptr, int8_t value, int8_t comparand); 
44     int8_t __TBB_machine_fetchadd1__TBB_full_fence (volatile void *ptr, int8_t addend);
45     int8_t __TBB_machine_fetchadd1acquire(volatile void *ptr, int8_t addend);
46     int8_t __TBB_machine_fetchadd1release(volatile void *ptr, int8_t addend);
47     int8_t __TBB_machine_fetchstore1acquire(volatile void *ptr, int8_t value);
48     int8_t __TBB_machine_fetchstore1release(volatile void *ptr, int8_t value);
49
50     int16_t __TBB_machine_cmpswp2__TBB_full_fence (volatile void *ptr, int16_t value, int16_t comparand);
51     int16_t __TBB_machine_fetchadd2__TBB_full_fence (volatile void *ptr, int16_t addend);
52     int16_t __TBB_machine_fetchadd2acquire(volatile void *ptr, int16_t addend);
53     int16_t __TBB_machine_fetchadd2release(volatile void *ptr, int16_t addend);
54     int16_t __TBB_machine_fetchstore2acquire(volatile void *ptr, int16_t value);
55     int16_t __TBB_machine_fetchstore2release(volatile void *ptr, int16_t value);
56
57     int32_t __TBB_machine_fetchstore4__TBB_full_fence (volatile void *ptr, int32_t value);
58     int32_t __TBB_machine_fetchstore4acquire(volatile void *ptr, int32_t value);
59     int32_t __TBB_machine_fetchstore4release(volatile void *ptr, int32_t value);
60     int32_t __TBB_machine_fetchadd4acquire(volatile void *ptr, int32_t addend);
61     int32_t __TBB_machine_fetchadd4release(volatile void *ptr, int32_t addend);
62
63     int64_t __TBB_machine_cmpswp8__TBB_full_fence (volatile void *ptr, int64_t value, int64_t comparand);
64     int64_t __TBB_machine_fetchstore8__TBB_full_fence (volatile void *ptr, int64_t value);
65     int64_t __TBB_machine_fetchstore8acquire(volatile void *ptr, int64_t value);
66     int64_t __TBB_machine_fetchstore8release(volatile void *ptr, int64_t value);
67     int64_t __TBB_machine_fetchadd8acquire(volatile void *ptr, int64_t addend);
68     int64_t __TBB_machine_fetchadd8release(volatile void *ptr, int64_t addend);
69
70     int8_t __TBB_machine_cmpswp1acquire(volatile void *ptr, int8_t value, int8_t comparand); 
71     int8_t __TBB_machine_cmpswp1release(volatile void *ptr, int8_t value, int8_t comparand); 
72     int8_t __TBB_machine_fetchstore1__TBB_full_fence (volatile void *ptr, int8_t value);
73
74     int16_t __TBB_machine_cmpswp2acquire(volatile void *ptr, int16_t value, int16_t comparand); 
75     int16_t __TBB_machine_cmpswp2release(volatile void *ptr, int16_t value, int16_t comparand); 
76     int16_t __TBB_machine_fetchstore2__TBB_full_fence (volatile void *ptr, int16_t value);
77
78     int32_t __TBB_machine_cmpswp4__TBB_full_fence (volatile void *ptr, int32_t value, int32_t comparand);
79     int32_t __TBB_machine_cmpswp4acquire(volatile void *ptr, int32_t value, int32_t comparand); 
80     int32_t __TBB_machine_cmpswp4release(volatile void *ptr, int32_t value, int32_t comparand); 
81     int32_t __TBB_machine_fetchadd4__TBB_full_fence (volatile void *ptr, int32_t value);
82
83     int64_t __TBB_machine_cmpswp8acquire(volatile void *ptr, int64_t value, int64_t comparand); 
84     int64_t __TBB_machine_cmpswp8release(volatile void *ptr, int64_t value, int64_t comparand); 
85     int64_t __TBB_machine_fetchadd8__TBB_full_fence (volatile void *ptr, int64_t value);
86
87     int64_t __TBB_machine_lg(uint64_t value);
88     void __TBB_machine_pause(int32_t delay);
89     bool __TBB_machine_trylockbyte( volatile unsigned char &ptr );
90     int64_t __TBB_machine_lockbyte( volatile unsigned char &ptr );
91
92     //! Retrieves the current RSE backing store pointer. IA64 specific.
93     void* __TBB_get_bsp();
94 }
95
96 #define __TBB_CompareAndSwap1(P,V,C) __TBB_machine_cmpswp1__TBB_full_fence(P,V,C)
97 #define __TBB_CompareAndSwap2(P,V,C) __TBB_machine_cmpswp2__TBB_full_fence(P,V,C) 
98
99 #define __TBB_FetchAndAdd1(P,V)        __TBB_machine_fetchadd1__TBB_full_fence(P,V)
100 #define __TBB_FetchAndAdd1acquire(P,V) __TBB_machine_fetchadd1acquire(P,V)
101 #define __TBB_FetchAndAdd1release(P,V) __TBB_machine_fetchadd1release(P,V)
102 #define __TBB_FetchAndAdd2(P,V)        __TBB_machine_fetchadd2__TBB_full_fence(P,V)
103 #define __TBB_FetchAndAdd2acquire(P,V) __TBB_machine_fetchadd2acquire(P,V)
104 #define __TBB_FetchAndAdd2release(P,V) __TBB_machine_fetchadd2release(P,V)
105 #define __TBB_FetchAndAdd4acquire(P,V) __TBB_machine_fetchadd4acquire(P,V)
106 #define __TBB_FetchAndAdd4release(P,V) __TBB_machine_fetchadd4release(P,V)
107 #define __TBB_FetchAndAdd8acquire(P,V) __TBB_machine_fetchadd8acquire(P,V)
108 #define __TBB_FetchAndAdd8release(P,V) __TBB_machine_fetchadd8release(P,V)
109
110 #define __TBB_FetchAndStore1acquire(P,V) __TBB_machine_fetchstore1acquire(P,V)
111 #define __TBB_FetchAndStore1release(P,V) __TBB_machine_fetchstore1release(P,V)
112 #define __TBB_FetchAndStore2acquire(P,V) __TBB_machine_fetchstore2acquire(P,V)
113 #define __TBB_FetchAndStore2release(P,V) __TBB_machine_fetchstore2release(P,V)
114 #define __TBB_FetchAndStore4acquire(P,V) __TBB_machine_fetchstore4acquire(P,V)
115 #define __TBB_FetchAndStore4release(P,V) __TBB_machine_fetchstore4release(P,V)
116 #define __TBB_FetchAndStore8acquire(P,V) __TBB_machine_fetchstore8acquire(P,V)
117 #define __TBB_FetchAndStore8release(P,V) __TBB_machine_fetchstore8release(P,V)
118
119 #define __TBB_CompareAndSwap1acquire(P,V,C) __TBB_machine_cmpswp1acquire(P,V,C)
120 #define __TBB_CompareAndSwap1release(P,V,C) __TBB_machine_cmpswp1release(P,V,C)
121 #define __TBB_CompareAndSwap2acquire(P,V,C) __TBB_machine_cmpswp2acquire(P,V,C)
122 #define __TBB_CompareAndSwap2release(P,V,C) __TBB_machine_cmpswp2release(P,V,C)
123 #define __TBB_CompareAndSwap4(P,V,C)        __TBB_machine_cmpswp4__TBB_full_fence(P,V,C)
124 #define __TBB_CompareAndSwap4acquire(P,V,C) __TBB_machine_cmpswp4acquire(P,V,C)
125 #define __TBB_CompareAndSwap4release(P,V,C) __TBB_machine_cmpswp4release(P,V,C)
126 #define __TBB_CompareAndSwap8(P,V,C)        __TBB_machine_cmpswp8__TBB_full_fence(P,V,C)
127 #define __TBB_CompareAndSwap8acquire(P,V,C) __TBB_machine_cmpswp8acquire(P,V,C)
128 #define __TBB_CompareAndSwap8release(P,V,C) __TBB_machine_cmpswp8release(P,V,C)
129
130 #define __TBB_FetchAndAdd4(P,V) __TBB_machine_fetchadd4__TBB_full_fence(P,V)
131 #define __TBB_FetchAndAdd8(P,V) __TBB_machine_fetchadd8__TBB_full_fence(P,V)
132
133 #define __TBB_FetchAndStore1(P,V) __TBB_machine_fetchstore1__TBB_full_fence(P,V)
134 #define __TBB_FetchAndStore2(P,V) __TBB_machine_fetchstore2__TBB_full_fence(P,V)
135 #define __TBB_FetchAndStore4(P,V) __TBB_machine_fetchstore4__TBB_full_fence(P,V)
136 #define __TBB_FetchAndStore8(P,V) __TBB_machine_fetchstore8__TBB_full_fence(P,V)
137
138 #define __TBB_FetchAndIncrementWacquire(P) __TBB_FetchAndAdd8acquire(P,1)
139 #define __TBB_FetchAndDecrementWrelease(P) __TBB_FetchAndAdd8release(P,-1)
140
141 #ifndef __INTEL_COMPILER
142 /* Even though GCC imbues volatile loads with acquire semantics, 
143    it sometimes moves loads over the acquire fence.  The
144    fences defined here stop such incorrect code motion. */
145 #define __TBB_release_consistency_helper() __asm__ __volatile__("": : :"memory")
146 #define __TBB_rel_acq_fence() __asm__ __volatile__("mf": : :"memory")
147 #else
148 #define __TBB_release_consistency_helper()
149 #define __TBB_rel_acq_fence() __mf()
150 #endif /* __INTEL_COMPILER */
151
152 // Special atomic functions
153 #define __TBB_CompareAndSwapW(P,V,C)   __TBB_CompareAndSwap8(P,V,C)
154 #define __TBB_FetchAndStoreW(P,V)      __TBB_FetchAndStore8(P,V)
155 #define __TBB_FetchAndAddW(P,V)        __TBB_FetchAndAdd8(P,V)
156 #define __TBB_FetchAndAddWrelease(P,V) __TBB_FetchAndAdd8release(P,V)
157
158 // Not needed
159 #undef __TBB_Store8
160 #undef __TBB_Load8
161
162 // Definition of Lock functions
163 #define __TBB_TryLockByte(P) __TBB_machine_trylockbyte(P)
164 #define __TBB_LockByte(P)    __TBB_machine_lockbyte(P)
165
166 // Definition of other utility functions
167 #define __TBB_Pause(V) __TBB_machine_pause(V)
168 #define __TBB_Log2(V)  __TBB_machine_lg(V)
169