2 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
3 * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
4 * Copyright (c) 1999-2003 by Hewlett-Packard Company. All rights reserved.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
18 #include "../atomic_load_store.h"
20 #include "../test_and_set_t_is_ao_t.h"
22 #define AO_NO_DD_ORDERING
23 /* Data dependence does not imply read ordering. */
28 __asm__ __volatile__("mb" : : : "memory");
30 #define AO_HAVE_nop_full
35 __asm__ __volatile__("wmb" : : : "memory");
37 #define AO_HAVE_nop_write
39 /* mb should be used for AO_nop_read(). That's the default. */
41 /* We believe that ldq_l ... stq_c does not imply any memory barrier. */
42 /* We should add an explicit fetch_and_add definition. */
44 AO_compare_and_swap(volatile AO_t *addr,
45 AO_t old, AO_t new_val)
47 unsigned long was_equal;
58 :"=&r" (temp), "=m" (*addr), "=&r" (was_equal)
59 : "r" (new_val), "Ir" (old)
61 return (int)was_equal;
63 #define AO_HAVE_compare_and_swap