<commit_before>/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkAtomics_win_DEFINED
#define SkAtomics_win_DEFINED

/** Windows Interlocked atomics. */

#include <intrin.h>
#include <stdint.h>

//MSDN says in order to declare an interlocked function for use as an
//intrinsic, include intrin.h and put the function in a #pragma intrinsic
//directive.
//The pragma appears to be unnecessary, but doesn't hurt.
#pragma intrinsic(_InterlockedIncrement, _InterlockedExchangeAdd, _InterlockedDecrement)
#pragma intrinsic(_InterlockedCompareExchange)

static inline int32_t sk_atomic_inc(int32_t* addr) {
    // InterlockedIncrement returns the new value, we want to return the old.
    return _InterlockedIncrement(reinterpret_cast<long*>(addr)) - 1;
}

static inline int32_t sk_atomic_add(int32_t* addr, int32_t inc) {
    return _InterlockedExchangeAdd(reinterpret_cast<long*>(addr), static_cast<long>(inc));
}

static inline int32_t sk_atomic_dec(int32_t* addr) {
    // InterlockedDecrement returns the new value, we want to return the old.
    return _InterlockedDecrement(reinterpret_cast<long*>(addr)) + 1;
}

static inline void sk_membar_acquire__after_atomic_dec() { }

static inline bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after) {
    return _InterlockedCompareExchange(reinterpret_cast<long*>(addr), after, before) == before;
}

static inline void* sk_atomic_cas(void** addr, void* before, void* after) {
    return InterlockedCompareExchangePointer(addr, after, before);
}

static inline void sk_membar_acquire__after_atomic_conditional_inc() { }

#endif<commit_msg>Revert of Fix SkAtomics_win.h typos. (https://codereview.chromium.org/293363017/)<commit_after>/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkAtomics_win_DEFINED
#define SkAtomics_win_DEFINED

/** Windows Interlocked atomics. */

#include <intrin.h>
#include <stdint.h>

//MSDN says in order to declare an interlocked function for use as an
//intrinsic, include intrin.h and put the function in a #pragma intrinsic
//directive.
//The pragma appears to be unnecessary, but doesn't hurt.
#pragma intrinsic(_InterlockedIncrement, _InterlockedExchangeAdd, _InterlockedDecrement)
#pragma intrinsic(_InterlockedCompareExchange)

static inline int32_t sk_atomic_inc(int32_t* addr) {
    // InterlockedIncrement returns the new value, we want to return the old.
    return _InterlockedIncrement(reinterpret_cast<long*>(addr)) - 1;
}

static inline int32_t sk_atomic_add(int32_t* addr, int32_t inc) {
    return _InterlockedExchangeAdd(reinterpret_cast<long*>(addr), static_cast<long>(inc));
}

static inline int32_t sk_atomic_dec(int32_t* addr) {
    // InterlockedDecrement returns the new value, we want to return the old.
    return _InterlockedDecrement(reinterpret_cast<long*>(addr)) + 1;
}

static inline void sk_membar_acquire__after_atomic_dec() { }

static inline bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after) {
    return _InterlockedCompareExchange(reinterpret_cast<long*>(addr), after, before) == before;
}

static inline void* sk_atomic_cas(void** addr, void* before, void* after) {
    return InterlockedCompareExchange(reinterpret_cast<long*>(addr), after, before);
}

static inline void sk_membar_acquire__after_atomic_conditional_inc() { }

#endif
{'fraction_non_alphanumeric': 0.09195402298850575, 'fraction_numerical': 0.01752873563218391, 'mean_word_length': 5.59280303030303, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 1, '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': '6115870', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1080, 'n_words': 322}