-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing cstdint includes (#1643)
(cherry picked from commit 0010204)
- Loading branch information
1 parent
faf5cfa
commit 9a8d031
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters