diff --git a/mediapipe/framework/deps/mathutil_unittest.cc b/mediapipe/framework/deps/mathutil_unittest.cc index 7468e927a..b25b73306 100644 --- a/mediapipe/framework/deps/mathutil_unittest.cc +++ b/mediapipe/framework/deps/mathutil_unittest.cc @@ -75,17 +75,17 @@ BENCHMARK(BM_IntCast); static void BM_Int64Cast(benchmark::State& state) { double x = 0.1; - int64 sum = 0; + int64_t sum = 0; for (auto _ : state) { - sum += static_cast(x); + sum += static_cast(x); x += 0.1; - sum += static_cast(x); + sum += static_cast(x); x += 0.1; - sum += static_cast(x); + sum += static_cast(x); x += 0.1; - sum += static_cast(x); + sum += static_cast(x); x += 0.1; - sum += static_cast(x); + sum += static_cast(x); x += 0.1; } EXPECT_NE(sum, 0); // Don't let 'sum' get optimized away. @@ -134,15 +134,15 @@ static void BM_Int64Round(benchmark::State& state) { double x = 0.1; int sum = 0; for (auto _ : state) { - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; } EXPECT_NE(sum, 0); // Don't let 'sum' get optimized away. @@ -153,15 +153,15 @@ static void BM_UintRound(benchmark::State& state) { double x = 0.1; int sum = 0; for (auto _ : state) { - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; - sum += mediapipe::MathUtil::Round(x); + sum += mediapipe::MathUtil::Round(x); x += 0.1; } EXPECT_NE(sum, 0); // Don't let 'sum' get optimized away. @@ -191,15 +191,15 @@ static void BM_SafeInt64Cast(benchmark::State& state) { double x = 0.1; int sum = 0; for (auto _ : state) { - sum += mediapipe::MathUtil::SafeCast(x); + sum += mediapipe::MathUtil::SafeCast(x); x += 0.1; - sum += mediapipe::MathUtil::SafeCast(x); + sum += mediapipe::MathUtil::SafeCast(x); x += 0.1; - sum += mediapipe::MathUtil::SafeCast(x); + sum += mediapipe::MathUtil::SafeCast(x); x += 0.1; - sum += mediapipe::MathUtil::SafeCast(x); + sum += mediapipe::MathUtil::SafeCast(x); x += 0.1; - sum += mediapipe::MathUtil::SafeCast(x); + sum += mediapipe::MathUtil::SafeCast(x); x += 0.1; } EXPECT_NE(sum, 0); // Don't let 'sum' get optimized away. @@ -229,15 +229,15 @@ static void BM_SafeInt64Round(benchmark::State& state) { double x = 0.1; int sum = 0; for (auto _ : state) { - sum += mediapipe::MathUtil::SafeRound(x); + sum += mediapipe::MathUtil::SafeRound(x); x += 0.1; - sum += mediapipe::MathUtil::SafeRound(x); + sum += mediapipe::MathUtil::SafeRound(x); x += 0.1; - sum += mediapipe::MathUtil::SafeRound(x); + sum += mediapipe::MathUtil::SafeRound(x); x += 0.1; - sum += mediapipe::MathUtil::SafeRound(x); + sum += mediapipe::MathUtil::SafeRound(x); x += 0.1; - sum += mediapipe::MathUtil::SafeRound(x); + sum += mediapipe::MathUtil::SafeRound(x); x += 0.1; } EXPECT_NE(sum, 0); // Don't let 'sum' get optimized away. @@ -262,8 +262,8 @@ TEST(MathUtil, IntRound) { // A double-precision number has a 53-bit mantissa (52 fraction bits), // so the following value can be represented exactly. - int64 value64 = static_cast(0x1234567890abcd00); - EXPECT_EQ(mediapipe::MathUtil::Round(static_cast(value64)), + int64_t value64 = static_cast(0x1234567890abcd00); + EXPECT_EQ(mediapipe::MathUtil::Round(static_cast(value64)), value64); } @@ -369,7 +369,7 @@ class SafeCastTester { if (sizeof(FloatIn) >= 64) { // A double-precision number has a 53-bit mantissa (52 fraction bits), // so the following value can be represented exactly by a double. - int64 value64 = static_cast(0x1234567890abcd00); + int64_t value64 = static_cast(0x1234567890abcd00); const IntOut expected = (sizeof(IntOut) >= 64) ? static_cast(value64) : imax; EXPECT_EQ( @@ -536,22 +536,22 @@ class SafeCastTester { }; TEST(MathUtil, SafeCast) { - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); - SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); + SafeCastTester::Run(); // Spot-check SafeCast EXPECT_EQ(mediapipe::MathUtil::SafeCast(static_cast(12345.678)), @@ -682,7 +682,7 @@ class SafeRoundTester { if (sizeof(FloatIn) >= 64) { // A double-precision number has a 53-bit mantissa (52 fraction bits), // so the following value can be represented exactly by a double. - int64 value64 = static_cast(0x1234567890abcd00); + int64_t value64 = static_cast(0x1234567890abcd00); const IntOut expected = (sizeof(IntOut) >= 64) ? static_cast(value64) : imax; EXPECT_EQ( @@ -843,22 +843,22 @@ class SafeRoundTester { }; TEST(MathUtil, SafeRound) { - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); - SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); + SafeRoundTester::Run(); // Spot-check SafeRound EXPECT_EQ(mediapipe::MathUtil::SafeRound(static_cast(12345.678)), diff --git a/mediapipe/framework/deps/monotonic_clock_test.cc b/mediapipe/framework/deps/monotonic_clock_test.cc index 533830e43..0a049392f 100644 --- a/mediapipe/framework/deps/monotonic_clock_test.cc +++ b/mediapipe/framework/deps/monotonic_clock_test.cc @@ -244,7 +244,7 @@ TEST_F(MonotonicClockTest, RealTime) { // Call mono_clock->Now() continuously for FLAGS_real_test_secs seconds. absl::Time start = absl::Now(); absl::Time time = start; - int64 num_calls = 0; + int64_t num_calls = 0; do { absl::Time last_time = time; time = mono_clock->TimeNow(); @@ -406,7 +406,7 @@ class ClockFrenzy { while (Running()) { // 40% of the time, advance a simulated clock. // 50% of the time, read a monotonic clock. - const int32 u = UniformRandom(100); + const int32_t u = UniformRandom(100); if (u < 40) { // Pick a simulated clock and advance it. const int nclocks = sim_clocks_.size(); @@ -463,9 +463,9 @@ class ClockFrenzy { // Thread-safe random number generation functions for use by other class // member functions. - int32 UniformRandom(int32 n) { + int32_t UniformRandom(int32_t n) { absl::MutexLock l(&lock_); - return std::uniform_int_distribution(0, n - 1)(*random_); + return std::uniform_int_distribution(0, n - 1)(*random_); } float RndFloatRandom() { diff --git a/mediapipe/framework/deps/safe_int_test.cc b/mediapipe/framework/deps/safe_int_test.cc index 7f385848f..83932d551 100644 --- a/mediapipe/framework/deps/safe_int_test.cc +++ b/mediapipe/framework/deps/safe_int_test.cc @@ -20,21 +20,21 @@ #include "mediapipe/framework/port/gtest.h" -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt8, int8, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt8, int8_t, mediapipe::intops::LogFatalOnError); -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt8, uint8, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt8, uint8_t, mediapipe::intops::LogFatalOnError); -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt16, int16, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt16, int16_t, mediapipe::intops::LogFatalOnError); -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt16, uint16, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt16, uint16_t, mediapipe::intops::LogFatalOnError); -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt32, int32, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt32, int32_t, mediapipe::intops::LogFatalOnError); -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt64, int64, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeInt64, int64_t, mediapipe::intops::LogFatalOnError); -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt32, uint32, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt32, uint32_t, mediapipe::intops::LogFatalOnError); -MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt64, uint64, +MEDIAPIPE_DEFINE_SAFE_INT_TYPE(SafeUInt64, uint64_t, mediapipe::intops::LogFatalOnError); namespace mediapipe { @@ -102,8 +102,8 @@ TYPED_TEST(SignNeutralSafeIntTest, TestCtorFailures) { typedef typename T::ValueType V; { // Test out-of-bounds construction. - if (std::numeric_limits::is_signed || sizeof(V) < sizeof(uint64)) { - EXPECT_DEATH((T(std::numeric_limits::max())), "bounds"); + if (std::numeric_limits::is_signed || sizeof(V) < sizeof(uint64_t)) { + EXPECT_DEATH((T(std::numeric_limits::max())), "bounds"); } } { // Test out-of-bounds construction from float. @@ -233,20 +233,20 @@ TYPED_TEST(SignNeutralSafeIntTest, TestMultiply) { typedef typename T::ValueType V; // Test positive vs. positive multiplication across types. - TEST_T_OP_NUM(9, *, int32, 3); - TEST_T_OP_NUM(9, *, uint32, 3); + TEST_T_OP_NUM(9, *, int32_t, 3); + TEST_T_OP_NUM(9, *, uint32_t, 3); TEST_T_OP_NUM(9, *, float, 3); TEST_T_OP_NUM(9, *, double, 3); // Test positive vs. zero multiplication commutatively across types. This // was a real bug. - TEST_T_OP_NUM(93, *, int32, 0); - TEST_T_OP_NUM(93, *, uint32, 0); + TEST_T_OP_NUM(93, *, int32_t, 0); + TEST_T_OP_NUM(93, *, uint32_t, 0); TEST_T_OP_NUM(93, *, float, 0); TEST_T_OP_NUM(93, *, double, 0); - TEST_T_OP_NUM(0, *, int32, 76); - TEST_T_OP_NUM(0, *, uint32, 76); + TEST_T_OP_NUM(0, *, int32_t, 76); + TEST_T_OP_NUM(0, *, uint32_t, 76); TEST_T_OP_NUM(0, *, float, 76); TEST_T_OP_NUM(0, *, double, 76); @@ -279,14 +279,14 @@ TYPED_TEST(SignNeutralSafeIntTest, TestDivide) { typedef typename T::ValueType V; // Test positive vs. positive division across types. - TEST_T_OP_NUM(9, /, int32, 3); - TEST_T_OP_NUM(9, /, uint32, 3); + TEST_T_OP_NUM(9, /, int32_t, 3); + TEST_T_OP_NUM(9, /, uint32_t, 3); TEST_T_OP_NUM(9, /, float, 3); TEST_T_OP_NUM(9, /, double, 3); // Test zero vs. positive division across types. - TEST_T_OP_NUM(0, /, int32, 76); - TEST_T_OP_NUM(0, /, uint32, 76); + TEST_T_OP_NUM(0, /, int32_t, 76); + TEST_T_OP_NUM(0, /, uint32_t, 76); TEST_T_OP_NUM(0, /, float, 76); TEST_T_OP_NUM(0, /, double, 76); } @@ -307,12 +307,12 @@ TYPED_TEST(SignNeutralSafeIntTest, TestModulo) { typedef typename T::ValueType V; // Test positive vs. positive modulo across signedness. - TEST_T_OP_NUM(7, %, int32, 6); - TEST_T_OP_NUM(7, %, uint32, 6); + TEST_T_OP_NUM(7, %, int32_t, 6); + TEST_T_OP_NUM(7, %, uint32_t, 6); // Test zero vs. positive modulo across signedness. - TEST_T_OP_NUM(0, %, int32, 6); - TEST_T_OP_NUM(0, %, uint32, 6); + TEST_T_OP_NUM(0, %, int32_t, 6); + TEST_T_OP_NUM(0, %, uint32_t, 6); } TYPED_TEST(SignNeutralSafeIntTest, TestModuloFailures) { @@ -534,28 +534,28 @@ TYPED_TEST(SignedSafeIntTest, TestMultiply) { typedef typename T::ValueType V; // Test negative vs. positive multiplication across types. - TEST_T_OP_NUM(-9, *, int32, 3); - TEST_T_OP_NUM(-9, *, uint32, 3); + TEST_T_OP_NUM(-9, *, int32_t, 3); + TEST_T_OP_NUM(-9, *, uint32_t, 3); TEST_T_OP_NUM(-9, *, float, 3); TEST_T_OP_NUM(-9, *, double, 3); // Test positive vs. negative multiplication across types. - TEST_T_OP_NUM(9, *, int32, -3); + TEST_T_OP_NUM(9, *, int32_t, -3); // Don't cover unsigneds that are initialized from negative values. TEST_T_OP_NUM(9, *, float, -3); TEST_T_OP_NUM(9, *, double, -3); // Test negative vs. negative multiplication across types. - TEST_T_OP_NUM(-9, *, int32, -3); + TEST_T_OP_NUM(-9, *, int32_t, -3); // Don't cover unsigneds that are initialized from negative values. TEST_T_OP_NUM(-9, *, float, -3); TEST_T_OP_NUM(-9, *, double, -3); // Test negative vs. zero multiplication commutatively across types. - TEST_T_OP_NUM(-93, *, int32, 0); - TEST_T_OP_NUM(-93, *, uint32, 0); + TEST_T_OP_NUM(-93, *, int32_t, 0); + TEST_T_OP_NUM(-93, *, uint32_t, 0); TEST_T_OP_NUM(-93, *, float, 0); TEST_T_OP_NUM(-93, *, double, 0); - TEST_T_OP_NUM(0, *, int32, -76); - TEST_T_OP_NUM(0, *, uint32, -76); + TEST_T_OP_NUM(0, *, int32_t, -76); + TEST_T_OP_NUM(0, *, uint32_t, -76); TEST_T_OP_NUM(0, *, float, -76); TEST_T_OP_NUM(0, *, double, -76); @@ -600,24 +600,24 @@ TYPED_TEST(SignedSafeIntTest, TestDivide) { typedef typename T::ValueType V; // Test negative vs. positive division across types. - TEST_T_OP_NUM(-9, /, int32, 3); - TEST_T_OP_NUM(-9, /, uint32, 3); + TEST_T_OP_NUM(-9, /, int32_t, 3); + TEST_T_OP_NUM(-9, /, uint32_t, 3); TEST_T_OP_NUM(-9, /, float, 3); TEST_T_OP_NUM(-9, /, double, 3); // Test positive vs. negative division across types. - TEST_T_OP_NUM(9, /, int32, -3); - TEST_T_OP_NUM(9, /, uint32, -3); + TEST_T_OP_NUM(9, /, int32_t, -3); + TEST_T_OP_NUM(9, /, uint32_t, -3); TEST_T_OP_NUM(9, /, float, -3); TEST_T_OP_NUM(9, /, double, -3); // Test negative vs. negative division across types. - TEST_T_OP_NUM(-9, /, int32, -3); - TEST_T_OP_NUM(-9, /, uint32, -3); + TEST_T_OP_NUM(-9, /, int32_t, -3); + TEST_T_OP_NUM(-9, /, uint32_t, -3); TEST_T_OP_NUM(-9, /, float, -3); TEST_T_OP_NUM(-9, /, double, -3); // Test zero vs. negative division across types. - TEST_T_OP_NUM(0, /, int32, -76); - TEST_T_OP_NUM(0, /, uint32, -76); + TEST_T_OP_NUM(0, /, int32_t, -76); + TEST_T_OP_NUM(0, /, uint32_t, -76); TEST_T_OP_NUM(0, /, float, -76); TEST_T_OP_NUM(0, /, double, -76); } @@ -638,18 +638,18 @@ TYPED_TEST(SignedSafeIntTest, TestModulo) { typedef typename T::ValueType V; // Test negative vs. positive modulo across signedness. - TEST_T_OP_NUM(-7, %, int32, 6); - TEST_T_OP_NUM(-7, %, uint32, 6); + TEST_T_OP_NUM(-7, %, int32_t, 6); + TEST_T_OP_NUM(-7, %, uint32_t, 6); // Test positive vs. negative modulo across signedness. - TEST_T_OP_NUM(7, %, int32, -6); - TEST_T_OP_NUM(7, %, uint32, -6); + TEST_T_OP_NUM(7, %, int32_t, -6); + TEST_T_OP_NUM(7, %, uint32_t, -6); // Test negative vs. negative modulo across signedness. - TEST_T_OP_NUM(-7, %, int32, -6); - TEST_T_OP_NUM(-7, %, uint32, -6); + TEST_T_OP_NUM(-7, %, int32_t, -6); + TEST_T_OP_NUM(-7, %, uint32_t, -6); // Test zero vs. negative modulo across signedness. - TEST_T_OP_NUM(0, %, int32, -6); - TEST_T_OP_NUM(0, %, uint32, -6); + TEST_T_OP_NUM(0, %, int32_t, -6); + TEST_T_OP_NUM(0, %, uint32_t, -6); } TYPED_TEST(SignedSafeIntTest, TestModuloFailures) {