*: Add support for RP2350
- targets/rp2040: Switch to final pins
- pw_libcxx: Provide more definitions of operator new
- roll: pico-sdk and picotool
- pw_blob_store: Temporarily disable on Pico
- pw_libcxx: Add alwayslink=True to pw_libcxx
- targets/rp2040: Pico SDK Beta 3 update
- pw_string: Remove <regex>
- pw_toolchain: Support cortex-m33 for clang
- pw_toolchain: Move arm_gcc C++ selection to toolchain features
- bazel: Register the clang M0 toolchain, not GCC
- pw_toolchain: Clang Bazel build
- targets/rp2040: Update device IDs to include rp2350
- targets/rp2040: Fix missing return in pico transitions
- targets/rp2040: Fix lint issues
- targets/rp2040: Initial changes for RP2350
Co-authored-by: Anthony DiGirolamo <tonymd@google.com>
Co-authored-by: Armando Montanez <amontanez@google.com>
Co-authored-by: Asad Memon <asadmemon@google.com>
Co-authored-by: Chad Norvell <chadnorvell@google.com>
Co-authored-by: Dave Roth <davidroth@google.com>
Co-authored-by: Erik Gilling <konkers@google.com>
Co-authored-by: Leonard Chan <leonardchan@google.com>
Co-authored-by: prabhukr <prabhukr@google.com>
Co-authored-by: Taylor Cramer <cramertj@google.com>
Co-authored-by: Ted Pudlik <tpudlik@google.com>
Change-Id: I5a08edcb69d175528ed3f5230fa9ad91a109ea12
No-Tree-Checks: true
Bug: b/354942782
Original-Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/228326
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Original-Reviewed-by: Armando Montanez <amontanez@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/llvm-integration/+/235151
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Prabhu Karthikeyan Rajasekaran <prabhukr@google.com>
diff --git a/pw_libcxx/BUILD.bazel b/pw_libcxx/BUILD.bazel
index 8254216..515cc5c 100644
--- a/pw_libcxx/BUILD.bazel
+++ b/pw_libcxx/BUILD.bazel
@@ -12,6 +12,11 @@
# License for the specific language governing permissions and limitations under
# the License.
+load(
+ "//pw_build:pigweed.bzl",
+ "pw_cc_test",
+)
+
package(default_visibility = ["//visibility:public"])
cc_library(
@@ -27,6 +32,15 @@
"@rules_cc//cc/compiler:clang": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
+ alwayslink = True,
+)
+
+pw_cc_test(
+ name = "operator_new_test",
+ srcs = ["operator_new_test.cc"],
+ deps = [
+ "//pw_unit_test",
+ ],
)
filegroup(
diff --git a/pw_libcxx/BUILD.gn b/pw_libcxx/BUILD.gn
index 602a113..a28a652 100644
--- a/pw_libcxx/BUILD.gn
+++ b/pw_libcxx/BUILD.gn
@@ -39,6 +39,10 @@
]
remove_public_deps = [ dir_pw_libcxx ]
}
+
+ pw_test("operator_new_test") {
+ sources = [ "operator_new_test.cc" ]
+ }
} else {
pw_static_library("pw_libcxx") {
add_global_link_deps = false
diff --git a/pw_libcxx/operator_new.cc b/pw_libcxx/operator_new.cc
index f13a9b3..d64a174 100644
--- a/pw_libcxx/operator_new.cc
+++ b/pw_libcxx/operator_new.cc
@@ -18,6 +18,32 @@
void* operator new(size_t size) { return malloc(size); }
+void* operator new[](size_t size) { return malloc(size); }
+
+void* operator new(size_t size, std::align_val_t alignment) {
+ return aligned_alloc(static_cast<size_t>(alignment), size);
+}
+
+void* operator new[](size_t size, std::align_val_t alignment) {
+ return aligned_alloc(static_cast<size_t>(alignment), size);
+}
+
void* operator new(size_t size, const std::nothrow_t&) noexcept {
return ::operator new(size);
}
+
+void* operator new[](size_t size, const std::nothrow_t&) noexcept {
+ return ::operator new[](size);
+}
+
+void* operator new(size_t size,
+ std::align_val_t alignment,
+ const std::nothrow_t&) noexcept {
+ return ::operator new(size, alignment);
+}
+
+void* operator new[](size_t size,
+ std::align_val_t alignment,
+ const std::nothrow_t&) noexcept {
+ return ::operator new[](size, alignment);
+}
diff --git a/pw_libcxx/operator_new_test.cc b/pw_libcxx/operator_new_test.cc
new file mode 100644
index 0000000..c036686
--- /dev/null
+++ b/pw_libcxx/operator_new_test.cc
@@ -0,0 +1,72 @@
+// Copyright 2024 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.
+
+#include <new>
+
+#include "pw_unit_test/framework.h"
+
+namespace pw {
+namespace {
+
+void CheckNonNull(void* ptr) {
+ EXPECT_NE(ptr, nullptr);
+ ::operator delete(ptr);
+}
+
+void CheckNonNullArray(void* ptr) {
+ EXPECT_NE(ptr, nullptr);
+ ::operator delete[](ptr);
+}
+
+void CheckNonNullWithAlignment(void* ptr, std::align_val_t alignment) {
+ EXPECT_NE(ptr, nullptr);
+ EXPECT_EQ(reinterpret_cast<uintptr_t>(ptr) % static_cast<size_t>(alignment),
+ size_t{0});
+ ::operator delete(ptr, alignment);
+}
+
+void CheckNonNullArrayWithAlignment(void* ptr, std::align_val_t alignment) {
+ EXPECT_NE(ptr, nullptr);
+ EXPECT_EQ(reinterpret_cast<uintptr_t>(ptr) % static_cast<size_t>(alignment),
+ size_t{0});
+ ::operator delete[](ptr, alignment);
+}
+
+TEST(OperatorNew, CallAllNews) {
+ constexpr std::align_val_t kAlignment{16};
+ constexpr size_t kSize{16};
+ char kBuff[kSize];
+
+ // Replaceable allocation functions
+ CheckNonNull(::operator new(kSize));
+ CheckNonNullArray(::operator new[](kSize));
+ CheckNonNullWithAlignment(::operator new(kSize, kAlignment), kAlignment);
+ CheckNonNullArrayWithAlignment(::operator new[](kSize, kAlignment),
+ kAlignment);
+
+ // Replaceable non-throwing allocation functions
+ CheckNonNull(::operator new(kSize, std::nothrow));
+ CheckNonNullArray(::operator new[](kSize, std::nothrow));
+ CheckNonNullWithAlignment(::operator new(kSize, kAlignment, std::nothrow),
+ kAlignment);
+ CheckNonNullArrayWithAlignment(
+ ::operator new[](kSize, kAlignment, std::nothrow), kAlignment);
+
+ // Non-allocating placement allocation functions
+ EXPECT_EQ(::operator new(kSize, kBuff), kBuff);
+ EXPECT_EQ(::operator new[](kSize, kBuff), kBuff);
+}
+
+} // namespace
+} // namespace pw