Commit ba9d552e by Benjamin Kosnik Committed by Benjamin Kosnik

Makefile.am (bits_headers): Remove allocator_traits.h.


2004-01-28  Benjamin Kosnik  <bkoz@redhat.com>

	* include/Makefile.am (bits_headers): Remove allocator_traits.h.
	* include/Makefile.in: Regenerate.
	* include/bits/allocator_traits.h: Remove.
	* include/bits/allocator.h: Remove allocator_traits.h include, and
	relevant comments.
	(allocator): Empty base class, inherit from the underlying allocator.
	* src/allocator-inst.cc: Move __pool_alloc instantiation to...
	* src/allocator.cc: ...here. New. For the underlying allocators.
	Add __mt_alloc, __pool_alloc, new_allocator, malloc_allocator bits.
	* config/linker-map.gnu: Remove __pool_alloc bits.
	* src/Makefile.am (sources): Add allocator.cc.
	* src/Makefile.in: Regenerate.
	* testsuite/20_util/allocator/1.cc: Split second test into...
	* testsuite/20_util/allocator/8230.cc: ...this.
	* include/bits/stl_bvector.h (__gnu_norm): Change bit_vector
	typedef to use std::allocatore. Format.
	* include/ext/pool_allocator.h: Remove allocator_traits.h include,
	_Alloc_traits.
	* include/ext/mt_allocator.h (__gnu_cxx): Qualify
	__throw_bad_alloc calls. Don't include <memory>.
	* include/ext/malloc_allocator.h: Remove <memory> include.
	* include/ext/new_allocator.h (new_allocator): Same.
	* include/ext/ropeimpl.h (__gnu_cxx): Remove __alloc using
	declaration. Switch __alloc to _Alloc.
	* include/ext/hashtable.h: Remove __alloc.
	* include/backward/alloc.h: Only inject allocator, not
	implementation details.

	* include/ext/mt_allocator.h: Replace free with delete.

From-SVN: r76821
parent 63d47f2a
2004-01-28 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (bits_headers): Remove allocator_traits.h.
* include/Makefile.in: Regenerate.
* include/bits/allocator_traits.h: Remove.
* include/bits/allocator.h: Remove allocator_traits.h include, and
relevant comments.
(allocator): Empty base class, inherit from the underlying allocator.
* src/allocator-inst.cc: Move __pool_alloc instantiation to...
* src/allocator.cc: ...here. New. For the underlying allocators.
Add __mt_alloc, __pool_alloc, new_allocator, malloc_allocator bits.
* config/linker-map.gnu: Remove __pool_alloc bits.
* src/Makefile.am (sources): Add allocator.cc.
* src/Makefile.in: Regenerate.
* testsuite/20_util/allocator/1.cc: Split second test into...
* testsuite/20_util/allocator/8230.cc: ...this.
* include/bits/stl_bvector.h (__gnu_norm): Change bit_vector
typedef to use std::allocatore. Format.
* include/ext/pool_allocator.h: Remove allocator_traits.h include,
_Alloc_traits.
* include/ext/mt_allocator.h (__gnu_cxx): Qualify
__throw_bad_alloc calls. Don't include <memory>.
* include/ext/malloc_allocator.h: Remove <memory> include.
* include/ext/new_allocator.h (new_allocator): Same.
* include/ext/ropeimpl.h (__gnu_cxx): Remove __alloc using
declaration. Switch __alloc to _Alloc.
* include/ext/hashtable.h: Remove __alloc.
* include/backward/alloc.h: Only inject allocator, not
implementation details.
* include/ext/mt_allocator.h: Replace free with delete.
2004-01-28 Benjamin Kosnik <bkoz@redhat.com>
* src/globals_io.cc: Change to __gnu_internal namespace.
* src/globals_locale.cc: Same.
* src/locale_init.cc: Same.
......
## Linker script for GNU ld 2.13.91+ only.
##
## Copyright (C) 2002, 2003 Free Software Foundation, Inc.
## Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
##
......@@ -207,10 +207,6 @@ GLIBCXX_3.4 {
__signbitf;
__signbitl;
# __gnu_cxx::__pool_alloc
_ZN9__gnu_cxx12__pool_allocILb1ELi0EE8allocateE[jm];
_ZN9__gnu_cxx12__pool_allocILb1ELi0EE10deallocateEPv[jm];
# __gnu_cxx::stdio_sync_filebuf
_ZTVN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEE;
......
## Makefile for the include subdirectory of the GNU C++ Standard library.
##
## Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
## Process this file with automake to produce Makefile.in.
......@@ -92,7 +92,6 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
${bits_srcdir}/allocator.h \
${bits_srcdir}/allocator_traits.h \
${bits_srcdir}/basic_ios.h \
${bits_srcdir}/basic_ios.tcc \
${bits_srcdir}/basic_string.h \
......
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.8 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
......@@ -287,7 +287,6 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
${bits_srcdir}/allocator.h \
${bits_srcdir}/allocator_traits.h \
${bits_srcdir}/basic_ios.h \
${bits_srcdir}/basic_ios.tcc \
${bits_srcdir}/basic_string.h \
......@@ -519,15 +518,15 @@ debug_headers = \
${debug_srcdir}/string \
${debug_srcdir}/vector
@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra =
# Some of the different "C" header models need extra files.
# Some "C" header schemes require the "C" compatibility headers.
# For --enable-cheaders=c_std
@GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc
@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra =
@GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers}
@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR)
host_builddir = ./${host_alias}/bits
......@@ -566,10 +565,10 @@ pch_input = ${host_builddir}/stdc++.h
pch_output_builddir = ${host_builddir}/stdc++.h.gch
pch_source = ${glibcxx_srcdir}/include/stdc++.h
PCHFLAGS = -Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS)
@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_input}
@GLIBCXX_BUILD_PCH_FALSE@pch_build =
@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch
@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_input}
@GLIBCXX_BUILD_PCH_FALSE@pch_install =
@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch
# List of all timestamp files. By keeping only one copy of this list, both
# CLEANFILES and all-local are kept up-to-date.
......@@ -673,7 +672,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
......
// Backward-compat support -*- C++ -*-
// Copyright (C) 2001, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -47,9 +47,6 @@
#include <bits/c++config.h>
#include <bits/allocator.h>
using __gnu_cxx::__pool_alloc;
using std::__alloc;
using std::__simple_alloc;
using std::allocator;
#endif
// Backward-compat support -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -59,7 +59,7 @@
#include "backward_warning.h"
#include <vector>
using std::bit_vector;
typedef std::vector<bool, allocator<bool> > bit_vector;
#endif /* _BACKWARD_BVECTOR_H */
......
// Allocators -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -45,82 +45,48 @@
* You should not attempt to use it directly.
*/
/**
* @defgroup Allocators Memory Allocators
* @if maint
* allocator.h implements some node allocators. These are NOT the same as
* allocators in the C++ standard, nor in the original H-P STL. They do not
* encapsulate different pointer types; we assume that there is only one
* pointer type. The C++ standard allocators are intended to allocate
* individual objects, not pools or arenas.
*
* In this file allocators are of two different styles: "standard" and
* "SGI" (quotes included). "Standard" allocators conform to 20.4. "SGI"
* allocators differ in AT LEAST the following ways (add to this list as you
* discover them):
*
* - "Standard" allocate() takes two parameters (n_count,hint=0) but "SGI"
* allocate() takes one paramter (n_size).
* - Likewise, "standard" deallocate()'s argument is a count, but in "SGI"
* is a byte size.
* - max_size(), construct(), and destroy() are missing in "SGI" allocators.
* - reallocate(p,oldsz,newsz) is added in "SGI", and behaves as
* if p=realloc(p,newsz).
*
* "SGI" allocators may be wrapped in __allocator to convert the interface
* into a "standard" one.
* @endif
*
* The canonical description of these classes is in docs/html/ext/howto.html
* or online at http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html#3
*/
#ifndef _ALLOCATOR_H
#define _ALLOCATOR_H 1
#include <bits/functexcept.h> // For __throw_bad_alloc
#include <bits/allocator_traits.h>
#if 1
# include <ext/mt_allocator.h>
# define __glibcxx_default_allocator __gnu_cxx::__mt_alloc
#endif
// Pick a default underlying allocator.
#include <ext/pool_allocator.h>
#if 0
# include <ext/pool_allocator.h>
# define __glibcxx_default_allocator __gnu_cxx::__pool_alloc
#endif
namespace std
{
typedef __gnu_cxx::__pool_alloc<true, 0> __alloc;
template<typename _Tp>
class allocator;
/// The version for the default allocator.
template<typename _Tp, typename _Tp1>
struct _Alloc_traits<_Tp, allocator<_Tp1> >
template<>
class allocator<void>
{
static const bool _S_instanceless = true;
typedef __simple_alloc<_Tp, __alloc> _Alloc_type;
typedef allocator<_Tp> allocator_type;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template<typename _Tp1>
struct rebind
{ typedef allocator<_Tp1> other; };
};
//@}
}
namespace std
{
/**
* @brief The "standard" allocator, as per [20.4].
*
* The private _Alloc is "SGI" style. (See comments at the top
* of allocator.h.)
*
* The underlying allocator behaves as follows.
* - __pool_alloc is used via two typedefs
* - "__alloc" typedef is threadsafe via the locks
* - __new_alloc is used for memory requests
*
* (See @link Allocators allocators info @endlink for more.)
*/
template<typename _Tp>
class allocator
class allocator: public __glibcxx_default_allocator<_Tp>
{
// The underlying allocator.
typedef __alloc _Alloc;
public:
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
......@@ -135,68 +101,17 @@ namespace std
allocator() throw() { }
allocator(const allocator&) throw() { }
allocator(const allocator& a) throw()
: __glibcxx_default_allocator<_Tp>(a) { }
template<typename _Tp1>
allocator(const allocator<_Tp1>&) throw() { }
~allocator() throw() { }
pointer
address(reference __x) const { return &__x; }
const_pointer
address(const_reference __x) const { return &__x; }
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.
_Tp*
allocate(size_type __n, const void* = 0)
{
_Tp* __ret = 0;
if (__n)
{
if (__n <= this->max_size())
__ret = static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp)));
else
__throw_bad_alloc();
}
return __ret;
}
// __p is not permitted to be a null pointer.
void
deallocate(pointer __p, size_type __n)
{ _Alloc::deallocate(__p, __n * sizeof(_Tp)); }
size_type
max_size() const throw() { return size_t(-1) / sizeof(_Tp); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_]allocator::construct
void
construct(pointer __p, const _Tp& __val) { ::new(__p) _Tp(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }
// Inherit everything else.
};
template<>
class allocator<void>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template<typename _Tp1>
struct rebind
{ typedef allocator<_Tp1> other; };
};
template<typename _T1, typename _T2>
inline bool
operator==(const allocator<_T1>&, const allocator<_T2>&)
......@@ -214,6 +129,9 @@ namespace std
extern template class allocator<char>;
extern template class allocator<wchar_t>;
#endif
// Undefine.
#undef __glibcxx_default_allocator
} // namespace std
#endif
// Allocators -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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.
// This library 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.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/*
* Copyright (c) 1996-1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
#ifndef _ALLOCATOR_TRAITS_H
#define _ALLOCATOR_TRAITS_H 1
#include <cstddef>
namespace std
{
/**
* @if maint
* This is used primarily (only?) in _Alloc_traits and other places to
* help provide the _Alloc_type typedef. All it does is forward the
* requests after some minimal checking.
*
* This is neither "standard"-conforming nor "SGI". The _Alloc parameter
* must be "SGI" style.
* @endif
* (See @link Allocators allocators info @endlink for more.)
*/
template<typename _Tp, typename _Alloc>
class __simple_alloc
{
public:
static _Tp*
allocate(size_t __n)
{
_Tp* __ret = 0;
if (__n)
__ret = static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp)));
return __ret;
}
static _Tp*
allocate()
{ return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }
static void
deallocate(_Tp* __p, size_t __n)
{ if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }
static void
deallocate(_Tp* __p)
{ _Alloc::deallocate(__p, sizeof (_Tp)); }
};
/**
* @if maint
* Allocator adaptor to turn an "SGI" style allocator (e.g.,
* __alloc, __malloc_alloc) into a "standard" conforming
* allocator. Note that this adaptor does *not* assume that all
* objects of the underlying alloc class are identical, nor does it
* assume that all of the underlying alloc's member functions are
* static member functions. Note, also, that __allocator<_Tp,
* __alloc> is essentially the same thing as allocator<_Tp>.
* @endif
* (See @link Allocators allocators info @endlink for more.)
*/
template<typename _Tp, typename _Alloc>
struct __allocator
{
_Alloc __underlying_alloc;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
template<typename _Tp1>
struct rebind
{ typedef __allocator<_Tp1, _Alloc> other; };
__allocator() throw() { }
__allocator(const __allocator& __a) throw()
: __underlying_alloc(__a.__underlying_alloc) { }
template<typename _Tp1>
__allocator(const __allocator<_Tp1, _Alloc>& __a) throw()
: __underlying_alloc(__a.__underlying_alloc) { }
~__allocator() throw() { }
pointer
address(reference __x) const { return &__x; }
const_pointer
address(const_reference __x) const { return &__x; }
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.
_Tp*
allocate(size_type __n, const void* = 0)
{
_Tp* __ret = 0;
if (__n)
__ret = static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp)));
return __ret;
}
// __p is not permitted to be a null pointer.
void
deallocate(pointer __p, size_type __n)
{ __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }
size_type
max_size() const throw() { return size_t(-1) / sizeof(_Tp); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_]allocator::construct
void
construct(pointer __p, const _Tp& __val) { ::new(__p) _Tp(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }
};
template<typename _Alloc>
struct __allocator<void, _Alloc>
{
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template<typename _Tp1>
struct rebind
{ typedef __allocator<_Tp1, _Alloc> other; };
};
template<typename _Tp, typename _Alloc>
inline bool
operator==(const __allocator<_Tp,_Alloc>& __a1,
const __allocator<_Tp,_Alloc>& __a2)
{ return __a1.__underlying_alloc == __a2.__underlying_alloc; }
template<typename _Tp, typename _Alloc>
inline bool
operator!=(const __allocator<_Tp, _Alloc>& __a1,
const __allocator<_Tp, _Alloc>& __a2)
{ return __a1.__underlying_alloc != __a2.__underlying_alloc; }
/**
* @if maint
* Another allocator adaptor: _Alloc_traits. This serves two purposes.
* First, make it possible to write containers that can use either "SGI"
* style allocators or "standard" allocators. Second, provide a mechanism
* so that containers can query whether or not the allocator has distinct
* instances. If not, the container can avoid wasting a word of memory to
* store an empty object. For examples of use, see stl_vector.h, etc, or
* any of the other classes derived from this one.
*
* This adaptor uses partial specialization. The general case of
* _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a
* standard-conforming allocator, possibly with non-equal instances and
* non-static members. (It still behaves correctly even if _Alloc has
* static member and if all instances are equal. Refinements affect
* performance, not correctness.)
*
* There are always two members: allocator_type, which is a standard-
* conforming allocator type for allocating objects of type _Tp, and
* _S_instanceless, a static const member of type bool. If
* _S_instanceless is true, this means that there is no difference
* between any two instances of type allocator_type. Furthermore, if
* _S_instanceless is true, then _Alloc_traits has one additional
* member: _Alloc_type. This type encapsulates allocation and
* deallocation of objects of type _Tp through a static interface; it
* has two member functions, whose signatures are
*
* - static _Tp* allocate(size_t)
* - static void deallocate(_Tp*, size_t)
*
* The size_t parameters are "standard" style (see top of
* allocator.h) in that they take counts, not sizes.
*
* @endif
* (See @link Allocators allocators info @endlink for more.)
*/
// The fully general version.
template<typename _Tp, typename _Allocator>
struct _Alloc_traits
{
static const bool _S_instanceless = false;
typedef typename _Allocator::template rebind<_Tp>::other allocator_type;
};
template<typename _Tp, typename _Allocator>
const bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless;
} // namespace std
#endif
......@@ -94,7 +94,7 @@ namespace __gnu_norm
}
~_Vector_base()
{ _M_deallocate(this->_M_start,
{ _M_deallocate(this->_M_start,
this->_M_end_of_storage - this->_M_start); }
public:
......
// Hashtable implementation used by containers -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -91,8 +91,8 @@ struct _Hashtable_node
_Val _M_val;
};
template <class _Val, class _Key, class _HashFcn,
class _ExtractKey, class _EqualKey, class _Alloc = std::__alloc>
template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
class _EqualKey, class _Alloc = std::allocator<_Val> >
class hashtable;
template <class _Val, class _Key, class _HashFcn,
......
// Allocator that wraps "C" malloc -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -31,7 +31,6 @@
#define _MALLOC_ALLOCATOR_H 1
#include <new>
#include <memory>
namespace __gnu_cxx
{
......@@ -78,7 +77,7 @@ namespace __gnu_cxx
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.
pointer
allocate(size_type __n, std::allocator<void>::const_pointer __h = 0)
allocate(size_type __n, const void* __h = 0)
{ return static_cast<_Tp*>(malloc(__n * sizeof(_Tp))); }
// __p is not permitted to be a null pointer.
......
......@@ -36,8 +36,6 @@
#define _MT_ALLOCATOR_H 1
#include <new>
#include <memory>
#include <cstdlib>
#include <bits/functexcept.h>
#include <bits/gthr.h>
#include <bits/atomicity.h>
......@@ -230,7 +228,7 @@ namespace __gnu_cxx
public:
pointer
allocate(size_t __n, std::allocator<void>::const_pointer __h = 0)
allocate(size_t __n, const void* __h = 0)
{
/*
* Although the test in __gthread_once() would suffice, we
......@@ -260,7 +258,7 @@ namespace __gnu_cxx
{
void* __ret = ::operator new(__n * sizeof(_Tp));
if (!__ret)
__throw_bad_alloc();
std::__throw_bad_alloc();
return static_cast<_Tp*>(__ret);
}
......@@ -314,10 +312,10 @@ namespace __gnu_cxx
__gthread_mutex_unlock(_S_bin[bin].mutex);
_S_bin[bin].first[thread_id] =
static_cast<block_record*>(::operator new(_S_chunk_size));
static_cast<block_record*>(::operator new(_S_chunk_size));
if (!_S_bin[bin].first[thread_id])
__throw_bad_alloc();
std::__throw_bad_alloc();
_S_bin[bin].free[thread_id] = block_count;
......@@ -385,7 +383,7 @@ namespace __gnu_cxx
static_cast<block_record*>(::operator new(_S_chunk_size));
if (!_S_bin[bin].first[0])
__throw_bad_alloc();
std::__throw_bad_alloc();
size_t bin_t = 1 << bin;
size_t block_count =
......@@ -441,11 +439,11 @@ namespace __gnu_cxx
{
/*
* Requests larger than _S_max_bytes are handled by
* malloc/free directly
* operators new/delete directly
*/
if (__n * sizeof(_Tp) > _S_max_bytes || _S_force_new)
{
free(__p);
::operator delete(__p);
return;
}
......@@ -584,10 +582,10 @@ namespace __gnu_cxx
* Setup the bin map for quick lookup of the relevant bin
*/
_S_binmap = (binmap_type*)
malloc ((_S_max_bytes + 1) * sizeof(binmap_type));
::operator new ((_S_max_bytes + 1) * sizeof(binmap_type));
if (!_S_binmap)
__throw_bad_alloc();
std::__throw_bad_alloc();
binmap_type* bp_t = _S_binmap;
binmap_type bin_max_t = 1;
......@@ -615,7 +613,7 @@ namespace __gnu_cxx
new(sizeof(thread_record) * _S_max_threads));
if (!_S_thread_freelist_first)
__throw_bad_alloc();
std::__throw_bad_alloc();
/*
* NOTE! The first assignable thread id is 1 since the global
......@@ -651,7 +649,7 @@ namespace __gnu_cxx
new(sizeof(bin_record) * _S_no_of_bins));
if (!_S_bin)
__throw_bad_alloc();
std::__throw_bad_alloc();
std::size_t __n = 1;
......@@ -666,13 +664,13 @@ namespace __gnu_cxx
new(sizeof(block_record*) * __n));
if (!_S_bin[bin].first)
__throw_bad_alloc();
std::__throw_bad_alloc();
_S_bin[bin].last = static_cast<block_record**>(::operator
new(sizeof(block_record*) * __n));
if (!_S_bin[bin].last)
__throw_bad_alloc();
std::__throw_bad_alloc();
#ifdef __GTHREADS
if (__gthread_active_p())
......@@ -681,13 +679,13 @@ namespace __gnu_cxx
new(sizeof(size_t) * __n));
if (!_S_bin[bin].free)
__throw_bad_alloc();
std::__throw_bad_alloc();
_S_bin[bin].used = static_cast<size_t*>(::operator
new(sizeof(size_t) * __n));
if (!_S_bin[bin].used)
__throw_bad_alloc();
std::__throw_bad_alloc();
_S_bin[bin].mutex = static_cast<__gthread_mutex_t*>(::operator
new(sizeof(__gthread_mutex_t)));
......@@ -781,8 +779,8 @@ namespace __gnu_cxx
__mt_alloc<_Tp>::_S_once_mt = __GTHREAD_ONCE_INIT;
#endif
template<typename _Tp> bool
volatile __mt_alloc<_Tp>::_S_initialized = false;
template<typename _Tp>
bool volatile __mt_alloc<_Tp>::_S_initialized = false;
template<typename _Tp> bool
__mt_alloc<_Tp>::_S_force_new = false;
......@@ -792,7 +790,7 @@ namespace __gnu_cxx
/*
* Allocation requests (after round-up to power of 2) below this
* value will be handled by the allocator. A raw malloc/free() call
* value will be handled by the allocator. A raw new/ call
* will be used for requests larger than this value.
*/
template<typename _Tp> size_t
......@@ -853,14 +851,12 @@ namespace __gnu_cxx
template<typename _Tp>
inline bool
operator==(const __mt_alloc<_Tp>&,
const __mt_alloc<_Tp>&)
operator==(const __mt_alloc<_Tp>&, const __mt_alloc<_Tp>&)
{ return true; }
template<typename _Tp>
inline bool
operator!=(const __mt_alloc<_Tp>&,
const __mt_alloc<_Tp>&)
operator!=(const __mt_alloc<_Tp>&, const __mt_alloc<_Tp>&)
{ return false; }
} // namespace __gnu_cxx
......
// Allocator that wraps operator new -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -77,7 +77,7 @@ namespace __gnu_cxx
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.
pointer
allocate(size_type __n, allocator<void>::const_pointer __h = 0)
allocate(size_type __n, const void* __h = 0)
{ return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); }
// __p is not permitted to be a null pointer.
......
// Allocators -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -51,7 +51,6 @@
#include <bits/functexcept.h>
#include <bits/stl_threads.h>
#include <bits/atomicity.h>
#include <bits/allocator_traits.h>
namespace __gnu_cxx
{
......@@ -360,33 +359,4 @@ namespace __gnu_cxx
#endif
} // namespace __gnu_cxx
namespace std
{
//@{
/// Versions for the predefined "SGI" style allocators.
template<typename _Tp, bool __thr, int __inst>
struct _Alloc_traits<_Tp, __gnu_cxx::__pool_alloc<__thr, __inst> >
{
static const bool _S_instanceless = true;
typedef __gnu_cxx::__pool_alloc<__thr, __inst> base_alloc_type;
typedef __simple_alloc<_Tp, base_alloc_type> _Alloc_type;
typedef __allocator<_Tp, base_alloc_type> allocator_type;
};
//@}
//@{
/// Versions for the __allocator adaptor used with the predefined
/// "SGI" style allocators.
template<typename _Tp, typename _Tp1, bool __thr, int __inst>
struct _Alloc_traits<_Tp, __allocator<_Tp1,
__gnu_cxx::__pool_alloc<__thr, __inst> > >
{
static const bool _S_instanceless = true;
typedef __gnu_cxx::__pool_alloc<__thr, __inst> base_alloc_type;
typedef __simple_alloc<_Tp, base_alloc_type> _Alloc_type;
typedef __allocator<_Tp, base_alloc_type> allocator_type;
};
//@}
} // namespace std
#endif
// SGI's rope class implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -59,7 +59,6 @@ namespace __gnu_cxx
using std::printf;
using std::basic_ostream;
using std::__throw_length_error;
using std::__alloc;
using std::_Destroy;
using std::uninitialized_fill_n;
......@@ -875,15 +874,15 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces(
size_t __len = __end - __begin;
bool __result;
_CharT* __buffer =
(_CharT*)__alloc::allocate(__len * sizeof(_CharT));
(_CharT*)_Alloc::allocate(__len * sizeof(_CharT));
try {
(*(__f->_M_fn))(__begin, __len, __buffer);
__result = __c(__buffer, __len);
__alloc::deallocate(__buffer, __len * sizeof(_CharT));
_Alloc::deallocate(__buffer, __len * sizeof(_CharT));
}
catch(...)
{
__alloc::deallocate(__buffer, __len * sizeof(_CharT));
_Alloc::deallocate(__buffer, __len * sizeof(_CharT));
__throw_exception_again;
}
return __result;
......
......@@ -91,6 +91,7 @@ basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
# Sources present in the src directory.
sources = \
allocator.cc \
codecvt.cc \
complex_io.cc \
ctype.cc \
......
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# Makefile.in generated by automake 1.7.8 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
......@@ -247,6 +247,7 @@ host_sources_extra = \
# Sources present in the src directory.
sources = \
allocator.cc \
codecvt.cc \
complex_io.cc \
ctype.cc \
......@@ -360,10 +361,10 @@ am__objects_1 = codecvt_members.lo collate_members.lo ctype_members.lo \
messages_members.lo monetary_members.lo numeric_members.lo \
time_members.lo
am__objects_2 = basic_file.lo c++locale.lo
am__objects_3 = codecvt.lo complex_io.lo ctype.lo debug.lo demangle.lo \
functexcept.lo globals_locale.lo globals_io.lo ios.lo \
ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \
locale.lo locale_init.lo locale_facets.lo localename.lo \
am__objects_3 = allocator.lo codecvt.lo complex_io.lo ctype.lo debug.lo \
demangle.lo functexcept.lo globals_locale.lo globals_io.lo \
ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo \
list.lo locale.lo locale_init.lo locale_facets.lo localename.lo \
stdexcept.lo strstream.lo tree.lo allocator-inst.lo \
concept-inst.lo fstream-inst.lo ext-inst.lo io-inst.lo \
istream-inst.lo locale-inst.lo locale-misc-inst.lo misc-inst.lo \
......@@ -552,7 +553,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
......
// Explicit instantiation file.
// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
// Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -39,8 +39,3 @@ namespace std
template class allocator<char>;
template class allocator<wchar_t>;
} // namespace std
namespace __gnu_cxx
{
template class __pool_alloc<true, 0>;
} // namespace __gnu_cxx
// Allocator details.
// Copyright (C) 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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.
// This library 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.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// ISO C++ 14882:
//
#include <bits/c++config.h>
#include <memory>
#include <ext/mt_allocator.h>
#include <ext/pool_allocator.h>
// Explicitly instantiate the static data members of the underlying
// allocator.
namespace __gnu_cxx
{
// Static data members and member functions of __mt_alloc.
static template class __mt_alloc<char>;
template
void __mt_alloc<char>::_S_init();
template
size_t __mt_alloc<char>::_S_get_thread_id();
template
void __mt_alloc<char>::_S_thread_key_destr(void*);
// Static members of __pool_alloc.
template class __pool_alloc<true, 0>;
} // namespace __gnu_cxx
// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
......@@ -58,32 +58,8 @@ void test01()
VERIFY( check_delete );
}
// libstdc++/8230
void test02()
{
bool test __attribute__((unused)) = true;
try
{
std::allocator<int> alloc;
const std::allocator<int>::size_type n = alloc.max_size();
int* p = alloc.allocate(n + 1);
p[n] = 2002;
}
catch(const std::bad_alloc& e)
{
// Allowed.
test = true;
}
catch(...)
{
test = false;
}
VERIFY( test );
}
int main()
{
test01();
test02();
return 0;
}
// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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.
// This library 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.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 20.4.1.1 allocator members
#include <memory>
#include <stdexcept>
#include <testsuite_hooks.h>
// libstdc++/8230
void test02()
{
bool test __attribute__((unused)) = true;
try
{
std::allocator<int> alloc;
const std::allocator<int>::size_type n = alloc.max_size();
int* p = alloc.allocate(n + 1);
p[n] = 2002;
}
catch(const std::bad_alloc& e)
{
// Allowed.
test = true;
}
catch(...)
{
test = false;
}
VERIFY( test );
}
int main()
{
test02();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment