summaryrefslogtreecommitdiff
path: root/libgo/go/sync/atomic/atomic.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/sync/atomic/atomic.c')
-rw-r--r--libgo/go/sync/atomic/atomic.c129
1 files changed, 106 insertions, 23 deletions
diff --git a/libgo/go/sync/atomic/atomic.c b/libgo/go/sync/atomic/atomic.c
index 32430df2ba2..f0ba57b3cca 100644
--- a/libgo/go/sync/atomic/atomic.c
+++ b/libgo/go/sync/atomic/atomic.c
@@ -8,8 +8,69 @@
#include "runtime.h"
+int32_t SwapInt32 (int32_t *, int32_t)
+ __asm__ (GOSYM_PREFIX "sync_atomic.SwapInt32")
+ __attribute__ ((no_split_stack));
+
+int32_t
+SwapInt32 (int32_t *addr, int32_t new)
+{
+ return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST);
+}
+
+int64_t SwapInt64 (int64_t *, int64_t)
+ __asm__ (GOSYM_PREFIX "sync_atomic.SwapInt64")
+ __attribute__ ((no_split_stack));
+
+int64_t
+SwapInt64 (int64_t *addr, int64_t new)
+{
+ return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST);
+}
+
+uint32_t SwapUint32 (uint32_t *, uint32_t)
+ __asm__ (GOSYM_PREFIX "sync_atomic.SwapUint32")
+ __attribute__ ((no_split_stack));
+
+uint32_t
+SwapUint32 (uint32_t *addr, uint32_t new)
+{
+ return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST);
+}
+
+uint64_t SwapUint64 (uint64_t *, uint64_t)
+ __asm__ (GOSYM_PREFIX "sync_atomic.SwapUint64")
+ __attribute__ ((no_split_stack));
+
+uint64_t
+SwapUint64 (uint64_t *addr, uint64_t new)
+{
+ return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST);
+}
+
+uintptr_t SwapUintptr (uintptr_t *, uintptr_t)
+ __asm__ (GOSYM_PREFIX "sync_atomic.SwapUintptr")
+ __attribute__ ((no_split_stack));
+
+uintptr_t
+SwapUintptr (uintptr_t *addr, uintptr_t new)
+{
+ return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST);
+}
+
+void *SwapPointer (void **, void *)
+ __asm__ (GOSYM_PREFIX "sync_atomic.SwapPointer")
+ __attribute__ ((no_split_stack));
+
+void *
+SwapPointer (void **addr, void *new)
+{
+ return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST);
+}
+
_Bool CompareAndSwapInt32 (int32_t *, int32_t, int32_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapInt32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapInt32")
+ __attribute__ ((no_split_stack));
_Bool
CompareAndSwapInt32 (int32_t *val, int32_t old, int32_t new)
@@ -18,7 +79,8 @@ CompareAndSwapInt32 (int32_t *val, int32_t old, int32_t new)
}
_Bool CompareAndSwapInt64 (int64_t *, int64_t, int64_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapInt64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapInt64")
+ __attribute__ ((no_split_stack));
_Bool
CompareAndSwapInt64 (int64_t *val, int64_t old, int64_t new)
@@ -27,7 +89,8 @@ CompareAndSwapInt64 (int64_t *val, int64_t old, int64_t new)
}
_Bool CompareAndSwapUint32 (uint32_t *, uint32_t, uint32_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapUint32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapUint32")
+ __attribute__ ((no_split_stack));
_Bool
CompareAndSwapUint32 (uint32_t *val, uint32_t old, uint32_t new)
@@ -36,7 +99,8 @@ CompareAndSwapUint32 (uint32_t *val, uint32_t old, uint32_t new)
}
_Bool CompareAndSwapUint64 (uint64_t *, uint64_t, uint64_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapUint64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapUint64")
+ __attribute__ ((no_split_stack));
_Bool
CompareAndSwapUint64 (uint64_t *val, uint64_t old, uint64_t new)
@@ -45,7 +109,8 @@ CompareAndSwapUint64 (uint64_t *val, uint64_t old, uint64_t new)
}
_Bool CompareAndSwapUintptr (uintptr_t *, uintptr_t, uintptr_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapUintptr");
+ __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapUintptr")
+ __attribute__ ((no_split_stack));
_Bool
CompareAndSwapUintptr (uintptr_t *val, uintptr_t old, uintptr_t new)
@@ -54,7 +119,8 @@ CompareAndSwapUintptr (uintptr_t *val, uintptr_t old, uintptr_t new)
}
_Bool CompareAndSwapPointer (void **, void *, void *)
- __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapPointer");
+ __asm__ (GOSYM_PREFIX "sync_atomic.CompareAndSwapPointer")
+ __attribute__ ((no_split_stack));
_Bool
CompareAndSwapPointer (void **val, void *old, void *new)
@@ -63,7 +129,8 @@ CompareAndSwapPointer (void **val, void *old, void *new)
}
int32_t AddInt32 (int32_t *, int32_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.AddInt32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.AddInt32")
+ __attribute__ ((no_split_stack));
int32_t
AddInt32 (int32_t *val, int32_t delta)
@@ -72,7 +139,8 @@ AddInt32 (int32_t *val, int32_t delta)
}
uint32_t AddUint32 (uint32_t *, uint32_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.AddUint32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.AddUint32")
+ __attribute__ ((no_split_stack));
uint32_t
AddUint32 (uint32_t *val, uint32_t delta)
@@ -81,7 +149,8 @@ AddUint32 (uint32_t *val, uint32_t delta)
}
int64_t AddInt64 (int64_t *, int64_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.AddInt64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.AddInt64")
+ __attribute__ ((no_split_stack));
int64_t
AddInt64 (int64_t *val, int64_t delta)
@@ -90,7 +159,8 @@ AddInt64 (int64_t *val, int64_t delta)
}
uint64_t AddUint64 (uint64_t *, uint64_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.AddUint64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.AddUint64")
+ __attribute__ ((no_split_stack));
uint64_t
AddUint64 (uint64_t *val, uint64_t delta)
@@ -99,7 +169,8 @@ AddUint64 (uint64_t *val, uint64_t delta)
}
uintptr_t AddUintptr (uintptr_t *, uintptr_t)
- __asm__ (GOSYM_PREFIX "sync_atomic.AddUintptr");
+ __asm__ (GOSYM_PREFIX "sync_atomic.AddUintptr")
+ __attribute__ ((no_split_stack));
uintptr_t
AddUintptr (uintptr_t *val, uintptr_t delta)
@@ -108,7 +179,8 @@ AddUintptr (uintptr_t *val, uintptr_t delta)
}
int32_t LoadInt32 (int32_t *addr)
- __asm__ (GOSYM_PREFIX "sync_atomic.LoadInt32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.LoadInt32")
+ __attribute__ ((no_split_stack));
int32_t
LoadInt32 (int32_t *addr)
@@ -122,7 +194,8 @@ LoadInt32 (int32_t *addr)
}
int64_t LoadInt64 (int64_t *addr)
- __asm__ (GOSYM_PREFIX "sync_atomic.LoadInt64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.LoadInt64")
+ __attribute__ ((no_split_stack));
int64_t
LoadInt64 (int64_t *addr)
@@ -136,7 +209,8 @@ LoadInt64 (int64_t *addr)
}
uint32_t LoadUint32 (uint32_t *addr)
- __asm__ (GOSYM_PREFIX "sync_atomic.LoadUint32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.LoadUint32")
+ __attribute__ ((no_split_stack));
uint32_t
LoadUint32 (uint32_t *addr)
@@ -150,7 +224,8 @@ LoadUint32 (uint32_t *addr)
}
uint64_t LoadUint64 (uint64_t *addr)
- __asm__ (GOSYM_PREFIX "sync_atomic.LoadUint64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.LoadUint64")
+ __attribute__ ((no_split_stack));
uint64_t
LoadUint64 (uint64_t *addr)
@@ -164,7 +239,8 @@ LoadUint64 (uint64_t *addr)
}
uintptr_t LoadUintptr (uintptr_t *addr)
- __asm__ (GOSYM_PREFIX "sync_atomic.LoadUintptr");
+ __asm__ (GOSYM_PREFIX "sync_atomic.LoadUintptr")
+ __attribute__ ((no_split_stack));
uintptr_t
LoadUintptr (uintptr_t *addr)
@@ -178,7 +254,8 @@ LoadUintptr (uintptr_t *addr)
}
void *LoadPointer (void **addr)
- __asm__ (GOSYM_PREFIX "sync_atomic.LoadPointer");
+ __asm__ (GOSYM_PREFIX "sync_atomic.LoadPointer")
+ __attribute__ ((no_split_stack));
void *
LoadPointer (void **addr)
@@ -192,7 +269,8 @@ LoadPointer (void **addr)
}
void StoreInt32 (int32_t *addr, int32_t val)
- __asm__ (GOSYM_PREFIX "sync_atomic.StoreInt32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.StoreInt32")
+ __attribute__ ((no_split_stack));
void
StoreInt32 (int32_t *addr, int32_t val)
@@ -205,7 +283,8 @@ StoreInt32 (int32_t *addr, int32_t val)
}
void StoreInt64 (int64_t *addr, int64_t val)
- __asm__ (GOSYM_PREFIX "sync_atomic.StoreInt64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.StoreInt64")
+ __attribute__ ((no_split_stack));
void
StoreInt64 (int64_t *addr, int64_t val)
@@ -218,7 +297,8 @@ StoreInt64 (int64_t *addr, int64_t val)
}
void StoreUint32 (uint32_t *addr, uint32_t val)
- __asm__ (GOSYM_PREFIX "sync_atomic.StoreUint32");
+ __asm__ (GOSYM_PREFIX "sync_atomic.StoreUint32")
+ __attribute__ ((no_split_stack));
void
StoreUint32 (uint32_t *addr, uint32_t val)
@@ -231,7 +311,8 @@ StoreUint32 (uint32_t *addr, uint32_t val)
}
void StoreUint64 (uint64_t *addr, uint64_t val)
- __asm__ (GOSYM_PREFIX "sync_atomic.StoreUint64");
+ __asm__ (GOSYM_PREFIX "sync_atomic.StoreUint64")
+ __attribute__ ((no_split_stack));
void
StoreUint64 (uint64_t *addr, uint64_t val)
@@ -244,7 +325,8 @@ StoreUint64 (uint64_t *addr, uint64_t val)
}
void StoreUintptr (uintptr_t *addr, uintptr_t val)
- __asm__ (GOSYM_PREFIX "sync_atomic.StoreUintptr");
+ __asm__ (GOSYM_PREFIX "sync_atomic.StoreUintptr")
+ __attribute__ ((no_split_stack));
void
StoreUintptr (uintptr_t *addr, uintptr_t val)
@@ -257,7 +339,8 @@ StoreUintptr (uintptr_t *addr, uintptr_t val)
}
void StorePointer (void **addr, void *val)
- __asm__ (GOSYM_PREFIX "sync_atomic.StorePointer");
+ __asm__ (GOSYM_PREFIX "sync_atomic.StorePointer")
+ __attribute__ ((no_split_stack));
void
StorePointer (void **addr, void *val)