V3 PATCH: __cxa_guard_acquire

Mark Mitchell mark@codesourcery.com
Mon Nov 25 15:16:00 GMT 2002


We were missing definitions of __cxa_guard_acquire and related
functions.  G++ doesn't use these, but they're required by the ABI,
and someday we may use them.  (This is where you can put goo so that
initializations of local statics happen in a thread-safe fashion.)

Tested on i686-pc-linux-gnu, applied on the mainline.

-- 
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2002-11-25  Mark Mitchell  <mark@codesourcery.com>

	* libsupc++/Makefile.am (sources): Add guard.cc.
	* libsupc++/Makefile.in: Regenerated.
	* libsupc++/cxxabi.h (__cxa_guard_acquire): New function.
	(__cxa_guard_release): Likewise.
	(__cxa_guard_abort): Likewise.
	* libsupc++/guard.cc: New file.

Index: libsupc++/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/Makefile.am,v
retrieving revision 1.35
diff -c -p -r1.35 Makefile.am
*** libsupc++/Makefile.am	7 Aug 2002 15:56:11 -0000	1.35
--- libsupc++/Makefile.am	25 Nov 2002 23:00:23 -0000
*************** sources = \
*** 84,89 ****
--- 84,90 ----
  	eh_terminate.cc \
  	eh_throw.cc \
  	eh_type.cc \
+ 	guard.cc \
  	new_handler.cc \
  	new_op.cc \
  	new_opnt.cc \
Index: libsupc++/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/Makefile.in,v
retrieving revision 1.85
diff -c -p -r1.85 Makefile.in
*** libsupc++/Makefile.in	26 Sep 2002 05:25:13 -0000	1.85
--- libsupc++/Makefile.in	25 Nov 2002 23:00:23 -0000
*************** sources = \
*** 193,198 ****
--- 193,199 ----
  	eh_terminate.cc \
  	eh_throw.cc \
  	eh_type.cc \
+ 	guard.cc \
  	new_handler.cc \
  	new_op.cc \
  	new_opnt.cc \
*************** libsupc__convenience_la_LIBADD = 
*** 289,303 ****
  libsupc__convenience_la_OBJECTS =  del_op.lo del_opnt.lo del_opv.lo \
  del_opvnt.lo eh_alloc.lo eh_aux_runtime.lo eh_catch.lo eh_exception.lo \
  eh_globals.lo eh_personality.lo eh_terminate.lo eh_throw.lo eh_type.lo \
! new_handler.lo new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo pure.lo \
! tinfo.lo tinfo2.lo vec.lo cxa_demangle.lo dyn-string.lo
  libsupc___la_LDFLAGS = 
  libsupc___la_LIBADD = 
  libsupc___la_OBJECTS =  del_op.lo del_opnt.lo del_opv.lo del_opvnt.lo \
  eh_alloc.lo eh_aux_runtime.lo eh_catch.lo eh_exception.lo eh_globals.lo \
! eh_personality.lo eh_terminate.lo eh_throw.lo eh_type.lo new_handler.lo \
! new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo pure.lo tinfo.lo \
! tinfo2.lo vec.lo cxa_demangle.lo dyn-string.lo
  CXXFLAGS = @CXXFLAGS@
  CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
  CXXLD = $(CXX)
--- 290,304 ----
  libsupc__convenience_la_OBJECTS =  del_op.lo del_opnt.lo del_opv.lo \
  del_opvnt.lo eh_alloc.lo eh_aux_runtime.lo eh_catch.lo eh_exception.lo \
  eh_globals.lo eh_personality.lo eh_terminate.lo eh_throw.lo eh_type.lo \
! guard.lo new_handler.lo new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo \
! pure.lo tinfo.lo tinfo2.lo vec.lo cxa_demangle.lo dyn-string.lo
  libsupc___la_LDFLAGS = 
  libsupc___la_LIBADD = 
  libsupc___la_OBJECTS =  del_op.lo del_opnt.lo del_opv.lo del_opvnt.lo \
  eh_alloc.lo eh_aux_runtime.lo eh_catch.lo eh_exception.lo eh_globals.lo \
! eh_personality.lo eh_terminate.lo eh_throw.lo eh_type.lo guard.lo \
! new_handler.lo new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo pure.lo \
! tinfo.lo tinfo2.lo vec.lo cxa_demangle.lo dyn-string.lo
  CXXFLAGS = @CXXFLAGS@
  CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
  CXXLD = $(CXX)
Index: libsupc++/cxxabi.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/cxxabi.h,v
retrieving revision 1.8
diff -c -p -r1.8 cxxabi.h
*** libsupc++/cxxabi.h	31 Jul 2002 21:50:33 -0000	1.8
--- libsupc++/cxxabi.h	25 Nov 2002 23:00:23 -0000
*************** void __cxa_vec_delete3 (void *__array_ad
*** 500,505 ****
--- 500,519 ----
                          __SIZE_TYPE__ __padding_size,
                          void (*__destructor) (void *),
                          void (*__dealloc) (void *, __SIZE_TYPE__));
+ 
+ /* guard variables */
+ 
+ /* The ABI requires a 64-bit type.  */
+ __extension__ typedef int __guard __attribute__((mode (__DI__)));
+ 
+ extern "C"
+ int __cxa_guard_acquire (__guard *);
+ 
+ extern "C"
+ void __cxa_guard_release (__guard *);
+ 
+ extern "C"
+ void __cxa_guard_abort (__guard *);
                    
  /* demangling routines */
  
Index: libsupc++/guard.cc
===================================================================
RCS file: libsupc++/guard.cc
diff -N libsupc++/guard.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libsupc++/guard.cc	25 Nov 2002 23:00:23 -0000
***************
*** 0 ****
--- 1,51 ----
+ // Copyright (C) 2002 Free Software Foundation, Inc.
+ //  
+ // 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 2, 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.
+ 
+ // You should have received a copy of the GNU General Public License
+ // along with GCC; see the file COPYING.  If not, write to
+ // the Free Software Foundation, 59 Temple Place - Suite 330,
+ // Boston, MA 02111-1307, USA. 
+ 
+ // As a special exception, you may use this file as part of a free software
+ // library without restriction.  Specifically, if other files instantiate
+ // templates or use macros or inline functions from this file, or you compile
+ // this file and link it with other files to produce an executable, this
+ // file does not by itself cause the resulting executable to be covered by
+ // the GNU General Public License.  This exception does not however
+ // invalidate any other reasons why the executable file might be covered by
+ // the GNU General Public License.
+ 
+ // Written by Mark Mitchell, CodeSourcery LLC, <mark@codesourcery.com>
+ 
+ #include <cxxabi.h>
+ 
+ namespace __cxxabiv1 
+ {
+   extern "C"
+   int __cxa_guard_acquire (__guard *g) 
+   {
+     return !*(char *)(g);
+   }
+ 
+   extern "C"
+   void __cxa_guard_release (__guard *g)
+   {
+     *(char *)g = 1;
+   }
+ 
+   extern "C"
+   void __cxa_guard_abort (__guard *)
+   {
+   }
+ }



More information about the Gcc-patches mailing list