Skip to content

Commit

Permalink
Switch to standard integer types in base/.
Browse files Browse the repository at this point in the history
BUG=138542
TBR=mark@chromium.org
NOPRESUBMIT=true

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

Cr-Commit-Position: refs/heads/master@{#366910}
  • Loading branch information
avi authored and Commit bot committed Dec 26, 2015
1 parent 28523e2 commit 9b6f429
Show file tree
Hide file tree
Showing 296 changed files with 1,213 additions and 815 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ deps_os = {

# For Linux and Chromium OS.
'src/third_party/cros_system_api':
Var('chromium_git') + '/chromiumos/platform/system_api.git' + '@' + 'ed198c46f73e67d9a494c3c0623e3ba16e4da5e8',
Var('chromium_git') + '/chromiumos/platform/system_api.git' + '@' + 'd9ecb3bd87504815d4c58a6a8b9031deb2498d19',

# Note that this is different from Android's freetype repo.
'src/third_party/freetype2/src':
Expand Down
4 changes: 2 additions & 2 deletions base/allocator/allocator_shim_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <limits.h>
#include <malloc.h>
#include <new.h>
#include <windows.h>

#include "base/basictypes.h"
#include <stddef.h>

// This shim make it possible to perform additional checks on allocations
// before passing them to the Heap functions.
Expand Down
1 change: 1 addition & 0 deletions base/allocator/unittest_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// of other libraries

#include <config.h>
#include <stddef.h>

inline int snprintf(char* buffer, size_t count, const char* format, ...) {
int result;
Expand Down
2 changes: 1 addition & 1 deletion base/at_exit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <stack>

#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/synchronization/lock.h"

namespace base {
Expand Down
2 changes: 1 addition & 1 deletion base/atomic_sequence_num.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define BASE_ATOMIC_SEQUENCE_NUM_H_

#include "base/atomicops.h"
#include "base/basictypes.h"
#include "base/macros.h"

namespace base {

Expand Down
6 changes: 5 additions & 1 deletion base/atomicops_internals_atomicword_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#ifndef BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
#define BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_

// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,
#include <stdint.h>

#include "build/build_config.h"

// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32_t,
// which in turn means int. On some LP32 platforms, intptr_t is an int, but
// on others, it's a long. When AtomicWord and Atomic32 are based on different
// fundamental types, their pointers are incompatible.
Expand Down
2 changes: 2 additions & 0 deletions base/atomicops_internals_portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include <atomic>

#include "build/build_config.h"

namespace base {
namespace subtle {

Expand Down
1 change: 1 addition & 0 deletions base/atomicops_internals_x86_msvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <intrin.h>

#include "base/macros.h"
#include "build/build_config.h"

#if defined(ARCH_CPU_64_BITS)
// windows.h #defines this (only on x64). This causes problems because the
Expand Down
2 changes: 1 addition & 1 deletion base/auto_reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef BASE_AUTO_RESET_H_
#define BASE_AUTO_RESET_H_

#include "base/basictypes.h"
#include "base/macros.h"

// base::AutoReset<> is useful for setting a variable to a new value only within
// a particular scope. An base::AutoReset<> object resets a variable to its
Expand Down
2 changes: 2 additions & 0 deletions base/base64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "base/base64.h"

#include <stddef.h>

#include "third_party/modp_b64/modp_b64.h"

namespace base {
Expand Down
3 changes: 3 additions & 0 deletions base/base64url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

#include "base/base64url.h"

#include <stddef.h>

#include "base/base64.h"
#include "base/macros.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_util.h"
#include "third_party/modp_b64/modp_b64.h"
Expand Down
1 change: 1 addition & 0 deletions base/base64url.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/strings/string_piece.h"

namespace base {
Expand Down
1 change: 1 addition & 0 deletions base/base64url_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "base/base64url.h"

#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {
Expand Down
1 change: 1 addition & 0 deletions base/base_paths_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <dlfcn.h>
#import <Foundation/Foundation.h>
#include <mach-o/dyld.h>
#include <stdint.h>

#include "base/base_paths.h"
#include "base/compiler_specific.h"
Expand Down
1 change: 1 addition & 0 deletions base/base_paths_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// Android).

#include <limits.h>
#include <stddef.h>

#include <ostream>
#include <string>
Expand Down
1 change: 1 addition & 0 deletions base/base_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "base/base_switches.h"
#include "build/build_config.h"

namespace switches {

Expand Down
16 changes: 8 additions & 8 deletions base/big_endian.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ bool BigEndianReader::Read(T* value) {
return true;
}

bool BigEndianReader::ReadU8(uint8* value) {
bool BigEndianReader::ReadU8(uint8_t* value) {
return Read(value);
}

bool BigEndianReader::ReadU16(uint16* value) {
bool BigEndianReader::ReadU16(uint16_t* value) {
return Read(value);
}

bool BigEndianReader::ReadU32(uint32* value) {
bool BigEndianReader::ReadU32(uint32_t* value) {
return Read(value);
}

bool BigEndianReader::ReadU64(uint64* value) {
bool BigEndianReader::ReadU64(uint64_t* value) {
return Read(value);
}

Expand Down Expand Up @@ -86,19 +86,19 @@ bool BigEndianWriter::Write(T value) {
return true;
}

bool BigEndianWriter::WriteU8(uint8 value) {
bool BigEndianWriter::WriteU8(uint8_t value) {
return Write(value);
}

bool BigEndianWriter::WriteU16(uint16 value) {
bool BigEndianWriter::WriteU16(uint16_t value) {
return Write(value);
}

bool BigEndianWriter::WriteU32(uint32 value) {
bool BigEndianWriter::WriteU32(uint32_t value) {
return Write(value);
}

bool BigEndianWriter::WriteU64(uint64 value) {
bool BigEndianWriter::WriteU64(uint64_t value) {
return Write(value);
}

Expand Down
32 changes: 17 additions & 15 deletions base/big_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#ifndef BASE_BIG_ENDIAN_H_
#define BASE_BIG_ENDIAN_H_

#include <stddef.h>
#include <stdint.h>

#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/strings/string_piece.h"

namespace base {
Expand All @@ -21,8 +23,8 @@ inline void ReadBigEndian(const char buf[], T* out) {
*out = buf[0];
for (size_t i = 1; i < sizeof(T); ++i) {
*out <<= 8;
// Must cast to uint8 to avoid clobbering by sign extension.
*out |= static_cast<uint8>(buf[i]);
// Must cast to uint8_t to avoid clobbering by sign extension.
*out |= static_cast<uint8_t>(buf[i]);
}
}

Expand All @@ -37,13 +39,13 @@ inline void WriteBigEndian(char buf[], T val) {
}

// Specializations to make clang happy about the (dead code) shifts above.
template<>
inline void ReadBigEndian<uint8>(const char buf[], uint8* out) {
template <>
inline void ReadBigEndian<uint8_t>(const char buf[], uint8_t* out) {
*out = buf[0];
}

template<>
inline void WriteBigEndian<uint8>(char buf[], uint8 val) {
template <>
inline void WriteBigEndian<uint8_t>(char buf[], uint8_t val) {
buf[0] = static_cast<char>(val);
}

Expand All @@ -60,10 +62,10 @@ class BASE_EXPORT BigEndianReader {
bool ReadBytes(void* out, size_t len);
// Creates a StringPiece in |out| that points to the underlying buffer.
bool ReadPiece(base::StringPiece* out, size_t len);
bool ReadU8(uint8* value);
bool ReadU16(uint16* value);
bool ReadU32(uint32* value);
bool ReadU64(uint64* value);
bool ReadU8(uint8_t* value);
bool ReadU16(uint16_t* value);
bool ReadU32(uint32_t* value);
bool ReadU64(uint64_t* value);

private:
// Hidden to promote type safety.
Expand All @@ -85,10 +87,10 @@ class BASE_EXPORT BigEndianWriter {

bool Skip(size_t len);
bool WriteBytes(const void* buf, size_t len);
bool WriteU8(uint8 value);
bool WriteU16(uint16 value);
bool WriteU32(uint32 value);
bool WriteU64(uint64 value);
bool WriteU8(uint8_t value);
bool WriteU16(uint16_t value);
bool WriteU32(uint32_t value);
bool WriteU64(uint64_t value);

private:
// Hidden to promote type safety.
Expand Down
26 changes: 14 additions & 12 deletions base/big_endian_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "base/big_endian.h"

#include <stdint.h>

#include "base/strings/string_piece.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand All @@ -13,10 +15,10 @@ TEST(BigEndianReaderTest, ReadsValues) {
char data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF,
0x1A, 0x2B, 0x3C, 0x4D, 0x5E };
char buf[2];
uint8 u8;
uint16 u16;
uint32 u32;
uint64 u64;
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint64_t u64;
base::StringPiece piece;
BigEndianReader reader(data, sizeof(data));

Expand All @@ -43,10 +45,10 @@ TEST(BigEndianReaderTest, ReadsValues) {
TEST(BigEndianReaderTest, RespectsLength) {
char data[8];
char buf[2];
uint8 u8;
uint16 u16;
uint32 u32;
uint64 u64;
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint64_t u64;
base::StringPiece piece;
BigEndianReader reader(data, sizeof(data));
// 8 left
Expand Down Expand Up @@ -88,10 +90,10 @@ TEST(BigEndianWriterTest, WritesValues) {
TEST(BigEndianWriterTest, RespectsLength) {
char data[8];
char buf[2];
uint8 u8 = 0;
uint16 u16 = 0;
uint32 u32 = 0;
uint64 u64 = 0;
uint8_t u8 = 0;
uint16_t u16 = 0;
uint32_t u32 = 0;
uint64_t u64 = 0;
BigEndianWriter writer(data, sizeof(data));
// 8 left
EXPECT_FALSE(writer.Skip(9));
Expand Down
4 changes: 3 additions & 1 deletion base/bind_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@
#ifndef BASE_BIND_HELPERS_H_
#define BASE_BIND_HELPERS_H_

#include <stddef.h>

#include <type_traits>
#include <utility>

#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/template_util.h"
#include "build/build_config.h"

namespace base {
namespace internal {
Expand Down
2 changes: 2 additions & 0 deletions base/bind_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef BASE_BIND_INTERNAL_H_
#define BASE_BIND_INTERNAL_H_

#include <stddef.h>

#include <type_traits>

#include "base/bind_helpers.h"
Expand Down
2 changes: 2 additions & 0 deletions base/bind_internal_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#ifndef BASE_BIND_INTERNAL_WIN_H_
#define BASE_BIND_INTERNAL_WIN_H_

#include "build/build_config.h"

// In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all
// the same as __cdecl which would turn the following specializations into
// multiple definitions.
Expand Down
2 changes: 2 additions & 0 deletions base/bind_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
#include <utility>

#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand Down
3 changes: 2 additions & 1 deletion base/bind_unittest.nc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// This is a "No Compile Test" suite.
// http://dev.chromium.org/developers/testing/no-compile-tests

#include "base/callback.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"

namespace base {
Expand Down
Loading

0 comments on commit 9b6f429

Please sign in to comment.