implemented Setup.hs to build boehm cpp libs and install them;
[hs-boehmgc.git] / gc-7.2 / libatomic_ops / src / atomic_ops / sysdeps / ibmc / powerpc.h
1 /* FIXME.  This is only a placeholder for the AIX compiler.             */
2 /* It doesn't work.  Please send a patch.                               */
3 /* Memory model documented at http://www-106.ibm.com/developerworks/    */
4 /* eserver/articles/archguide.html and (clearer)                        */
5 /* http://www-106.ibm.com/developerworks/eserver/articles/powerpc.html. */
6 /* There appears to be no implicit ordering between any kind of         */
7 /* independent memory references.                                       */
8 /* Architecture enforces some ordering based on control dependence.     */
9 /* I don't know if that could help.                                     */
10 /* Data-dependent loads are always ordered.                             */
11 /* Based on the above references, eieio is intended for use on          */
12 /* uncached memory, which we don't support.  It does not order loads    */
13 /* from cached memory.                                                  */
14 /* Thanks to Maged Michael, Doug Lea, and Roger Hoover for helping to   */
15 /* track some of this down and correcting my misunderstandings. -HB     */
16
17 #include "../all_aligned_atomic_load_store.h"
18
19 void AO_sync(void);
20 #pragma mc_func AO_sync { "7c0004ac" }
21
22 #ifdef __NO_LWSYNC__
23 # define AO_lwsync AO_sync
24 #else
25   void AO_lwsync(void);
26 #pragma mc_func AO_lwsync { "7c2004ac" }
27 #endif
28
29 #define AO_nop_write() AO_lwsync()
30 #define AO_HAVE_nop_write
31
32 #define AO_nop_read() AO_lwsync()
33 #define AO_HAVE_nop_read
34
35 /* We explicitly specify load_acquire and store_release, since these    */
36 /* rely on the fact that lwsync is also a LoadStore barrier.            */
37 AO_INLINE AO_t
38 AO_load_acquire(const volatile AO_t *addr)
39 {
40   AO_t result = *addr;
41   AO_lwsync();
42   return result;
43 }
44 #define AO_HAVE_load_acquire
45
46 AO_INLINE void
47 AO_store_release(volatile AO_t *addr, AO_t value)
48 {
49   AO_lwsync();
50   *addr = value;
51 }
52 #define AO_HAVE_store_release
53
54 /* This is similar to the code in the garbage collector.  Deleting      */
55 /* this and having it synthesized from compare_and_swap would probably  */
56 /* only cost us a load immediate instruction.                           */
57 /*AO_INLINE AO_TS_VAL_t
58 AO_test_and_set(volatile AO_TS_t *addr) {
59 # error FIXME Implement me
60 }
61 #define AO_HAVE_test_and_set*/
62
63 AO_INLINE AO_TS_VAL_t
64 AO_test_and_set_acquire(volatile AO_TS_t *addr) {
65   AO_TS_VAL_t result = AO_test_and_set(addr);
66   AO_lwsync();
67   return result;
68 }
69 #define AO_HAVE_test_and_set_acquire
70
71 AO_INLINE AO_TS_VAL_t
72 AO_test_and_set_release(volatile AO_TS_t *addr) {
73   AO_lwsync();
74   return AO_test_and_set(addr);
75 }
76 #define AO_HAVE_test_and_set_release
77
78 AO_INLINE AO_TS_VAL_t
79 AO_test_and_set_full(volatile AO_TS_t *addr) {
80   AO_TS_VAL_t result;
81   AO_lwsync();
82   result = AO_test_and_set(addr);
83   AO_lwsync();
84   return result;
85 }
86 #define AO_HAVE_test_and_set_full
87
88 /*AO_INLINE int
89 AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)
90 {
91 # error FIXME Implement me
92 }
93 #define AO_HAVE_compare_and_swap*/
94
95 AO_INLINE int
96 AO_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val)
97 {
98   int result = AO_compare_and_swap(addr, old, new_val);
99   AO_lwsync();
100   return result;
101 }
102 #define AO_HAVE_compare_and_swap_acquire
103
104 AO_INLINE int
105 AO_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val)
106 {
107   AO_lwsync();
108   return AO_compare_and_swap(addr, old, new_val);
109 }
110 #define AO_HAVE_compare_and_swap_release
111
112 AO_INLINE int
113 AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
114 {
115   int result;
116   AO_lwsync();
117   result = AO_compare_and_swap(addr, old, new_val);
118   AO_lwsync();
119   return result;
120 }
121 #define AO_HAVE_compare_and_swap_full
122
123 /* FIXME: We should also implement fetch_and_add and or primitives      */
124 /* directly.                                                            */