libiberty.texi 11 KB

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