diff mbox

[google] Move delete with size to its own file (issue6655052)

Message ID 20121011202117.06BDB2214DE@agni2.mtv.corp.google.com
State New
Headers show

Commit Message

Easwaran Raman Oct. 11, 2012, 8:21 p.m. UTC
This patch moves the two argument delete operator into its own file.
When a program provides its own definition of operator delete (void
*), but not operator delete (void *, size_t), we could end up linking
two files that define _ZdlPv resulting in a linker error. Bootstraps
with no test regressions on a x86_64 machine running linux. Ok for
google/4_7 and google/main branches?

Google ref b/6982747

2012-10-11  Easwaran Raman  <eraman@google.com>

	* libsupc++/Makefile.am: Add del_opsz.cc to sources.
	* libsupc++/Makefile.in: Regenerated.
	* libsupc++/del_opsz.cc: New file.
	* libsupc++/del_op.cc(operator delete(void*,std::size_t)):
	  Remove.


--
This patch is available for review at http://codereview.appspot.com/6655052

Comments

Xinliang David Li Oct. 11, 2012, 8:41 p.m. UTC | #1
ok.

thanks,

David

On Thu, Oct 11, 2012 at 1:21 PM, Easwaran Raman <eraman@google.com> wrote:
> This patch moves the two argument delete operator into its own file.
> When a program provides its own definition of operator delete (void
> *), but not operator delete (void *, size_t), we could end up linking
> two files that define _ZdlPv resulting in a linker error. Bootstraps
> with no test regressions on a x86_64 machine running linux. Ok for
> google/4_7 and google/main branches?
>
> Google ref b/6982747
>
> 2012-10-11  Easwaran Raman  <eraman@google.com>
>
>         * libsupc++/Makefile.am: Add del_opsz.cc to sources.
>         * libsupc++/Makefile.in: Regenerated.
>         * libsupc++/del_opsz.cc: New file.
>         * libsupc++/del_op.cc(operator delete(void*,std::size_t)):
>           Remove.
>
> Index: libstdc++-v3/libsupc++/Makefile.in
> ===================================================================
> --- libstdc++-v3/libsupc++/Makefile.in  (revision 192373)
> +++ libstdc++-v3/libsupc++/Makefile.in  (working copy)
> @@ -92,8 +92,8 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_
>  libsupc___la_LIBADD =
>  am__objects_1 = array_type_info.lo atexit_arm.lo bad_alloc.lo \
>         bad_cast.lo bad_typeid.lo class_type_info.lo del_op.lo \
> -       del_opnt.lo del_opv.lo del_opvnt.lo dyncast.lo eh_alloc.lo \
> -       eh_arm.lo eh_aux_runtime.lo eh_call.lo eh_catch.lo \
> +       del_opsz.lo del_opnt.lo del_opv.lo del_opvnt.lo dyncast.lo \
> +       eh_alloc.lo eh_arm.lo eh_aux_runtime.lo eh_call.lo eh_catch.lo \
>         eh_exception.lo eh_globals.lo eh_personality.lo eh_ptr.lo \
>         eh_term_handler.lo eh_terminate.lo eh_tm.lo eh_throw.lo \
>         eh_type.lo eh_unex_handler.lo enum_type_info.lo \
> @@ -362,6 +362,7 @@ sources = \
>         bad_typeid.cc \
>         class_type_info.cc \
>         del_op.cc \
> +       del_opsz.cc \
>         del_opnt.cc \
>         del_opv.cc \
>         del_opvnt.cc \
> Index: libstdc++-v3/libsupc++/del_op.cc
> ===================================================================
> --- libstdc++-v3/libsupc++/del_op.cc    (revision 192373)
> +++ libstdc++-v3/libsupc++/del_op.cc    (working copy)
> @@ -47,11 +47,3 @@ operator delete(void* ptr) _GLIBCXX_USE_NOEXCEPT
>    if (ptr)
>      std::free(ptr);
>  }
> -
> -_GLIBCXX_WEAK_DEFINITION void
> -operator delete(void* ptr,
> -                std::size_t bytes __attribute__((__unused__))) throw ()
> -{
> -  if (ptr)
> -    std::free(ptr);
> -}
> Index: libstdc++-v3/libsupc++/del_opsz.cc
> ===================================================================
> --- libstdc++-v3/libsupc++/del_opsz.cc  (revision 0)
> +++ libstdc++-v3/libsupc++/del_opsz.cc  (revision 0)
> @@ -0,0 +1,50 @@
> +// Boilerplate support routines for -*- C++ -*- dynamic memory management.
> +
> +// Copyright (C) 2012
> +// Free Software Foundation
> +//
> +// This file is part of GCC.
> +//
> +// GCC is free software; you can redistribute it and/or modify
> +// it under the terms of the GNU General Public License as published by
> +// the Free Software Foundation; either version 3, or (at your option)
> +// any later version.
> +//
> +// GCC is distributed in the hope that it will be useful,
> +// but WITHOUT ANY WARRANTY; without even the implied warranty of
> +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +// GNU General Public License for more details.
> +//
> +// Under Section 7 of GPL version 3, you are granted additional
> +// permissions described in the GCC Runtime Library Exception, version
> +// 3.1, as published by the Free Software Foundation.
> +
> +// You should have received a copy of the GNU General Public License and
> +// a copy of the GCC Runtime Library Exception along with this program;
> +// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +// <http://www.gnu.org/licenses/>.
> +
> +#include <bits/c++config.h>
> +
> +#if !_GLIBCXX_HOSTED
> +// A freestanding C runtime may not provide "free" -- but there is no
> +// other reasonable way to implement "operator delete".
> +namespace std
> +{
> +_GLIBCXX_BEGIN_NAMESPACE_VERSION
> +  extern "C" void free(void*);
> +_GLIBCXX_END_NAMESPACE_VERSION
> +} // namespace
> +#else
> +# include <cstdlib>
> +#endif
> +
> +#include "new"
> +
> +_GLIBCXX_WEAK_DEFINITION void
> +operator delete(void* ptr,
> +                std::size_t bytes __attribute__((__unused__))) throw ()
> +{
> +  if (ptr)
> +    std::free(ptr);
> +}
> Index: libstdc++-v3/libsupc++/Makefile.am
> ===================================================================
> --- libstdc++-v3/libsupc++/Makefile.am  (revision 192373)
> +++ libstdc++-v3/libsupc++/Makefile.am  (working copy)
> @@ -53,6 +53,7 @@ sources = \
>         bad_typeid.cc \
>         class_type_info.cc \
>         del_op.cc \
> +       del_opsz.cc \
>         del_opnt.cc \
>         del_opv.cc \
>         del_opvnt.cc \
>
> --
> This patch is available for review at http://codereview.appspot.com/6655052
diff mbox

Patch

Index: libstdc++-v3/libsupc++/Makefile.in
===================================================================
--- libstdc++-v3/libsupc++/Makefile.in	(revision 192373)
+++ libstdc++-v3/libsupc++/Makefile.in	(working copy)
@@ -92,8 +92,8 @@  LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_
 libsupc___la_LIBADD =
 am__objects_1 = array_type_info.lo atexit_arm.lo bad_alloc.lo \
 	bad_cast.lo bad_typeid.lo class_type_info.lo del_op.lo \
-	del_opnt.lo del_opv.lo del_opvnt.lo dyncast.lo eh_alloc.lo \
-	eh_arm.lo eh_aux_runtime.lo eh_call.lo eh_catch.lo \
+	del_opsz.lo del_opnt.lo del_opv.lo del_opvnt.lo dyncast.lo \
+	eh_alloc.lo eh_arm.lo eh_aux_runtime.lo eh_call.lo eh_catch.lo \
 	eh_exception.lo eh_globals.lo eh_personality.lo eh_ptr.lo \
 	eh_term_handler.lo eh_terminate.lo eh_tm.lo eh_throw.lo \
 	eh_type.lo eh_unex_handler.lo enum_type_info.lo \
@@ -362,6 +362,7 @@  sources = \
 	bad_typeid.cc \
 	class_type_info.cc \
 	del_op.cc \
+	del_opsz.cc \
 	del_opnt.cc \
 	del_opv.cc \
 	del_opvnt.cc \
Index: libstdc++-v3/libsupc++/del_op.cc
===================================================================
--- libstdc++-v3/libsupc++/del_op.cc	(revision 192373)
+++ libstdc++-v3/libsupc++/del_op.cc	(working copy)
@@ -47,11 +47,3 @@  operator delete(void* ptr) _GLIBCXX_USE_NOEXCEPT
   if (ptr)
     std::free(ptr);
 }
-
-_GLIBCXX_WEAK_DEFINITION void
-operator delete(void* ptr,
-                std::size_t bytes __attribute__((__unused__))) throw ()
-{
-  if (ptr)
-    std::free(ptr);
-}
Index: libstdc++-v3/libsupc++/del_opsz.cc
===================================================================
--- libstdc++-v3/libsupc++/del_opsz.cc	(revision 0)
+++ libstdc++-v3/libsupc++/del_opsz.cc	(revision 0)
@@ -0,0 +1,50 @@ 
+// Boilerplate support routines for -*- C++ -*- dynamic memory management.
+
+// Copyright (C) 2012
+// Free Software Foundation
+//
+// This file is part of GCC.
+//
+// GCC is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// GCC is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+#include <bits/c++config.h>
+
+#if !_GLIBCXX_HOSTED
+// A freestanding C runtime may not provide "free" -- but there is no
+// other reasonable way to implement "operator delete".
+namespace std
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  extern "C" void free(void*);
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+#else
+# include <cstdlib>
+#endif
+
+#include "new"
+
+_GLIBCXX_WEAK_DEFINITION void
+operator delete(void* ptr,
+                std::size_t bytes __attribute__((__unused__))) throw ()
+{
+  if (ptr)
+    std::free(ptr);
+}
Index: libstdc++-v3/libsupc++/Makefile.am
===================================================================
--- libstdc++-v3/libsupc++/Makefile.am	(revision 192373)
+++ libstdc++-v3/libsupc++/Makefile.am	(working copy)
@@ -53,6 +53,7 @@  sources = \
 	bad_typeid.cc \
 	class_type_info.cc \
 	del_op.cc \
+	del_opsz.cc \
 	del_opnt.cc \
 	del_opv.cc \
 	del_opvnt.cc \