<commit_before>#ifndef __YARNS_ATOMIC__
#define __YARNS_ATOMIC__

#include <stdbool.h>

#define ATOMIC_API_GCC 1
#define ATOMIC_API_OSATOMIC 2

#if defined(__ppc__)
#define ATOMIC_API ATOMIC_API_OSATOMIC
#else
#define ATOMIC_API ATOMIC_API_GCC
#endif

#if ATOMIC_API == ATOMIC_API_GCC

static inline bool atomic_cswap_value ( volatile unsigned long* ptr, unsigned long oldValue, unsigned long newValue )
{
	return __sync_bool_compare_and_swap(ptr, oldValue, newValue);
}

static inline bool atomic_cswap_pointer ( void* volatile* ptr, void* oldValue, void* newValue )
{
	return __sync_bool_compare_and_swap(ptr, oldValue, newValue);
}

static inline unsigned long atomic_add ( volatile unsigned long* ptr, long amount )
{
	return __sync_fetch_and_add(ptr, amount);
}

#else

#include <libkern/OSAtomic.h>

static inline bool atomic_cswap_value ( volatile unsigned long* ptr, unsigned long oldValue, unsigned long newValue )
{
#ifdef __LP64__
	return OSAtomicCompareAndSwap64(oldValue, newValue, (int64_t volatile*)ptr);
#else
	return OSAtomicCompareAndSwap32(oldValue, newValue, (int32_t volatile*)ptr);<commit_msg>Made atomic_cswap_value under the OSAtomic API use memory barriers.<commit_after>#ifndef __YARNS_ATOMIC__
#define __YARNS_ATOMIC__

#include <stdbool.h>

#define ATOMIC_API_GCC 1
#define ATOMIC_API_OSATOMIC 2

#if defined(__ppc__)
#define ATOMIC_API ATOMIC_API_OSATOMIC
#else
#define ATOMIC_API ATOMIC_API_GCC
#endif

#if ATOMIC_API == ATOMIC_API_GCC

static inline bool atomic_cswap_value ( volatile unsigned long* ptr, unsigned long oldValue, unsigned long newValue )
{
	return __sync_bool_compare_and_swap(ptr, oldValue, newValue);
}

static inline bool atomic_cswap_pointer ( void* volatile* ptr, void* oldValue, void* newValue )
{
	return __sync_bool_compare_and_swap(ptr, oldValue, newValue);
}

static inline unsigned long atomic_add ( volatile unsigned long* ptr, long amount )
{
	return __sync_fetch_and_add(ptr, amount);
}

#else

#include <libkern/OSAtomic.h>

static inline bool atomic_cswap_value ( volatile unsigned long* ptr, unsigned long oldValue, unsigned long newValue )
{
#ifdef __LP64__
	return OSAtomicCompareAndSwap64Barrier(oldValue, newValue, (int64_t volatile*)ptr);
#else
	return OSAtomicCompareAndSwap32Barrier(oldValue, newValue, (int32_t volatile*)ptr);
{'fraction_non_alphanumeric': 0.07702349869451697, 'fraction_numerical': 0.010443864229765013, 'mean_word_length': 7.210714285714285, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1496401', 'n_tokens_mistral': 825, 'n_tokens_neox': 803, 'n_words': 211}