PATCH: Kill command-line use of -D__USE_MALLOC

Loren James Rittle rittle@latour.rsch.comm.mot.com
Tue May 14 00:05:00 GMT 2002


This patch was inspired by PR libstdc++/6641 (which I already closed
with commentary).  The SGI STL macro _NOTHREADS was completely removed
before the 3.1 release (in that case, because all related issues were
now being handled by standard gcc multilib mechanisms and/or gthr.h
weak symbol support).  The macro __USE_MALLOC is worse than _NOTHREADS
in that it can change the external ABI but it still has valid uses
according to some users.  I would like (at the very least) to yield a
proper error regarding the situation when the macro is defined
improperly by the user instead of generating linker errors.

We informed library users against changing our implementation via
per-command line macros in gcc 3.0 documentation.  Given how they were
used in the STL code (and/or how we changed it over time to require
non-header implementations), it could violate the one-definition rule
for inline functions and templates.

Regression check on i386-unknown-freebsd4.6.  OK for mainline?

	libstdc++/6641
	* include/bits/c++config (__USE_MALLOC): Report case where
	the user improperly defined it on the command line.

Index: include/bits/c++config
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/c++config,v
retrieving revision 1.357
diff -c -r1.357 c++config
*** include/bits/c++config	13 May 2002 07:16:56 -0000	1.357
--- include/bits/c++config	14 May 2002 03:46:08 -0000
***************
*** 69,75 ****
  // that threads are properly configured on your platform before
  // assigning blame to the STL container-memory allocator.  After doing
  // so, please report any possible issues to libstdc++@gcc.gnu.org .
! // Do not blindly #define __USE_MALLOC here or on the command line.
  
  // The remainder of the prewritten config is mostly automatic; all the
  // user hooks are listed above.
--- 69,83 ----
  // that threads are properly configured on your platform before
  // assigning blame to the STL container-memory allocator.  After doing
  // so, please report any possible issues to libstdc++@gcc.gnu.org .
! // Do not define __USE_MALLOC on the command line.  Enforce it here:
! #ifdef __USE_MALLOC
! #error __USE_MALLOC should only be defined within \
! libstdc++-v3/include/bits/c++config before full recompilation of the library.
! #endif
! // Define __USE_MALLOC after this point in the file in order to aid debugging
! // or globally change allocation policy.  This breaks the ABI, thus
! // completely recompile the library.  A patch to better support
! // changing the global allocator policy would be probably be accepted.
  
  // The remainder of the prewritten config is mostly automatic; all the
  // user hooks are listed above.



More information about the Libstdc++ mailing list