Skip to content
Snippets Groups Projects
Commit 94f0f79e authored by Abseil Team's avatar Abseil Team Committed by Shaindel Schwartz
Browse files

Changes imported from Abseil "staging" branch:

  - aba727a5943a014392e3873349cee9dd5efc634e Avoid using 128-bit intrinsics for Clang on Windows. by Abseil Team <absl-team@google.com>
  - cdd19f1eda562af8906bff8feff827eb8e8e9797 Utilize the rtems TID infrastructure on myriad2 platforms. by Abseil Team <absl-team@google.com>
  - 52f7f55daa84ea25fa210d1b9d2bd64d128e1d81 Use intrinsic 128 bit integer when available for division... by Alex Strelnikov <strel@google.com>
  - 51f881b1152c0c861cf7fcac53f30d3c7ce12902 Merge GitHub #95: Fix compiler version check for clang-cl... by Derek Mauro <dmauro@google.com>

GitOrigin-RevId: aba727a5943a014392e3873349cee9dd5efc634e
Change-Id: I9b52d84095537acbbc96d3f74917f78da9a51156
parent 5337d2d0
No related branches found
No related tags found
No related merge requests found
...@@ -176,16 +176,22 @@ ...@@ -176,16 +176,22 @@
// Checks whether the __int128 compiler extension for a 128-bit integral type is // Checks whether the __int128 compiler extension for a 128-bit integral type is
// supported. // supported.
// //
// Notes: __SIZEOF_INT128__ is defined by Clang and GCC when __int128 is // Note: __SIZEOF_INT128__ is defined by Clang and GCC when __int128 is
// supported, except on ppc64 and aarch64 where __int128 exists but has exhibits // supported, but we avoid using it in certain cases:
// a sporadic compiler crashing bug. Nvidia's nvcc also defines __GNUC__ and // * On Clang:
// __SIZEOF_INT128__ but not all versions actually support __int128. // * Building using Clang for Windows, where the Clang runtime library has
// 128-bit support only on LP64 architectures, but Windows is LLP64.
// * Building for aarch64, where __int128 exists but has exhibits a sporadic
// compiler crashing bug.
// * On Nvidia's nvcc:
// * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions
// actually support __int128.
#ifdef ABSL_HAVE_INTRINSIC_INT128 #ifdef ABSL_HAVE_INTRINSIC_INT128
#error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set #error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set
#elif defined(__SIZEOF_INT128__) #elif defined(__SIZEOF_INT128__)
#if (defined(__clang__) && !defined(__aarch64__)) || \ #if (defined(__clang__) && !defined(_WIN32) && !defined(__aarch64__)) || \
(defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \ (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
(!defined(__clang__) && !defined(__CUDACC__) && defined(__GNUC__)) (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))
#define ABSL_HAVE_INTRINSIC_INT128 1 #define ABSL_HAVE_INTRINSIC_INT128 1
#elif defined(__CUDACC__) #elif defined(__CUDACC__)
// __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a
......
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif
#if defined(__myriad2__)
#include <rtems.h>
#endif
#include <string.h> #include <string.h>
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
...@@ -310,6 +314,14 @@ pid_t GetTID() { ...@@ -310,6 +314,14 @@ pid_t GetTID() {
return reinterpret_cast<struct pthread_tcb *>(current_uthread)->id; return reinterpret_cast<struct pthread_tcb *>(current_uthread)->id;
} }
#elif defined(__myriad2__)
pid_t GetTID() {
uint32_t tid;
rtems_task_ident(RTEMS_SELF, 0, &tid);
return tid;
}
#else #else
// Fallback implementation of GetTID using pthread_getspecific. // Fallback implementation of GetTID using pthread_getspecific.
......
...@@ -130,16 +130,26 @@ uint128::uint128(double v) : uint128(MakeUint128FromFloat(v)) {} ...@@ -130,16 +130,26 @@ uint128::uint128(double v) : uint128(MakeUint128FromFloat(v)) {}
uint128::uint128(long double v) : uint128(MakeUint128FromFloat(v)) {} uint128::uint128(long double v) : uint128(MakeUint128FromFloat(v)) {}
uint128 operator/(uint128 lhs, uint128 rhs) { uint128 operator/(uint128 lhs, uint128 rhs) {
#if defined(ABSL_HAVE_INTRINSIC_INT128)
return static_cast<unsigned __int128>(lhs) /
static_cast<unsigned __int128>(rhs);
#else // ABSL_HAVE_INTRINSIC_INT128
uint128 quotient = 0; uint128 quotient = 0;
uint128 remainder = 0; uint128 remainder = 0;
DivModImpl(lhs, rhs, &quotient, &remainder); DivModImpl(lhs, rhs, &quotient, &remainder);
return quotient; return quotient;
#endif // ABSL_HAVE_INTRINSIC_INT128
} }
uint128 operator%(uint128 lhs, uint128 rhs) { uint128 operator%(uint128 lhs, uint128 rhs) {
#if defined(ABSL_HAVE_INTRINSIC_INT128)
return static_cast<unsigned __int128>(lhs) %
static_cast<unsigned __int128>(rhs);
#else // ABSL_HAVE_INTRINSIC_INT128
uint128 quotient = 0; uint128 quotient = 0;
uint128 remainder = 0; uint128 remainder = 0;
DivModImpl(lhs, rhs, &quotient, &remainder); DivModImpl(lhs, rhs, &quotient, &remainder);
return remainder; return remainder;
#endif // ABSL_HAVE_INTRINSIC_INT128
} }
namespace { namespace {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment