Makefile.am (doxygen-maint): The script isn't executable in CVS.

2001-11-23  Phil Edwards  <pme@gcc.gnu.org>

	* Makefile.am (doxygen-maint):  The script isn't executable in CVS.
	* Makefile.in:  Regenerated.
	* docs/doxygen/TODO:  New file listing doxygen work to be done.
	* docs/doxygen/run_doxygen:  Fix up man pages.
	* docs/doxygen/user.cfg.in:  Insert maint-only toggles.
	* docs/doxygen/maint.cfg.in:  Copy from user.cfg and turn toggles on.
	* include/bits/stl_construct.h:  Use new hooks for internal functions.

	* docs/html/17_intro/TODO:  Small updates.
	* docs/html/faq/index.html:  Likewise.
	* docs/html/faq/index.txt:  Regenerated.

	* include/bits/stl_alloc.h:  Doxygenate, reindent comments, remove
	SGI-isms and wrappers.
	(simple_alloc, debug_alloc):  Uglify class names.
	(__default_alloc_template):  Uglify "threads" template parameter and
	update corresponding macros.
	* include/backward/alloc.h:  Bring up to date.

From-SVN: r47296
This commit is contained in:
Phil Edwards 2001-11-24 03:28:27 +00:00
parent 05ce35e6f2
commit b00378457a
13 changed files with 575 additions and 337 deletions

View File

@ -1,3 +1,24 @@
2001-11-23 Phil Edwards <pme@gcc.gnu.org>
* Makefile.am (doxygen-maint): The script isn't executable in CVS.
* Makefile.in: Regenerated.
* docs/doxygen/TODO: New file listing doxygen work to be done.
* docs/doxygen/run_doxygen: Fix up man pages.
* docs/doxygen/user.cfg.in: Insert maint-only toggles.
* docs/doxygen/maint.cfg.in: Copy from user.cfg and turn toggles on.
* include/bits/stl_construct.h: Use new hooks for internal functions.
* docs/html/17_intro/TODO: Small updates.
* docs/html/faq/index.html: Likewise.
* docs/html/faq/index.txt: Regenerated.
* include/bits/stl_alloc.h: Doxygenate, reindent comments, remove
SGI-isms and wrappers.
(simple_alloc, debug_alloc): Uglify class names.
(__default_alloc_template): Uglify "threads" template parameter and
update corresponding macros.
* include/backward/alloc.h: Bring up to date.
2001-11-23 Jason Merrill <jason@redhat.com>
* src/vterminate.cc (__verbose_terminate_handler): Add leading

View File

@ -53,7 +53,8 @@ doxygen:
doxygen-maint:
-(srcdir=`cd ${top_srcdir}; pwd`; \
outdir=`pwd`; \
${srcdir}/docs/doxygen/run_doxygen --mode=maint $${srcdir} $${outdir})
/bin/sh ${srcdir}/docs/doxygen/run_doxygen \
--mode=maint $${srcdir} $${outdir})
.PHONY: doxygen doxygen-maint

View File

@ -507,7 +507,8 @@ doxygen:
doxygen-maint:
-(srcdir=`cd ${top_srcdir}; pwd`; \
outdir=`pwd`; \
${srcdir}/docs/doxygen/run_doxygen --mode=maint $${srcdir} $${outdir})
/bin/sh ${srcdir}/docs/doxygen/run_doxygen \
--mode=maint $${srcdir} $${outdir})
.PHONY: doxygen doxygen-maint

View File

@ -0,0 +1,52 @@
The approach I've been using for a given header is to recursively do each
of the "bits" headers which make up the standard header. So, e.g., while
there are five headers making up <algorithm>, three of them were already
documented in the course of doing other headers.
"Untouched" means I've deliberately skipped it for various reasons, or
haven't gotten to it yet. It /will/ be done (by somebody, eventually.)
Area Still needs to be doxygen-documented
-----------------------------------------------------------
c17 FINISHED (Nothing in Clause 17 "exists" in terms of code.)
c18 <limits>, Note A
c19 Note A
c20 std_memory.h[20.4], rel_ops (should they be doc'd?), Note A
c21 Untouched, Note B
c22 Untouched
c23 See doxygroups.cc and Note B.
stl_alloc.h, stl_uninitialized.h remain from the common files.
c24 Untouched
c25 stl_tempbuf.h (small), stl_algo.h (big)
c26 <complex>, <valarray>, stl_numeric.h[26.4], Note A
c27 Untouched
backward/ Not scanned by doxygen. Should it be?
ext/ Untouched
__gnu_cxx Extensions such as verbose_terminate_handler are documented
but do not appear in output, since the __gnu_cxx namespace is
itself undocumented. Should it be? Eeeeeeehhh...
[1.3.5] "implementation-defined behavior: behavior ... that depends
on the implementation *and that each implementation shall
document*." [my emphasis] Not all implementation choices
have been thus described; doxygen is not necessarily the
appropriate place for such descriptions, either.
-----------------------------------------------------------
NOTES:
A) So far I have not tried to document any of the <c*> headers. So entities
such as atexit() are undocumented throughout the library.
B) Huge chunks of containers and strings are described in common "Tables"
in the standard. How to reproduce this information?
vim:ts=4:et:

View File

@ -1,4 +1,4 @@
# Doxyfile 1.2.4
# Doxyfile 1.2.6
# This file describes the settings to be used by doxygen for a project
#
@ -9,6 +9,10 @@
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
### When doxygen is run, the current directory is the top of
### the libstdc++-v3 source directory. Keep this in mind while
### writing relative-path directories.
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
@ -16,13 +20,13 @@
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME = "libstdc++"
PROJECT_NAME = "libstdc++-v3 Source"
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 3
PROJECT_NUMBER =
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
@ -46,8 +50,8 @@ OUTPUT_LANGUAGE = English
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
#EXTRACT_ALL = NO
EXTRACT_ALL = YES
EXTRACT_ALL = NO
#EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
@ -65,21 +69,21 @@ EXTRACT_STATIC = YES
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_MEMBERS = YES
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these class will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
HIDE_UNDOC_CLASSES = YES
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = NO
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
@ -118,12 +122,12 @@ INTERNAL_DOCS = NO
# generate a class diagram (in Html and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off.
CLASS_DIAGRAMS = NO
CLASS_DIAGRAMS = YES
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = NO
SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
@ -142,7 +146,7 @@ STRIP_CODE_COMMENTS = YES
# in case and if your file system supports case sensitive file names. Windows
# users are advised to set this option to NO.
CASE_SENSE_NAMES = YES
CASE_SENSE_NAMES = NO
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
@ -186,14 +190,14 @@ INLINE_INFO = YES
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = NO
SORT_MEMBER_DOCS = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
#DISTRIBUTE_GROUP_DOC = NO
DISTRIBUTE_GROUP_DOC = YES
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
@ -203,19 +207,25 @@ TAB_SIZE = 4
# The ENABLE_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
ENABLED_SECTIONS = maint
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
GENERATE_TODOLIST = NO
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = YES
GENERATE_TESTLIST = NO
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
GENERATE_BUGLIST = YES
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
@ -224,7 +234,31 @@ GENERATE_TESTLIST = YES
# will result in a user defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
#ALIASES =
ALIASES = "maint=\if maint" \
"endmaint=\endif"
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consist of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
MAX_INITIALIZER_LINES = 30
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C.
# For instance some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = NO
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
@ -239,7 +273,6 @@ QUIET = YES
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
### pme Turned off; apparently doxygen can't grok templates
WARNINGS = NO
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
@ -259,25 +292,47 @@ WARN_FORMAT = "$file:$line: $text"
# and error messages should be written. If left blank the output is written
# to stderr.
#WARN_LOGFILE =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = include src libmath libsupc++ libio config
INPUT = docs/doxygen \
libsupc++ \
include \
src \
libsupc++/exception libsupc++/new libsupc++/typeinfo include/ext/hash_map \
include/ext/hash_set include/ext/rope include/ext/slist include/std/algorithm \
include/std/bitset include/std/cassert include/std/cctype \
include/std/cerrno include/std/cfloat include/std/ciso646 include/std/climits \
include/std/clocale include/std/cmath include/std/complex include/std/csetjmp \
include/std/csignal include/std/cstdarg include/std/cstddef \
include/std/cstdio include/std/cstdlib include/std/cstring \
include/std/ctime include/std/cwchar include/std/cwctype include/std/deque \
include/std/fstream include/std/functional include/std/iomanip \
include/std/ios include/std/iosfwd include/std/iostream include/std/istream \
include/std/iterator include/std/limits include/std/list include/std/locale \
include/std/map include/std/memory include/std/numeric include/std/ostream \
include/std/queue include/std/set include/std/sstream include/std/stack \
include/std/stdexcept include/std/streambuf include/std/string \
include/std/utility include/std/valarray include/std/vector
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
FILE_PATTERNS = *.cc *.h c++config
FILE_PATTERNS = *.doxy \
*.cc \
*.tcc \
*.h \
c++config
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
@ -288,13 +343,16 @@ RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
EXCLUDE = include/c \
include/c_shadow \
docs/doxygen/stdheader.cc
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = CVS
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
@ -328,7 +386,7 @@ INPUT_FILTER =
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse.
#FILTER_SOURCE_FILES = NO
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
@ -385,7 +443,7 @@ HTML_FOOTER =
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet
HTML_STYLESHEET =
HTML_STYLESHEET = docs/doxygen/style.css
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
@ -400,30 +458,47 @@ HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set YES to add extra items for group members
# to the contents of the Html help documentation and to the tree view.
TOC_EXPAND = NO
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
DISABLE_INDEX = YES
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
#ENUM_VALUES_PER_LINE = 4
ENUM_VALUES_PER_LINE = 4
# If the GENERATE_TREEVIEW tag is set to YES, a side pannel will be
# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
# generated containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript and frames is required (for instance Netscape 4.0+
# or Internet explorer 4.0+).
GENERATE_TREEVIEW = YES
GENERATE_TREEVIEW = NO
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
#TREEVIEW_WIDTH = 250
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
@ -528,7 +603,7 @@ RTF_STYLESHEET_FILE =
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = NO
GENERATE_MAN = YES
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@ -603,7 +678,7 @@ EXPAND_AS_DEFINED =
# The TAGFILES tag can be used to specify one or more tagfiles.
TAGFILES =
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
@ -630,7 +705,7 @@ PERL_PATH = /usr/bin/perl
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
HAVE_DOT = YES
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
@ -689,7 +764,13 @@ MAX_DOT_GRAPH_HEIGHT = 1024
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
#GENERATE_LEGEND = YES
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermedate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
@ -738,3 +819,5 @@ EXT_DOC_PATHS =
# End of file

View File

@ -4,7 +4,7 @@
#
# Synopsis: run_doxygen --mode=[user|maint] v3srcdir v3builddir
#
# Originally hacked together by Phil Edwards <pme@sources.redhat.com>
# Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
# We can check now that the version of doxygen is >= this variable.
@ -162,6 +162,20 @@ for f in $problematic; do
done
rm stdheader
# Some of the pages for generated modules have text that confuses certain
# implementations of man(1), e.g., Linux's. We need to have another top-level
# *roff tag to /stop/ the .SH NAME entry.
#problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
problematic='Containers.3 Sequences.3 Assoc_containers.3'
for f in $problematic; do
sed '/^\.SH NAME/{
n
a\
.SH SYNOPSIS
}' $f > TEMP
mv TEMP $f
done
cp ${srcdir}/docs/doxygen/Intro.3 .
}

View File

@ -50,8 +50,8 @@ OUTPUT_LANGUAGE = English
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
#EXTRACT_ALL = NO
EXTRACT_ALL = YES
EXTRACT_ALL = NO
#EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
@ -125,7 +125,7 @@ INTERNAL_DOCS = NO
CLASS_DIAGRAMS = YES
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = YES
@ -234,7 +234,8 @@ GENERATE_BUGLIST = YES
# will result in a user defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
ALIASES = "maint=\if maint" \
"endmaint=\endif"
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consist of for it to appear in

View File

@ -152,8 +152,6 @@ sources, with macro-guards.
- write filebuf for wide characters
- replace stl/bits/stl_config
- add feature-test macros for non-standard extensions
- move major extensions into separate namespace (e.g. stl::)
@ -166,8 +164,6 @@ sources, with macro-guards.
facets, and construct them lazily so unused facets need not be constructed
when the locale is.
- get mknumeric_limits coope with 'exotic' OSes.
- <cmath>: provide missing names.
- provide testsuites for numerics.

View File

@ -99,7 +99,7 @@ http://gcc.gnu.org/onlinedocs/libstdc++/faq/</a>.</p>
<h1><a name="1_0">1.0 General Information</a></h1>
<!-- I suspect these will mostly be links to/into existing documents. -->
<h2><a name="1_1">1.1 What is libstdc++-v3?</a></h2>
<p>The GNU Standard C++ Library v3, or libstdc++-2.9x, is an
<p>The GNU Standard C++ Library v3 is an
ongoing project to implement the ISO 14882 Standard C++ library
as described in chapters 17 through 27 and annex D. As the
library reaches stable plateaus, it is captured in a snapshot
@ -109,10 +109,15 @@ http://gcc.gnu.org/onlinedocs/libstdc++/faq/</a>.</p>
far the project has come, or just want the latest
bleeding-edge code, the up-to-date source is available over
anonymous CVS, and can even be browsed over the Web (see below).
</p>
</p>
<p>The older libstdc++-v2 project is no longer maintained; the code
has been completely replaced and rewritten.
<a href="#4_4_interface">If you are using V2</a>, then you need to
report bugs to your system vendor, not to the V3 list.
</p>
<p>A more formal description of the V3 goals can be found in the
official <a href="../17_intro/DESIGN">design document</a>.
</p>
</p>
<hr>
<h2><a name="1_2">1.2 Why should I use libstdc++?</a></h2>
@ -582,8 +587,10 @@ New:
do anyhow; see the last paragraph of the page describing
<a href="http://gcc.gnu.org/gnatswrite.html">the GCC bug database</a>).
</p>
<p>If the headers are in <CODE>${prefix}/include/g++-3</CODE>, then
you are using the old libstdc++-v2 library, which is nonstandard
<p>If the headers are in <code>${prefix}/include/g++-3</code>, or if
the installed library's name looks like <code>libstdc++-2.10.a</code>
or <code>libstdc++-libc6-2.10.so</code>,
then you are using the old libstdc++-v2 library, which is nonstandard
and unmaintained. Do not report problems with -v2 to the -v3
mailing list.
</p>

View File

@ -59,17 +59,21 @@
1.1 What is libstdc++-v3?
The GNU Standard C++ Library v3, or libstdc++-2.9x, is an ongoing
project to implement the ISO 14882 Standard C++ library as described
in chapters 17 through 27 and annex D. As the library reaches stable
plateaus, it is captured in a snapshot and released. The current
release is [45]the eleventh snapshot. For those who want to see
exactly how far the project has come, or just want the latest
bleeding-edge code, the up-to-date source is available over anonymous
CVS, and can even be browsed over the Web (see below).
The GNU Standard C++ Library v3 is an ongoing project to implement the
ISO 14882 Standard C++ library as described in chapters 17 through 27
and annex D. As the library reaches stable plateaus, it is captured in
a snapshot and released. The current release is [45]the eleventh
snapshot. For those who want to see exactly how far the project has
come, or just want the latest bleeding-edge code, the up-to-date
source is available over anonymous CVS, and can even be browsed over
the Web (see below).
The older libstdc++-v2 project is no longer maintained; the code has
been completely replaced and rewritten. [46]If you are using V2, then
you need to report bugs to your system vendor, not to the V3 list.
A more formal description of the V3 goals can be found in the official
[46]design document.
[47]design document.
_________________________________________________________________
1.2 Why should I use libstdc++?
@ -82,8 +86,8 @@
The GNU C/C++/FORTRAN/<pick-a-language> compiler (gcc, g++, etc) is
widely considered to be one of the leading compilers in the world. Its
development has recently been taken over by the [47]GCC team. All of
the rapid development and near-legendary [48]portability that are the
development has recently been taken over by the [48]GCC team. All of
the rapid development and near-legendary [49]portability that are the
hallmarks of an open-source project are being applied to libstdc++.
That means that all of the Standard classes and functions (such as
@ -101,16 +105,16 @@
Development and discussion is held on the libstdc++ mailing list.
Subscribing to the list, or searching the list archives, is open to
everyone. You can read instructions for doing so on the [49]homepage.
everyone. You can read instructions for doing so on the [50]homepage.
If you have questions, ideas, code, or are just curious, sign up!
_________________________________________________________________
1.4 How do I get libstdc++?
The eleventh (and latest) snapshot of libstdc++-v3 is [50]available
The eleventh (and latest) snapshot of libstdc++-v3 is [51]available
via ftp. The filename is libstdc++-2.92.tar.gz.
The [51]homepage has instructions for retrieving the latest CVS
The [52]homepage has instructions for retrieving the latest CVS
sources, and for browsing the CVS sources over the web.
The subset commonly known as the Standard Template Library (chapters
@ -126,7 +130,7 @@
1.6 How do I contribute to the effort?
Here is [52]a page devoted to this topic. Subscribing to the mailing
Here is [53]a page devoted to this topic. Subscribing to the mailing
list (see above, or the homepage) is a very good idea if you have
something to contribute, or if you have spare time and want to help.
Contributions don't have to be in the form of source code; anybody who
@ -161,11 +165,11 @@
extracted into an updated utilities library, but nobody has stated
such a project yet.
(The [53]Boost site houses free C++ libraries that do varying things,
(The [54]Boost site houses free C++ libraries that do varying things,
and happened to be started by members of the Standards Committee.
Certain "useful stuff" classes will probably migrate there.)
For the bold and/or desperate, the [54]GCC FAQ describes where to find
For the bold and/or desperate, the [55]GCC FAQ describes where to find
the last libg++ source.
_________________________________________________________________
@ -175,16 +179,16 @@
remains unanswered, then just ask the mailing list. At present, you do
not need to be subscribed to the list to send a message to it. More
information is available on the homepage (including how to browse the
list archives); to send to the list, use [55]libstdc++@gcc.gnu.org.
list archives); to send to the list, use [56]libstdc++@gcc.gnu.org.
If you have a question that you think should be included here, or if
you have a question about a question/answer here, contact [56]Phil
Edwards or [57]Gabriel Dos Reis.
you have a question about a question/answer here, contact [57]Phil
Edwards or [58]Gabriel Dos Reis.
_________________________________________________________________
1.9 What are the license terms for libstdc++-v3?
See [58]our license description for these and related questions.
See [59]our license description for these and related questions.
_________________________________________________________________
2.0 Installation
@ -201,13 +205,13 @@
* The GNU Autotools are needed if you are messing with the configury
or makefiles.
The file [59]documentation.html provides a good overview of the steps
The file [60]documentation.html provides a good overview of the steps
necessary to build, install, and use the library. Instructions for
configuring the library with new flags such as --enable-threads are
there also, as well as patches and instructions for working with GCC
2.95.
The top-level install.html and [60]RELEASE-NOTES files contain the
The top-level install.html and [61]RELEASE-NOTES files contain the
exact build and installation instructions. You may wish to browse
those files over CVSweb ahead of time to get a feel for what's
required. RELEASE-NOTES is located in the ".../docs/17_intro/"
@ -224,8 +228,8 @@
The Concurrent Versions System is one of several revision control
packages. It was selected for GNU projects because it's free (speech),
free (beer), and very high quality. The [61]CVS entry in the GNU
software catalogue has a better description as well as a [62]link to
free (beer), and very high quality. The [62]CVS entry in the GNU
software catalogue has a better description as well as a [63]link to
the makers of CVS.
The "anonymous client checkout" feature of CVS is similar to anonymous
@ -276,7 +280,7 @@
people don't like it, so here are two pseudo-solutions:
If the only functions from libstdc++.a which you need are language
support functions (those listed in [63]clause 18 of the standard,
support functions (those listed in [64]clause 18 of the standard,
e.g., new and delete), then try linking against libsupc++.a (usually
specifying -lsupc++ when calling g++ for the final link step will do
it). This library contains only those support routines, one per object
@ -314,8 +318,8 @@
Since the goal of ISO Standardization is for all C++ implementations
to be able to share code, the final libstdc++ should, in theory, be
usable under any ISO-compliant compiler. It will still be targeted
and optimized for GCC/g++, however.
usable under any ISO-compliant compiler. It will still be targeted and
optimized for GCC/g++, however.
_________________________________________________________________
3.2 [removed]
@ -332,7 +336,7 @@
install GNU as and arrange for the GCC build to use it (or merge the
sources and build it during the bootstrap).
Anyone who [64]knows the DEC assembler well enough to provide the
Anyone who [65]knows the DEC assembler well enough to provide the
equivalent of these two pseudos would win praise and accolades from
many.
_________________________________________________________________
@ -360,7 +364,7 @@
include/Makefile, resulting in files like gthr.h and gthr-single.h not
being found.
Please read [65]the configuration instructions for GCC, specifically
Please read [66]the configuration instructions for GCC, specifically
the part about configuring in a separate build directory, and how
strongly recommended it is. Building in the source directory is
fragile, is rarely tested, and tends to break, as in this case. This
@ -412,17 +416,17 @@ New:
4.3 Bugs in the C++ language/lib specification
Yes, unfortunately, there are some. In a [66]message to the list,
Yes, unfortunately, there are some. In a [67]message to the list,
Nathan Myers announced that he has started a list of problems in the
ISO C++ Standard itself, especially with regard to the chapters that
concern the library. The list itself is [67]posted on his website.
concern the library. The list itself is [68]posted on his website.
Developers who are having problems interpreting the Standard may wish
to consult his notes.
For those people who are not part of the ISO Library Group (i.e.,
nearly all of us needing to read this page in the first place :-), a
public list of the library defects is occasionally published [68]here.
Some of these have resulted in [69]code changes.
public list of the library defects is occasionally published [69]here.
Some of these have resulted in [70]code changes.
_________________________________________________________________
4.4 Things in libstdc++ that look like bugs
@ -455,7 +459,7 @@ New:
state on the previous file. The reason is that the state flags are not
cleared on a successful call to open(). The standard unfortunately did
not specify behavior in this case, and to everybody's great sorrow,
the [70]proposed LWG resolution (see DR #22) is to leave the flags
the [71]proposed LWG resolution (see DR #22) is to leave the flags
unchanged. You must insert a call to fs.clear() between the calls to
close() and open(), and then everything will work like we all expect
it to work.
@ -465,22 +469,24 @@ New:
same namespace as other comparison functions (e.g., 'using' them and
the <iterator> header), then you will suddenly be faced with huge
numbers of ambiguity errors. This was discussed on the -v3 list;
Nathan Myers [71]sums things up here.
Nathan Myers [72]sums things up here.
The g++-3 headers are not ours
If you have found an extremely broken header file which is causing
problems for you, look carefully before submitting a "high" priority
bug report (which you probably shouldn't do anyhow; see the last
paragraph of the page describing [72]the GCC bug database).
paragraph of the page describing [73]the GCC bug database).
If the headers are in ${prefix}/include/g++-3, then you are using the
old libstdc++-v2 library, which is nonstandard and unmaintained. Do
not report problems with -v2 to the -v3 mailing list.
If the headers are in ${prefix}/include/g++-3, or if the installed
library's name looks like libstdc++-2.10.a or libstdc++-libc6-2.10.so,
then you are using the old libstdc++-v2 library, which is nonstandard
and unmaintained. Do not report problems with -v2 to the -v3 mailing
list.
Currently our header files are installed in ${prefix}/include/g++-v3
(see the 'v'?). This may change with the next release of GCC, as it
may be too confusing, but [73]the question has not yet been decided.
may be too confusing, but [74]the question has not yet been decided.
glibc If you're on a GNU/Linux system and have just upgraded to glibc
2.2, but are still using gcc 2.95.2, then you should have read the
@ -493,7 +499,7 @@ type has changed in glibc 2.2. The patch is at
http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
Note that 2.95.x shipped with the [74]old v2 library which is no
Note that 2.95.x shipped with the [75]old v2 library which is no
longer maintained. Also note that gcc 2.95.3 fixes this problem, but
requires a separate patch for libstdc++-v3.
@ -506,23 +512,23 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
visibility, or you just plain forgot, etc).
More information, including how to optionally enable/disable the
checks, is available [75]here.
checks, is available [76]here.
_________________________________________________________________
4.5 Aw, that's easy to fix!
If you have found a bug in the library and you think you have a
working fix, then send it in! The main GCC site has a page on
[76]submitting patches that covers the procedure, but for libstdc++
[77]submitting patches that covers the procedure, but for libstdc++
you should also send the patch to our mailing list in addition to the
GCC patches mailing list. The libstdc++ [77]contributors' page also
GCC patches mailing list. The libstdc++ [78]contributors' page also
talks about how to submit patches.
In addition to the description, the patch, and the ChangeLog entry, it
is a Good Thing if you can additionally create a small test program to
test for the presence of the bug that your patch fixes. Bugs have a
way of being reintroduced; if an old bug creeps back in, it will be
caught immediately by the [78]testsuite -- but only if such a test
caught immediately by the [79]testsuite -- but only if such a test
exists.
_________________________________________________________________
@ -556,7 +562,7 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
libstdc++. Some of that is already happening, see 4.2. Some of
those changes are being predicted by the library maintainers, and
we add code to the library based on what the current proposed
resolution specifies. Those additions are listed in [79]the
resolution specifies. Those additions are listed in [80]the
extensions page.
2. Performance tuning. Lots of performance tuning. This too is
already underway for post-3.0 releases, starting with memory
@ -572,13 +578,13 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
type from C99.) Bugfixes and rewrites (to improve or fix thread
safety, for instance) will of course be a continuing task.
[80]This question about the next libstdc++ prompted some brief but
interesting [81]speculation.
[81]This question about the next libstdc++ prompted some brief but
interesting [82]speculation.
_________________________________________________________________
5.3 What about the STL from SGI?
The [82]STL from SGI, version 3.3, was the most recent merge of the
The [83]STL from SGI, version 3.3, was the most recent merge of the
STL codebase. The code in libstdc++ contains many fixes and changes,
and it is very likely that the SGI code is no longer under active
development. We expect that no future merges will take place.
@ -599,7 +605,7 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
#include <ext/hash_map>
Extensions to the library have [83]their own page.
Extensions to the library have [84]their own page.
_________________________________________________________________
5.5 [removed]
@ -648,8 +654,8 @@ a
otherwise documented as safe, do not assume that two threads may
access a shared standard library object at the same time.
See chapters [84]17 (library introduction), [85]23 (containers), and
[86]27 (I/O) for more information.
See chapters [85]17 (library introduction), [86]23 (containers), and
[87]27 (I/O) for more information.
_________________________________________________________________
5.7 How do I get a copy of the ISO C++ Standard?
@ -660,11 +666,11 @@ a
their two-meeting commitment for voting rights, may get a copy of the
standard from their respective national standards organization. In the
USA, this national standards organization is ANSI and their website is
right [87]here. (And if you've already registered with them, clicking
this link will take you to directly to the place where you can [88]buy
right [88]here. (And if you've already registered with them, clicking
this link will take you to directly to the place where you can [89]buy
the standard on-line.
Who is your country's member body? Visit the [89]ISO homepage and find
Who is your country's member body? Visit the [90]ISO homepage and find
out!
_________________________________________________________________
@ -715,8 +721,8 @@ a
encompasses the standard library.
_________________________________________________________________
See [90]license.html for copying conditions. Comments and suggestions
are welcome, and may be sent to [91]the libstdc++ mailing list.
See [91]license.html for copying conditions. Comments and suggestions
are welcome, and may be sent to [92]the libstdc++ mailing list.
References
@ -765,49 +771,50 @@ References
43. ../faq/index.html#5_7
44. ../faq/index.html#5_8
45. http://gcc.gnu.org/libstdc++/download.html
46. ../17_intro/DESIGN
47. http://gcc.gnu.org/
48. http://gcc.gnu.org/gcc-2.95/buildstat.html
49. http://gcc.gnu.org/libstdc++/
50. http://gcc.gnu.org/libstdc++/download.html
51. http://gcc.gnu.org/libstdc++/
52. ../17_intro/contribute.html
53. http://www.boost.org/
54. http://gcc.gnu.org/fom_serv/cache/33.html
55. mailto:libstdc++@gcc.gnu.org
56. mailto:pme@gcc.gnu.org
57. mailto:gdr@gcc.gnu.org
58. ../17_intro/license.html
59. ../documentation.html
60. ../17_intro/RELEASE-NOTES
61. http://www.gnu.org/software/cvs/cvs.html
62. http://www.cvshome.org/
63. ../18_support/howto.html
64. http://gcc.gnu.org/ml/libstdc++/2000-12/msg00279.html
65. http://gcc.gnu.org/install/configure.html
66. http://gcc.gnu.org/ml/libstdc++/1998/msg00006.html
67. http://www.cantrip.org/draft-bugs.txt
68. http://anubis.dkuug.dk/jtc1/sc22/wg21/
69. ../faq/index.html#5_2
70. ../ext/howto.html#5
71. http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html
72. http://gcc.gnu.org/gnatswrite.html
73. http://gcc.gnu.org/ml/gcc/2000-10/msg00732.html
74. ../faq/index.html#4_4_interface
75. ../19_diagnostics/howto.html#3
76. http://gcc.gnu.org/contribute.html
77. ../17_intro/contribute.html
78. ../faq/index.html#2_4
79. ../ext/howto.html#5
80. http://gcc.gnu.org/ml/libstdc++/1999/msg00080.html
81. http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html
82. http://www.sgi.com/Technology/STL/
83. ../ext/howto.html
84. ../17_intro/howto.html#3
85. ../23_containers/howto.html#3
86. ../27_io/howto.html#9
87. http://www.ansi.org/
88. http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998
89. http://www.iso.ch/
90. ../17_intro/license.html
91. mailto:libstdc++@gcc.gnu.org
46. ../faq/index.html#4_4_interface
47. ../17_intro/DESIGN
48. http://gcc.gnu.org/
49. http://gcc.gnu.org/gcc-2.95/buildstat.html
50. http://gcc.gnu.org/libstdc++/
51. http://gcc.gnu.org/libstdc++/download.html
52. http://gcc.gnu.org/libstdc++/
53. ../17_intro/contribute.html
54. http://www.boost.org/
55. http://gcc.gnu.org/fom_serv/cache/33.html
56. mailto:libstdc++@gcc.gnu.org
57. mailto:pme@gcc.gnu.org
58. mailto:gdr@gcc.gnu.org
59. ../17_intro/license.html
60. ../documentation.html
61. ../17_intro/RELEASE-NOTES
62. http://www.gnu.org/software/cvs/cvs.html
63. http://www.cvshome.org/
64. ../18_support/howto.html
65. http://gcc.gnu.org/ml/libstdc++/2000-12/msg00279.html
66. http://gcc.gnu.org/install/configure.html
67. http://gcc.gnu.org/ml/libstdc++/1998/msg00006.html
68. http://www.cantrip.org/draft-bugs.txt
69. http://anubis.dkuug.dk/jtc1/sc22/wg21/
70. ../faq/index.html#5_2
71. ../ext/howto.html#5
72. http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html
73. http://gcc.gnu.org/gnatswrite.html
74. http://gcc.gnu.org/ml/gcc/2000-10/msg00732.html
75. ../faq/index.html#4_4_interface
76. ../19_diagnostics/howto.html#3
77. http://gcc.gnu.org/contribute.html
78. ../17_intro/contribute.html
79. ../faq/index.html#2_4
80. ../ext/howto.html#5
81. http://gcc.gnu.org/ml/libstdc++/1999/msg00080.html
82. http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html
83. http://www.sgi.com/Technology/STL/
84. ../ext/howto.html
85. ../17_intro/howto.html#3
86. ../23_containers/howto.html#3
87. ../27_io/howto.html#9
88. http://www.ansi.org/
89. http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998
90. http://www.iso.ch/
91. ../17_intro/license.html
92. mailto:libstdc++@gcc.gnu.org

View File

@ -48,8 +48,8 @@
#include <bits/stl_alloc.h>
using std::__malloc_alloc_template;
using std::simple_alloc;
using std::debug_alloc;
using std::__simple_alloc;
using std::__debug_alloc;
using std::alloc;
using std::single_client_alloc;
using std::allocator;

View File

@ -48,22 +48,34 @@
#ifndef __SGI_STL_INTERNAL_ALLOC_H
#define __SGI_STL_INTERNAL_ALLOC_H
// 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
// types; indeed we assume that there is only one pointer type.
// The allocation primitives are intended to allocate individual objects,
// not larger arenas as with the original STL allocators.
// This header implements some node allocators. These are NOT the same as
// allocators in the C++ standard, nor in the original HP 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 n 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).
#include <bits/functexcept.h> // for __throw_bad_alloc
#include <bits/std_cstddef.h>
#include <bits/std_cstdlib.h>
#include <bits/std_cstring.h>
#include <bits/std_cassert.h>
#ifndef __RESTRICT
# define __RESTRICT
#endif
// To see the effects of this block of macro wrangling, jump to
// "Default node allocator" below.
#ifdef __STL_THREADS
# include <bits/stl_threads.h>
# define __NODE_ALLOCATOR_THREADS true
@ -78,15 +90,15 @@
// The above is copied from malloc.h. Including <malloc.h>
// would be cleaner but fails with certain levels of standard
// conformance.
# define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \
# define __NODE_ALLOCATOR_LOCK if (__threads && __us_rsthread_malloc) \
{ _S_node_allocator_lock._M_acquire_lock(); }
# define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \
# define __NODE_ALLOCATOR_UNLOCK if (__threads && __us_rsthread_malloc) \
{ _S_node_allocator_lock._M_release_lock(); }
# else /* !__STL_SGI_THREADS */
# define __NODE_ALLOCATOR_LOCK \
{ if (threads) _S_node_allocator_lock._M_acquire_lock(); }
{ if (__threads) _S_node_allocator_lock._M_acquire_lock(); }
# define __NODE_ALLOCATOR_UNLOCK \
{ if (threads) _S_node_allocator_lock._M_release_lock(); }
{ if (__threads) _S_node_allocator_lock._M_release_lock(); }
# endif
#else
// Thread-unsafe
@ -97,7 +109,13 @@
namespace std
{
// A new-based allocator, as required by the standard.
/**
* @maint
* A new-based allocator, as required by the standard. Allocation and
* deallocation forward to global new and delete. "SGI" style, minus
* reallocate().
* @endmaint
*/
class __new_alloc
{
public:
@ -110,8 +128,16 @@ namespace std
{ ::operator delete(__p); }
};
// Malloc-based allocator. Typically slower than default alloc below.
// Typically thread-safe and more storage efficient.
/**
* @maint
* A malloc-based allocator. Typically slower than the
* __default_alloc_template (below). Typically thread-safe and more
* storage efficient. The template argument is unused and is only present
* to permit multiple instantiations (but see __default_alloc_template
* for caveats). "SGI" style, plus __set_malloc_handler for OOM conditions.
* @endmaint
*/
template <int __inst>
class __malloc_alloc_template
{
@ -191,127 +217,141 @@ namespace std
}
}
// Determines the underlying allocator choice.
# ifdef __USE_MALLOC
typedef __malloc_alloc_template<0> __mem_interface;
// Determines the underlying allocator choice for the node allocator.
#ifdef __USE_MALLOC
typedef __malloc_alloc_template<0> __mem_interface;
#else
typedef __new_alloc __mem_interface;
typedef __new_alloc __mem_interface;
#endif
template<class _Tp, class _Alloc>
class simple_alloc {
public:
/**
* This is used primarily (only?) in _Alloc_traits and other places to
* help provide the _Alloc_type typedef.
*
* This is neither "standard"-conforming nor "SGI". The _Alloc parameter
* must be "SGI" style.
*/
template<class _Tp, class _Alloc>
class __simple_alloc
{
public:
static _Tp* allocate(size_t __n)
{ return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); }
static _Tp* allocate(void)
{ return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }
{ return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); }
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)); }
{ if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }
static void deallocate(_Tp* __p)
{ _Alloc::deallocate(__p, sizeof (_Tp)); }
};
{ _Alloc::deallocate(__p, sizeof (_Tp)); }
};
// Allocator adaptor to check size arguments for debugging.
// Reports errors using assert. Checking can be disabled with
// NDEBUG, but it's far better to just use the underlying allocator
// instead when no checking is desired.
// There is some evidence that this can confuse Purify.
template <class _Alloc>
class debug_alloc {
private:
enum {_S_extra = 8}; // Size of space used to store size. Note
// that this must be large enough to preserve
// alignment.
public:
static void* allocate(size_t __n)
/**
* An adaptor for an underlying allocator (_Alloc) to check the size
* arguments for debugging. Errors are reported using assert; these
* checks can be disabled via NDEBUG, but the space penalty is still
* paid, therefore it is far better to just use the underlying allocator
* by itelf when no checking is desired.
*
* "There is some evidence that this can confuse Purify." - SGI comment
*
* This adaptor is "SGI" style. The _Alloc parameter must also be "SGI".
*/
template <class _Alloc>
class __debug_alloc
{
char* __result = (char*)_Alloc::allocate(__n + (int) _S_extra);
*(size_t*)__result = __n;
return __result + (int) _S_extra;
}
static void deallocate(void* __p, size_t __n)
{
char* __real_p = (char*)__p - (int) _S_extra;
assert(*(size_t*)__real_p == __n);
_Alloc::deallocate(__real_p, __n + (int) _S_extra);
}
static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz)
{
char* __real_p = (char*)__p - (int) _S_extra;
assert(*(size_t*)__real_p == __old_sz);
char* __result = (char*)
_Alloc::reallocate(__real_p, __old_sz + (int) _S_extra,
__new_sz + (int) _S_extra);
*(size_t*)__result = __new_sz;
return __result + (int) _S_extra;
}
};
private:
enum {_S_extra = 8}; // Size of space used to store size. Note that this
// must be large enough to preserve alignment.
public:
static void* allocate(size_t __n)
{
char* __result = (char*)_Alloc::allocate(__n + (int) _S_extra);
*(size_t*)__result = __n;
return __result + (int) _S_extra;
}
static void deallocate(void* __p, size_t __n)
{
char* __real_p = (char*)__p - (int) _S_extra;
assert(*(size_t*)__real_p == __n);
_Alloc::deallocate(__real_p, __n + (int) _S_extra);
}
static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz)
{
char* __real_p = (char*)__p - (int) _S_extra;
assert(*(size_t*)__real_p == __old_sz);
char* __result = (char*)
_Alloc::reallocate(__real_p, __old_sz + (int) _S_extra,
__new_sz + (int) _S_extra);
*(size_t*)__result = __new_sz;
return __result + (int) _S_extra;
}
};
# ifdef __USE_MALLOC
#ifdef __USE_MALLOC
typedef __mem_interface alloc;
typedef __mem_interface single_client_alloc;
# else
#else
// Default node allocator.
// With a reasonable compiler, this should be roughly as fast as the
// original STL class-specific allocators, but with less fragmentation.
// Default_alloc_template parameters are experimental and MAY
// DISAPPEAR in the future. Clients should just use alloc for now.
//
// Important implementation properties:
// 1. If the client request an object of size > _MAX_BYTES, the resulting
// object will be obtained directly from malloc.
// 2. In all other cases, we allocate an object of size exactly
// _S_round_up(requested_size). Thus the client has enough size
// information that we can return the object to the proper free list
// without permanently losing part of the object.
//
// The first template parameter specifies whether more than one thread
// may use this allocator. It is safe to allocate an object from
// one instance of a default_alloc and deallocate it with another
// one. This effectively transfers its ownership to the second one.
// This may have undesirable effects on reference locality.
// The second parameter is unreferenced and serves only to allow the
// creation of multiple default_alloc instances.
// Node that containers built on different allocator instances have
// different types, limiting the utility of this approach.
template <bool threads, int inst>
class __default_alloc_template {
/**
* @maint
* Default node allocator.
*
* Important implementation properties:
* 1. If the clients request an object of size > _MAX_BYTES, the resulting
* object will be obtained directly from malloc.
* 2. In all other cases, we allocate an object of size exactly
* _S_round_up(requested_size). Thus the client has enough size
* information that we can return the object to the proper free list
* without permanently losing part of the object.
*
* The first template parameter specifies whether more than one thread may
* use this allocator. It is safe to allocate an object from one instance
* of a default_alloc and deallocate it with another one. This effectively
* transfers its ownership to the second one. This may have undesirable
* effects on reference locality.
*
* The second parameter is unused and serves only to allow the creation of
* multiple default_alloc instances. Note that containers built on different
* allocator instances have different types, limiting the utility of this
* approach. If you do not wish to share the free lists with the main
* default_alloc instance, instantiate this with a non-zero __inst.
* @endmaint
*/
template <bool __threads, int __inst>
class __default_alloc_template
{
private:
// Really we should use static const int x = N
// instead of enum { x = N }, but few compilers accept the former.
enum {_ALIGN = 8};
enum {_MAX_BYTES = 128};
enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN
static size_t
_S_round_up(size_t __bytes)
{ return (((__bytes) + (size_t) _ALIGN-1) & ~((size_t) _ALIGN - 1)); }
union _Obj {
union _Obj* _M_free_list_link;
char _M_client_data[1]; /* The client sees this. */
union _Obj* _M_free_list_link;
char _M_client_data[1]; // The client sees this.
};
static _Obj* volatile _S_free_list[];
// Specifying a size results in duplicate def for 4.1
static size_t _S_freelist_index(size_t __bytes) {
return (((__bytes) + (size_t)_ALIGN-1)/(size_t)_ALIGN - 1);
}
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);
@ -324,24 +364,24 @@ private:
static char* _S_end_free;
static size_t _S_heap_size;
# ifdef __STL_THREADS
#ifdef __STL_THREADS
static _STL_mutex_lock _S_node_allocator_lock;
# endif
#endif
// It would be nice to use _STL_auto_lock here. But we
// don't need the NULL check. And we do need a test whether
// threads have actually been started.
class _Lock;
friend class _Lock;
class _Lock {
public:
_Lock() { __NODE_ALLOCATOR_LOCK; }
~_Lock() { __NODE_ALLOCATOR_UNLOCK; }
};
// It would be nice to use _STL_auto_lock here. But we
// don't need the NULL check. And we do need a test whether
// threads have actually been started.
class _Lock;
friend class _Lock;
class _Lock {
public:
_Lock() { __NODE_ALLOCATOR_LOCK; }
~_Lock() { __NODE_ALLOCATOR_UNLOCK; }
};
public:
/* __n must be > 0 */
// __n must be > 0
static void* allocate(size_t __n)
{
void* __ret = 0;
@ -358,7 +398,7 @@ public:
/*REFERENCED*/
_Lock __lock_instance;
# endif
_Obj* __RESTRICT __result = *__my_free_list;
_Obj* __restrict__ __result = *__my_free_list;
if (__result == 0)
__ret = _S_refill(_S_round_up(__n));
else
@ -371,7 +411,7 @@ public:
return __ret;
};
/* __p may not be 0 */
// __p may not be 0
static void deallocate(void* __p, size_t __n)
{
if (__n > (size_t) _MAX_BYTES)
@ -396,8 +436,6 @@ public:
static void* reallocate(void* __p, size_t __old_sz, size_t __new_sz);
};
typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;
typedef __default_alloc_template<false, 0> single_client_alloc;
template <bool __threads, int __inst>
inline bool operator==(const __default_alloc_template<__threads, __inst>&,
@ -414,11 +452,9 @@ inline bool operator!=(const __default_alloc_template<__threads, __inst>&,
}
/* We allocate memory in large chunks in order to avoid fragmenting */
/* the malloc heap too much. */
/* We assume that size is properly aligned. */
/* We hold the allocation lock. */
// 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,
@ -492,9 +528,8 @@ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
}
/* Returns an object of size __n, and optionally adds to size __n free list.*/
/* We assume that __n is properly aligned. */
/* We hold the allocation lock. */
// 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)
@ -526,6 +561,7 @@ __default_alloc_template<__threads, __inst>::_S_refill(size_t __n)
return(__result);
}
template <bool threads, int inst>
void*
__default_alloc_template<threads, inst>::reallocate(void* __p,
@ -567,23 +603,35 @@ 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
] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
// 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.
] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// __NODE_ALLOCATOR_THREADS is predicated on __STL_THREADS being defined or not
typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;
typedef __default_alloc_template<false, 0> single_client_alloc;
#endif /* ! __USE_MALLOC */
// This implements allocators as specified in the C++ standard.
//
// Note that standard-conforming allocators use many language features
// that are not yet widely implemented. In particular, they rely on
// member templates, partial specialization, partial ordering of function
// templates, the typename keyword, and the use of the template keyword
// to refer to a template member of a dependent type.
/**
* This is a "standard" allocator, as per [20.4]. The private _Alloc is
* "SGI" style. (See comments at the top of stl_alloc.h.)
*
* The underlying allocator behaves as follows.
* - if __USE_MALLOC then
* - thread safety depends on malloc and is entirely out of our hands
* - __malloc_alloc_template is used for memory requests
* - else (the default)
* - __default_alloc_template is used via two typedefs
* - "single_client_alloc" typedef does no locking for threads
* - "alloc" typedef is threadsafe via the locks
* - __new_alloc is used for memory requests
*
*/
template <class _Tp>
class allocator {
class allocator
{
typedef alloc _Alloc; // The underlying allocator.
public:
typedef size_t size_type;
@ -651,15 +699,18 @@ inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&)
return false;
}
// 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>.
/**
* Allocator adaptor to turn an "SGI" style allocator (e.g. alloc,
* __malloc_alloc_template) into a "standard" conformaing 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>.
*/
template <class _Tp, class _Alloc>
struct __allocator {
struct __allocator
{
_Alloc __underlying_alloc;
typedef size_t size_type;
@ -730,6 +781,7 @@ inline bool operator!=(const __allocator<_Tp, _Alloc>& __a1,
return __a1.__underlying_alloc != __a2.__underlying_alloc;
}
// Comparison operators for all of the predifined SGI-style allocators.
// This ensures that __allocator<malloc_alloc> (for example) will
// work correctly.
@ -749,17 +801,18 @@ inline bool operator!=(const __malloc_alloc_template<__inst>&,
}
template <class _Alloc>
inline bool operator==(const debug_alloc<_Alloc>&,
const debug_alloc<_Alloc>&) {
inline bool operator==(const __debug_alloc<_Alloc>&,
const __debug_alloc<_Alloc>&) {
return true;
}
template <class _Alloc>
inline bool operator!=(const debug_alloc<_Alloc>&,
const debug_alloc<_Alloc>&) {
inline bool operator!=(const __debug_alloc<_Alloc>&,
const __debug_alloc<_Alloc>&) {
return false;
}
// 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-conforming allocator.
@ -804,7 +857,7 @@ template <class _Tp, class _Tp1>
struct _Alloc_traits<_Tp, allocator<_Tp1> >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, alloc> _Alloc_type;
typedef __simple_alloc<_Tp, alloc> _Alloc_type;
typedef allocator<_Tp> allocator_type;
};
@ -814,7 +867,7 @@ template <class _Tp, int __inst>
struct _Alloc_traits<_Tp, __malloc_alloc_template<__inst> >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;
typedef __simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;
typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type;
};
@ -823,7 +876,7 @@ template <class _Tp, bool __threads, int __inst>
struct _Alloc_traits<_Tp, __default_alloc_template<__threads, __inst> >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, __default_alloc_template<__threads, __inst> >
typedef __simple_alloc<_Tp, __default_alloc_template<__threads, __inst> >
_Alloc_type;
typedef __allocator<_Tp, __default_alloc_template<__threads, __inst> >
allocator_type;
@ -831,11 +884,11 @@ struct _Alloc_traits<_Tp, __default_alloc_template<__threads, __inst> >
#endif
template <class _Tp, class _Alloc>
struct _Alloc_traits<_Tp, debug_alloc<_Alloc> >
struct _Alloc_traits<_Tp, __debug_alloc<_Alloc> >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type;
typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type;
typedef __simple_alloc<_Tp, __debug_alloc<_Alloc> > _Alloc_type;
typedef __allocator<_Tp, __debug_alloc<_Alloc> > allocator_type;
};
// Versions for the __allocator adaptor used with the predefined
@ -846,7 +899,7 @@ struct _Alloc_traits<_Tp,
__allocator<_Tp1, __malloc_alloc_template<__inst> > >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;
typedef __simple_alloc<_Tp, __malloc_alloc_template<__inst> > _Alloc_type;
typedef __allocator<_Tp, __malloc_alloc_template<__inst> > allocator_type;
};
@ -857,7 +910,7 @@ struct _Alloc_traits<_Tp,
__default_alloc_template<__thr, __inst> > >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, __default_alloc_template<__thr,__inst> >
typedef __simple_alloc<_Tp, __default_alloc_template<__thr,__inst> >
_Alloc_type;
typedef __allocator<_Tp, __default_alloc_template<__thr,__inst> >
allocator_type;
@ -865,11 +918,11 @@ struct _Alloc_traits<_Tp,
#endif
template <class _Tp, class _Tp1, class _Alloc>
struct _Alloc_traits<_Tp, __allocator<_Tp1, debug_alloc<_Alloc> > >
struct _Alloc_traits<_Tp, __allocator<_Tp1, __debug_alloc<_Alloc> > >
{
static const bool _S_instanceless = true;
typedef simple_alloc<_Tp, debug_alloc<_Alloc> > _Alloc_type;
typedef __allocator<_Tp, debug_alloc<_Alloc> > allocator_type;
typedef __simple_alloc<_Tp, __debug_alloc<_Alloc> > _Alloc_type;
typedef __allocator<_Tp, __debug_alloc<_Alloc> > allocator_type;
};
} // namespace std

View File

@ -67,10 +67,10 @@
namespace std
{
/**
* Invoke an allocated object's constructor with an initializer.
*
* This function is not part of the C++ standard but is used internally
* within the library.
* @maint
* Constructs an object in existing memory by invoking an allocated
* object's constructor with an initializer.
* @endmaint
*/
template <class _T1, class _T2>
inline void
@ -78,10 +78,10 @@ namespace std
{ new (static_cast<void*>(__p)) _T1(__value); }
/**
* Invoke an allocated object's constructor without an initializer.
*
* This function is not part of the C++ standard but is used internally
* within the library.
* @maint
* Constructs an object in existing memory by invoking an allocated
* object's default constructor (no initializers).
* @endmaint
*/
template <class _T1>
inline void
@ -89,9 +89,11 @@ namespace std
{ new (static_cast<void*>(__p)) _T1(); }
/**
* @maint
* Destroy a range of objects with nontrivial destructors.
*
* This is a helper function used only by _Destroy().
* @endmaint
*/
template <class _ForwardIterator>
inline void
@ -99,11 +101,13 @@ namespace std
{ for ( ; __first != __last; ++__first) _Destroy(&*__first); }
/**
* @maint
* Destroy a range of objects with trivial destructors. Since the destructors
* are trivial, there's nothing to do and hopefully this function will be
* entirely optimized away.
*
* This is a helper function used only by _Destroy().
* @endmaint
*/
template <class _ForwardIterator>
inline void
@ -111,10 +115,9 @@ namespace std
{ }
/**
* @maint
* Destroy the object pointed to by a pointer type.
*
* This function is not part of the C++ standard but is used internally
* within the library.
* @endmaint
*/
template <class _Tp>
inline void
@ -122,12 +125,11 @@ namespace std
{ __pointer->~_Tp(); }
/**
* @maint
* Destroy a range of objects. If the value_type of the object has
* a trivial destructor, the compiler should optimize all of this
* away, otherwise the objects' destructors must be invoked.
*
* This function is not part of the C++ standard but is used internally
* within the library.
* @endmaint
*/
template <class _ForwardIterator>
inline void