- 51e2d3690b9065da84dbbf71fb52f87149670719 Fix ABSL_HAVE_THREAD_LOCAL
on Apple 32-bit iOS simulato... by Xiaoyi Zhang <zhangxy@google.com>
- d38332e4d6b51542a42ff49fb0fc4f4a756fdd05 Internal change. by Abseil Team <absl-team@google.com> GitOrigin-RevId: 51e2d3690b9065da84dbbf71fb52f87149670719 Change-Id: I9403fc6308a6c731f1c8e2cd70fdb382fafd960e
This commit is contained in:
parent
abd0824ba6
commit
3f622d6c59
2 changed files with 20 additions and 13 deletions
|
@ -138,12 +138,16 @@
|
||||||
// supported.
|
// supported.
|
||||||
#ifdef ABSL_HAVE_THREAD_LOCAL
|
#ifdef ABSL_HAVE_THREAD_LOCAL
|
||||||
#error ABSL_HAVE_THREAD_LOCAL cannot be directly set
|
#error ABSL_HAVE_THREAD_LOCAL cannot be directly set
|
||||||
#elif (!defined(__apple_build_version__) || \
|
#elif defined(__APPLE__)
|
||||||
(__apple_build_version__ >= 8000042)) && \
|
|
||||||
!(defined(__APPLE__) && TARGET_OS_IPHONE && \
|
|
||||||
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
|
|
||||||
// Notes: Xcode's clang did not support `thread_local` until version
|
// Notes: Xcode's clang did not support `thread_local` until version
|
||||||
// 8, and even then not for all iOS < 9.0.
|
// 8, and even then not for all iOS < 9.0. Also, Xcode 9.3 started disallowing
|
||||||
|
// `thread_local` for 32-bit iOS simulator targeting iOS 9.x.
|
||||||
|
// `__has_feature` is only supported by Clang so it has be inside
|
||||||
|
// `defined(__APPLE__)` check.
|
||||||
|
#if __has_feature(cxx_thread_local)
|
||||||
|
#define ABSL_HAVE_THREAD_LOCAL 1
|
||||||
|
#endif
|
||||||
|
#else // !defined(__APPLE__)
|
||||||
#define ABSL_HAVE_THREAD_LOCAL 1
|
#define ABSL_HAVE_THREAD_LOCAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/base/casts.h"
|
||||||
#include "absl/numeric/int128.h"
|
#include "absl/numeric/int128.h"
|
||||||
#include "absl/time/time.h"
|
#include "absl/time/time.h"
|
||||||
|
|
||||||
|
@ -165,14 +166,16 @@ inline Duration MakeDurationFromU128(uint128 u128, bool is_neg) {
|
||||||
return time_internal::MakeDuration(rep_hi, rep_lo);
|
return time_internal::MakeDuration(rep_hi, rep_lo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert int64_t to uint64_t in twos-complement system.
|
// Convert between int64_t and uint64_t, preserving representation. This
|
||||||
inline uint64_t EncodeTwosComp(int64_t v) { return static_cast<uint64_t>(v); }
|
// allows us to do arithmetic in the unsigned domain, where overflow has
|
||||||
|
// well-defined behavior. See operator+=() and operator-=().
|
||||||
// Convert uint64_t to int64_t in twos-complement system.
|
//
|
||||||
inline int64_t DecodeTwosComp(uint64_t v) {
|
// C99 7.20.1.1.1, as referenced by C++11 18.4.1.2, says, "The typedef
|
||||||
if (v <= kint64max) return static_cast<int64_t>(v);
|
// name intN_t designates a signed integer type with width N, no padding
|
||||||
return static_cast<int64_t>(v - kint64max - 1) + kint64min;
|
// bits, and a two's complement representation." So, we can convert to
|
||||||
}
|
// and from the corresponding uint64_t value using a bit cast.
|
||||||
|
inline uint64_t EncodeTwosComp(int64_t v) { return bit_cast<uint64_t>(v); }
|
||||||
|
inline int64_t DecodeTwosComp(uint64_t v) { return bit_cast<int64_t>(v); }
|
||||||
|
|
||||||
// Note: The overflow detection in this function is done using greater/less *or
|
// Note: The overflow detection in this function is done using greater/less *or
|
||||||
// equal* because kint64max/min is too large to be represented exactly in a
|
// equal* because kint64max/min is too large to be represented exactly in a
|
||||||
|
|
Loading…
Reference in a new issue