summaryrefslogtreecommitdiff
blob: 4e8dd66a355426cddf1085e246c0d6e3f8d0fc6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--- libatomic_ops/src/atomic_ops.h
+++ libatomic_ops/src/atomic_ops.h
@@ -228,6 +228,10 @@
 # if defined(__cris__) || defined(CRIS)
 #   include "atomic_ops/sysdeps/gcc/cris.h"
 # endif
+# if defined(__sh__) || defined(SH4)
+#   include "atomic_ops/sysdeps/gcc/sh.h"
+#   define AO_CAN_EMUL_CAS
+# endif /* __sh__ */
 #endif /* __GNUC__ && !AO_USE_PTHREAD_DEFS */
 
 #if defined(__INTEL_COMPILER) && !defined(AO_USE_PTHREAD_DEFS)
only in patch2:
unchanged:
--- libatomic_ops/src/atomic_ops/sysdeps/Makefile.am
+++ libatomic_ops/src/atomic_ops/sysdeps/Makefile.am
@@ -29,6 +29,7 @@
 	  gcc/powerpc.h gcc/sparc.h \
 	  gcc/hppa.h gcc/m68k.h gcc/s390.h \
 	  gcc/ia64.h gcc/x86_64.h gcc/cris.h \
+	  gcc/sh.h \
 	\
 	  icc/ia64.h \
 	\
--- libatomic_ops/src/atomic_ops/sysdeps/gcc/sh.h
+++ libatomic_ops/src/atomic_ops/sysdeps/gcc/sh.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2009 by Takashi YOSHII. All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include "../all_atomic_load_store.h"
+#include "../ordered.h"
+
+/* sh has tas.b(byte) only */
+#include "../test_and_set_t_is_char.h"
+
+AO_INLINE AO_TS_VAL_t
+AO_test_and_set_full(volatile AO_TS_t *addr)
+{
+  int oldval;
+  __asm__ __volatile__(
+        "tas.b @%1; movt %0"
+        : "=r" (oldval)
+        : "r" (addr)
+        : "t", "memory");
+  return oldval? AO_TS_CLEAR : AO_TS_SET;
+}
+#define AO_HAVE_test_and_set_full