This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f64a48f4e5 cxx: size and un-size functions should be defined in one
file
f64a48f4e5 is described below
commit f64a48f4e595b31d95756f46c5aa8f0c3fb92a8a
Author: Gao Feng <[email protected]>
AuthorDate: Tue Jan 7 14:18:11 2025 +0800
cxx: size and un-size functions should be defined in one file
fix error when "-Werror=sized-deallocation" is enabled.
refer to https://timsong-cpp.github.io/cppwp/n4861/new.delete,
displace the default versions defined by the C++ standard library.
---
libs/libxx/libcxxmini/CMakeLists.txt | 2 -
libs/libxx/libcxxmini/Make.defs | 4 +-
libs/libxx/libcxxmini/libxx_delete.cxx | 29 ++++++++++++++
libs/libxx/libcxxmini/libxx_delete_sized.cxx | 57 ---------------------------
libs/libxx/libcxxmini/libxx_deletea.cxx | 20 ++++++++++
libs/libxx/libcxxmini/libxx_deletea_sized.cxx | 48 ----------------------
6 files changed, 51 insertions(+), 109 deletions(-)
diff --git a/libs/libxx/libcxxmini/CMakeLists.txt
b/libs/libxx/libcxxmini/CMakeLists.txt
index a4d3192d9c..a36ef8c96f 100644
--- a/libs/libxx/libcxxmini/CMakeLists.txt
+++ b/libs/libxx/libcxxmini/CMakeLists.txt
@@ -33,9 +33,7 @@ if(CONFIG_LIBCXXMINI)
PRIVATE libxx_cxa_guard.cxx
libxx_cxapurevirtual.cxx
libxx_delete.cxx
- libxx_delete_sized.cxx
libxx_deletea.cxx
- libxx_deletea_sized.cxx
libxx_new.cxx
libxx_newa.cxx
libxx_dynamic_cast.cxx
diff --git a/libs/libxx/libcxxmini/Make.defs b/libs/libxx/libcxxmini/Make.defs
index 6cd7543362..816de50011 100644
--- a/libs/libxx/libcxxmini/Make.defs
+++ b/libs/libxx/libcxxmini/Make.defs
@@ -21,8 +21,8 @@
###########################################################################
CXXSRCS += libxx_cxa_guard.cxx libxx_cxapurevirtual.cxx
-CXXSRCS += libxx_delete.cxx libxx_delete_sized.cxx libxx_deletea.cxx
-CXXSRCS += libxx_deletea_sized.cxx libxx_new.cxx libxx_newa.cxx
+CXXSRCS += libxx_delete.cxx libxx_deletea.cxx
+CXXSRCS += libxx_new.cxx libxx_newa.cxx
CXXSRCS += libxx_dynamic_cast.cxx libxx_typeinfo.cxx
ifneq ($(CONFIG_XTENSA_TOOLCHAIN_XCC), y)
diff --git a/libs/libxx/libcxxmini/libxx_delete.cxx
b/libs/libxx/libcxxmini/libxx_delete.cxx
index 11ee18e383..8cd04d0f81 100644
--- a/libs/libxx/libcxxmini/libxx_delete.cxx
+++ b/libs/libxx/libcxxmini/libxx_delete.cxx
@@ -25,6 +25,8 @@
#include <nuttx/config.h>
+#include <cstddef>
+
#include <nuttx/lib/lib.h>
//***************************************************************************
@@ -39,3 +41,30 @@ void operator delete(FAR void *ptr) throw()
{
lib_free(ptr);
}
+
+#ifdef CONFIG_HAVE_CXX14
+
+//***************************************************************************
+// Operators
+//***************************************************************************
+
+//***************************************************************************
+// Name: delete
+//
+// NOTE:
+// This should take a type of size_t. But size_t has an unknown underlying
+// type. In the nuttx sys/types.h header file, size_t is typed as uint32_t
+// (which is determined by architecture-specific logic). But the C++
+// compiler may believe that size_t is of a different type resulting in
+// compilation errors in the operator. Using the underlying integer type
+// instead of size_t seems to resolve the compilation issues. Need to
+// REVISIT this.
+//
+//***************************************************************************
+
+void operator delete(FAR void *ptr, std::size_t size)
+{
+ lib_free(ptr);
+}
+
+#endif /* CONFIG_HAVE_CXX14 */
diff --git a/libs/libxx/libcxxmini/libxx_delete_sized.cxx
b/libs/libxx/libcxxmini/libxx_delete_sized.cxx
deleted file mode 100644
index b2148cd098..0000000000
--- a/libs/libxx/libcxxmini/libxx_delete_sized.cxx
+++ /dev/null
@@ -1,57 +0,0 @@
-//***************************************************************************
-// libs/libxx/libcxxmini/libxx_delete_sized.cxx
-//
-// SPDX-License-Identifier: Apache-2.0
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership. The
-// ASF licenses this file to you 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
-//
-//***************************************************************************
-
-//***************************************************************************
-// Included Files
-//***************************************************************************
-
-#include <nuttx/compiler.h>
-
-#include <cstddef>
-
-#include <nuttx/lib/lib.h>
-
-#ifdef CONFIG_HAVE_CXX14
-
-//***************************************************************************
-// Operators
-//***************************************************************************
-
-//***************************************************************************
-// Name: delete
-//
-// NOTE:
-// This should take a type of size_t. But size_t has an unknown underlying
-// type. In the nuttx sys/types.h header file, size_t is typed as uint32_t
-// (which is determined by architecture-specific logic). But the C++
-// compiler may believe that size_t is of a different type resulting in
-// compilation errors in the operator. Using the underlying integer type
-// instead of size_t seems to resolve the compilation issues. Need to
-// REVISIT this.
-//
-//***************************************************************************
-
-void operator delete(FAR void *ptr, std::size_t size)
-{
- lib_free(ptr);
-}
-
-#endif /* CONFIG_HAVE_CXX14 */
diff --git a/libs/libxx/libcxxmini/libxx_deletea.cxx
b/libs/libxx/libcxxmini/libxx_deletea.cxx
index c5a7d90571..ca935f05da 100644
--- a/libs/libxx/libcxxmini/libxx_deletea.cxx
+++ b/libs/libxx/libcxxmini/libxx_deletea.cxx
@@ -22,6 +22,9 @@
//***************************************************************************
#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <cstddef>
#include <nuttx/lib/lib.h>
@@ -37,3 +40,20 @@ void operator delete[](FAR void *ptr) throw()
{
lib_free(ptr);
}
+
+#ifdef CONFIG_HAVE_CXX14
+
+//***************************************************************************
+// Operators
+//***************************************************************************
+
+//***************************************************************************
+// Name: delete[]
+//***************************************************************************
+
+void operator delete[](FAR void *ptr, std::size_t size)
+{
+ lib_free(ptr);
+}
+
+#endif /* CONFIG_HAVE_CXX14 */
diff --git a/libs/libxx/libcxxmini/libxx_deletea_sized.cxx
b/libs/libxx/libcxxmini/libxx_deletea_sized.cxx
deleted file mode 100644
index ab1dda939e..0000000000
--- a/libs/libxx/libcxxmini/libxx_deletea_sized.cxx
+++ /dev/null
@@ -1,48 +0,0 @@
-//***************************************************************************
-// libs/libxx/libcxxmini/libxx_deletea_sized.cxx
-//
-// SPDX-License-Identifier: Apache-2.0
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership. The
-// ASF licenses this file to you 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
-//
-//***************************************************************************
-
-//***************************************************************************
-// Included Files
-//***************************************************************************
-
-#include <nuttx/config.h>
-#include <nuttx/compiler.h>
-
-#include <cstddef>
-
-#include <nuttx/lib/lib.h>
-
-#ifdef CONFIG_HAVE_CXX14
-
-//***************************************************************************
-// Operators
-//***************************************************************************
-
-//***************************************************************************
-// Name: delete[]
-//***************************************************************************
-
-void operator delete[](FAR void *ptr, std::size_t size)
-{
- lib_free(ptr);
-}
-
-#endif /* CONFIG_HAVE_CXX14 */