* Removed hack used by BeOS to trick stl allocator into using malloc/free for

all allocations, instead we now directly request the use of malloc/free in
  stl_config.h. This avoids warnings about 'arrays of size 0' when building
  any stl-code with -pedantic (like e.g. ICU does).
  Alternatively, we could active pthread-type threading support, but since in
  some small tests, I have not been able to see any advantage, I've just added
  a respective comment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31609 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2009-07-16 21:27:21 +00:00
parent 2d214dbbcb
commit da82d38f42
2 changed files with 13 additions and 9 deletions

View File

@ -30,7 +30,6 @@
# define __USE_MALLOC
#endif
// This implements some standard node allocators. These are
// NOT the same as the allocators in the C++ draft standard or in
// in the original STL. They do not encapsulate different pointer
@ -329,11 +328,7 @@ private:
// instead of enum { x = N }, but few compilers accept the former.
# ifndef __SUNPRO_CC
enum {_ALIGN = 8};
# if (defined(__BEOS__) || defined(__HAIKU__))
enum {_MAX_BYTES = 0};
# else
enum {_MAX_BYTES = 128};
# endif
enum {_NFREELISTS = _MAX_BYTES/_ALIGN};
# endif
static size_t
@ -710,11 +705,7 @@ template <bool __threads, int __inst>
__default_alloc_template<__threads, __inst>::_Obj* __VOLATILE
__default_alloc_template<__threads, __inst> ::_S_free_list[
_NFREELISTS
#if (defined(__BEOS__) || defined(__HAIKU__))
] = { };
#else
] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
#endif
// The 16 zeros are necessary to make version 4.1 of the SunPro
// compiler happy. Otherwise it appears to allocate too little
// space for the array.

View File

@ -87,6 +87,19 @@
// * _NOTHREADS: if defined, don't use any multithreading support.
# define __USE_MALLOC
// BeOS used to trick the STL allocator (in stl_alloc.h) into falling back
// to malloc/free-allocation by setting MAX_BYTES to 0.
// By requesting to use those directly, we should get the same allocator,
// but will avoid the '... creates array of size 0'-warnings that are
// produced by 'gcc -strict' (for instance when building ICU).
// Alternatively, we could define _PTHREADS here and use the real STL
// allocator with posix threads enabled (however, this would have to be
// tested first, and most probably requires a rebuild of gcc2, too,
// in order to make sure that no code existing in libstdc++.r4.so is
// still using the old allocator).
// Other macros defined by this file:
// * bool, true, and false, if __STL_NO_BOOL is defined.