| 1 | /* |
| 2 | * Copyright (c) 2009 by Takashi YOSHII. All rights reserved. |
| 3 | * |
| 4 | * |
| 5 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED |
| 6 | * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. |
| 7 | * |
| 8 | * Permission is hereby granted to use or copy this program |
| 9 | * for any purpose, provided the above notices are retained on all copies. |
| 10 | * Permission to modify the code and to distribute modified code is granted, |
| 11 | * provided the above notices are retained, and a notice that the code was |
| 12 | * modified is included with the above copyright notice. |
| 13 | */ |
| 14 | |
| 15 | #include "../all_atomic_load_store.h" |
| 16 | #include "../ordered.h" |
| 17 | |
| 18 | /* sh has tas.b(byte) only */ |
| 19 | #include "../test_and_set_t_is_char.h" |
| 20 | |
| 21 | AO_INLINE AO_TS_VAL_t |
| 22 | AO_test_and_set_full(volatile AO_TS_t *addr) |
| 23 | { |
| 24 | int oldval; |
| 25 | __asm__ __volatile__( |
| 26 | "tas.b @%1; movt %0" |
| 27 | : "=r" (oldval) |
| 28 | : "r" (addr) |
| 29 | : "t", "memory"); |
| 30 | return oldval? AO_TS_CLEAR : AO_TS_SET; |
| 31 | } |
| 32 | #define AO_HAVE_test_and_set_full |
| 33 | |
| 34 | /* TODO: Very incomplete. */ |
| 35 | |