-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pw_polyfill: Move std::endian polyfill to pw::endian
- Provide the endian enum as pw::endian. Alias it to std::endian in the <bit> polyfill header. - Remove automatic polyfilling for Bazel. The current setup doesn't seem to support having the <bit> polyfill depend on pw_bytes/bit.h. Since automatic polyfills are being removed anyway, it is simpler to remove them from Bazel now. Bug: b/235237667 Change-Id: I20fa9c7bfca2b6858ee2a121ef755a953ce78ef0 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/97570 Commit-Queue: Wyatt Hepler <[email protected]> Reviewed-by: Ted Pudlik <[email protected]>
- Loading branch information
Showing
14 changed files
with
104 additions
and
140 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 was deleted.
Oops, something went wrong.
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
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,44 @@ | ||
// Copyright 2022 The Pigweed Authors | ||
// | ||
// 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 | ||
// | ||
// https://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. | ||
|
||
// Features from the <bit> header introduced in C++20. | ||
#pragma once | ||
|
||
#if __has_include(<bit>) | ||
#include <bit> | ||
#endif // __has_include(<bit>) | ||
|
||
namespace pw { | ||
|
||
#ifdef __cpp_lib_endian | ||
|
||
using std::endian; | ||
|
||
#elif defined(__GNUC__) | ||
|
||
enum class endian { | ||
little = __ORDER_LITTLE_ENDIAN__, | ||
big = __ORDER_BIG_ENDIAN__, | ||
native = __BYTE_ORDER__, | ||
}; | ||
|
||
#else | ||
|
||
static_assert(false, | ||
"The pw::endian enum is not defined for this compiler. Add a " | ||
"definition to pw_bytes/bit.h."); | ||
|
||
#endif // __cpp_lib_endian | ||
|
||
} // namespace pw |
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
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
Oops, something went wrong.