PAPI
7.1.0.0
Loading...
Searching...
No Matches
avr32.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2009 Bradley Smith <brad@brad-smith.co.uk>
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the
6
* "Software"), to deal in the Software without restriction, including
7
* without limitation the rights to use, copy, modify, merge, publish,
8
* distribute, sublicense, and/or sell copies of the Software, and to
9
* permit persons to whom the Software is furnished to do so, subject to
10
* the following conditions:
11
*
12
* The above copyright notice and this permission notice shall be included
13
* in all copies or substantial portions of the Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
*
23
*/
24
25
#include "../all_atomic_load_store.h"
26
27
#include "../ordered.h"
/* There are no multiprocessor implementations. */
28
29
#include "../test_and_set_t_is_ao_t.h"
30
31
#ifndef AO_PREFER_GENERALIZED
32
AO_INLINE
AO_TS_VAL_t
33
AO_test_and_set_full
(
volatile
AO_TS_t
*addr)
34
{
35
register
long
ret;
36
37
__asm__ __volatile__(
38
"xchg %[oldval], %[mem], %[newval]"
39
: [oldval]
"=&r"
(ret)
40
: [mem]
"r"
(addr), [newval]
"r"
(1)
41
:
"memory"
);
42
43
return
(
AO_TS_VAL_t
)ret;
44
}
45
# define AO_HAVE_test_and_set_full
46
#endif
/* !AO_PREFER_GENERALIZED */
47
48
AO_INLINE
int
49
AO_compare_and_swap_full
(
volatile
AO_t
*addr,
AO_t
old,
AO_t
new_val)
50
{
51
register
long
ret;
52
53
__asm__ __volatile__(
54
"1: ssrf 5\n"
55
" ld.w %[res], %[mem]\n"
56
" eor %[res], %[oldval]\n"
57
" brne 2f\n"
58
" stcond %[mem], %[newval]\n"
59
" brne 1b\n"
60
"2:\n"
61
: [res]
"=&r"
(ret), [mem]
"=m"
(*addr)
62
:
"m"
(*addr), [newval]
"r"
(new_val), [oldval]
"r"
(old)
63
:
"cc"
,
"memory"
);
64
65
return
(
int
)ret;
66
}
67
#define AO_HAVE_compare_and_swap_full
68
69
/* TODO: implement AO_fetch_compare_and_swap. */
70
71
#define AO_T_IS_INT
AO_t
#define AO_t
Definition:
atomic_ops.h:156
AO_INLINE
#define AO_INLINE
Definition:
atomic_ops.h:186
AO_compare_and_swap_full
AO_INLINE int AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
Definition:
avr32.h:49
AO_test_and_set_full
AO_INLINE AO_TS_VAL_t AO_test_and_set_full(volatile AO_TS_t *addr)
Definition:
avr32.h:33
AO_TS_t
#define AO_TS_t
Definition:
gcc/hppa.h:39
AO_TS_VAL_t
#define AO_TS_VAL_t
Definition:
gcc/hppa.h:44
src
atomic_ops
sysdeps
gcc
avr32.h
Generated on Wed Dec 20 2023 18:12:50 for PAPI by
1.9.6