~ubuntu-branches/ubuntu/quantal/libgc/quantal

« back to all changes in this revision

Viewing changes to libatomic_ops-1.2/src/atomic_ops/sysdeps/icc/ia64.h

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-02-19 12:19:56 UTC
  • mfrom: (1.3.2 upstream) (0.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110219121956-67rb69xlt5nud3v2
Tags: 1:7.1-5
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2003 by Hewlett-Packard Company.  All rights reserved.
 
3
 * 
 
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 
5
 * of this software and associated documentation files (the "Software"), to deal
 
6
 * in the Software without restriction, including without limitation the rights
 
7
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
8
 * copies of the Software, and to permit persons to whom the Software is
 
9
 * furnished to do so, subject to the following conditions:
 
10
 * 
 
11
 * The above copyright notice and this permission notice shall be included in
 
12
 * all copies or substantial portions of the Software.
 
13
 * 
 
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
19
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
20
 * SOFTWARE. 
 
21
 */
 
22
 
 
23
/*
 
24
 * This file specifies Itanimum primitives for use with the Intel (ecc)
 
25
 * compiler.  We use intrinsics instead of the inline assembly code in the
 
26
 * gcc file.
 
27
 */
 
28
 
 
29
#include "../all_atomic_load_store.h"
 
30
 
 
31
#include "../test_and_set_t_is_char.h"
 
32
 
 
33
#include <ia64intrin.h>
 
34
 
 
35
/* The acquire release semantics of volatile can be turned off.  And volatile   */
 
36
/* operations in icc9 don't imply ordering with respect to other nonvolatile    */
 
37
/* operations.                                                                  */
 
38
 
 
39
#define AO_INTEL_PTR_t void *
 
40
 
 
41
AO_INLINE AO_t
 
42
AO_load_acquire(volatile AO_t *p)
 
43
{
 
44
  return (AO_t)(__ld8_acq((AO_INTEL_PTR_t)p));
 
45
}
 
46
#define AO_HAVE_load_acquire
 
47
 
 
48
AO_INLINE void
 
49
AO_store_release(volatile AO_t *p, AO_t val)
 
50
{
 
51
  __st8_rel((AO_INTEL_PTR_t)p, (__int64)val);
 
52
}
 
53
#define AO_HAVE_store_release
 
54
 
 
55
AO_INLINE unsigned char
 
56
AO_char_load_acquire(volatile unsigned char *p)
 
57
{
 
58
  /* A normal volatile load generates an ld.acq         */
 
59
  return (__ld1_acq((AO_INTEL_PTR_t)p));
 
60
}
 
61
#define AO_HAVE_char_load_acquire
 
62
 
 
63
AO_INLINE void
 
64
AO_char_store_release(volatile unsigned char *p, unsigned char val)
 
65
{
 
66
  __st1_rel((AO_INTEL_PTR_t)p, val);
 
67
}
 
68
#define AO_HAVE_char_store_release
 
69
 
 
70
AO_INLINE unsigned short
 
71
AO_short_load_acquire(volatile unsigned short *p)
 
72
{
 
73
  /* A normal volatile load generates an ld.acq         */
 
74
  return (__ld2_acq((AO_INTEL_PTR_t)p));
 
75
}
 
76
#define AO_HAVE_short_load_acquire
 
77
 
 
78
AO_INLINE void
 
79
AO_short_store_release(volatile unsigned short *p, unsigned short val)
 
80
{
 
81
  __st2_rel((AO_INTEL_PTR_t)p, val);
 
82
}
 
83
#define AO_HAVE_short_store_release
 
84
 
 
85
AO_INLINE unsigned int
 
86
AO_int_load_acquire(volatile unsigned int *p)
 
87
{
 
88
  /* A normal volatile load generates an ld.acq         */
 
89
  return (__ld4_acq((AO_INTEL_PTR_t)p));
 
90
}
 
91
#define AO_HAVE_int_load_acquire
 
92
 
 
93
AO_INLINE void
 
94
AO_int_store_release(volatile unsigned int *p, unsigned int val)
 
95
{
 
96
  __st4_rel((AO_INTEL_PTR_t)p, val);
 
97
}
 
98
#define AO_HAVE_int_store_release
 
99
 
 
100
AO_INLINE void
 
101
AO_nop_full()
 
102
{
 
103
  __mf();
 
104
}
 
105
#define AO_HAVE_nop_full
 
106
 
 
107
AO_INLINE AO_t
 
108
AO_fetch_and_add1_acquire (volatile AO_t *p)
 
109
{
 
110
  return __fetchadd8_acq((unsigned __int64 *)p, 1);
 
111
}
 
112
#define AO_HAVE_fetch_and_add1_acquire
 
113
 
 
114
AO_INLINE AO_t
 
115
AO_fetch_and_add1_release (volatile AO_t *p)
 
116
{
 
117
  return __fetchadd8_rel((unsigned __int64 *)p, 1);
 
118
}
 
119
 
 
120
#define AO_HAVE_fetch_and_add1_release
 
121
 
 
122
AO_INLINE AO_t
 
123
AO_fetch_and_sub1_acquire (volatile AO_t *p)
 
124
{
 
125
  return __fetchadd8_acq((unsigned __int64 *)p, -1);
 
126
}
 
127
 
 
128
#define AO_HAVE_fetch_and_sub1_acquire
 
129
 
 
130
AO_INLINE AO_t
 
131
AO_fetch_and_sub1_release (volatile AO_t *p)
 
132
{
 
133
  return __fetchadd8_rel((unsigned __int64 *)p, -1);
 
134
}
 
135
 
 
136
#define AO_HAVE_fetch_and_sub1_release
 
137
 
 
138
AO_INLINE int
 
139
AO_compare_and_swap_acquire(volatile AO_t *addr,
 
140
                             AO_t old, AO_t new_val) 
 
141
{
 
142
  AO_t oldval;
 
143
  oldval = _InterlockedCompareExchange64_acq(addr, new_val, old);
 
144
  return (oldval == old);
 
145
}
 
146
 
 
147
#define AO_HAVE_compare_and_swap_acquire
 
148
 
 
149
AO_INLINE int
 
150
AO_compare_and_swap_release(volatile AO_t *addr,
 
151
                             AO_t old, AO_t new_val) 
 
152
{
 
153
  AO_t oldval;
 
154
  oldval = _InterlockedCompareExchange64_rel(addr, new_val, old);
 
155
  return (oldval == old);
 
156
}
 
157
 
 
158
#define AO_HAVE_compare_and_swap_release
 
159
 
 
160
AO_INLINE int
 
161
AO_char_compare_and_swap_acquire(volatile unsigned char *addr,
 
162
                                 unsigned char old, unsigned char new_val) 
 
163
{
 
164
  unsigned char oldval;
 
165
  oldval = _InterlockedCompareExchange8_acq(addr, new_val, old);
 
166
  return (oldval == old);
 
167
}
 
168
 
 
169
#define AO_HAVE_char_compare_and_swap_acquire
 
170
 
 
171
AO_INLINE int
 
172
AO_char_compare_and_swap_release(volatile unsigned char *addr,
 
173
                            unsigned char old, unsigned char new_val) 
 
174
{
 
175
  unsigned char oldval;
 
176
  oldval = _InterlockedCompareExchange8_rel(addr, new_val, old);
 
177
  return (oldval == old);
 
178
}
 
179
 
 
180
#define AO_HAVE_char_compare_and_swap_release
 
181
 
 
182
AO_INLINE int
 
183
AO_short_compare_and_swap_acquire(volatile unsigned short *addr,
 
184
                                 unsigned short old, unsigned short new_val) 
 
185
{
 
186
  unsigned short oldval;
 
187
  oldval = _InterlockedCompareExchange16_acq(addr, new_val, old);
 
188
  return (oldval == old);
 
189
}
 
190
 
 
191
#define AO_HAVE_short_compare_and_swap_acquire
 
192
 
 
193
AO_INLINE int
 
194
AO_short_compare_and_swap_release(volatile unsigned short *addr,
 
195
                            unsigned short old, unsigned short new_val) 
 
196
{
 
197
  unsigned short oldval;
 
198
  oldval = _InterlockedCompareExchange16_rel(addr, new_val, old);
 
199
  return (oldval == old);
 
200
}
 
201
 
 
202
#define AO_HAVE_short_compare_and_swap_release
 
203
 
 
204
AO_INLINE int
 
205
AO_int_compare_and_swap_acquire(volatile unsigned int *addr,
 
206
                                 unsigned int old, unsigned int new_val) 
 
207
{
 
208
  unsigned int oldval;
 
209
  oldval = _InterlockedCompareExchange_acq(addr, new_val, old);
 
210
  return (oldval == old);
 
211
}
 
212
 
 
213
#define AO_HAVE_int_compare_and_swap_acquire
 
214
 
 
215
AO_INLINE int
 
216
AO_int_compare_and_swap_release(volatile unsigned int *addr,
 
217
                            unsigned int old, unsigned int new_val) 
 
218
{
 
219
  unsigned int oldval;
 
220
  oldval = _InterlockedCompareExchange_rel(addr, new_val, old);
 
221
  return (oldval == old);
 
222
}
 
223
 
 
224
#define AO_HAVE_int_compare_and_swap_release
 
225