OSDN Git Service

f284aa5b2b23bd267dd2911a81832a8438cdc1b9
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / docs / html / 17_intro / howto.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
2 <HTML>
3 <HEAD>
4    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
5    <META NAME="AUTHOR" CONTENT="pme@sources.redhat.com (Phil Edwards)">
6    <META NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, gcc, g++, libg++, STL">
7    <META NAME="DESCRIPTION" CONTENT="HOWTO for libstdc++ chapter 17.">
8    <META NAME="GENERATOR" CONTENT="vi and eight fingers">
9    <TITLE>libstdc++-v3 HOWTO:  Chapter 17</TITLE>
10 <LINK REL=StyleSheet HREF="../lib3styles.css">
11 <!-- $Id: howto.html,v 1.3 2001/05/30 08:30:02 ljrittle Exp $ -->
12 </HEAD>
13 <BODY>
14
15 <H1 CLASS="centered"><A NAME="top">Chapter 17:  Library Introduction</A></H1>
16
17 <P>Chapter 17 is actually a list of definitions and descriptions used
18    in the following chapters of the Standard when describing the actual
19    library.  Here, we use &quot;Introduction&quot; as an introduction
20    to the <EM>GNU implementation of</EM> the ISO Standard C++ Library.
21 </P>
22
23
24 <!-- ####################################################### -->
25 <HR>
26 <H1>Contents</H1>
27 <UL>
28    <LI><A HREF="#2">The Standard C++ header files</A>
29    <LI><A HREF="#3">Thread-safety</A>
30    <LI><A HREF="#4"><TT>&lt;foo&gt;</TT> vs <TT>&lt;foo.h&gt;</TT></A>
31    <LI><A HREF="porting-howto.html">Porting-howto</A>
32 </UL>
33
34 <HR>
35
36 <!-- ####################################################### -->
37
38 <H2><A NAME="2">The Standard C++ header files</A></H2>
39    <P>The Standard C++ Library specifies 50 header files that must be
40       available to all hosted implementations.  Actually, the word
41       &quot;files&quot; is a misnomer, since the contents of the headers
42       don't necessarily have to be in any kind of external file.  The
43       only rule is that when you <TT>#include</TT> a certain header, the
44       contents of that header, as defined by the Standard, become
45       available to you, no matter how.
46    </P>
47    <P>The names of the headers can be easily seen in
48       <A HREF="headers_cc.txt"><TT>testsuite/17_intro/headers.cc</TT></A>,
49       which is a small testbed we use to make certain that the headers
50       all compile and run.
51    </P>
52
53 <HR>
54 <H2><A NAME="3">Thread-safety</A></H2>
55    <P>This is a thorny issue that gets brought up on the libstdc++-v3
56       and gcc mailing lists on a regular basis (probably by a cron job).
57       This entry will mention a very little bit about the general MT
58       issues with libstdc++.  The latest status and quick notes will be
59       in FAQ 5.6.  Some discussion about thread-safe containers will be
60       in section 6.8 (the HOWTOs on containers).
61    </P>
62    <P>The libstdc++ code (all of it, not just the containers) has been
63       designed so that thread-safety will be easily possible.  The first
64       (!) problem is finding a <EM>fast</EM> method of implementation
65       portable to all platforms.  A minor problem that pops up every so
66       often is different interpretations of what &quot;thread-safe&quot;
67       means for a library (not a general program).  We currently use the
68       <A HREF="http://www.sgi.com/tech/stl/thread_safety.html">same
69       definition that SGI</A> uses for their STL subset.
70    </P>
71    <P>A recent journal article has described &quot;atomic integer
72       operations,&quot; which would allow us to, well, perform updates
73       on integers atomically, and without requiring an explicit mutex
74       lock.  This appears promising, but the major difficulty is that
75       these operations &quot;may not be available on all systems, and
76       if they are, may have different interfaces.&quot; [quoting from
77       mailing list messages]
78    </P>
79    <P>Here is a small link farm to threads (no pun) in the mail archives
80       that discuss the threading problem.  Each link is to the first
81       relevent message in the thread; from there you can use
82       &quot;Thread Next&quot; to move down the thread.  This farm is in
83       latest-to-oldest order.
84       <UL>
85         <LI>
86       </UL>
87       <BR>
88       Here are discussions that took place before the current snapshot;
89       they are still relevant and instructive.
90       <BR>
91       <UL>
92         <LI>One way of preventing memory leaks by the old default memory
93             allocator in multithreaded code is
94             <A HREF="http://gcc.gnu.org/ml/gcc/1999-11n/msg00431.html">discussed here</A>.
95         <LI><A HREF="http://gcc.gnu.org/ml/libstdc++/1999-q3/msg00167.html">This thread
96             concerns strings</A>.
97         <LI><A HREF="http://gcc.gnu.org/ml/libstdc++/1999-q2/msg00339.html">So does this
98             one</A>.  This initial message also refers to another
99             thread in the GCC mailing list...
100         <LI><A HREF="http://gcc.gnu.org/ml/gcc/1999-06n/msg00680.html">which is here</A>,
101             and goes on for some time.  Ironically, the initial message
102             in this thread also mentions another threading thread...
103         <LI><A HREF="http://gcc.gnu.org/ml/gcc-bugs/1999-04n/msg00777.html">beginning here</A>,
104             and talking about pthreads.  (Note that a much more recent
105             message from the first thread in this list notes that
106             <A HREF="http://gcc.gnu.org/ml/libstdc++/1999-q3/msg00176.html">pthreads
107             should not be used as a starting point</A> for making
108             libstdc++ threadsafe.)
109         <LI><A HREF="http://gcc.gnu.org/ml/libstdc++/1999-q2/msg00168.html">This
110             message</A>,
111             <A HREF="http://gcc.gnu.org/ml/libstdc++/1999-q2/msg00159.html">this one</A>,
112             and <A HREF="http://gcc.gnu.org/ml/libstdc++/1999-q2/msg00156.html">this one</A>
113             are the tops of related threads (all within the same time
114             period) discussing threading and the IO library.  Much of it
115             is dealing with the C library, but C++ is included as well.
116       </UL>
117    </P>
118    <P>This section will be updated as new and interesting issues come
119       to light.
120    </P>
121    <P>Return <A HREF="#top">to top of page</A> or
122       <A HREF="../faq/index.html">to the FAQ</A>.
123    </P>
124
125 <HR>
126 <H2><A NAME="4"><TT>&lt;foo&gt;</TT> vs <TT>&lt;foo.h&gt;</TT></A></H2>
127    <P>The new-style headers are fully supported in libstdc++-v3.  The compiler
128       itself fully supports namespaces, including <TT>std::</TT>.
129    </P>
130    <P>For those of you new to ISO C++98, no, that isn't a typo, the headers
131       really have new names.  Marshall Cline's C++ FAQ Lite has a good
132       explanation in
133 <A HREF="http://www.cerfnet.com/~mpcline/On-Line-C++-FAQ/coding-standards.html#[25.4]">item [25.4]</A>.
134    </P>
135    <P>Return <A HREF="#top">to top of page</A> or
136       <A HREF="../faq/index.html">to the FAQ</A>.
137    </P>
138
139
140
141 <!-- ####################################################### -->
142
143 <HR>
144 <P CLASS="fineprint"><EM>
145 Comments and suggestions are welcome, and may be sent to
146 <A HREF="mailto:libstdc++@gcc.gnu.org">the mailing list</A>.
147 <BR> $Id: howto.html,v 1.3 2001/05/30 08:30:02 ljrittle Exp $
148 </EM></P>
149
150
151 </BODY>
152 </HTML>
153
154