8 * libc: (libc). The ANSI C library.
14 This file documents the ANSI C library.
16 Copyright (C) 1992, 1993, 1994-2014 Red Hat, Inc.
18 @file{libc} includes software developed by the
19 University of California, Berkeley and its contributors.
21 libc includes software developed by Martin Jackson, Graham Haley
22 and Steve Chamberlain of Tadpole Technology and released to Cygnus.
24 libc uses floating-point conversion software developed at AT&T, which
25 includes this copyright information:
27 The author of this software is David M. Gay.
29 Copyright (c) 1991 by AT&T.
31 Permission to use, copy, modify, and distribute this software for any
32 purpose without fee is hereby granted, provided that this entire notice
33 is included in all copies of any software which is or includes a copy
34 or modification of this software and in all copies of the supporting
35 documentation for such software.
37 THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
38 WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
39 REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
40 OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
42 Permission is granted to make and distribute verbatim copies of
43 this manual provided the copyright notice and this permission notice
44 are preserved on all copies.
47 Permission is granted to process this file through Tex and print the
48 results, provided the printed document carries copying permission
49 notice identical to this one except for the removal of this paragraph
50 (this paragraph not being relevant to the printed manual).
53 Permission is granted to copy and distribute modified versions of this
54 manual under the conditions for verbatim copying, subject to the terms
55 of the GNU General Public License, which includes the provision that the
56 entire resulting derived work is distributed under the terms of a
57 permission notice identical to this one.
59 Permission is granted to copy and distribute translations of this manual
60 into another language, under the above conditions for modified versions.
66 @setchapternewpage odd
67 @settitle Red Hat newlib C Library, Full
69 @title The Red Hat newlib C Library
70 @subtitle Full Configuration
72 @subtitle @code{libc} 4.5.0
73 @subtitle December 2024
74 @author Steve Chamberlain
76 @author Red Hat Support
82 sac@@cygnus.com, pesch@@cygnus.com, jjohnstn@@redhat.com\hfill {\it The Red Hat newlib C Library}\par
83 Copyright \copyright{} 1992, 1993, 1994-2004 Red Hat Inc.
85 \global\parindent=0pt % Steve likes it this way
88 @file{libc} includes software developed by the
89 University of California, Berkeley and its contributors.
91 @file{libc} includes software developed by Martin Jackson, Graham Haley
92 and Steve Chamberlain of Tadpole Technology and released to Cygnus.
94 @file{libc} uses floating-point conversion software developed at AT&T,
95 which includes this copyright information:
99 The author of this software is David M. Gay.
101 Copyright (c) 1991 by AT&T.
103 Permission to use, copy, modify, and distribute this software for any
104 purpose without fee is hereby granted, provided that this entire notice
105 is included in all copies of any software which is or includes a copy
106 or modification of this software and in all copies of the supporting
107 documentation for such software.
109 THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
110 WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
111 REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
112 OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
116 Permission is granted to make and distribute verbatim copies of
117 this manual provided the copyright notice and this permission notice
118 are preserved on all copies.
120 Permission is granted to copy and distribute modified versions of this
121 manual under the conditions for verbatim copying, subject to the terms
122 of the GNU General Public License, which includes the provision that the
123 entire resulting derived work is distributed under the terms of a
124 permission notice identical to this one.
126 Permission is granted to copy and distribute translations of this manual
127 into another language, under the above conditions for modified versions.
133 @top The Red Hat newlib C Library
154 * Encoding conversions::
155 * Overflow Protection::
163 @chapter Introduction
165 This reference manual describes the functions provided by the Red Hat
166 ``newlib'' version of the standard ANSI C library. This document is not
167 intended as an overview or a tutorial for the C library. Each library
168 function is listed with a synopsis of its use, a brief description,
169 return values (including error handling), and portability issues.
171 Some of the library functions depend on support from the underlying
172 operating system and may not be available on every platform. For
173 embedded systems in particular, many of these underlying operating
174 system services may not be available or may not be fully functional.
175 The specific operating system subroutines required for a particular
176 library function are listed in the ``Portability'' section of the
177 function description. @xref{Syscalls}, for a description of the
178 relevant operating system calls.
180 @include targetdep.tex
183 @chapter Variable Argument Lists
185 The @code{printf} family of functions is defined to accept a variable
186 number of arguments, rather than a fixed argument list. You can define
187 your own functions with a variable argument list, by using macro
188 definitions from either @file{stdarg.h} (for compatibility with ANSI C)
189 or from @file{varargs.h} (for compatibility with a popular convention
198 @section ANSI-standard macros, @file{stdarg.h}
200 In ANSI C, a function has a variable number of arguments when its
201 parameter list ends in an ellipsis (@code{...}). The parameter list
202 must also include at least one explicitly named argument; that argument
203 is used to initialize the variable list data structure.
205 ANSI C defines three macros (@code{va_start}, @code{va_arg}, and
206 @code{va_end}) to operate on variable argument lists. @file{stdarg.h}
207 also defines a special type to represent variable argument lists: this
208 type is called @code{va_list}.
211 * Function va_start::
217 @node Function va_start
218 @subsection Initialize variable argument list
223 void va_start(va_list @var{ap}, @var{rightmost});
226 @strong{Description}@*
227 Use @code{va_start} to initialize the variable argument list @var{ap},
228 so that @code{va_arg} can extract values from it. @var{rightmost} is
229 the name of the last explicit argument in the parameter list (the
230 argument immediately preceding the ellipsis @samp{...} that flags
231 variable arguments in an ANSI C function header). You can only use
232 @code{va_start} in a function declared using this ellipsis notation
233 (not, for example, in one of its subfunctions).
236 @code{va_start} does not return a result.
238 @strong{Portability}@*
239 ANSI C requires @code{va_start}.
242 @node Function va_arg
243 @subsection Extract a value from argument list
248 @var{type} va_arg(va_list @var{ap}, @var{type});
251 @strong{Description}@*
252 @code{va_arg} returns the next unprocessed value from a variable
253 argument list @var{ap} (which you must previously create with
254 @var{va_start}). Specify the type for the value as the second parameter
255 to the macro, @var{type}.
257 You may pass a @code{va_list} object @var{ap} to a subfunction, and use
258 @code{va_arg} from the subfunction rather than from the function
259 actually declared with an ellipsis in the header; however, in that case
260 you may @emph{only} use @code{va_arg} from the subfunction. ANSI C does
261 not permit extracting successive values from a single variable-argument
262 list from different levels of the calling stack.
264 There is no mechanism for testing whether there is actually a next
265 argument available; you might instead pass an argument count (or some
266 other data that implies an argument count) as one of the fixed arguments
267 in your function call.
270 @code{va_arg} returns the next argument, an object of type @var{type}.
272 @strong{Portability}@*
273 ANSI C requires @code{va_arg}.
276 @node Function va_end
277 @subsection Abandon a variable argument list
282 void va_end(va_list @var{ap});
285 @strong{Description}@*
286 Use @code{va_end} to declare that your program will not use the variable
287 argument list @var{ap} any further.
290 @code{va_end} does not return a result.
292 @strong{Portability}@*
293 ANSI C requires @code{va_end}.
296 @section Traditional macros, @file{varargs.h}
298 If your C compiler predates ANSI C, you may still be able to use
299 variable argument lists using the macros from the @file{varargs.h}
300 header file. These macros resemble their ANSI counterparts, but have
301 important differences in usage. In particular, since traditional C has
302 no declaration mechanism for variable argument lists, two additional
303 macros are provided simply for the purpose of defining functions with
304 variable argument lists.
306 As with @file{stdarg.h}, the type @code{va_list} is used to hold a data
307 structure representing a variable argument list.
310 * Function va_alist::
311 * Function va_start-trad::
312 * Function va_arg-trad::
313 * Function va_end-trad::
317 @node Function va_alist
318 @subsection Declare variable arguments
324 @var{function}(va_alist)
328 @strong{Description}@*
329 To use the @file{varargs.h} version of variable argument lists, you must
330 declare your function with a call to the macro @code{va_alist} as its
331 argument list, and use @code{va_dcl} as the declaration. @emph{Do not
332 use a semicolon after @code{va_dcl}.}
335 These macros cannot be used in a context where a return is syntactically
338 @strong{Portability}@*
339 @var{va_alist} and @var{va_dcl} were the most widespread method of
340 declaring variable argument lists prior to ANSI C.
343 @node Function va_start-trad
344 @subsection Initialize variable argument list
353 @strong{Description}@*
354 With the @file{varargs.h} macros, use @code{va_start} to initialize a
355 data structure @var{ap} to permit manipulating a variable argument list.
356 @var{ap} must have the type @var{va_alist}.
359 @code{va_start} does not return a result.
361 @strong{Portability}@*
362 @code{va_start} is also defined as a macro in ANSI C, but the
363 definitions are incompatible; the ANSI version has another parameter
367 @node Function va_arg-trad
368 @subsection Extract a value from argument list
373 @var{type} va_arg(va_list @var{ap}, @var{type});
376 @strong{Description}@*
377 @code{va_arg} returns the next unprocessed value from a variable
378 argument list @var{ap} (which you must previously create with
379 @var{va_start}). Specify the type for the value as the second parameter
380 to the macro, @var{type}.
383 @code{va_arg} returns the next argument, an object of type @var{type}.
385 @strong{Portability}@*
386 The @code{va_arg} defined in @file{varargs.h} has the same syntax and
387 usage as the ANSI C version from @file{stdarg.h}.
390 @node Function va_end-trad
391 @subsection Abandon a variable argument list
396 va_end(va_list @var{ap});
399 @strong{Description}@*
400 Use @code{va_end} to declare that your program will not use the variable
401 argument list @var{ap} any further.
404 @code{va_end} does not return a result.
406 @strong{Portability}@*
407 The @code{va_end} defined in @file{varargs.h} has the same syntax and
408 usage as the ANSI C version from @file{stdarg.h}.
411 @unnumbered Document Index
415 @unnumbered Function Index
419 % I think something like @@colophon should be in texinfo. In the
421 \long\def\colophon{\hbox to0pt{}\vfill
422 \centerline{The body of this manual is set in}
423 \centerline{\fontname\tenrm,}
424 \centerline{with headings in {\bf\fontname\tenbf}}
425 \centerline{and examples in {\tt\fontname\tentt}.}
426 \centerline{{\it\fontname\tenit\/} and}
427 \centerline{{\sl\fontname\tensl\/}}
428 \centerline{are used for emphasis.}\vfill}
430 % Blame: pesch@@cygnus.com, 28mar91.