summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/Makefile.am5
-rw-r--r--libstdc++-v3/include/Makefile.in5
-rw-r--r--libstdc++-v3/include/bits/basic_file.h264
-rw-r--r--libstdc++-v3/include/bits/basic_string.h1
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc8
-rw-r--r--libstdc++-v3/include/bits/localefwd.h2
-rw-r--r--libstdc++-v3/include/bits/stl_algo.h4
-rw-r--r--libstdc++-v3/include/bits/stl_alloc.h455
-rw-r--r--libstdc++-v3/include/bits/stl_bvector.h5
-rw-r--r--libstdc++-v3/include/bits/stl_tree.h9
10 files changed, 248 insertions, 510 deletions
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index f3fef8db6eb..32a0c049f29 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -34,7 +34,6 @@ glibcpp_builddir=@glibcpp_builddir@
bits_srcdir = ${glibcpp_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
- ${bits_srcdir}/basic_file.h \
${bits_srcdir}/basic_ios.h \
${bits_srcdir}/basic_ios.tcc \
${bits_srcdir}/basic_string.h \
@@ -278,7 +277,7 @@ target_headers = \
${glibcpp_srcdir}/@CPU_LIMITS_INC_SRCDIR@/cpu_limits.h
# These extra_target_headers files are all built with ad hoc naming rules.
extra_target_headers = \
- ${target_builddir}/basic_file_model.h \
+ ${target_builddir}/basic_file.h \
${target_builddir}/c++config.h \
${target_builddir}/c++io.h \
${target_builddir}/c++locale.h \
@@ -360,7 +359,7 @@ stamp-target: ${target_headers} ${target_builddir}
@cd ${target_builddir} ;\
if [ ! -f stamp-target ]; then \
@LN_S@ ${target_headers} . || true ;\
- @LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file_model.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 367ee986f47..858a7d9c299 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -159,7 +159,6 @@ glibcpp_builddir = @glibcpp_builddir@
bits_srcdir = ${glibcpp_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
- ${bits_srcdir}/basic_file.h \
${bits_srcdir}/basic_ios.h \
${bits_srcdir}/basic_ios.tcc \
${bits_srcdir}/basic_string.h \
@@ -412,7 +411,7 @@ target_headers = \
# These extra_target_headers files are all built with ad hoc naming rules.
extra_target_headers = \
- ${target_builddir}/basic_file_model.h \
+ ${target_builddir}/basic_file.h \
${target_builddir}/c++config.h \
${target_builddir}/c++io.h \
${target_builddir}/c++locale.h \
@@ -611,7 +610,7 @@ stamp-target: ${target_headers} ${target_builddir}
@cd ${target_builddir} ;\
if [ ! -f stamp-target ]; then \
@LN_S@ ${target_headers} . || true ;\
- @LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file_model.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\
diff --git a/libstdc++-v3/include/bits/basic_file.h b/libstdc++-v3/include/bits/basic_file.h
deleted file mode 100644
index 51dde5bc4c3..00000000000
--- a/libstdc++-v3/include/bits/basic_file.h
+++ /dev/null
@@ -1,264 +0,0 @@
-// Wrapper of C-language FILE struct -*- C++ -*-
-
-// Copyright (C) 1999, 2000, 2001 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: 27.8 File-based streams
-//
-
-/** @file basic_file.h
- * This is an internal header file, included by other library headers.
- * You should not attempt to use it directly.
- */
-
-#ifndef _CPP_BASIC_FILE
-#define _CPP_BASIC_FILE 1
-
-#pragma GCC system_header
-
-#include <bits/c++config.h>
-#include <ios>
-
-namespace std
-{
- // Ulrich is going to make some detailed comment here, explaining
- // all this unpleasantness, providing detailed performance analysis
- // as to why we have to do all this lame vtable hacking instead of a
- // sane, function-based approach. This verbiage will provide a clear
- // and detailed description of the whole object-layout,
- // vtable-swapping, sordid history of this hack.
- template<typename _CharT>
- struct __basic_file_base: public __c_file_type
- {
- virtual
- ~__basic_file_base() { };
-
- virtual int
- overflow(int __c = EOF) = 0;
-
- virtual int
- underflow() = 0;
-
- virtual int
- uflow() = 0;
-
- virtual int
- pbackfail(int __c) = 0;
-
- virtual streamsize
- xsputn(const _CharT* __s, streamsize __n) = 0;
-
- virtual streamsize
- xsgetn(_CharT* __s, streamsize __n) = 0;
-
- virtual streamoff
- seekoff(streamoff __off, ios_base::seekdir __way,
- ios_base::openmode __mode = ios_base::in | ios_base::out) = 0;
-
- virtual streamoff
- seekpos(streamoff __pos,
- ios_base::openmode __mode = ios_base::in | ios_base::out) = 0;
-
- virtual streambuf*
- setbuf(_CharT* __b, int __len) = 0;
-
- virtual int
- sync() = 0;
-
- virtual int
- doallocate() = 0;
-
- virtual streamsize
- sys_read(_CharT* __s, streamsize __n) = 0;
-
- virtual streamsize
- sys_write(const _CharT* __s, streamsize __n) = 0;
-
- virtual streamoff
- sys_seek(streamoff __off, ios_base::seekdir __way) = 0;
-
- virtual int
- sys_close() = 0;
-
- virtual int
- sys_stat(void* __v) = 0;
-
- virtual int
- showmanyc() = 0;
-
- virtual void
- imbue(void* __v) = 0;
- };
-
- // Some of these member functions are based on libio/filebuf.cc.
- // Also note that the order and number of virtual functions has to precisely
- // match the order and number in the _IO_jump_t struct defined in libioP.h.
- template<typename _CharT>
-#ifdef _GLIBCPP_BASIC_FILE_INHERITANCE
- class __basic_file: public __basic_file_base<_CharT>
-#else
- class __basic_file
-#endif
- {
-#if _GLIBCPP_BASIC_FILE_ENCAPSULATION
- // underlying data source/sink
- __c_file_type* _M_cfile;
- // true iff we opened _M_cfile, and thus must close it ourselves
- bool _M_cfile_created;
-#else
-# ifdef _GLIBCPP_USE_WCHAR_T
- __c_wfile_type _M_wfile;
-# endif
-#endif
-
- public:
- __basic_file(__c_lock* __lock = 0);
-
- void
- _M_open_mode(ios_base::openmode __mode, int& __p_mode, int& __rw_mode,
- char* __c_mode);
-
- // Equivalent to the normal fopen function.
- __basic_file*
- open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
-
- // Used for opening the standard streams, cin, cout, cerr, clog,
- // and their wide-stream equivalents. Instead of calling open, it
- // just sets
- // - for libio: __c_file_type->_fileno and the respective _flags bits
- // - for stdio: _M_cfile = __file and some internal flags
- // and returns.
- __basic_file*
- sys_open(__c_file_type* __file, ios_base::openmode __mode);
-
- _CharT
- sys_getc();
-
- _CharT
- sys_ungetc(_CharT);
-
- __basic_file*
- close();
-
- bool
- is_open();
-
- int
- fd();
-
- // NB: Must match FILE specific jump table starting here--this
- // means all virtual functions starting with the dtor must match,
- // slot by slot. For glibc-based dystems, this means the _IO_FILE
- // as the FILE struct and _IO_jump_t as the jump table.
- virtual
- ~__basic_file(); // Takes the place of __finish.
-
- virtual int
- overflow(int __c = EOF);
-
- virtual int
- underflow();
-
- virtual int
- uflow();
-
- virtual int
- pbackfail(int __c);
-
- // A complex "write" function that sets all of __c_file_type's
- // pointers and associated data members correctly and manages its
- // relation to the external byte sequence.
- virtual streamsize
- xsputn(const _CharT* __s, streamsize __n);
-
- // A complex "read" function that sets all of __c_file_type's
- // pointers and associated data members correctly and manages its
- // relation to the external byte sequence.
- virtual streamsize
- xsgetn(_CharT* __s, streamsize __n);
-
- // A complex "seekoff" function that sets all of __c_file_type's
- // pointers and associated data members correctly and manages its
- // relation to the external byte sequence.
- virtual streamoff
- seekoff(streamoff __off, ios_base::seekdir __way,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
-
- // A complex "seekpos" function that sets all of __c_file_type's
- // pointers and associated data members correctly and manages its
- // relation to the external byte sequence.
- virtual streamoff
- seekpos(streamoff __pos,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
-
- virtual streambuf*
- setbuf(_CharT* __b, int __len);
-
- virtual int
- sync();
-
- virtual int
- doallocate();
-
- // A simple read function for the external byte sequence, that
- // does no mucking around with or setting of the pointers or flags
- // in __c_file_type.
- virtual streamsize
- sys_read(_CharT* __s, streamsize __n);
-
- // A simple write function for the external byte sequence, that
- // does no mucking around with or setting of the pointers or flags
- // in __c_file_type.
- virtual streamsize
- sys_write(const _CharT* __s, streamsize __n);
-
- // A simple seek function for the external byte sequence, that
- // does no mucking around with or setting of the pointers or flags
- // in __c_file_type.
- virtual streamoff
- sys_seek(streamoff __off, ios_base::seekdir __way);
-
- virtual int
- sys_close();
-
- virtual int
- sys_stat(void* __v);
-
- virtual int
- showmanyc();
-
- virtual void
- imbue(void* __v);
- };
-} // namespace std
-
-// Now include the bits that are dependent on the underlying I/O
-// model chosen at configure time.
-#include <bits/basic_file_model.h>
-
-#endif // _CPP_BASIC_FILE
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 5756e9eac44..913484cbb7f 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -119,7 +119,6 @@ namespace std
// 4. All fields==0 is an empty string, given the extra storage
// beyond-the-end for a null terminator; thus, the shared
// empty string representation needs no constructor.
-
struct _Rep
{
// Types:
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index b57c7f642f9..896cd02afa7 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -44,14 +44,14 @@
namespace std
{
template<typename _CharT, typename _Traits, typename _Alloc>
- const _CharT
+ const typename basic_string<_CharT, _Traits, _Alloc>::size_type
basic_string<_CharT, _Traits, _Alloc>::
- _Rep::_S_terminal = _CharT();
+ _Rep::_S_max_size = (((npos - sizeof(_Rep))/sizeof(_CharT)) - 1) / 4;
template<typename _CharT, typename _Traits, typename _Alloc>
- const typename basic_string<_CharT, _Traits, _Alloc>::size_type
+ const _CharT
basic_string<_CharT, _Traits, _Alloc>::
- _Rep::_S_max_size = (((npos - sizeof(_Rep))/sizeof(_CharT)) - 1) / 4;
+ _Rep::_S_terminal = _CharT();
template<typename _CharT, typename _Traits, typename _Alloc>
const typename basic_string<_CharT, _Traits, _Alloc>::size_type
diff --git a/libstdc++-v3/include/bits/localefwd.h b/libstdc++-v3/include/bits/localefwd.h
index bcb60b7e4e4..172adae2e04 100644
--- a/libstdc++-v3/include/bits/localefwd.h
+++ b/libstdc++-v3/include/bits/localefwd.h
@@ -446,7 +446,7 @@ namespace std
// NB: There is no accessor for _M_index because it may be used
// before the constructor is run; the effect of calling a member
// function (even an inline) would be undefined.
- mutable size_t _M_index;
+ mutable size_t _M_index;
// Last id number assigned
static _Atomic_word _S_highwater;
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 653aaa6a2e1..1eee7b37b11 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -1775,7 +1775,7 @@ __result, __binary_pred, _IterType());
}
}
- const int __stl_threshold = 16;
+ extern const int __stl_threshold;
// sort() and its auxiliary functions.
@@ -2060,7 +2060,7 @@ __result, __binary_pred, _IterType());
__comp);
}
- const int __stl_chunk_size = 7;
+ extern const int __stl_chunk_size;
template<typename _RandomAccessIter, typename _Distance>
void
diff --git a/libstdc++-v3/include/bits/stl_alloc.h b/libstdc++-v3/include/bits/stl_alloc.h
index 66d2ef66529..7a4d9e9e4a6 100644
--- a/libstdc++-v3/include/bits/stl_alloc.h
+++ b/libstdc++-v3/include/bits/stl_alloc.h
@@ -1,6 +1,6 @@
// Allocators -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 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
@@ -321,267 +321,274 @@ typedef __mem_interface __single_client_alloc;
* @endmaint
* (See @link Allocators allocators info @endlink for more.)
*/
-template <bool __threads, int __inst>
-class __default_alloc_template
-{
+template<bool __threads, int __inst>
+ class __default_alloc_template
+ {
+ private:
+ enum {_ALIGN = 8};
+ enum {_MAX_BYTES = 128};
+ enum {_NFREELISTS = _MAX_BYTES / _ALIGN};
+
+ union _Obj
+ {
+ union _Obj* _M_free_list_link;
+ char _M_client_data[1]; // The client sees this.
+ };
-private:
- enum {_ALIGN = 8};
- enum {_MAX_BYTES = 128};
- enum {_NFREELISTS = _MAX_BYTES / _ALIGN};
+ static _Obj* volatile _S_free_list[_NFREELISTS];
- static size_t
- _S_round_up(size_t __bytes)
- { return (((__bytes) + (size_t) _ALIGN-1) & ~((size_t) _ALIGN - 1)); }
+ // Chunk allocation state.
+ static char* _S_start_free;
+ static char* _S_end_free;
+ static size_t _S_heap_size;
+
+ static _STL_mutex_lock _S_node_allocator_lock;
- union _Obj {
- union _Obj* _M_free_list_link;
- char _M_client_data[1]; // The client sees this.
- };
+ static size_t
+ _S_round_up(size_t __bytes)
+ { return (((__bytes) + (size_t) _ALIGN-1) & ~((size_t) _ALIGN - 1)); }
- static _Obj* volatile _S_free_list[];
- static size_t _S_freelist_index(size_t __bytes)
+ static size_t
+ _S_freelist_index(size_t __bytes)
{ return (((__bytes) + (size_t)_ALIGN-1)/(size_t)_ALIGN - 1); }
- // Returns an object of size __n, and optionally adds to size __n free list.
- static void* _S_refill(size_t __n);
- // Allocates a chunk for nobjs of size size. nobjs may be reduced
- // if it is inconvenient to allocate the requested number.
- static char* _S_chunk_alloc(size_t __size, int& __nobjs);
-
- // Chunk allocation state.
- static char* _S_start_free;
- static char* _S_end_free;
- static size_t _S_heap_size;
-
- static _STL_mutex_lock _S_node_allocator_lock;
+ // Returns an object of size __n, and optionally adds to size __n
+ // free list.
+ static void*
+ _S_refill(size_t __n);
- // It would be nice to use _STL_auto_lock here. But we need a test whether
- // threads are in use.
- class _Lock {
+ // Allocates a chunk for nobjs of size size. nobjs may be reduced
+ // if it is inconvenient to allocate the requested number.
+ static char*
+ _S_chunk_alloc(size_t __size, int& __nobjs);
+
+ // It would be nice to use _STL_auto_lock here. But we need a
+ // test whether threads are in use.
+ class _Lock
+ {
public:
_Lock() { if (__threads) _S_node_allocator_lock._M_acquire_lock(); }
~_Lock() { if (__threads) _S_node_allocator_lock._M_release_lock(); }
- } __attribute__ ((__unused__));
- friend class _Lock;
-
-public:
-
- // __n must be > 0
- static void* allocate(size_t __n)
- {
- void* __ret = 0;
+ } __attribute__ ((__unused__));
+ friend class _Lock;
+
+ public:
+ // __n must be > 0
+ static void*
+ allocate(size_t __n)
+ {
+ void* __ret = 0;
+
+ if (__n > (size_t) _MAX_BYTES)
+ __ret = __mem_interface::allocate(__n);
+ else
+ {
+ _Obj* volatile* __my_free_list = _S_free_list
+ + _S_freelist_index(__n);
+ // Acquire the lock here with a constructor call. This
+ // ensures that it is released in exit or during stack
+ // unwinding.
+ _Lock __lock_instance;
+ _Obj* __restrict__ __result = *__my_free_list;
+ if (__result == 0)
+ __ret = _S_refill(_S_round_up(__n));
+ else
+ {
+ *__my_free_list = __result -> _M_free_list_link;
+ __ret = __result;
+ }
+ }
+ return __ret;
+ };
- if (__n > (size_t) _MAX_BYTES)
- __ret = __mem_interface::allocate(__n);
- else
- {
- _Obj* volatile* __my_free_list = _S_free_list + _S_freelist_index(__n);
- // Acquire the lock here with a constructor call. This ensures that
- // it is released in exit or during stack unwinding.
- _Lock __lock_instance;
- _Obj* __restrict__ __result = *__my_free_list;
- if (__result == 0)
- __ret = _S_refill(_S_round_up(__n));
- else
- {
- *__my_free_list = __result -> _M_free_list_link;
- __ret = __result;
- }
- }
+ // __p may not be 0
+ static void
+ deallocate(void* __p, size_t __n)
+ {
+ if (__n > (size_t) _MAX_BYTES)
+ __mem_interface::deallocate(__p, __n);
+ else
+ {
+ _Obj* volatile* __my_free_list
+ = _S_free_list + _S_freelist_index(__n);
+ _Obj* __q = (_Obj*)__p;
+
+ // Acquire the lock here with a constructor call. This ensures that
+ // it is released in exit or during stack unwinding.
+ _Lock __lock_instance;
+ __q -> _M_free_list_link = *__my_free_list;
+ *__my_free_list = __q;
+ }
+ }
- return __ret;
+ static void*
+ reallocate(void* __p, size_t __old_sz, size_t __new_sz);
};
- // __p may not be 0
- static void deallocate(void* __p, size_t __n)
- {
- if (__n > (size_t) _MAX_BYTES)
- __mem_interface::deallocate(__p, __n);
- else
- {
- _Obj* volatile* __my_free_list
- = _S_free_list + _S_freelist_index(__n);
- _Obj* __q = (_Obj*)__p;
-
- // Acquire the lock here with a constructor call. This ensures that
- // it is released in exit or during stack unwinding.
- _Lock __lock_instance;
- __q -> _M_free_list_link = *__my_free_list;
- *__my_free_list = __q;
- }
- }
-
- static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz);
-};
+ template<bool __threads, int __inst>
+ inline bool
+ operator==(const __default_alloc_template<__threads, __inst>&,
+ const __default_alloc_template<__threads, __inst>&)
+ { return true; }
-template <bool __threads, int __inst>
-inline bool operator==(const __default_alloc_template<__threads, __inst>&,
- const __default_alloc_template<__threads, __inst>&)
-{
- return true;
-}
-
-template <bool __threads, int __inst>
-inline bool operator!=(const __default_alloc_template<__threads, __inst>&,
- const __default_alloc_template<__threads, __inst>&)
-{
- return false;
-}
-
+ template<bool __threads, int __inst>
+ inline bool
+ operator!=(const __default_alloc_template<__threads, __inst>&,
+ const __default_alloc_template<__threads, __inst>&)
+ { return false; }
-// We allocate memory in large chunks in order to avoid fragmenting the
-// malloc heap (or whatever __mem_interface is using) too much. We assume
-// that __size is properly aligned. We hold the allocation lock.
-template <bool __threads, int __inst>
-char*
-__default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
- int& __nobjs)
-{
- char* __result;
- size_t __total_bytes = __size * __nobjs;
- size_t __bytes_left = _S_end_free - _S_start_free;
- if (__bytes_left >= __total_bytes)
+ // We allocate memory in large chunks in order to avoid fragmenting the
+ // malloc heap (or whatever __mem_interface is using) too much. We assume
+ // that __size is properly aligned. We hold the allocation lock.
+ template<bool __threads, int __inst>
+ char*
+ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
+ int& __nobjs)
+ {
+ char* __result;
+ size_t __total_bytes = __size * __nobjs;
+ size_t __bytes_left = _S_end_free - _S_start_free;
+
+ if (__bytes_left >= __total_bytes)
{
__result = _S_start_free;
_S_start_free += __total_bytes;
return(__result);
}
- else if (__bytes_left >= __size)
- {
- __nobjs = (int)(__bytes_left/__size);
- __total_bytes = __size * __nobjs;
- __result = _S_start_free;
- _S_start_free += __total_bytes;
- return(__result);
- }
- else
- {
- size_t __bytes_to_get =
- 2 * __total_bytes + _S_round_up(_S_heap_size >> 4);
- // Try to make use of the left-over piece.
- if (__bytes_left > 0)
- {
- _Obj* volatile* __my_free_list =
- _S_free_list + _S_freelist_index(__bytes_left);
-
- ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
- *__my_free_list = (_Obj*)_S_start_free;
- }
- _S_start_free = (char*) __mem_interface::allocate(__bytes_to_get);
- if (0 == _S_start_free)
- {
- size_t __i;
- _Obj* volatile* __my_free_list;
- _Obj* __p;
- // Try to make do with what we have. That can't hurt. We
- // do not try smaller requests, since that tends to result
- // in disaster on multi-process machines.
- __i = __size;
- for (; __i <= (size_t) _MAX_BYTES; __i += (size_t) _ALIGN)
- {
- __my_free_list = _S_free_list + _S_freelist_index(__i);
- __p = *__my_free_list;
- if (0 != __p)
- {
- *__my_free_list = __p -> _M_free_list_link;
- _S_start_free = (char*)__p;
- _S_end_free = _S_start_free + __i;
- return(_S_chunk_alloc(__size, __nobjs));
- // Any leftover piece will eventually make it to the
- // right free list.
- }
- }
- _S_end_free = 0; // In case of exception.
- _S_start_free = (char*)__mem_interface::allocate(__bytes_to_get);
- // This should either throw an exception or remedy the situation.
- // Thus we assume it succeeded.
- }
- _S_heap_size += __bytes_to_get;
- _S_end_free = _S_start_free + __bytes_to_get;
- return(_S_chunk_alloc(__size, __nobjs));
- }
-}
-
-
-// Returns an object of size __n, and optionally adds to "size __n"'s free list.
-// We assume that __n is properly aligned. We hold the allocation lock.
-template <bool __threads, int __inst>
-void*
-__default_alloc_template<__threads, __inst>::_S_refill(size_t __n)
-{
- int __nobjs = 20;
- char* __chunk = _S_chunk_alloc(__n, __nobjs);
- _Obj* volatile* __my_free_list;
- _Obj* __result;
- _Obj* __current_obj;
- _Obj* __next_obj;
- int __i;
-
- if (1 == __nobjs) return(__chunk);
- __my_free_list = _S_free_list + _S_freelist_index(__n);
-
- /* Build free list in chunk */
+ else if (__bytes_left >= __size)
+ {
+ __nobjs = (int)(__bytes_left/__size);
+ __total_bytes = __size * __nobjs;
+ __result = _S_start_free;
+ _S_start_free += __total_bytes;
+ return(__result);
+ }
+ else
+ {
+ size_t __bytes_to_get =
+ 2 * __total_bytes + _S_round_up(_S_heap_size >> 4);
+ // Try to make use of the left-over piece.
+ if (__bytes_left > 0)
+ {
+ _Obj* volatile* __my_free_list =
+ _S_free_list + _S_freelist_index(__bytes_left);
+
+ ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
+ *__my_free_list = (_Obj*)_S_start_free;
+ }
+ _S_start_free = (char*) __mem_interface::allocate(__bytes_to_get);
+ if (0 == _S_start_free)
+ {
+ size_t __i;
+ _Obj* volatile* __my_free_list;
+ _Obj* __p;
+ // Try to make do with what we have. That can't hurt. We
+ // do not try smaller requests, since that tends to result
+ // in disaster on multi-process machines.
+ __i = __size;
+ for (; __i <= (size_t) _MAX_BYTES; __i += (size_t) _ALIGN)
+ {
+ __my_free_list = _S_free_list + _S_freelist_index(__i);
+ __p = *__my_free_list;
+ if (0 != __p)
+ {
+ *__my_free_list = __p -> _M_free_list_link;
+ _S_start_free = (char*)__p;
+ _S_end_free = _S_start_free + __i;
+ return(_S_chunk_alloc(__size, __nobjs));
+ // Any leftover piece will eventually make it to the
+ // right free list.
+ }
+ }
+ _S_end_free = 0; // In case of exception.
+ _S_start_free = (char*)__mem_interface::allocate(__bytes_to_get);
+ // This should either throw an exception or remedy the situation.
+ // Thus we assume it succeeded.
+ }
+ _S_heap_size += __bytes_to_get;
+ _S_end_free = _S_start_free + __bytes_to_get;
+ return(_S_chunk_alloc(__size, __nobjs));
+ }
+ }
+
+
+ // Returns an object of size __n, and optionally adds to "size
+ // __n"'s free list. We assume that __n is properly aligned. We
+ // hold the allocation lock.
+ template<bool __threads, int __inst>
+ void*
+ __default_alloc_template<__threads, __inst>::_S_refill(size_t __n)
+ {
+ int __nobjs = 20;
+ char* __chunk = _S_chunk_alloc(__n, __nobjs);
+ _Obj* volatile* __my_free_list;
+ _Obj* __result;
+ _Obj* __current_obj;
+ _Obj* __next_obj;
+ int __i;
+
+ if (1 == __nobjs) return(__chunk);
+ __my_free_list = _S_free_list + _S_freelist_index(__n);
+
+ /* Build free list in chunk */
__result = (_Obj*)__chunk;
*__my_free_list = __next_obj = (_Obj*)(__chunk + __n);
for (__i = 1; ; __i++) {
__current_obj = __next_obj;
__next_obj = (_Obj*)((char*)__next_obj + __n);
if (__nobjs - 1 == __i) {
- __current_obj -> _M_free_list_link = 0;
- break;
+ __current_obj -> _M_free_list_link = 0;
+ break;
} else {
- __current_obj -> _M_free_list_link = __next_obj;
+ __current_obj -> _M_free_list_link = __next_obj;
}
}
- return(__result);
-}
-
+ return(__result);
+ }
-template <bool threads, int inst>
-void*
-__default_alloc_template<threads, inst>::reallocate(void* __p,
- size_t __old_sz,
- size_t __new_sz)
-{
- void* __result;
- size_t __copy_sz;
- if (__old_sz > (size_t) _MAX_BYTES && __new_sz > (size_t) _MAX_BYTES) {
+ template<bool threads, int inst>
+ void*
+ __default_alloc_template<threads, inst>::reallocate(void* __p,
+ size_t __old_sz,
+ size_t __new_sz)
+ {
+ void* __result;
+ size_t __copy_sz;
+
+ if (__old_sz > (size_t) _MAX_BYTES && __new_sz > (size_t) _MAX_BYTES) {
return(realloc(__p, __new_sz));
+ }
+ if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p);
+ __result = allocate(__new_sz);
+ __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz;
+ memcpy(__result, __p, __copy_sz);
+ deallocate(__p, __old_sz);
+ return(__result);
}
- if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return(__p);
- __result = allocate(__new_sz);
- __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz;
- memcpy(__result, __p, __copy_sz);
- deallocate(__p, __old_sz);
- return(__result);
-}
-
-template <bool __threads, int __inst>
+
+ template<bool __threads, int __inst>
_STL_mutex_lock
__default_alloc_template<__threads, __inst>::_S_node_allocator_lock
- __STL_MUTEX_INITIALIZER;
-
-template <bool __threads, int __inst>
-char* __default_alloc_template<__threads, __inst>::_S_start_free = 0;
-
-template <bool __threads, int __inst>
-char* __default_alloc_template<__threads, __inst>::_S_end_free = 0;
-
-template <bool __threads, int __inst>
-size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;
-
-template <bool __threads, int __inst>
-typename __default_alloc_template<__threads, __inst>::_Obj* volatile
-__default_alloc_template<__threads, __inst> ::_S_free_list[
- __default_alloc_template<__threads, __inst>::_NFREELISTS ];
-
-
-typedef __default_alloc_template<true, 0> __alloc;
-typedef __default_alloc_template<false, 0> __single_client_alloc;
+ __STL_MUTEX_INITIALIZER;
+
+ template<bool __threads, int __inst>
+ char* __default_alloc_template<__threads, __inst>::_S_start_free = 0;
+
+ template<bool __threads, int __inst>
+ char* __default_alloc_template<__threads, __inst>::_S_end_free = 0;
+
+ template<bool __threads, int __inst>
+ size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;
+
+ template<bool __threads, int __inst>
+ typename __default_alloc_template<__threads, __inst>::_Obj* volatile
+ __default_alloc_template<__threads, __inst>::_S_free_list[_NFREELISTS];
+
+ typedef __default_alloc_template<true, 0> __alloc;
+ typedef __default_alloc_template<false, 0> __single_client_alloc;
#endif /* ! __USE_MALLOC */
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 9c108c5e3ef..66c7e2de594 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -1,6 +1,6 @@
// bit_vector and vector<bool> specialization -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 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
@@ -63,8 +63,7 @@
namespace std
{
-
-static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));
+ extern const int __WORD_BIT;
struct _Bit_reference {
unsigned int* _M_p;
diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
index 5a0b94839ae..ef50c9ee38a 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -1,6 +1,6 @@
// RB tree implementation -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002 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
@@ -90,10 +90,9 @@ iterators invalidated are those referring to the deleted node.
namespace std
{
-
-typedef bool _Rb_tree_Color_type;
-const _Rb_tree_Color_type _S_rb_tree_red = false;
-const _Rb_tree_Color_type _S_rb_tree_black = true;
+ typedef bool _Rb_tree_Color_type;
+ extern const _Rb_tree_Color_type _S_rb_tree_red; // false
+ extern const _Rb_tree_Color_type _S_rb_tree_black; // true
struct _Rb_tree_node_base
{