libiberty.texi 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. \input texinfo @c -*-texinfo-*-
  2. @c %**start of header
  3. @setfilename libiberty.info
  4. @settitle @sc{gnu} libiberty
  5. @c %**end of header
  6. @syncodeindex fn cp
  7. @syncodeindex vr cp
  8. @syncodeindex pg cp
  9. @finalout
  10. @c %**end of header
  11. @dircategory GNU libraries
  12. @direntry
  13. * Libiberty: (libiberty). Library of utility functions which
  14. are missing or broken on some systems.
  15. @end direntry
  16. @macro libib
  17. @code{libiberty}
  18. @end macro
  19. @ifinfo
  20. This manual describes the GNU @libib library of utility subroutines.
  21. Copyright @copyright{} 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  22. 2009, 2010 Free Software Foundation, Inc.
  23. Permission is granted to copy, distribute and/or modify this document
  24. under the terms of the GNU Free Documentation License, Version 1.3
  25. or any later version published by the Free Software Foundation;
  26. with no Invariant Sections, with no Front-Cover Texts, and with no
  27. Back-Cover Texts. A copy of the license is included in the
  28. section entitled ``GNU Free Documentation License''.
  29. @ignore
  30. Permission is granted to process this file through TeX and print the
  31. results, provided the printed document carries a copying permission
  32. notice identical to this one except for the removal of this paragraph
  33. (this paragraph not being relevant to the printed manual).
  34. @end ignore
  35. @end ifinfo
  36. @titlepage
  37. @title @sc{gnu} libiberty
  38. @author Phil Edwards et al.
  39. @page
  40. @vskip 0pt plus 1filll
  41. Copyright @copyright{} 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  42. 2009, 2010 Free Software Foundation, Inc.
  43. Permission is granted to copy, distribute and/or modify this document
  44. under the terms of the GNU Free Documentation License, Version 1.3
  45. or any later version published by the Free Software Foundation;
  46. with no Invariant Sections, with no Front-Cover Texts, and with no
  47. Back-Cover Texts. A copy of the license is included in the
  48. section entitled ``GNU Free Documentation License''.
  49. @end titlepage
  50. @contents
  51. @page
  52. @ifnottex
  53. @node Top,Using,,
  54. @top Introduction
  55. The @libib{} library is a collection of subroutines used by various
  56. GNU programs. It is available under the Library General Public
  57. License; for more information, see @ref{Library Copying}.
  58. @end ifnottex
  59. @menu
  60. * Using:: How to use libiberty in your code.
  61. * Overview:: Overview of available function groups.
  62. * Functions:: Available functions, macros, and global variables.
  63. * Licenses:: The various licenses under which libiberty sources are
  64. distributed.
  65. * Index:: Index of functions and categories.
  66. @end menu
  67. @node Using
  68. @chapter Using
  69. @cindex using libiberty
  70. @cindex libiberty usage
  71. @cindex how to use
  72. @c THIS SECTION IS CRAP AND NEEDS REWRITING BADLY.
  73. To date, @libib{} is generally not installed on its own. It has evolved
  74. over years but does not have its own version number nor release schedule.
  75. Possibly the easiest way to use @libib{} in your projects is to drop the
  76. @libib{} code into your project's sources, and to build the library along
  77. with your own sources; the library would then be linked in at the end. This
  78. prevents any possible version mismatches with other copies of libiberty
  79. elsewhere on the system.
  80. Passing @option{--enable-install-libiberty} to the @command{configure}
  81. script when building @libib{} causes the header files and archive library
  82. to be installed when @kbd{make install} is run. This option also takes
  83. an (optional) argument to specify the installation location, in the same
  84. manner as @option{--prefix}.
  85. For your own projects, an approach which offers stability and flexibility
  86. is to include @libib{} with your code, but allow the end user to optionally
  87. choose to use a previously-installed version instead. In this way the
  88. user may choose (for example) to install @libib{} as part of GCC, and use
  89. that version for all software built with that compiler. (This approach
  90. has proven useful with software using the GNU @code{readline} library.)
  91. Making use of @libib{} code usually requires that you include one or more
  92. header files from the @libib{} distribution. (They will be named as
  93. necessary in the function descriptions.) At link time, you will need to
  94. add @option{-liberty} to your link command invocation.
  95. @node Overview
  96. @chapter Overview
  97. Functions contained in @libib{} can be divided into three general categories.
  98. @menu
  99. * Supplemental Functions:: Providing functions which don't exist
  100. on older operating systems.
  101. * Replacement Functions:: These functions are sometimes buggy or
  102. unpredictable on some operating systems.
  103. * Extensions:: Functions which provide useful extensions
  104. or safety wrappers around existing code.
  105. @end menu
  106. @node Supplemental Functions
  107. @section Supplemental Functions
  108. @cindex supplemental functions
  109. @cindex functions, supplemental
  110. @cindex functions, missing
  111. Certain operating systems do not provide functions which have since
  112. become standardized, or at least common. For example, the Single
  113. Unix Specification Version 2 requires that the @code{basename}
  114. function be provided, but an OS which predates that specification
  115. might not have this function. This should not prevent well-written
  116. code from running on such a system.
  117. Similarly, some functions exist only among a particular ``flavor''
  118. or ``family'' of operating systems. As an example, the @code{bzero}
  119. function is often not present on systems outside the BSD-derived
  120. family of systems.
  121. Many such functions are provided in @libib{}. They are quickly
  122. listed here with little description, as systems which lack them
  123. become less and less common. Each function @var{foo} is implemented
  124. in @file{@var{foo}.c} but not declared in any @libib{} header file; more
  125. comments and caveats for each function's implementation are often
  126. available in the source file. Generally, the function can simply
  127. be declared as @code{extern}.
  128. @node Replacement Functions
  129. @section Replacement Functions
  130. @cindex replacement functions
  131. @cindex functions, replacement
  132. Some functions have extremely limited implementations on different
  133. platforms. Other functions are tedious to use correctly; for example,
  134. proper use of @code{malloc} calls for the return value to be checked and
  135. appropriate action taken if memory has been exhausted. A group of
  136. ``replacement functions'' is available in @libib{} to address these issues
  137. for some of the most commonly used subroutines.
  138. All of these functions are declared in the @file{libiberty.h} header
  139. file. Many of the implementations will use preprocessor macros set by
  140. GNU Autoconf, if you decide to make use of that program. Some of these
  141. functions may call one another.
  142. @menu
  143. * Memory Allocation:: Testing and handling failed memory
  144. requests automatically.
  145. * Exit Handlers:: Calling routines on program exit.
  146. * Error Reporting:: Mapping errno and signal numbers to
  147. more useful string formats.
  148. @end menu
  149. @node Memory Allocation
  150. @subsection Memory Allocation
  151. @cindex memory allocation
  152. The functions beginning with the letter @samp{x} are wrappers around
  153. standard functions; the functions provided by the system environment
  154. are called and their results checked before the results are passed back
  155. to client code. If the standard functions fail, these wrappers will
  156. terminate the program. Thus, these versions can be used with impunity.
  157. @node Exit Handlers
  158. @subsection Exit Handlers
  159. @cindex exit handlers
  160. The existence and implementation of the @code{atexit} routine varies
  161. amongst the flavors of Unix. @libib{} provides an unvarying dependable
  162. implementation via @code{xatexit} and @code{xexit}.
  163. @node Error Reporting
  164. @subsection Error Reporting
  165. @cindex error reporting
  166. These are a set of routines to facilitate programming with the system
  167. @code{errno} interface. The @libib{} source file @file{strerror.c}
  168. contains a good deal of documentation for these functions.
  169. @c signal stuff
  170. @node Extensions
  171. @section Extensions
  172. @cindex extensions
  173. @cindex functions, extension
  174. @libib{} includes additional functionality above and beyond standard
  175. functions, which has proven generically useful in GNU programs, such as
  176. obstacks and regex. These functions are often copied from other
  177. projects as they gain popularity, and are included here to provide a
  178. central location from which to use, maintain, and distribute them.
  179. @menu
  180. * Obstacks:: Stacks of arbitrary objects.
  181. @end menu
  182. @c This is generated from the glibc manual using contrib/make-obstacks-texi.pl
  183. @include obstacks.texi
  184. @node Functions
  185. @chapter Function, Variable, and Macro Listing.
  186. @include functions.texi
  187. @node Licenses
  188. @appendix Licenses
  189. @menu
  190. * Library Copying:: The GNU Library General Public License
  191. * BSD:: Regents of the University of California
  192. @end menu
  193. @c This takes care of Library Copying. It is the copying-lib.texi from the
  194. @c GNU web site, with its @node line altered to make makeinfo shut up.
  195. @include copying-lib.texi
  196. @page
  197. @node BSD
  198. @appendixsec BSD
  199. Copyright @copyright{} 1990 Regents of the University of California.
  200. All rights reserved.
  201. Redistribution and use in source and binary forms, with or without
  202. modification, are permitted provided that the following conditions
  203. are met:
  204. @enumerate
  205. @item
  206. Redistributions of source code must retain the above copyright
  207. notice, this list of conditions and the following disclaimer.
  208. @item
  209. Redistributions in binary form must reproduce the above copyright
  210. notice, this list of conditions and the following disclaimer in the
  211. documentation and/or other materials provided with the distribution.
  212. @item
  213. [rescinded 22 July 1999]
  214. @item
  215. Neither the name of the University nor the names of its contributors
  216. may be used to endorse or promote products derived from this software
  217. without specific prior written permission.
  218. @end enumerate
  219. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  220. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  221. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  222. ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  223. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  224. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  225. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  226. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  227. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  228. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  229. SUCH DAMAGE.
  230. @node Index
  231. @unnumbered Index
  232. @printindex cp
  233. @bye