/* Copyright (c) 1997-2010
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
   http://www.polymake.de

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version: http://www.gnu.org/licenses/gpl.txt.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
--------------------------------------------------------------------------------
   $Project: polymake $$Id: pool_allocator.h 9991 2010-12-12 23:36:28Z gawrilow $
*/

#ifndef POLYMAKE_INTERNAL_POOL_ALLOCATOR_H
#define POLYMAKE_INTERNAL_POOL_ALLOCATOR_H

// This file is a wrapper for gcc >= 3.4

#include <ext/pool_allocator.h>

namespace std {
template <typename T> class allocator;
}

namespace pm {
#if __GNUC__==3 && __GNUC_PATCHLEVEL__ == 0     // 3.4.0
template <typename T>
class base_raw_allocator : public __gnu_cxx::__pool_alloc<true,0> {
public:
   static
   T* allocate(size_t n)
   {
      return __builtin_expect(n==0,0) ? 0 : reinterpret_cast<T*>(__gnu_cxx::__pool_alloc<true,0>::allocate(n*sizeof(T)));
   }
};
#  define ___glibcxx_base_allocator pm::base_raw_allocator
#elif __GNUC__==3 || __GNUC__==4 && __GNUC_MINOR__==0   // 3.4.1 .. 4.0.2
#  define ___glibcxx_base_allocator __gnu_cxx::__pool_alloc
#else
#  define __glibcxx_base_allocator __gnu_cxx::__pool_alloc
#endif

typedef std::allocator<char[1]> allocator;
}

#endif // POLYMAKE_INTERNAL_POOL_ALLOCATOR_H

// Local Variables:
// mode:C++
// c-basic-offset:3
// indent-tabs-mode:nil
// End:
