~ubuntu-branches/ubuntu/saucy/eglibc/saucy

« back to all changes in this revision

Viewing changes to ports/sysdeps/aarch64/bits/atomic.h

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-01-10 18:39:35 UTC
  • mfrom: (1.5.2) (4.4.24 experimental)
  • Revision ID: package-import@ubuntu.com-20130110183935-afsgfxkmg7wk5eaj
Tags: 2.17-0ubuntu1
* Merge with Debian, bringing in a new upstream and many small fixes:
  - patches/any/cvs-malloc-deadlock.diff: Dropped, merged upstream.
  - patches/ubuntu/lddebug-scopes.diff: Rebase for upstream changes.
  - patches/ubuntu/local-CVE-2012-3406.diff: Rebased against upstream.
  - patches/ubuntu/no-asm-mtune-i686.diff: Fixed in recent binutils.
* This upstream merge fixes a nasty hang in pulseaudio (LP: #1085342)
* Bump MIN_KERNEL_SUPPORTED to 2.6.32 on ARM, now that we no longer
  have to support shonky 2.6.31 kernels on imx51 babbage builders.
* Drop patches/ubuntu/local-disable-nscd-host-caching.diff, as these
  issues were apparently resolved upstream a while ago (LP: #613662)
* Fix the compiled-in bug URL to point to launchpad.net, not Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
 
2
 
 
3
   This file is part of the GNU C Library.
 
4
 
 
5
   The GNU C Library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   The GNU C Library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with the GNU C Library.  If not, see
 
17
   <http://www.gnu.org/licenses/>.  */
 
18
 
 
19
#ifndef _AARCH64_BITS_ATOMIC_H
 
20
#define _AARCH64_BITS_ATOMIC_H  1
 
21
 
 
22
#include <stdint.h>
 
23
 
 
24
typedef int8_t  atomic8_t;
 
25
typedef int16_t atomic16_t;
 
26
typedef int32_t atomic32_t;
 
27
typedef int64_t atomic64_t;
 
28
 
 
29
typedef uint8_t  uatomic8_t;
 
30
typedef uint16_t uatomic16_t;
 
31
typedef uint32_t uatomic32_t;
 
32
typedef uint64_t uatomic64_t;
 
33
 
 
34
typedef intptr_t atomicptr_t;
 
35
typedef uintptr_t uatomicptr_t;
 
36
typedef intmax_t atomic_max_t;
 
37
typedef uintmax_t uatomic_max_t;
 
38
 
 
39
 
 
40
/* Compare and exchange.
 
41
   For all "bool" routines, we return FALSE if exchange succesful.  */
 
42
 
 
43
# define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \
 
44
  ({                                                                    \
 
45
    typeof (*mem) __oldval = (oldval);                                  \
 
46
    !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   \
 
47
                                  model, __ATOMIC_RELAXED);             \
 
48
  })
 
49
 
 
50
# define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \
 
51
  ({                                                                    \
 
52
    typeof (*mem) __oldval = (oldval);                                  \
 
53
    !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   \
 
54
                                  model, __ATOMIC_RELAXED);             \
 
55
  })
 
56
 
 
57
# define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \
 
58
  ({                                                                    \
 
59
    typeof (*mem) __oldval = (oldval);                                  \
 
60
    !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   \
 
61
                                  model, __ATOMIC_RELAXED);             \
 
62
  })
 
63
 
 
64
#  define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \
 
65
  ({                                                                    \
 
66
    typeof (*mem) __oldval = (oldval);                                  \
 
67
    !__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   \
 
68
                                  model, __ATOMIC_RELAXED);             \
 
69
  })
 
70
 
 
71
# define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \
 
72
  ({                                                                    \
 
73
    typeof (*mem) __oldval = (oldval);                                  \
 
74
    __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,    \
 
75
                                 model, __ATOMIC_RELAXED);              \
 
76
    __oldval;                                                           \
 
77
  })
 
78
 
 
79
# define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \
 
80
  ({                                                                    \
 
81
    typeof (*mem) __oldval = (oldval);                                  \
 
82
    __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,    \
 
83
                                 model, __ATOMIC_RELAXED);              \
 
84
    __oldval;                                                           \
 
85
  })
 
86
 
 
87
# define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \
 
88
  ({                                                                    \
 
89
    typeof (*mem) __oldval = (oldval);                                  \
 
90
    __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,    \
 
91
                                 model, __ATOMIC_RELAXED);              \
 
92
    __oldval;                                                           \
 
93
  })
 
94
 
 
95
#  define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \
 
96
  ({                                                                    \
 
97
    typeof (*mem) __oldval = (oldval);                                  \
 
98
    __atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,    \
 
99
                                 model, __ATOMIC_RELAXED);              \
 
100
    __oldval;                                                           \
 
101
  })
 
102
 
 
103
 
 
104
/* Compare and exchange with "acquire" semantics, ie barrier after.  */
 
105
 
 
106
# define atomic_compare_and_exchange_bool_acq(mem, new, old)    \
 
107
  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int,  \
 
108
                        mem, new, old, __ATOMIC_ACQUIRE)
 
109
 
 
110
# define atomic_compare_and_exchange_val_acq(mem, new, old)     \
 
111
  __atomic_val_bysize (__arch_compare_and_exchange_val, int,    \
 
112
                       mem, new, old, __ATOMIC_ACQUIRE)
 
113
 
 
114
/* Compare and exchange with "release" semantics, ie barrier before.  */
 
115
 
 
116
# define atomic_compare_and_exchange_bool_rel(mem, new, old)    \
 
117
  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int,  \
 
118
                        mem, new, old, __ATOMIC_RELEASE)
 
119
 
 
120
# define atomic_compare_and_exchange_val_rel(mem, new, old)      \
 
121
  __atomic_val_bysize (__arch_compare_and_exchange_val, int,    \
 
122
                       mem, new, old, __ATOMIC_RELEASE)
 
123
 
 
124
 
 
125
/* Atomic exchange (without compare).  */
 
126
 
 
127
# define __arch_exchange_8_int(mem, newval, model)      \
 
128
  __atomic_exchange_n (mem, newval, model)
 
129
 
 
130
# define __arch_exchange_16_int(mem, newval, model)     \
 
131
  __atomic_exchange_n (mem, newval, model)
 
132
 
 
133
# define __arch_exchange_32_int(mem, newval, model)     \
 
134
  __atomic_exchange_n (mem, newval, model)
 
135
 
 
136
#  define __arch_exchange_64_int(mem, newval, model)    \
 
137
  __atomic_exchange_n (mem, newval, model)
 
138
 
 
139
# define atomic_exchange_acq(mem, value)                                \
 
140
  __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_ACQUIRE)
 
141
 
 
142
# define atomic_exchange_rel(mem, value)                                \
 
143
  __atomic_val_bysize (__arch_exchange, int, mem, value, __ATOMIC_RELEASE)
 
144
 
 
145
 
 
146
/* Atomically add value and return the previous (unincremented) value.  */
 
147
 
 
148
# define __arch_exchange_and_add_8_int(mem, value, model)       \
 
149
  __atomic_fetch_add (mem, value, model)
 
150
 
 
151
# define __arch_exchange_and_add_16_int(mem, value, model)      \
 
152
  __atomic_fetch_add (mem, value, model)
 
153
 
 
154
# define __arch_exchange_and_add_32_int(mem, value, model)      \
 
155
  __atomic_fetch_add (mem, value, model)
 
156
 
 
157
#  define __arch_exchange_and_add_64_int(mem, value, model)     \
 
158
  __atomic_fetch_add (mem, value, model)
 
159
 
 
160
# define atomic_exchange_and_add_acq(mem, value)                        \
 
161
  __atomic_val_bysize (__arch_exchange_and_add, int, mem, value,        \
 
162
                       __ATOMIC_ACQUIRE)
 
163
 
 
164
# define atomic_exchange_and_add_rel(mem, value)                        \
 
165
  __atomic_val_bysize (__arch_exchange_and_add, int, mem, value,        \
 
166
                       __ATOMIC_RELEASE)
 
167
 
 
168
/* Barrier macro. */
 
169
#define atomic_full_barrier() __sync_synchronize()
 
170
 
 
171
#endif