Skip to content

Commit

Permalink
third_party/fuchsia: Add stdcompat/functional.h
Browse files Browse the repository at this point in the history
Add sdk/lib/stdcompat/include/lib/stdcompat/functional.h to Fuchsia
Copybara rules. This is used by Sapphire.

Change-Id: I275d689caaab58b59d74ccf64207dfeba8e497ef
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126694
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Ben Lawson <[email protected]>
  • Loading branch information
BenjaminLawson authored and CQ Bot Account committed Jan 20, 2023
1 parent e3d96d3 commit 809a423
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 37 deletions.
1 change: 1 addition & 0 deletions third_party/fuchsia/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pw_cc_library(
"repo/sdk/lib/stdcompat/include/lib/stdcompat/memory.h",
],
hdrs = [
"repo/sdk/lib/stdcompat/include/lib/stdcompat/functional.h",
"repo/sdk/lib/stdcompat/include/lib/stdcompat/internal/bit.h",
"repo/sdk/lib/stdcompat/include/lib/stdcompat/optional.h",
"repo/sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h",
Expand Down
1 change: 1 addition & 0 deletions third_party/fuchsia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pw_source_set("stdcompat") {
public_configs = [ ":stdcompat_public_include_path" ]
public = [
"repo/sdk/lib/stdcompat/include/lib/stdcompat/bit.h",
"repo/sdk/lib/stdcompat/include/lib/stdcompat/functional.h",
"repo/sdk/lib/stdcompat/include/lib/stdcompat/memory.h",
"repo/sdk/lib/stdcompat/include/lib/stdcompat/optional.h",
"repo/sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h",
Expand Down
1 change: 1 addition & 0 deletions third_party/fuchsia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pw_add_library(pw_third_party.fuchsia.fit INTERFACE
pw_add_library(pw_third_party.fuchsia.stdcompat INTERFACE
HEADERS
repo/sdk/lib/stdcompat/include/lib/stdcompat/bit.h
repo/sdk/lib/stdcompat/include/lib/stdcompat/functional.h
repo/sdk/lib/stdcompat/include/lib/stdcompat/memory.h
repo/sdk/lib/stdcompat/include/lib/stdcompat/optional.h
repo/sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h
Expand Down
1 change: 1 addition & 0 deletions third_party/fuchsia/copy.bara.sky
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fuchsia_repo_files = [
"sdk/lib/fit/test/function_tests.cc",
# stdcompat
"sdk/lib/stdcompat/include/lib/stdcompat/bit.h",
"sdk/lib/stdcompat/include/lib/stdcompat/functional.h",
"sdk/lib/stdcompat/include/lib/stdcompat/memory.h",
"sdk/lib/stdcompat/include/lib/stdcompat/optional.h",
"sdk/lib/stdcompat/include/lib/stdcompat/type_traits.h",
Expand Down
50 changes: 13 additions & 37 deletions third_party/fuchsia/pigweed_adaptations.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 The Pigweed Authors
# Copyright 2023 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
Expand Down Expand Up @@ -114,7 +114,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/nullable.h b/t
diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h
--- a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h
+++ b/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h
@@ -54,6 +54,8 @@
@@ -55,6 +55,8 @@
// // fit::result with a different "success" vluae type (or
// // fit::result<E>).

Expand All @@ -123,19 +123,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
namespace fit {

// Convenience type to indicate failure without elaboration.
@@ -248,7 +250,10 @@ class LIB_FIT_NODISCARD result<E, T> {

// Implicit conversion from fit::failed. This overload is only enabled when the error type E is
// fit::failed.
- constexpr result(failed_or_none) : storage_{::fit::internal::error_v, failed{}} {}
+ constexpr result(failed_or_none) : storage_ {
+ ::fit::internal::error_v, failed {}
+ }
+ {}

// Implicit conversion from success<U>, where T is constructible from U.
template <typename U, ::fit::internal::requires_conditions<std::is_constructible<T, U>> = true>
@@ -279,25 +284,25 @@ class LIB_FIT_NODISCARD result<E, T> {
@@ -280,25 +282,25 @@ class LIB_FIT_NODISCARD result<E, T> {
if (is_error()) {
return storage_.error_or_value.error;
}
Expand Down Expand Up @@ -165,7 +153,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
}

// Moves the underlying error and returns it as an instance of fit::error, simplifying
@@ -308,7 +313,7 @@ class LIB_FIT_NODISCARD result<E, T> {
@@ -309,7 +311,7 @@ class LIB_FIT_NODISCARD result<E, T> {
if (is_error()) {
return error<E>(std::move(storage_.error_or_value.error));
}
Expand All @@ -174,7 +162,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
}

// Accessors for the underlying value.
@@ -318,25 +323,25 @@ class LIB_FIT_NODISCARD result<E, T> {
@@ -319,25 +321,25 @@ class LIB_FIT_NODISCARD result<E, T> {
if (is_ok()) {
return storage_.error_or_value.value;
}
Expand Down Expand Up @@ -204,7 +192,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
}

// Moves the underlying value and returns it as an instance of fit::success, simplifying
@@ -347,7 +352,7 @@ class LIB_FIT_NODISCARD result<E, T> {
@@ -348,7 +350,7 @@ class LIB_FIT_NODISCARD result<E, T> {
if (is_ok()) {
return success<T>(std::move(storage_.error_or_value.value));
}
Expand All @@ -213,7 +201,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
}

// Contingent accessors for the underlying value.
@@ -376,13 +381,13 @@ class LIB_FIT_NODISCARD result<E, T> {
@@ -377,13 +379,13 @@ class LIB_FIT_NODISCARD result<E, T> {
if (is_ok()) {
return ::fit::internal::arrow_operator<T>::forward(storage_.error_or_value.value);
}
Expand All @@ -229,28 +217,16 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
}

// Accessors for the underlying value. This is a syntax sugar for value().
@@ -405,7 +410,7 @@ class LIB_FIT_NODISCARD result<E, T> {
@@ -406,7 +408,7 @@ class LIB_FIT_NODISCARD result<E, T> {
storage_.error_or_value.error += std::move(error.value_);
return *this;
}
- __builtin_abort();
+ PW_ASSERT(false);
}

constexpr void swap(result& other) {
@@ -453,7 +458,10 @@ class LIB_FIT_NODISCARD result<E> {

// Implicit conversion from fit::failure. This overload is only enabled when the error type E is
// fit::failed.
- constexpr result(failure_or_none) : storage_{::fit::internal::error_v, failed{}} {}
+ constexpr result(failure_or_none) : storage_ {
+ ::fit::internal::error_v, failed {}
+ }
+ {}

// Implicit conversion from fit::success<>.
constexpr result(success<>) : storage_{::fit::internal::value_v} {}
@@ -478,25 +486,25 @@ class LIB_FIT_NODISCARD result<E> {
// Maps a result<E, T> to a result<E2, T> by transforming the error through
@@ -517,25 +519,25 @@ class LIB_FIT_NODISCARD result<E> {
if (is_error()) {
return storage_.error_or_value.error;
}
Expand Down Expand Up @@ -280,7 +256,7 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
}

// Moves the underlying error and returns it as an instance of fit::error, simplifying
@@ -507,7 +515,7 @@ class LIB_FIT_NODISCARD result<E> {
@@ -546,7 +548,7 @@ class LIB_FIT_NODISCARD result<E> {
if (is_error()) {
return error<E>(std::move(storage_.error_or_value.error));
}
Expand All @@ -289,12 +265,12 @@ diff --git a/third_party/fuchsia/repo/sdk/lib/fit/include/lib/fit/result.h b/thi
}

// Augments the error value of the result with the given value. The operator E::operator+=(F) must
@@ -521,7 +529,7 @@ class LIB_FIT_NODISCARD result<E> {
@@ -560,7 +562,7 @@ class LIB_FIT_NODISCARD result<E> {
storage_.error_or_value.error += std::move(error.value_);
return *this;
}
- __builtin_abort();
+ PW_ASSERT(false);
}

constexpr void swap(result& other) {
// Maps a result<E, T> to a result<E2, T> by transforming the error through

0 comments on commit 809a423

Please sign in to comment.