This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: weak for Darwin


Geoff Keating wrote:

>>OK.  What do you think about adding a macro named something like
>>_GLIBCXX_WEAK_DEFINITION that is __attribute__((weak)) for Darwin,
>>nothing for PE targets, and whatever the concensus is for other 
>>targets?
> 
> Sure.  Will you make a patch, or should I?

I'm not really sure where the correct place to define this macro is.
The attached patch puts it in include/bits/c++config and the override in
config/os/mingw32/os_defines.h.  Is this right?

Aaron W. LaFramboise
2004-11-01  Aaron W. LaFramboise <aaronavay62@aaronwl.com>

	* config/os/mingw32/os_defines.h
	(_GLIBCXX_WEAK_DEFINITION): Define.
	* include/bits/c++config (_GLIBCXX_WEAK_DEFINITION): Define.
	* libsupc++/del_op.cc (operator delete(void *)): Use
	_GLIBCXX_WEAK_DEFINITION.
	* libsupc++/del_opnt.cc
	(operator delete(void *, const std::nothrow_t&): Same.
	* libsupc++/del_opv.cc (operator delete[](void *)): Same.
	* libsupc++/del_opvnt.cc
	(operator delete[](void *, const std::nothrow_t&): Same.
	* libsupc++/new_op.cc (operator new(std::size_t)): Same.
	* libsupc++/new_opnt.cc
	(operator new(std::size_t, const std::nothrow_t&)): Same
	* libsupc++/new_opv.cc (operator new[](std::size_t)): Same.
	* libsupc++/new_opvnt.cc
	(operator new[](std::size_t, const std::nothrow_t&)): Same.

Index: gcc/libstdc++-v3/config/os/mingw32/os_defines.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/os/mingw32/os_defines.h,v
retrieving revision 1.3
diff -c -3 -p -r1.3 os_defines.h
*** gcc/libstdc++-v3/config/os/mingw32/os_defines.h	5 Jul 2003 04:05:32 -0000	1.3
--- gcc/libstdc++-v3/config/os/mingw32/os_defines.h	2 Nov 2004 04:21:40 -0000
***************
*** 45,48 ****
--- 45,52 ----
  #undef NOMINMAX
  #define NOMINMAX 1
  
+ // PECOFF weak symbols should not be used for definitions as they
+ // don't satisfy references from other objects.
+ #define _GLIBCXX_WEAK_DEFINITION
+ 
  #endif
Index: gcc/libstdc++-v3/include/bits/c++config
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/c++config,v
retrieving revision 1.1268
diff -c -3 -p -r1.1268 c++config
*** gcc/libstdc++-v3/include/bits/c++config	28 Oct 2004 00:16:17 -0000	1.1268
--- gcc/libstdc++-v3/include/bits/c++config	2 Nov 2004 04:21:40 -0000
***************
*** 51,56 ****
--- 51,63 ----
  # define _GLIBCXX_EXTERN_TEMPLATE 1
  #endif
  
+ // Certain function definitions that are meant to be overridable from
+ // user code are decorated with this macro.  For some targets,
+ // weakening these definitions is inappropriate.
+ #ifndef _GLIBCXX_WEAK_DEFINITION
+ #define _GLIBCXX_WEAK_DEFINITION __attribute__((__weak__))
+ #endif
+ 
  // Debug mode support. Debug mode basic_string is not allowed to be
  // associated with std, because of locale and exception link
  // dependence.
Index: gcc/libstdc++-v3/libsupc++/del_op.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc,v
retrieving revision 1.7
diff -c -3 -p -r1.7 del_op.cc
*** gcc/libstdc++-v3/libsupc++/del_op.cc	26 Oct 2004 06:09:05 -0000	1.7
--- gcc/libstdc++-v3/libsupc++/del_op.cc	2 Nov 2004 04:21:40 -0000
*************** using std::free;
*** 39,45 ****
  extern "C" void free(void *);
  #endif
  
! __attribute__((weak)) void
  operator delete (void *ptr) throw ()
  {
    if (ptr)
--- 39,45 ----
  extern "C" void free(void *);
  #endif
  
! _GLIBCXX_WEAK_DEFINITION void
  operator delete (void *ptr) throw ()
  {
    if (ptr)
Index: gcc/libstdc++-v3/libsupc++/del_opnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_opnt.cc,v
retrieving revision 1.4
diff -c -3 -p -r1.4 del_opnt.cc
*** gcc/libstdc++-v3/libsupc++/del_opnt.cc	26 Oct 2004 06:09:05 -0000	1.4
--- gcc/libstdc++-v3/libsupc++/del_opnt.cc	2 Nov 2004 04:21:40 -0000
***************
*** 32,38 ****
  
  extern "C" void free (void *);
  
! __attribute__((weak)) void
  operator delete (void *ptr, const std::nothrow_t&) throw ()
  {
    if (ptr)
--- 32,38 ----
  
  extern "C" void free (void *);
  
! _GLIBCXX_WEAK_DEFINITION void
  operator delete (void *ptr, const std::nothrow_t&) throw ()
  {
    if (ptr)
Index: gcc/libstdc++-v3/libsupc++/del_opv.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_opv.cc,v
retrieving revision 1.4
diff -c -3 -p -r1.4 del_opv.cc
*** gcc/libstdc++-v3/libsupc++/del_opv.cc	26 Oct 2004 06:09:05 -0000	1.4
--- gcc/libstdc++-v3/libsupc++/del_opv.cc	2 Nov 2004 04:21:40 -0000
***************
*** 30,36 ****
  
  #include "new"
  
! __attribute__((weak)) void
  operator delete[] (void *ptr) throw ()
  {
    ::operator delete (ptr);
--- 30,36 ----
  
  #include "new"
  
! _GLIBCXX_WEAK_DEFINITION void
  operator delete[] (void *ptr) throw ()
  {
    ::operator delete (ptr);
Index: gcc/libstdc++-v3/libsupc++/del_opvnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_opvnt.cc,v
retrieving revision 1.4
diff -c -3 -p -r1.4 del_opvnt.cc
*** gcc/libstdc++-v3/libsupc++/del_opvnt.cc	26 Oct 2004 06:09:05 -0000	1.4
--- gcc/libstdc++-v3/libsupc++/del_opvnt.cc	2 Nov 2004 04:21:40 -0000
***************
*** 30,36 ****
  
  #include "new"
  
! __attribute__((weak)) void
  operator delete[] (void *ptr, const std::nothrow_t&) throw ()
  {
    ::operator delete (ptr);
--- 30,36 ----
  
  #include "new"
  
! _GLIBCXX_WEAK_DEFINITION void
  operator delete[] (void *ptr, const std::nothrow_t&) throw ()
  {
    ::operator delete (ptr);
Index: gcc/libstdc++-v3/libsupc++/new_op.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_op.cc,v
retrieving revision 1.9
diff -c -3 -p -r1.9 new_op.cc
*** gcc/libstdc++-v3/libsupc++/new_op.cc	26 Oct 2004 06:09:05 -0000	1.9
--- gcc/libstdc++-v3/libsupc++/new_op.cc	2 Nov 2004 04:21:40 -0000
*************** extern "C" void *malloc (std::size_t);
*** 43,49 ****
  
  extern new_handler __new_handler;
  
! __attribute__((weak)) void *
  operator new (std::size_t sz) throw (std::bad_alloc)
  {
    void *p;
--- 43,49 ----
  
  extern new_handler __new_handler;
  
! _GLIBCXX_WEAK_DEFINITION void *
  operator new (std::size_t sz) throw (std::bad_alloc)
  {
    void *p;
Index: gcc/libstdc++-v3/libsupc++/new_opnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_opnt.cc,v
retrieving revision 1.5
diff -c -3 -p -r1.5 new_opnt.cc
*** gcc/libstdc++-v3/libsupc++/new_opnt.cc	26 Oct 2004 06:09:05 -0000	1.5
--- gcc/libstdc++-v3/libsupc++/new_opnt.cc	2 Nov 2004 04:21:40 -0000
*************** using std::bad_alloc;
*** 36,42 ****
  extern "C" void *malloc (std::size_t);
  extern new_handler __new_handler;
  
! __attribute__((weak)) void *
  operator new (std::size_t sz, const std::nothrow_t&) throw()
  {
    void *p;
--- 36,42 ----
  extern "C" void *malloc (std::size_t);
  extern new_handler __new_handler;
  
! _GLIBCXX_WEAK_DEFINITION void *
  operator new (std::size_t sz, const std::nothrow_t&) throw()
  {
    void *p;
Index: gcc/libstdc++-v3/libsupc++/new_opv.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_opv.cc,v
retrieving revision 1.5
diff -c -3 -p -r1.5 new_opv.cc
*** gcc/libstdc++-v3/libsupc++/new_opv.cc	26 Oct 2004 06:09:05 -0000	1.5
--- gcc/libstdc++-v3/libsupc++/new_opv.cc	2 Nov 2004 04:21:40 -0000
***************
*** 30,36 ****
  
  #include "new"
  
! __attribute__((weak)) void *
  operator new[] (std::size_t sz) throw (std::bad_alloc)
  {
    return ::operator new(sz);
--- 30,36 ----
  
  #include "new"
  
! _GLIBCXX_WEAK_DEFINITION void *
  operator new[] (std::size_t sz) throw (std::bad_alloc)
  {
    return ::operator new(sz);
Index: gcc/libstdc++-v3/libsupc++/new_opvnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_opvnt.cc,v
retrieving revision 1.5
diff -c -3 -p -r1.5 new_opvnt.cc
*** gcc/libstdc++-v3/libsupc++/new_opvnt.cc	26 Oct 2004 06:09:05 -0000	1.5
--- gcc/libstdc++-v3/libsupc++/new_opvnt.cc	2 Nov 2004 04:21:40 -0000
***************
*** 30,36 ****
  
  #include "new"
  
! __attribute__((weak)) void *
  operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
  {
    return ::operator new(sz, nothrow);
--- 30,36 ----
  
  #include "new"
  
! _GLIBCXX_WEAK_DEFINITION void *
  operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
  {
    return ::operator new(sz, nothrow);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]