<commit_before>﻿/**
 * @file atomic_int_type.h
 * @brief 整数类型的原子操作跨平台适配
 * Licensed under the MIT licenses.
 *
 * @version 1.0
 * @author OWenT
 * @date 2016-06-14
 *
 * @note VC 2012+, GCC 4.4 + 使用C++0x/11实现实现原子操作
 * @note 低版本 VC使用InterlockedExchange等实现原子操作
 * @note 低版本 GCC采用__sync_lock_test_and_set等实现原子操作
 *
 * @history
 *     2016-06-14
 */

#ifndef UTIL_LOCK_ATOMIC_INT_TYPE_H
#define UTIL_LOCK_ATOMIC_INT_TYPE_H

#pragma once

#include "std/explicit_declare.h"

#if defined(__GNUC__)

// patch for old gcc
#ifndef __STDC_LIMIT_MACROS
#define _UNDEF__STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
#define _UNDEF__STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <limits.h>
#include <stdint.h>
#ifdef _UNDEF__STDC_LIMIT_MACROS
#undef __STDC_LIMIT_MACROS
#undef _UNDEF__STDC_LIMIT_MACROS
#endif
#ifdef _UNDEF__STDC_CONSTANT_MACROS
#undef __STDC_CONSTANT_MACROS
#undef _UNDEF__STDC_CONSTANT_MACROS
#endif

#endif

#if __cplusplus >= 201103L
#include <cstdint>
#elif defined(_MSC_VER) && defined(_MSVC_LANG) && _MSVC_LANG >= 201402L
#include <cstdint>
#endif

#if defined(__cplusplus) && __cplusplus >= 201103L

#include <atomic>
#define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

#elif defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) && __cplusplus >= 201103L

#include <atomic>
#define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

#elif defined(_MSC_VER) && (_MSC_VER >= 1900) // 1900 means VC 14.0,2015, there some problem with std::atomic implement in old MSVC

#include <atomic>
#define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

// There is a BUG in gcc 4.6, which will cause 'undefined reference to `std::atomic_thread_fence(std::memory_order)'
// In gcc 4.7 and upper, we can use -std=c++11 or upper
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51038
// #elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
//
// #include <atomic>
// #define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

#endif

#if !defined(__UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD) && defined(_MSC_VER)
#include "atomic_int_type_msvc_impl.h"
#endif

#include <cstddef>

#include "config/compile_optimize.h"
#include "config/compiler_features.h"


namespace util {
    namespace lock {<commit_msg>add commonts for using atomic_int_type_msvc_impl on MSVC 12<commit_after>﻿/**
 * @file atomic_int_type.h
 * @brief 整数类型的原子操作跨平台适配
 * Licensed under the MIT licenses.
 *
 * @version 1.0
 * @author OWenT
 * @date 2016-06-14
 *
 * @note VC 2012+, GCC 4.4 + 使用C++0x/11实现实现原子操作
 * @note 低版本 VC使用InterlockedExchange等实现原子操作
 * @note 低版本 GCC采用__sync_lock_test_and_set等实现原子操作
 *
 * @history
 *     2016-06-14
 */

#ifndef UTIL_LOCK_ATOMIC_INT_TYPE_H
#define UTIL_LOCK_ATOMIC_INT_TYPE_H

#pragma once

#include "std/explicit_declare.h"

#if defined(__GNUC__)

// patch for old gcc
#ifndef __STDC_LIMIT_MACROS
#define _UNDEF__STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
#define _UNDEF__STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <limits.h>
#include <stdint.h>
#ifdef _UNDEF__STDC_LIMIT_MACROS
#undef __STDC_LIMIT_MACROS
#undef _UNDEF__STDC_LIMIT_MACROS
#endif
#ifdef _UNDEF__STDC_CONSTANT_MACROS
#undef __STDC_CONSTANT_MACROS
#undef _UNDEF__STDC_CONSTANT_MACROS
#endif

#endif

#if __cplusplus >= 201103L
#include <cstdint>
#elif defined(_MSC_VER) && defined(_MSVC_LANG) && _MSVC_LANG >= 201402L
#include <cstdint>
#endif

#if defined(__cplusplus) && __cplusplus >= 201103L

#include <atomic>
#define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

#elif defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) && __cplusplus >= 201103L

#include <atomic>
#define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

#elif defined(_MSC_VER) && (_MSC_VER >= 1900) // 1900 means VC 14.0,2015, there some problem with std::atomic implement in old MSVC

// VS 2013 or below may cause deadlock, more details can be seen at:
//   https://ci.appveyor.com/project/owt5008137/atframe-utils/builds/21245325
//   https://devblogs.microsoft.com/cppblog/stl-fixes-in-vs-2015-part-2/

#include <atomic>
#define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

// There is a BUG in gcc 4.6, which will cause 'undefined reference to `std::atomic_thread_fence(std::memory_order)'
// In gcc 4.7 and upper, we can use -std=c++11 or upper
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51038
// #elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
//
// #include <atomic>
// #define __UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD

#endif

#if !defined(__UTIL_LOCK_ATOMIC_INT_TYPE_ATOMIC_STD) && defined(_MSC_VER)
#include "atomic_int_type_msvc_impl.h"
#endif

#include <cstddef>

#include "config/compile_optimize.h"
#include "config/compiler_features.h"


namespace util {
    namespace lock {
{'fraction_non_alphanumeric': 0.1113364429121882, 'fraction_numerical': 0.03934293246805922, 'mean_word_length': 5.8310249307479225, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 39, 'https://': 4, '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': '1184701', 'n_tokens_mistral': 2231, 'n_tokens_neox': 2049, 'n_words': 400}