Skip to content

Commit

Permalink
Add missing cstdint includes (#1643)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0010204)
  • Loading branch information
andrewsavage1 authored and anonymous1-me committed Sep 28, 2023
1 parent faf5cfa commit 9a8d031
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
5 changes: 5 additions & 0 deletions third_party/angle/include/GLSLANG/ShaderVars.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#define GLSLANG_SHADERVARS_H_

#include <algorithm>
<<<<<<< HEAD
=======
#include <array>
#include <cstdint>
>>>>>>> 00102040267 (Add missing cstdint includes (#1643))
#include <string>
#include <vector>

Expand Down
4 changes: 4 additions & 0 deletions third_party/angle/src/common/angleutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include <climits>
#include <cstdarg>
#include <cstddef>
<<<<<<< HEAD
#include <string>
=======
#include <cstdint>
>>>>>>> 00102040267 (Add missing cstdint includes (#1643))
#include <set>
#include <sstream>
#include <vector>
Expand Down
71 changes: 71 additions & 0 deletions third_party/crashpad/util/misc/reinterpret_bytes.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright 2017 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "util/misc/reinterpret_bytes.h"

#include <string.h>

#include <algorithm>
#include <cstdint>

#include "base/logging.h"

namespace crashpad {
namespace internal {

bool ReinterpretBytesImpl(const char* data,
size_t data_size,
char* dest,
size_t dest_size) {
// Verify that any unused bytes from data are zero.
// The unused bytes are at the start of the data buffer for big-endian and the
// end of the buffer for little-endian.
if (dest_size < data_size) {
auto extra_bytes = data;
#if defined(ARCH_CPU_LITTLE_ENDIAN)
extra_bytes += dest_size;
#endif // ARCH_CPU_LITTLE_ENDIAN

uint64_t zero = 0;
size_t extra_bytes_size = data_size - dest_size;
while (extra_bytes_size > 0) {
size_t to_check = std::min(extra_bytes_size, sizeof(zero));
if (memcmp(extra_bytes, &zero, to_check) != 0) {
LOG(ERROR) << "information loss";
return false;
}
extra_bytes += to_check;
extra_bytes_size -= to_check;
}
}

// Zero out the destination, in case it is larger than data.
memset(dest, 0, dest_size);

#if defined(ARCH_CPU_LITTLE_ENDIAN)
// Copy a prefix of data to a prefix of dest for little-endian
memcpy(dest, data, std::min(dest_size, data_size));
#else
// or the suffix of data to the suffix of dest for big-endian
if (data_size >= dest_size) {
memcpy(dest, data + data_size - dest_size, dest_size);
} else {
memcpy(dest + dest_size - data_size, data, data_size);
}
#endif // ARCH_CPU_LITTLE_ENDIAN
return true;
}

} // namespace internal
} // namespace crashpad
18 changes: 18 additions & 0 deletions third_party/v8/src/inspector/v8-string-conversions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INSPECTOR_V8_STRING_CONVERSIONS_H_
#define V8_INSPECTOR_V8_STRING_CONVERSIONS_H_

#include <cstdint>
#include <string>

// Conversion routines between UT8 and UTF16, used by string-16.{h,cc}. You may
// want to use string-16.h directly rather than these.
namespace v8_inspector {
std::basic_string<uint16_t> UTF8ToUTF16(const char* stringStart, size_t length);
std::string UTF16ToUTF8(const uint16_t* stringStart, size_t length);
} // namespace v8_inspector

#endif // V8_INSPECTOR_V8_STRING_CONVERSIONS_H_
1 change: 1 addition & 0 deletions v8/src/base/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef V8_BASE_LOGGING_H_
#define V8_BASE_LOGGING_H_

#include <cstdint>
#include <cstring>
#include <sstream>
#include <string>
Expand Down
1 change: 1 addition & 0 deletions v8/src/base/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef V8_BASE_MACROS_H_
#define V8_BASE_MACROS_H_

#include <cstdint>
#include <limits>

#include "src/base/compiler-specific.h"
Expand Down

0 comments on commit 9a8d031

Please sign in to comment.