2 * Copyright (c) 2005,2007 Thiemo Seufer <ths@networkno.de>
\r
4 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
\r
5 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
\r
7 * Permission is hereby granted to use or copy this program
\r
8 * for any purpose, provided the above notices are retained on all copies.
\r
9 * Permission to modify the code and to distribute modified code is granted,
\r
10 * provided the above notices are retained, and a notice that the code was
\r
11 * modified is included with the above copyright notice.
\r
15 * FIXME: This should probably make finer distinctions. SGI MIPS is
\r
16 * much more strongly ordered, and in fact closer to sequentially
\r
17 * consistent. This is really aimed at modern embedded implementations.
\r
18 * It looks to me like this assumes a 32-bit ABI. -HB
\r
21 #include "../all_aligned_atomic_load_store.h"
\r
22 #include "../acquire_release_volatile.h"
\r
23 #include "../test_and_set_t_is_ao_t.h"
\r
24 #include "../standard_ao_double_t.h"
\r
26 /* Data dependence does not imply read ordering. */
\r
27 #define AO_NO_DD_ORDERING
\r
32 __asm__ __volatile__(
\r
35 " .set noreorder \n"
\r
42 #define AO_HAVE_nop_full
\r
45 AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)
\r
47 register int was_equal = 0;
\r
50 __asm__ __volatile__(
\r
53 " .set noreorder \n"
\r
56 " bne %0, %4, 2f \n"
\r
63 : "=&r" (temp), "+R" (*addr), "+r" (was_equal)
\r
64 : "r" (new_val), "r" (old)
\r
69 #define AO_HAVE_compare_and_swap
\r
71 /* FIXME: I think the implementations below should be automatically */
\r
72 /* generated if we omit them. - HB */
\r
75 AO_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val) {
\r
76 int result = AO_compare_and_swap(addr, old, new_val);
\r
81 #define AO_HAVE_compare_and_swap_acquire
\r
84 AO_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val) {
\r
86 return AO_compare_and_swap(addr, old, new_val);
\r
89 #define AO_HAVE_compare_and_swap_release
\r
92 AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) {
\r
95 result = AO_compare_and_swap(addr, old, new_val);
\r
100 #define AO_HAVE_compare_and_swap_full
\r
103 * FIXME: We should also implement fetch_and_add and or primitives
\r
107 #include "../ao_t_is_int.h"
\r