From da82d38f4205fc2e44187eeb78938048a8a3dcd2 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 16 Jul 2009 21:27:21 +0000 Subject: [PATCH] * 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 --- headers/cpp/stl_alloc.h | 9 --------- headers/cpp/stl_config.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/headers/cpp/stl_alloc.h b/headers/cpp/stl_alloc.h index b44f5f305a..206fd0fa2e 100644 --- a/headers/cpp/stl_alloc.h +++ b/headers/cpp/stl_alloc.h @@ -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 __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. diff --git a/headers/cpp/stl_config.h b/headers/cpp/stl_config.h index 2e29bca27f..5c619adf1a 100644 --- a/headers/cpp/stl_config.h +++ b/headers/cpp/stl_config.h @@ -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.