From 528fb226174de5b392f5e16536d068974c1aca5f Mon Sep 17 00:00:00 2001 From: John Maddock Date: Fri, 30 Nov 2001 11:58:04 +0000 Subject: [PATCH] * Changed BOOST_RE_THREADS to BOOST_HAS_THREADS, * Updated allocator code to use SGI node based allocator when available. [SVN r11829] --- include/boost/detail/allocator.hpp | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/boost/detail/allocator.hpp b/include/boost/detail/allocator.hpp index 3c7e4af..5196a87 100644 --- a/include/boost/detail/allocator.hpp +++ b/include/boost/detail/allocator.hpp @@ -22,6 +22,22 @@ using ::size_t; } #endif +// see if we have SGI alloc class: +#if defined(BOOST_NO_STD_ALLOCATOR) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__GLIBCPP__) || defined(__STL_CONFIG_H)) +# define BOOST_HAVE_SGI_ALLOCATOR +# include +# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) +namespace boost{ namespace detail{ + typedef std::__sgi_alloc alloc_type; +}} +# else +namespace boost{ namespace detail{ + typedef std::alloc alloc_type; +}} +# endif +#endif + + namespace boost{ namespace detail{ template @@ -99,16 +115,28 @@ public: pointer allocate(size_type n, const void* = 0) { + #ifdef BOOST_HAVE_SGI_ALLOCATOR + return n != 0 ? + reinterpret_cast(alloc_type::allocate(n * sizeof(value_type))) + : 0; + #else return n != 0 ? reinterpret_cast(::operator new(n * sizeof(value_type))) : 0; + #endif } void deallocate(pointer p, size_type n) { + #ifdef BOOST_HAVE_SGI_ALLOCATOR + assert( (p == 0) == (n == 0) ); + if (p != 0) + alloc_type::deallocate((void*)p, n); + #else assert( (p == 0) == (n == 0) ); if (p != 0) ::operator delete((void*)p); + #endif } size_type max_size() const @@ -158,16 +186,28 @@ public: pointer allocate(size_type n, const void* = 0) { + #ifdef BOOST_HAVE_SGI_ALLOCATOR + return n != 0 ? + reinterpret_cast(alloc_type::allocate(n)) + : 0; + #else return n != 0 ? reinterpret_cast(::operator new(n)) : 0; + #endif } void deallocate(pointer p, size_type n) { + #ifdef BOOST_HAVE_SGI_ALLOCATOR + assert( (p == 0) == (n == 0) ); + if (p != 0) + alloc_type::deallocate((void*)p, n); + #else assert( (p == 0) == (n == 0) ); if (p != 0) ::operator delete((void*)p); + #endif } };