1718d7149SJérôme Duval/*
2718d7149SJérôme Duval * Copyright 2003, Marcus Overhagen. All rights reserved.
347a21c5cSAugustin Cavalier * Distributed under the terms of the MIT License.
4718d7149SJérôme Duval */
550e0ce4bSbeveloper
6327981c3SAxel Dörfler
750e0ce4bSbeveloper#include <SupportDefs.h>
850e0ce4bSbeveloper
950e0ce4bSbeveloper#include <syscalls.h>
1050e0ce4bSbeveloper
11327981c3SAxel Dörfler
1250e0ce4bSbeveloper#ifdef ATOMIC_FUNCS_ARE_SYSCALLS
13327981c3SAxel Dörfler
1424f0b1e2SAlexander von Gluck IVvoid
1524f0b1e2SAlexander von Gluck IVatomic_set(int32 *value, int32 newValue)
1650e0ce4bSbeveloper{
1724f0b1e2SAlexander von Gluck IV	_kern_atomic_set(value, newValue);
1850e0ce4bSbeveloper}
1950e0ce4bSbeveloper
2024f0b1e2SAlexander von Gluck IV
218f4db360SIthamar R. Ademaint32
228f4db360SIthamar R. Ademaatomic_get_and_set(int32 *value, int32 newValue)
238f4db360SIthamar R. Adema{
248f4db360SIthamar R. Adema	return _kern_atomic_get_and_set(value, newValue);
258f4db360SIthamar R. Adema}
268f4db360SIthamar R. Adema
278f4db360SIthamar R. Adema
2850e0ce4bSbeveloperint32
2924f0b1e2SAlexander von Gluck IVatomic_test_and_set(int32 *value, int32 newValue, int32 testAgainst)
3050e0ce4bSbeveloper{
3150e0ce4bSbeveloper	return _kern_atomic_test_and_set(value, newValue, testAgainst);
3250e0ce4bSbeveloper}
3350e0ce4bSbeveloper
3424f0b1e2SAlexander von Gluck IV
3550e0ce4bSbeveloperint32
3624f0b1e2SAlexander von Gluck IVatomic_add(int32 *value, int32 addValue)
3750e0ce4bSbeveloper{
3850e0ce4bSbeveloper	return _kern_atomic_add(value, addValue);
3950e0ce4bSbeveloper}
4050e0ce4bSbeveloper
4124f0b1e2SAlexander von Gluck IV
4250e0ce4bSbeveloperint32
4324f0b1e2SAlexander von Gluck IVatomic_and(int32 *value, int32 andValue)
4450e0ce4bSbeveloper{
4550e0ce4bSbeveloper	return _kern_atomic_and(value, andValue);
4650e0ce4bSbeveloper}
4750e0ce4bSbeveloper
4824f0b1e2SAlexander von Gluck IV
4950e0ce4bSbeveloperint32
5024f0b1e2SAlexander von Gluck IVatomic_or(int32 *value, int32 orValue)
5150e0ce4bSbeveloper{
5250e0ce4bSbeveloper	return _kern_atomic_or(value, orValue);
5350e0ce4bSbeveloper}
5450e0ce4bSbeveloper
5524f0b1e2SAlexander von Gluck IV
5650e0ce4bSbeveloperint32
5724f0b1e2SAlexander von Gluck IVatomic_get(int32 *value)
5850e0ce4bSbeveloper{
59188b5de0Sbeveloper	return _kern_atomic_get(value);
6050e0ce4bSbeveloper}
61327981c3SAxel Dörfler
6224f0b1e2SAlexander von Gluck IV
63327981c3SAxel Dörfler#endif	/* ATOMIC_FUNCS_ARE_SYSCALLS */
6450e0ce4bSbeveloper
6550e0ce4bSbeveloper#ifdef ATOMIC64_FUNCS_ARE_SYSCALLS
66327981c3SAxel Dörfler
6724f0b1e2SAlexander von Gluck IVvoid
6824f0b1e2SAlexander von Gluck IVatomic_set64(int64 *value, int64 newValue)
6950e0ce4bSbeveloper{
7024f0b1e2SAlexander von Gluck IV	_kern_atomic_set64(value, newValue);
7150e0ce4bSbeveloper}
7250e0ce4bSbeveloper
7324f0b1e2SAlexander von Gluck IV
7450e0ce4bSbeveloperint64
7524f0b1e2SAlexander von Gluck IVatomic_test_and_set64(int64 *value, int64 newValue, int64 testAgainst)
7650e0ce4bSbeveloper{
7750e0ce4bSbeveloper	return _kern_atomic_test_and_set64(value, newValue, testAgainst);
7850e0ce4bSbeveloper}
7950e0ce4bSbeveloper
8024f0b1e2SAlexander von Gluck IV
8150e0ce4bSbeveloperint64
8224f0b1e2SAlexander von Gluck IVatomic_add64(int64 *value, int64 addValue)
8350e0ce4bSbeveloper{
8450e0ce4bSbeveloper	return _kern_atomic_add64(value, addValue);
8550e0ce4bSbeveloper}
8650e0ce4bSbeveloper
8724f0b1e2SAlexander von Gluck IV
8850e0ce4bSbeveloperint64
8924f0b1e2SAlexander von Gluck IVatomic_and64(int64 *value, int64 andValue)
9050e0ce4bSbeveloper{
9150e0ce4bSbeveloper	return _kern_atomic_and64(value, andValue);
9250e0ce4bSbeveloper}
9350e0ce4bSbeveloper
9424f0b1e2SAlexander von Gluck IV
9550e0ce4bSbeveloperint64
9624f0b1e2SAlexander von Gluck IVatomic_or64(int64 *value, int64 orValue)
9750e0ce4bSbeveloper{
9850e0ce4bSbeveloper	return _kern_atomic_or64(value, orValue);
9950e0ce4bSbeveloper}
10050e0ce4bSbeveloper
10124f0b1e2SAlexander von Gluck IV
10250e0ce4bSbeveloperint64
10324f0b1e2SAlexander von Gluck IVatomic_get64(int64 *value)
10450e0ce4bSbeveloper{
105188b5de0Sbeveloper	return _kern_atomic_get64(value);
10650e0ce4bSbeveloper}
107327981c3SAxel Dörfler
10824f0b1e2SAlexander von Gluck IV
109327981c3SAxel Dörfler#endif	/* ATOMIC64_FUNCS_ARE_SYSCALLS */
11075453edcSFrançois Revol
111376472a8SAugustin Cavalier#if defined(__arm__) && !defined(__clang__)
112f9ab70a1SFrançois Revol
113c436d67dSFrançois Revol/* GCC compatibility: libstdc++ needs this one.
114c436d67dSFrançois Revol * TODO: Update libstdc++ and drop this.
115c436d67dSFrançois Revol * cf. http://fedoraproject.org/wiki/Architectures/ARM/GCCBuiltInAtomicOperations
116c436d67dSFrançois Revol */
117f9ab70a1SFrançois Revolextern int32_t __sync_fetch_and_add_4(int32_t *value, int32_t addValue);
11875453edcSFrançois Revol
11975453edcSFrançois Revolextern int32_t __sync_fetch_and_add_4(int32_t *value, int32_t addValue)
12075453edcSFrançois Revol{
12124f0b1e2SAlexander von Gluck IV	return atomic_add((int32 *)value, addValue);
12275453edcSFrançois Revol}
123f9ab70a1SFrançois Revol
124f9ab70a1SFrançois Revol#endif
125