#ifndef SWIFT_ATOMIC_ATOMIC_H
#define SWIFT_ATOMIC_ATOMIC_H

#include <swift/stdlib.h>

#include <swift/atomic/api.h>

typedef struct swift_atomic_t swift_atomic_t;

struct swift_atomic_t {
	int value;
};

#define SWIFT_ATOMIC(...) ((swift_atomic_t){__VA_ARGS__})

SWIFT_ATOMIC_API int swift_atomic_get(swift_atomic_t *atomic);
SWIFT_ATOMIC_API void swift_atomic_set(swift_atomic_t *atomic, int value);
SWIFT_ATOMIC_API void swift_atomic_add(swift_atomic_t *atomic, int value);
SWIFT_ATOMIC_API void swift_atomic_sub(swift_atomic_t *atomic, int value);
SWIFT_ATOMIC_API void swift_atomic_inc(swift_atomic_t *atomic);
SWIFT_ATOMIC_API void swift_atomic_dec(swift_atomic_t *atomic);
SWIFT_ATOMIC_API int swift_atomic_add_ret(swift_atomic_t *atomic, int value);
SWIFT_ATOMIC_API int swift_atomic_sub_ret(swift_atomic_t *atomic, int value);
SWIFT_ATOMIC_API int swift_atomic_inc_ret(swift_atomic_t *atomic);
SWIFT_ATOMIC_API int swift_atomic_dec_ret(swift_atomic_t *atomic);
SWIFT_ATOMIC_API bool swift_atomic_inc_test(swift_atomic_t *atomic);
SWIFT_ATOMIC_API bool swift_atomic_dec_test(swift_atomic_t *atomic);
SWIFT_ATOMIC_API bool swift_atomic_add_unless(swift_atomic_t *atomic,
	int addend, int comparand);
SWIFT_ATOMIC_API int swift_atomic_swap(swift_atomic_t *atomic, int value);
SWIFT_ATOMIC_API bool swift_atomic_cmp_swap(swift_atomic_t *atomic,
	int old_value, int value);

#endif /* SWIFT_ATOMIC_ATOMIC_H */

