Commit 3208992c authored by tfarina's avatar tfarina Committed by Commit bot

base: Remove the remaining usage of GG_(U)INTn_C macros.

According to comment in base/port.h, in Chromium, we force-define
__STDC_CONSTANT_MACROS, so we can just use the regular (U)INTn_C macros from
<stdint.h>.

BUG=138542
TEST=base_unittests
R=danakj@chromium.org

Review URL: https://codereview.chromium.org/1128203010

Cr-Commit-Position: refs/heads/master@{#330440}
parent 6edecc8c
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "base/containers/hash_tables.h" #include "base/containers/hash_tables.h"
#include <stdint.h>
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
...@@ -31,7 +32,7 @@ TEST_F(HashPairTest, IntegerPairs) { ...@@ -31,7 +32,7 @@ TEST_F(HashPairTest, IntegerPairs) {
INSERT_PAIR_TEST(Int16Int16Pair, 4, 6); INSERT_PAIR_TEST(Int16Int16Pair, 4, 6);
INSERT_PAIR_TEST(Int16Int32Pair, 9, (1 << 29) + 378128932); INSERT_PAIR_TEST(Int16Int32Pair, 9, (1 << 29) + 378128932);
INSERT_PAIR_TEST(Int16Int64Pair, 10, INSERT_PAIR_TEST(Int16Int64Pair, 10,
(GG_INT64_C(1) << 60) + GG_INT64_C(78931732321)); (INT64_C(1) << 60) + INT64_C(78931732321));
typedef std::pair<int32, int16> Int32Int16Pair; typedef std::pair<int32, int16> Int32Int16Pair;
typedef std::pair<int32, int32> Int32Int32Pair; typedef std::pair<int32, int32> Int32Int32Pair;
...@@ -40,7 +41,7 @@ TEST_F(HashPairTest, IntegerPairs) { ...@@ -40,7 +41,7 @@ TEST_F(HashPairTest, IntegerPairs) {
INSERT_PAIR_TEST(Int32Int16Pair, 4, 6); INSERT_PAIR_TEST(Int32Int16Pair, 4, 6);
INSERT_PAIR_TEST(Int32Int32Pair, 9, (1 << 29) + 378128932); INSERT_PAIR_TEST(Int32Int32Pair, 9, (1 << 29) + 378128932);
INSERT_PAIR_TEST(Int32Int64Pair, 10, INSERT_PAIR_TEST(Int32Int64Pair, 10,
(GG_INT64_C(1) << 60) + GG_INT64_C(78931732321)); (INT64_C(1) << 60) + INT64_C(78931732321));
typedef std::pair<int64, int16> Int64Int16Pair; typedef std::pair<int64, int16> Int64Int16Pair;
typedef std::pair<int64, int32> Int64Int32Pair; typedef std::pair<int64, int32> Int64Int32Pair;
...@@ -49,7 +50,7 @@ TEST_F(HashPairTest, IntegerPairs) { ...@@ -49,7 +50,7 @@ TEST_F(HashPairTest, IntegerPairs) {
INSERT_PAIR_TEST(Int64Int16Pair, 4, 6); INSERT_PAIR_TEST(Int64Int16Pair, 4, 6);
INSERT_PAIR_TEST(Int64Int32Pair, 9, (1 << 29) + 378128932); INSERT_PAIR_TEST(Int64Int32Pair, 9, (1 << 29) + 378128932);
INSERT_PAIR_TEST(Int64Int64Pair, 10, INSERT_PAIR_TEST(Int64Int64Pair, 10,
(GG_INT64_C(1) << 60) + GG_INT64_C(78931732321)); (INT64_C(1) << 60) + INT64_C(78931732321));
} }
// Verify that base::hash_set<const char*> compares by pointer value, not as C // Verify that base::hash_set<const char*> compares by pointer value, not as C
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "base/rand_util.h" #include "base/rand_util.h"
#include <math.h> #include <math.h>
#include <stdint.h>
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
...@@ -37,7 +38,7 @@ double BitsToOpenEndedUnitInterval(uint64 bits) { ...@@ -37,7 +38,7 @@ double BitsToOpenEndedUnitInterval(uint64 bits) {
COMPILE_ASSERT(std::numeric_limits<double>::radix == 2, otherwise_use_scalbn); COMPILE_ASSERT(std::numeric_limits<double>::radix == 2, otherwise_use_scalbn);
static const int kBits = std::numeric_limits<double>::digits; static const int kBits = std::numeric_limits<double>::digits;
uint64 random_bits = bits & ((GG_UINT64_C(1) << kBits) - 1); uint64 random_bits = bits & ((UINT64_C(1) << kBits) - 1);
double result = ldexp(static_cast<double>(random_bits), -1 * kBits); double result = ldexp(static_cast<double>(random_bits), -1 * kBits);
DCHECK_GE(result, 0.0); DCHECK_GE(result, 0.0);
DCHECK_LT(result, 1.0); DCHECK_LT(result, 1.0);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/strings/string_number_conversions.h"
#include <errno.h> #include <errno.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
...@@ -10,7 +12,6 @@ ...@@ -10,7 +12,6 @@
#include <limits> #include <limits>
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -237,10 +238,10 @@ TEST(StringNumberConversionsTest, StringToInt64) { ...@@ -237,10 +238,10 @@ TEST(StringNumberConversionsTest, StringToInt64) {
{"42", 42, true}, {"42", 42, true},
{"-2147483648", INT_MIN, true}, {"-2147483648", INT_MIN, true},
{"2147483647", INT_MAX, true}, {"2147483647", INT_MAX, true},
{"-2147483649", GG_INT64_C(-2147483649), true}, {"-2147483649", INT64_C(-2147483649), true},
{"-99999999999", GG_INT64_C(-99999999999), true}, {"-99999999999", INT64_C(-99999999999), true},
{"2147483648", GG_INT64_C(2147483648), true}, {"2147483648", INT64_C(2147483648), true},
{"99999999999", GG_INT64_C(99999999999), true}, {"99999999999", INT64_C(99999999999), true},
{"9223372036854775807", kint64max, true}, {"9223372036854775807", kint64max, true},
{"-9223372036854775808", kint64min, true}, {"-9223372036854775808", kint64min, true},
{"09", 9, true}, {"09", 9, true},
...@@ -304,8 +305,8 @@ TEST(StringNumberConversionsTest, StringToUint64) { ...@@ -304,8 +305,8 @@ TEST(StringNumberConversionsTest, StringToUint64) {
{"2147483647", INT_MAX, true}, {"2147483647", INT_MAX, true},
{"-2147483649", 0, false}, {"-2147483649", 0, false},
{"-99999999999", 0, false}, {"-99999999999", 0, false},
{"2147483648", GG_UINT64_C(2147483648), true}, {"2147483648", UINT64_C(2147483648), true},
{"99999999999", GG_UINT64_C(99999999999), true}, {"99999999999", UINT64_C(99999999999), true},
{"9223372036854775807", kint64max, true}, {"9223372036854775807", kint64max, true},
{"-9223372036854775808", 0, false}, {"-9223372036854775808", 0, false},
{"09", 9, true}, {"09", 9, true},
...@@ -327,7 +328,7 @@ TEST(StringNumberConversionsTest, StringToUint64) { ...@@ -327,7 +328,7 @@ TEST(StringNumberConversionsTest, StringToUint64) {
{"-", 0, false}, {"-", 0, false},
{"-9223372036854775809", 0, false}, {"-9223372036854775809", 0, false},
{"-99999999999999999999", 0, false}, {"-99999999999999999999", 0, false},
{"9223372036854775808", GG_UINT64_C(9223372036854775808), true}, {"9223372036854775808", UINT64_C(9223372036854775808), true},
{"99999999999999999999", kuint64max, false}, {"99999999999999999999", kuint64max, false},
{"18446744073709551615", kuint64max, true}, {"18446744073709551615", kuint64max, true},
{"18446744073709551616", kuint64max, false}, {"18446744073709551616", kuint64max, false},
...@@ -550,7 +551,7 @@ TEST(StringNumberConversionsTest, HexStringToInt64) { ...@@ -550,7 +551,7 @@ TEST(StringNumberConversionsTest, HexStringToInt64) {
{"42", 66, true}, {"42", 66, true},
{"-42", -66, true}, {"-42", -66, true},
{"+42", 66, true}, {"+42", 66, true},
{"40acd88557b", GG_INT64_C(4444444448123), true}, {"40acd88557b", INT64_C(4444444448123), true},
{"7fffffff", INT_MAX, true}, {"7fffffff", INT_MAX, true},
{"-80000000", INT_MIN, true}, {"-80000000", INT_MIN, true},
{"ffffffff", 0xffffffff, true}, {"ffffffff", 0xffffffff, true},
...@@ -558,7 +559,7 @@ TEST(StringNumberConversionsTest, HexStringToInt64) { ...@@ -558,7 +559,7 @@ TEST(StringNumberConversionsTest, HexStringToInt64) {
{"0x42", 66, true}, {"0x42", 66, true},
{"-0x42", -66, true}, {"-0x42", -66, true},
{"+0x42", 66, true}, {"+0x42", 66, true},
{"0x40acd88557b", GG_INT64_C(4444444448123), true}, {"0x40acd88557b", INT64_C(4444444448123), true},
{"0x7fffffff", INT_MAX, true}, {"0x7fffffff", INT_MAX, true},
{"-0x80000000", INT_MIN, true}, {"-0x80000000", INT_MIN, true},
{"0xffffffff", 0xffffffff, true}, {"0xffffffff", 0xffffffff, true},
...@@ -607,7 +608,7 @@ TEST(StringNumberConversionsTest, HexStringToUInt64) { ...@@ -607,7 +608,7 @@ TEST(StringNumberConversionsTest, HexStringToUInt64) {
{"42", 66, true}, {"42", 66, true},
{"-42", 0, false}, {"-42", 0, false},
{"+42", 66, true}, {"+42", 66, true},
{"40acd88557b", GG_INT64_C(4444444448123), true}, {"40acd88557b", INT64_C(4444444448123), true},
{"7fffffff", INT_MAX, true}, {"7fffffff", INT_MAX, true},
{"-80000000", 0, false}, {"-80000000", 0, false},
{"ffffffff", 0xffffffff, true}, {"ffffffff", 0xffffffff, true},
...@@ -615,14 +616,14 @@ TEST(StringNumberConversionsTest, HexStringToUInt64) { ...@@ -615,14 +616,14 @@ TEST(StringNumberConversionsTest, HexStringToUInt64) {
{"0x42", 66, true}, {"0x42", 66, true},
{"-0x42", 0, false}, {"-0x42", 0, false},
{"+0x42", 66, true}, {"+0x42", 66, true},
{"0x40acd88557b", GG_INT64_C(4444444448123), true}, {"0x40acd88557b", INT64_C(4444444448123), true},
{"0x7fffffff", INT_MAX, true}, {"0x7fffffff", INT_MAX, true},
{"-0x80000000", 0, false}, {"-0x80000000", 0, false},
{"0xffffffff", 0xffffffff, true}, {"0xffffffff", 0xffffffff, true},
{"0XDeadBeef", 0xdeadbeef, true}, {"0XDeadBeef", 0xdeadbeef, true},
{"0x7fffffffffffffff", kint64max, true}, {"0x7fffffffffffffff", kint64max, true},
{"-0x8000000000000000", 0, false}, {"-0x8000000000000000", 0, false},
{"0x8000000000000000", GG_UINT64_C(0x8000000000000000), true}, {"0x8000000000000000", UINT64_C(0x8000000000000000), true},
{"-0x8000000000000001", 0, false}, {"-0x8000000000000001", 0, false},
{"0xFFFFFFFFFFFFFFFF", kuint64max, true}, {"0xFFFFFFFFFFFFFFFF", kuint64max, true},
{"FFFFFFFFFFFFFFFF", kuint64max, true}, {"FFFFFFFFFFFFFFFF", kuint64max, true},
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <CoreFoundation/CFTimeZone.h> #include <CoreFoundation/CFTimeZone.h>
#include <mach/mach.h> #include <mach/mach.h>
#include <mach/mach_time.h> #include <mach/mach_time.h>
#include <stdint.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -114,7 +115,7 @@ namespace base { ...@@ -114,7 +115,7 @@ namespace base {
// => Thu Jan 01 00:00:00 UTC 1970 // => Thu Jan 01 00:00:00 UTC 1970
// irb(main):011:0> Time.at(-11644473600).getutc() // irb(main):011:0> Time.at(-11644473600).getutc()
// => Mon Jan 01 00:00:00 UTC 1601 // => Mon Jan 01 00:00:00 UTC 1601
static const int64 kWindowsEpochDeltaSeconds = GG_INT64_C(11644473600); static const int64 kWindowsEpochDeltaSeconds = INT64_C(11644473600);
// static // static
const int64 Time::kWindowsEpochDeltaMicroseconds = const int64 Time::kWindowsEpochDeltaMicroseconds =
......
...@@ -137,7 +137,7 @@ struct timespec TimeDelta::ToTimeSpec() const { ...@@ -137,7 +137,7 @@ struct timespec TimeDelta::ToTimeSpec() const {
// => Thu Jan 01 00:00:00 UTC 1970 // => Thu Jan 01 00:00:00 UTC 1970
// irb(main):011:0> Time.at(-11644473600).getutc() // irb(main):011:0> Time.at(-11644473600).getutc()
// => Mon Jan 01 00:00:00 UTC 1601 // => Mon Jan 01 00:00:00 UTC 1601
static const int64 kWindowsEpochDeltaSeconds = GG_INT64_C(11644473600); static const int64 kWindowsEpochDeltaSeconds = INT64_C(11644473600);
// static // static
const int64 Time::kWindowsEpochDeltaMicroseconds = const int64 Time::kWindowsEpochDeltaMicroseconds =
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include "base/time/time.h" #include "base/time/time.h"
#include <stdint.h>
#include <time.h> #include <time.h>
#include <limits> #include <limits>
#include <string> #include <string>
...@@ -832,7 +832,7 @@ TEST(TimeDelta, WindowsEpoch) { ...@@ -832,7 +832,7 @@ TEST(TimeDelta, WindowsEpoch) {
exploded.millisecond = 0; exploded.millisecond = 0;
Time t = Time::FromUTCExploded(exploded); Time t = Time::FromUTCExploded(exploded);
// Unix 1970 epoch. // Unix 1970 epoch.
EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue()); EXPECT_EQ(INT64_C(11644473600000000), t.ToInternalValue());
// We can't test 1601 epoch, since the system time functions on Linux // We can't test 1601 epoch, since the system time functions on Linux
// only compute years starting from 1900. // only compute years starting from 1900.
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#pragma comment(lib, "winmm.lib") #pragma comment(lib, "winmm.lib")
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include <stdint.h>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/cpu.h" #include "base/cpu.h"
...@@ -106,7 +107,7 @@ base::LazyInstance<base::Lock>::Leaky g_high_res_lock = ...@@ -106,7 +107,7 @@ base::LazyInstance<base::Lock>::Leaky g_high_res_lock =
// number of leap year days between 1601 and 1970: (1970-1601)/4 excluding // number of leap year days between 1601 and 1970: (1970-1601)/4 excluding
// 1700, 1800, and 1900. // 1700, 1800, and 1900.
// static // static
const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(11644473600000000); const int64 Time::kTimeTToMicrosecondsOffset = INT64_C(11644473600000000);
// static // static
Time Time::Now() { Time Time::Now() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment