-
Notifications
You must be signed in to change notification settings - Fork 880
perfetto: support big-endian in in-process tracing SDK code paths #7449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
miladfarca
wants to merge
8
commits into
google:main
Choose a base branch
from
miladfarca:add-big-endian-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+311
−124
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f8d9726
Big-endian support
miladfarca a542af3
update
miladfarca 2b0cc9b
update
miladfarca 34b4cd1
update
miladfarca 7e78892
update
miladfarca 5bff205
update
miladfarca cfa0c8b
update
miladfarca 81239d9
update
miladfarca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,249 @@ | ||
| /* | ||
| * Copyright (C) 2020 The Android Open Source Project | ||
| * | ||
| * 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. | ||
| */ | ||
|
|
||
| #ifndef INCLUDE_PERFETTO_BASE_ENDIAN_H_ | ||
| #define INCLUDE_PERFETTO_BASE_ENDIAN_H_ | ||
|
|
||
| #include <stdint.h> | ||
| #include <stdlib.h> // For MSVC | ||
| #include <string.h> | ||
|
|
||
| #include "perfetto/base/build_config.h" | ||
| #include "perfetto/base/compiler.h" | ||
|
|
||
| namespace perfetto { | ||
| namespace base { | ||
|
|
||
| #if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_MSVC) | ||
| inline uint16_t ByteSwap16(uint16_t x) { | ||
| return _byteswap_ushort(x); | ||
| } | ||
| inline uint32_t ByteSwap32(uint32_t x) { | ||
| return _byteswap_ulong(x); | ||
| } | ||
| inline uint64_t ByteSwap64(uint64_t x) { | ||
| return _byteswap_uint64(x); | ||
| } | ||
| #else | ||
| inline uint16_t ByteSwap16(uint16_t x) { | ||
| return __builtin_bswap16(x); | ||
| } | ||
| inline uint32_t ByteSwap32(uint32_t x) { | ||
| return __builtin_bswap32(x); | ||
| } | ||
| inline uint64_t ByteSwap64(uint64_t x) { | ||
| return __builtin_bswap64(x); | ||
| } | ||
| #endif | ||
|
|
||
| #if PERFETTO_IS_LITTLE_ENDIAN() | ||
| inline uint16_t HostToLE16(uint16_t x) { | ||
| return x; | ||
| } | ||
| inline uint32_t HostToLE32(uint32_t x) { | ||
| return x; | ||
| } | ||
| inline uint64_t HostToLE64(uint64_t x) { | ||
| return x; | ||
| } | ||
| inline uint16_t LE16ToHost(uint16_t x) { | ||
| return x; | ||
| } | ||
| inline uint32_t LE32ToHost(uint32_t x) { | ||
| return x; | ||
| } | ||
| inline uint64_t LE64ToHost(uint64_t x) { | ||
| return x; | ||
| } | ||
| inline uint16_t HostToBE16(uint16_t x) { | ||
| return ByteSwap16(x); | ||
| } | ||
| inline uint32_t HostToBE32(uint32_t x) { | ||
| return ByteSwap32(x); | ||
| } | ||
| inline uint64_t HostToBE64(uint64_t x) { | ||
| return ByteSwap64(x); | ||
| } | ||
| inline uint16_t BE16ToHost(uint16_t x) { | ||
| return ByteSwap16(x); | ||
| } | ||
| inline uint32_t BE32ToHost(uint32_t x) { | ||
| return ByteSwap32(x); | ||
| } | ||
| inline uint64_t BE64ToHost(uint64_t x) { | ||
| return ByteSwap64(x); | ||
| } | ||
| inline float HostToLEFloat(float x) { | ||
| return x; | ||
| } | ||
| inline double HostToLEDouble(double x) { | ||
| return x; | ||
| } | ||
| inline float LEFloatToHost(float x) { | ||
| return x; | ||
| } | ||
| inline double LEDoubleToHost(double x) { | ||
| return x; | ||
| } | ||
| inline float HostToBEFloat(float x) { | ||
| uint32_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap32(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| inline double HostToBEDouble(double x) { | ||
| uint64_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap64(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| inline float BEFloatToHost(float x) { | ||
| uint32_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap32(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| inline double BEDoubleToHost(double x) { | ||
| uint64_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap64(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| #else | ||
| inline uint16_t HostToLE16(uint16_t x) { | ||
| return ByteSwap16(x); | ||
| } | ||
| inline uint32_t HostToLE32(uint32_t x) { | ||
| return ByteSwap32(x); | ||
| } | ||
| inline uint64_t HostToLE64(uint64_t x) { | ||
| return ByteSwap64(x); | ||
| } | ||
| inline uint16_t LE16ToHost(uint16_t x) { | ||
| return ByteSwap16(x); | ||
| } | ||
| inline uint32_t LE32ToHost(uint32_t x) { | ||
| return ByteSwap32(x); | ||
| } | ||
| inline uint64_t LE64ToHost(uint64_t x) { | ||
| return ByteSwap64(x); | ||
| } | ||
| inline uint16_t HostToBE16(uint16_t x) { | ||
| return x; | ||
| } | ||
| inline uint32_t HostToBE32(uint32_t x) { | ||
| return x; | ||
| } | ||
| inline uint64_t HostToBE64(uint64_t x) { | ||
| return x; | ||
| } | ||
| inline uint16_t BE16ToHost(uint16_t x) { | ||
| return x; | ||
| } | ||
| inline uint32_t BE32ToHost(uint32_t x) { | ||
| return x; | ||
| } | ||
| inline uint64_t BE64ToHost(uint64_t x) { | ||
| return x; | ||
| } | ||
| inline float HostToLEFloat(float x) { | ||
| uint32_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap32(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| inline double HostToLEDouble(double x) { | ||
| uint64_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap64(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| inline float LEFloatToHost(float x) { | ||
| uint32_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap32(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| inline double LEDoubleToHost(double x) { | ||
| uint64_t u; | ||
| memcpy(&u, &x, sizeof(u)); | ||
| u = ByteSwap64(u); | ||
| memcpy(&x, &u, sizeof(u)); | ||
| return x; | ||
| } | ||
| inline float HostToBEFloat(float x) { | ||
| return x; | ||
| } | ||
| inline double HostToBEDouble(double x) { | ||
| return x; | ||
| } | ||
| inline float BEFloatToHost(float x) { | ||
| return x; | ||
| } | ||
| inline double BEDoubleToHost(double x) { | ||
| return x; | ||
| } | ||
| #endif | ||
|
|
||
| inline uint32_t HostToLE(uint32_t x) { | ||
| return HostToLE32(x); | ||
| } | ||
| inline int32_t HostToLE(int32_t x) { | ||
| return static_cast<int32_t>(HostToLE32(static_cast<uint32_t>(x))); | ||
| } | ||
| inline uint64_t HostToLE(uint64_t x) { | ||
| return HostToLE64(x); | ||
| } | ||
| inline int64_t HostToLE(int64_t x) { | ||
| return static_cast<int64_t>(HostToLE64(static_cast<uint64_t>(x))); | ||
| } | ||
| inline float HostToLE(float x) { | ||
| return HostToLEFloat(x); | ||
| } | ||
| inline double HostToLE(double x) { | ||
| return HostToLEDouble(x); | ||
| } | ||
|
|
||
| inline uint32_t LEToHost(uint32_t x) { | ||
| return LE32ToHost(x); | ||
| } | ||
| inline int32_t LEToHost(int32_t x) { | ||
| return static_cast<int32_t>(LE32ToHost(static_cast<uint32_t>(x))); | ||
| } | ||
| inline uint64_t LEToHost(uint64_t x) { | ||
| return LE64ToHost(x); | ||
| } | ||
| inline int64_t LEToHost(int64_t x) { | ||
| return static_cast<int64_t>(LE64ToHost(static_cast<uint64_t>(x))); | ||
| } | ||
| inline float LEToHost(float x) { | ||
| return LEFloatToHost(x); | ||
| } | ||
| inline double LEToHost(double x) { | ||
| return LEDoubleToHost(x); | ||
| } | ||
|
|
||
| } // namespace base | ||
| } // namespace perfetto | ||
|
|
||
| #endif // INCLUDE_PERFETTO_BASE_ENDIAN_H_ |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.