xref: /openbsd-src/gnu/lib/libiberty/src/libiberty.texi (revision 20fce977aadac3358da45d5027d7d19cdc03b0fe)
1*9588ddcfSespie\input texinfo  @c -*-texinfo-*-
2*9588ddcfSespie@c %**start of header
3*9588ddcfSespie@setfilename libiberty.info
4*9588ddcfSespie@settitle @sc{gnu} libiberty
5*9588ddcfSespie@c %**end of header
6*9588ddcfSespie
7*9588ddcfSespie@syncodeindex fn cp
8*9588ddcfSespie@syncodeindex vr cp
9*9588ddcfSespie@syncodeindex pg cp
10*9588ddcfSespie
11*9588ddcfSespie@finalout
12*9588ddcfSespie@c %**end of header
13*9588ddcfSespie
14*9588ddcfSespie@dircategory GNU libraries
15*9588ddcfSespie@direntry
16*9588ddcfSespie* Libiberty: (libiberty).          Library of utility functions which
17*9588ddcfSespie                                   are missing or broken on some systems.
18*9588ddcfSespie@end direntry
19*9588ddcfSespie
20*9588ddcfSespie@macro libib
21*9588ddcfSespie@code{libiberty}
22*9588ddcfSespie@end macro
23*9588ddcfSespie
24*9588ddcfSespie@c The edition date is written in three locations.  Search for 'thedate'.
25*9588ddcfSespie@ifinfo
26*9588ddcfSespieThis manual describes the GNU @libib library of utility subroutines.
27*9588ddcfSespieThis edition accompanies GCC 3, September 2001.
28*9588ddcfSespie
29*9588ddcfSespieCopyright @copyright{} 2001 Free Software Foundation, Inc.
30*9588ddcfSespie
31*9588ddcfSespie      Permission is granted to copy, distribute and/or modify this document
32*9588ddcfSespie      under the terms of the GNU Free Documentation License, Version 1.2
33*9588ddcfSespie      or any later version published by the Free Software Foundation;
34*9588ddcfSespie      with no Invariant Sections, with no Front-Cover Texts, and with no
35*9588ddcfSespie      Back-Cover Texts.  A copy of the license is included in the
36*9588ddcfSespie      section entitled ``GNU Free Documentation License''.
37*9588ddcfSespie
38*9588ddcfSespie@ignore
39*9588ddcfSespiePermission is granted to process this file through TeX and print the
40*9588ddcfSespieresults, provided the printed document carries a copying permission
41*9588ddcfSespienotice identical to this one except for the removal of this paragraph
42*9588ddcfSespie(this paragraph not being relevant to the printed manual).
43*9588ddcfSespie
44*9588ddcfSespie@end ignore
45*9588ddcfSespie@end ifinfo
46*9588ddcfSespie
47*9588ddcfSespie
48*9588ddcfSespie@c The edition date is written in three locations.  Search for 'thedate'.
49*9588ddcfSespie@titlepage
50*9588ddcfSespie@title @sc{gnu} libiberty
51*9588ddcfSespie@subtitle September 2001
52*9588ddcfSespie@subtitle for GCC 3
53*9588ddcfSespie@author Phil Edwards et al.
54*9588ddcfSespie@page
55*9588ddcfSespie
56*9588ddcfSespie
57*9588ddcfSespie@vskip 0pt plus 1filll
58*9588ddcfSespieCopyright @copyright{} 2001 Free Software Foundation, Inc.
59*9588ddcfSespie
60*9588ddcfSespie      Permission is granted to copy, distribute and/or modify this document
61*9588ddcfSespie      under the terms of the GNU Free Documentation License, Version 1.2
62*9588ddcfSespie      or any later version published by the Free Software Foundation;
63*9588ddcfSespie      with no Invariant Sections, with no Front-Cover Texts, and with no
64*9588ddcfSespie      Back-Cover Texts.  A copy of the license is included in the
65*9588ddcfSespie      section entitled ``GNU Free Documentation License''.
66*9588ddcfSespie
67*9588ddcfSespie@end titlepage
68*9588ddcfSespie@contents
69*9588ddcfSespie@page
70*9588ddcfSespie
71*9588ddcfSespie@ifnottex
72*9588ddcfSespie@node    Top,Using,,
73*9588ddcfSespie@top     Introduction
74*9588ddcfSespie
75*9588ddcfSespieThe @libib{} library is a collection of subroutines used by various
76*9588ddcfSespieGNU programs.  It is available under the Library General Public
77*9588ddcfSespieLicense; for more information, see @ref{Library Copying}.
78*9588ddcfSespie
79*9588ddcfSespie@c The edition date is written in three locations.  Search for 'thedate'.
80*9588ddcfSespieThis edition accompanies GCC 3, September 2001.
81*9588ddcfSespie
82*9588ddcfSespie@end ifnottex
83*9588ddcfSespie
84*9588ddcfSespie@menu
85*9588ddcfSespie* Using::              How to use libiberty in your code.
86*9588ddcfSespie
87*9588ddcfSespie* Overview::           Overview of available function groups.
88*9588ddcfSespie
89*9588ddcfSespie* Functions::          Available functions, macros, and global variables.
90*9588ddcfSespie
91*9588ddcfSespie* Obstacks::           Object Stacks.
92*9588ddcfSespie
93*9588ddcfSespie* Licenses::           The various licenses under which libiberty sources are
94*9588ddcfSespie                       distributed.
95*9588ddcfSespie
96*9588ddcfSespie* Index::              Index of functions and categories.
97*9588ddcfSespie@end menu
98*9588ddcfSespie
99*9588ddcfSespie@node Using
100*9588ddcfSespie@chapter Using
101*9588ddcfSespie@cindex using libiberty
102*9588ddcfSespie@cindex libiberty usage
103*9588ddcfSespie@cindex how to use
104*9588ddcfSespie
105*9588ddcfSespie@c THIS SECTION IS CRAP AND NEEDS REWRITING BADLY.
106*9588ddcfSespie
107*9588ddcfSespieTo date, @libib{} is generally not installed on its own.  It has evolved
108*9588ddcfSespieover years but does not have its own version number nor release schedule.
109*9588ddcfSespie
110*9588ddcfSespiePossibly the easiest way to use @libib{} in your projects is to drop the
111*9588ddcfSespie@libib{} code into your project's sources, and to build the library along
112*9588ddcfSespiewith your own sources; the library would then be linked in at the end.  This
113*9588ddcfSespieprevents any possible version mismatches with other copies of libiberty
114*9588ddcfSespieelsewhere on the system.
115*9588ddcfSespie
116*9588ddcfSespiePassing @option{--enable-install-libiberty} to the @command{configure}
117*9588ddcfSespiescript when building @libib{} causes the header files and archive library
118*9588ddcfSespieto be installed when @kbd{make install} is run.  This option also takes
119*9588ddcfSespiean (optional) argument to specify the installation location, in the same
120*9588ddcfSespiemanner as @option{--prefix}.
121*9588ddcfSespie
122*9588ddcfSespieFor your own projects, an approach which offers stability and flexibility
123*9588ddcfSespieis to include @libib{} with your code, but allow the end user to optionally
124*9588ddcfSespiechoose to use a previously-installed version instead.  In this way the
125*9588ddcfSespieuser may choose (for example) to install @libib{} as part of GCC, and use
126*9588ddcfSespiethat version for all software built with that compiler.  (This approach
127*9588ddcfSespiehas proven useful with software using the GNU @code{readline} library.)
128*9588ddcfSespie
129*9588ddcfSespieMaking use of @libib{} code usually requires that you include one or more
130*9588ddcfSespieheader files from the @libib{} distribution.  (They will be named as
131*9588ddcfSespienecessary in the function descriptions.)  At link time, you will need to
132*9588ddcfSespieadd @option{-liberty} to your link command invocation.
133*9588ddcfSespie
134*9588ddcfSespie
135*9588ddcfSespie@node Overview
136*9588ddcfSespie@chapter Overview
137*9588ddcfSespie
138*9588ddcfSespieFunctions contained in @libib{} can be divided into three general categories.
139*9588ddcfSespie
140*9588ddcfSespie
141*9588ddcfSespie@menu
142*9588ddcfSespie* Supplemental Functions::       Providing functions which don't exist
143*9588ddcfSespie                                 on older operating systems.
144*9588ddcfSespie
145*9588ddcfSespie* Replacement Functions::        These functions are sometimes buggy or
146*9588ddcfSespie                                 unpredictable on some operating systems.
147*9588ddcfSespie
148*9588ddcfSespie* Extensions::                   Functions which provide useful extensions
149*9588ddcfSespie                                 or safety wrappers around existing code.
150*9588ddcfSespie@end menu
151*9588ddcfSespie
152*9588ddcfSespie@node Supplemental Functions
153*9588ddcfSespie@section Supplemental Functions
154*9588ddcfSespie@cindex supplemental functions
155*9588ddcfSespie@cindex functions, supplemental
156*9588ddcfSespie@cindex functions, missing
157*9588ddcfSespie
158*9588ddcfSespieCertain operating systems do not provide functions which have since
159*9588ddcfSespiebecome standardized, or at least common.  For example, the Single
160*9588ddcfSespieUnix Specification Version 2 requires that the @code{basename}
161*9588ddcfSespiefunction be provided, but an OS which predates that specification
162*9588ddcfSespiemight not have this function.  This should not prevent well-written
163*9588ddcfSespiecode from running on such a system.
164*9588ddcfSespie
165*9588ddcfSespieSimilarly, some functions exist only among a particular ``flavor''
166*9588ddcfSespieor ``family'' of operating systems.  As an example, the @code{bzero}
167*9588ddcfSespiefunction is often not present on systems outside the BSD-derived
168*9588ddcfSespiefamily of systems.
169*9588ddcfSespie
170*9588ddcfSespieMany such functions are provided in @libib{}.  They are quickly
171*9588ddcfSespielisted here with little description, as systems which lack them
172*9588ddcfSespiebecome less and less common.  Each function @var{foo} is implemented
173*9588ddcfSespiein @file{@var{foo}.c} but not declared in any @libib{} header file; more
174*9588ddcfSespiecomments and caveats for each function's implementation are often
175*9588ddcfSespieavailable in the source file.  Generally, the function can simply
176*9588ddcfSespiebe declared as @code{extern}.
177*9588ddcfSespie
178*9588ddcfSespie
179*9588ddcfSespie
180*9588ddcfSespie@node Replacement Functions
181*9588ddcfSespie@section Replacement Functions
182*9588ddcfSespie@cindex replacement functions
183*9588ddcfSespie@cindex functions, replacement
184*9588ddcfSespie
185*9588ddcfSespieSome functions have extremely limited implementations on different
186*9588ddcfSespieplatforms.  Other functions are tedious to use correctly; for example,
187*9588ddcfSespieproper use of @code{malloc} calls for the return value to be checked and
188*9588ddcfSespieappropriate action taken if memory has been exhausted.  A group of
189*9588ddcfSespie``replacement functions'' is available in @libib{} to address these issues
190*9588ddcfSespiefor some of the most commonly used subroutines.
191*9588ddcfSespie
192*9588ddcfSespieAll of these functions are declared in the @file{libiberty.h} header
193*9588ddcfSespiefile.  Many of the implementations will use preprocessor macros set by
194*9588ddcfSespieGNU Autoconf, if you decide to make use of that program.  Some of these
195*9588ddcfSespiefunctions may call one another.
196*9588ddcfSespie
197*9588ddcfSespie
198*9588ddcfSespie@menu
199*9588ddcfSespie* Memory Allocation::            Testing and handling failed memory
200*9588ddcfSespie                                   requests automatically.
201*9588ddcfSespie* Exit Handlers::                Calling routines on program exit.
202*9588ddcfSespie* Error Reporting::              Mapping errno and signal numbers to
203*9588ddcfSespie                                   more useful string formats.
204*9588ddcfSespie@end menu
205*9588ddcfSespie
206*9588ddcfSespie@node Memory Allocation
207*9588ddcfSespie@subsection Memory Allocation
208*9588ddcfSespie@cindex memory allocation
209*9588ddcfSespie
210*9588ddcfSespieThe functions beginning with the letter @samp{x} are wrappers around
211*9588ddcfSespiestandard functions; the functions provided by the system environment
212*9588ddcfSespieare called and their results checked before the results are passed back
213*9588ddcfSespieto client code.  If the standard functions fail, these wrappers will
214*9588ddcfSespieterminate the program.  Thus, these versions can be used with impunity.
215*9588ddcfSespie
216*9588ddcfSespie
217*9588ddcfSespie@node Exit Handlers
218*9588ddcfSespie@subsection Exit Handlers
219*9588ddcfSespie@cindex exit handlers
220*9588ddcfSespie
221*9588ddcfSespieThe existence and implementation of the @code{atexit} routine varies
222*9588ddcfSespieamongst the flavors of Unix.  @libib{} provides an unvarying dependable
223*9588ddcfSespieimplementation via @code{xatexit} and @code{xexit}.
224*9588ddcfSespie
225*9588ddcfSespie
226*9588ddcfSespie@node Error Reporting
227*9588ddcfSespie@subsection Error Reporting
228*9588ddcfSespie@cindex error reporting
229*9588ddcfSespie
230*9588ddcfSespieThese are a set of routines to facilitate programming with the system
231*9588ddcfSespie@code{errno} interface.  The @libib{} source file @file{strerror.c}
232*9588ddcfSespiecontains a good deal of documentation for these functions.
233*9588ddcfSespie
234*9588ddcfSespie@c signal stuff
235*9588ddcfSespie
236*9588ddcfSespie
237*9588ddcfSespie@node Extensions
238*9588ddcfSespie@section Extensions
239*9588ddcfSespie@cindex extensions
240*9588ddcfSespie@cindex functions, extension
241*9588ddcfSespie
242*9588ddcfSespie@libib{} includes additional functionality above and beyond standard
243*9588ddcfSespiefunctions, which has proven generically useful in GNU programs, such as
244*9588ddcfSespieobstacks and regex.  These functions are often copied from other
245*9588ddcfSespieprojects as they gain popularity, and are included here to provide a
246*9588ddcfSespiecentral location from which to use, maintain, and distribute them.
247*9588ddcfSespie
248*9588ddcfSespie@menu
249*9588ddcfSespie* Obstacks::                     Stacks of arbitrary objects.
250*9588ddcfSespie@end menu
251*9588ddcfSespie
252*9588ddcfSespie@c This is generated from the glibc manual using a make-obstacks-texi.sh
253*9588ddcfSespie@c script of Phil's.  Hope it's accurate.
254*9588ddcfSespie@include obstacks.texi
255*9588ddcfSespie
256*9588ddcfSespie@node Functions
257*9588ddcfSespie@chapter Function, Variable, and Macro Listing.
258*9588ddcfSespie@include functions.texi
259*9588ddcfSespie
260*9588ddcfSespie@node Licenses
261*9588ddcfSespie@appendix Licenses
262*9588ddcfSespie
263*9588ddcfSespie@menu
264*9588ddcfSespie
265*9588ddcfSespie* Library Copying::   The GNU Library General Public License
266*9588ddcfSespie* BSD::               Regents of the University of California
267*9588ddcfSespie
268*9588ddcfSespie@end menu
269*9588ddcfSespie
270*9588ddcfSespie@c This takes care of Library Copying.  It is the copying-lib.texi from the
271*9588ddcfSespie@c GNU web site, with its @node line altered to make makeinfo shut up.
272*9588ddcfSespie@include copying-lib.texi
273*9588ddcfSespie
274*9588ddcfSespie@page
275*9588ddcfSespie@node BSD
276*9588ddcfSespie@appendixsec BSD
277*9588ddcfSespie
278*9588ddcfSespieCopyright @copyright{} 1990 Regents of the University of California.
279*9588ddcfSespieAll rights reserved.
280*9588ddcfSespie
281*9588ddcfSespieRedistribution and use in source and binary forms, with or without
282*9588ddcfSespiemodification, are permitted provided that the following conditions
283*9588ddcfSespieare met:
284*9588ddcfSespie
285*9588ddcfSespie@enumerate
286*9588ddcfSespie
287*9588ddcfSespie@item
288*9588ddcfSespieRedistributions of source code must retain the above copyright
289*9588ddcfSespienotice, this list of conditions and the following disclaimer.
290*9588ddcfSespie
291*9588ddcfSespie@item
292*9588ddcfSespieRedistributions in binary form must reproduce the above copyright
293*9588ddcfSespienotice, this list of conditions and the following disclaimer in the
294*9588ddcfSespiedocumentation and/or other materials provided with the distribution.
295*9588ddcfSespie
296*9588ddcfSespie@item
297*9588ddcfSespie[rescinded 22 July 1999]
298*9588ddcfSespie
299*9588ddcfSespie@item
300*9588ddcfSespieNeither the name of the University nor the names of its contributors
301*9588ddcfSespiemay be used to endorse or promote products derived from this software
302*9588ddcfSespiewithout specific prior written permission.
303*9588ddcfSespie
304*9588ddcfSespie@end enumerate
305*9588ddcfSespie
306*9588ddcfSespieTHIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
307*9588ddcfSespieANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
308*9588ddcfSespieIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
309*9588ddcfSespieARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
310*9588ddcfSespieFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311*9588ddcfSespieDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
312*9588ddcfSespieOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
313*9588ddcfSespieHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
314*9588ddcfSespieLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
315*9588ddcfSespieOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
316*9588ddcfSespieSUCH DAMAGE.
317*9588ddcfSespie
318*9588ddcfSespie@node Index
319*9588ddcfSespie@unnumbered Index
320*9588ddcfSespie
321*9588ddcfSespie@printindex cp
322*9588ddcfSespie
323*9588ddcfSespie@bye
324*9588ddcfSespie
325