1 /*
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.
5 *
6 *
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
9 *
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.
15 *
16 */
17
18 /* The cas instruction causes an emulation trap for the */
19 /* 060 with a misaligned pointer, so let's avoid this. */
20 #undef AO_t
21 typedef unsigned long AO_t __attribute__ ((aligned (4)));
22
23 /* FIXME. Very incomplete. */
24 #include "../all_aligned_atomic_load_store.h"
25
26 /* Are there any m68k multiprocessors still around? */
27 /* AFAIK, Alliants were sequentially consistent. */
28 #include "../ordered.h"
29
30 #include "../test_and_set_t_is_char.h"
31
32 /* Contributed by Tony Mantler or new. Should be changed to MIT license? */
33 AO_INLINE AO_TS_VAL_t
AO_test_and_set_full(volatile AO_TS_t * addr)34 AO_test_and_set_full(volatile AO_TS_t *addr) {
35 AO_TS_t oldval;
36
37 /* The value at addr is semi-phony. */
38 /* 'tas' sets bit 7 while the return */
39 /* value pretends all bits were set, */
40 /* which at least matches AO_TS_SET. */
41 __asm__ __volatile__(
42 "tas %1; sne %0"
43 : "=d" (oldval), "=m" (*addr)
44 : "m" (*addr)
45 : "memory");
46 return oldval;
47 }
48
49 #define AO_HAVE_test_and_set_full
50
51 /* Returns nonzero if the comparison succeeded. */
52 AO_INLINE int
AO_compare_and_swap_full(volatile AO_t * addr,AO_t old,AO_t new_val)53 AO_compare_and_swap_full(volatile AO_t *addr,
54 AO_t old, AO_t new_val)
55 {
56 char result;
57
58 __asm__ __volatile__(
59 "cas.l %3,%4,%1; seq %0"
60 : "=d" (result), "=m" (*addr)
61 : "m" (*addr), "d" (old), "d" (new_val)
62 : "memory");
63 return -result;
64 }
65
66 #define AO_HAVE_compare_and_swap_full
67
68
69 #include "../ao_t_is_int.h"
70