Fix bootstrap/PR63632
[official-gcc.git] / libiberty / functions.texi
blob387aee0bb9c39305573094c27628b4e7cff3c706
1 @c Automatically generated from *.c and others (the comments before
2 @c each entry tell you which file and where in that file).  DO NOT EDIT!
3 @c Edit the *.c files, configure with --enable-maintainer-mode,
4 @c run 'make stamp-functions' and gather-docs will build a new copy.
6 @c alloca.c:26
7 @deftypefn Replacement void* alloca (size_t @var{size})
9 This function allocates memory which will be automatically reclaimed
10 after the procedure exits.  The @libib{} implementation does not free
11 the memory immediately but will do so eventually during subsequent
12 calls to this function.  Memory is allocated using @code{xmalloc} under
13 normal circumstances.
15 The header file @file{alloca-conf.h} can be used in conjunction with the
16 GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make
17 available this function.  The @code{AC_FUNC_ALLOCA} test requires that
18 client code use a block of preprocessor code to be safe (see the Autoconf
19 manual for more); this header incorporates that logic and more, including
20 the possibility of a GCC built-in function.
22 @end deftypefn
24 @c asprintf.c:32
25 @deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...)
27 Like @code{sprintf}, but instead of passing a pointer to a buffer, you
28 pass a pointer to a pointer.  This function will compute the size of
29 the buffer needed, allocate memory with @code{malloc}, and store a
30 pointer to the allocated memory in @code{*@var{resptr}}.  The value
31 returned is the same as @code{sprintf} would return.  If memory could
32 not be allocated, minus one is returned and @code{NULL} is stored in
33 @code{*@var{resptr}}.
35 @end deftypefn
37 @c atexit.c:6
38 @deftypefn Supplemental int atexit (void (*@var{f})())
40 Causes function @var{f} to be called at exit.  Returns 0.
42 @end deftypefn
44 @c basename.c:6
45 @deftypefn Supplemental char* basename (const char *@var{name})
47 Returns a pointer to the last component of pathname @var{name}.
48 Behavior is undefined if the pathname ends in a directory separator.
50 @end deftypefn
52 @c bcmp.c:6
53 @deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})
55 Compares the first @var{count} bytes of two areas of memory.  Returns
56 zero if they are the same, nonzero otherwise.  Returns zero if
57 @var{count} is zero.  A nonzero result only indicates a difference,
58 it does not indicate any sorting order (say, by having a positive
59 result mean @var{x} sorts before @var{y}).
61 @end deftypefn
63 @c bcopy.c:3
64 @deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
66 Copies @var{length} bytes from memory region @var{in} to region
67 @var{out}.  The use of @code{bcopy} is deprecated in new programs.
69 @end deftypefn
71 @c bsearch.c:33
72 @deftypefn Supplemental void* bsearch (const void *@var{key}, @
73   const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, @
74   int (*@var{compar})(const void *, const void *))
76 Performs a search over an array of @var{nmemb} elements pointed to by
77 @var{base} for a member that matches the object pointed to by @var{key}.
78 The size of each member is specified by @var{size}.  The array contents
79 should be sorted in ascending order according to the @var{compar}
80 comparison function.  This routine should take two arguments pointing to
81 the @var{key} and to an array member, in that order, and should return an
82 integer less than, equal to, or greater than zero if the @var{key} object
83 is respectively less than, matching, or greater than the array member.
85 @end deftypefn
87 @c argv.c:135
88 @deftypefn Extension char** buildargv (char *@var{sp})
90 Given a pointer to a string, parse the string extracting fields
91 separated by whitespace and optionally enclosed within either single
92 or double quotes (which are stripped off), and build a vector of
93 pointers to copies of the string for each field.  The input string
94 remains unchanged.  The last element of the vector is followed by a
95 @code{NULL} element.
97 All of the memory for the pointer array and copies of the string
98 is obtained from @code{xmalloc}.  All of the memory can be returned to the
99 system with the single function call @code{freeargv}, which takes the
100 returned result of @code{buildargv}, as it's argument.
102 Returns a pointer to the argument vector if successful.  Returns
103 @code{NULL} if @var{sp} is @code{NULL} or if there is insufficient
104 memory to complete building the argument vector.
106 If the input is a null string (as opposed to a @code{NULL} pointer),
107 then buildarg returns an argument vector that has one arg, a null
108 string.
110 @end deftypefn
112 @c bzero.c:6
113 @deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})
115 Zeros @var{count} bytes starting at @var{mem}.  Use of this function
116 is deprecated in favor of @code{memset}.
118 @end deftypefn
120 @c calloc.c:6
121 @deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
123 Uses @code{malloc} to allocate storage for @var{nelem} objects of
124 @var{elsize} bytes each, then zeros the memory.
126 @end deftypefn
128 @c choose-temp.c:45
129 @deftypefn Extension char* choose_temp_base (void)
131 Return a prefix for temporary file names or @code{NULL} if unable to
132 find one.  The current directory is chosen if all else fails so the
133 program is exited if a temporary directory can't be found (@code{mktemp}
134 fails).  The buffer for the result is obtained with @code{xmalloc}.
136 This function is provided for backwards compatibility only.  Its use is
137 not recommended.
139 @end deftypefn
141 @c make-temp-file.c:96
142 @deftypefn Replacement const char* choose_tmpdir ()
144 Returns a pointer to a directory path suitable for creating temporary
145 files in.
147 @end deftypefn
149 @c clock.c:27
150 @deftypefn Supplemental long clock (void)
152 Returns an approximation of the CPU time used by the process as a
153 @code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the
154 number of seconds used.
156 @end deftypefn
158 @c concat.c:24
159 @deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @
160   @dots{}, @code{NULL})
162 Concatenate zero or more of strings and return the result in freshly
163 @code{xmalloc}ed memory.  The argument list is terminated by the first
164 @code{NULL} pointer encountered.  Pointers to empty strings are ignored.
166 @end deftypefn
168 @c argv.c:470
169 @deftypefn Extension int countargv (char **@var{argv})
171 Return the number of elements in @var{argv}.
172 Returns zero if @var{argv} is NULL.
174 @end deftypefn
176 @c crc32.c:141
177 @deftypefn Extension {unsigned int} crc32 (const unsigned char *@var{buf}, @
178   int @var{len}, unsigned int @var{init})
180 Compute the 32-bit CRC of @var{buf} which has length @var{len}.  The
181 starting value is @var{init}; this may be used to compute the CRC of
182 data split across multiple buffers by passing the return value of each
183 call as the @var{init} parameter of the next.
185 This is intended to match the CRC used by the @command{gdb} remote
186 protocol for the @samp{qCRC} command.  In order to get the same
187 results as gdb for a block of data, you must pass the first CRC
188 parameter as @code{0xffffffff}.
190 This CRC can be specified as:
192   Width  : 32
193   Poly   : 0x04c11db7
194   Init   : parameter, typically 0xffffffff
195   RefIn  : false
196   RefOut : false
197   XorOut : 0
199 This differs from the "standard" CRC-32 algorithm in that the values
200 are not reflected, and there is no final XOR value.  These differences
201 make it easy to compose the values of multiple blocks.
203 @end deftypefn
205 @c argv.c:52
206 @deftypefn Extension char** dupargv (char **@var{vector})
208 Duplicate an argument vector.  Simply scans through @var{vector},
209 duplicating each argument until the terminating @code{NULL} is found.
210 Returns a pointer to the argument vector if successful.  Returns
211 @code{NULL} if there is insufficient memory to complete building the
212 argument vector.
214 @end deftypefn
216 @c strerror.c:567
217 @deftypefn Extension int errno_max (void)
219 Returns the maximum @code{errno} value for which a corresponding
220 symbolic name or message is available.  Note that in the case where we
221 use the @code{sys_errlist} supplied by the system, it is possible for
222 there to be more symbolic names than messages, or vice versa.  In
223 fact, the manual page for @code{perror(3C)} explicitly warns that one
224 should check the size of the table (@code{sys_nerr}) before indexing
225 it, since new error codes may be added to the system before they are
226 added to the table.  Thus @code{sys_nerr} might be smaller than value
227 implied by the largest @code{errno} value defined in @code{<errno.h>}.
229 We return the maximum value that can be used to obtain a meaningful
230 symbolic name or message.
232 @end deftypefn
234 @c argv.c:341
235 @deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp})
237 The @var{argcp} and @code{argvp} arguments are pointers to the usual
238 @code{argc} and @code{argv} arguments to @code{main}.  This function
239 looks for arguments that begin with the character @samp{@@}.  Any such
240 arguments are interpreted as ``response files''.  The contents of the
241 response file are interpreted as additional command line options.  In
242 particular, the file is separated into whitespace-separated strings;
243 each such string is taken as a command-line option.  The new options
244 are inserted in place of the option naming the response file, and
245 @code{*argcp} and @code{*argvp} will be updated.  If the value of
246 @code{*argvp} is modified by this function, then the new value has
247 been dynamically allocated and can be deallocated by the caller with
248 @code{freeargv}.  However, most callers will simply call
249 @code{expandargv} near the beginning of @code{main} and allow the
250 operating system to free the memory when the program exits.
252 @end deftypefn
254 @c fdmatch.c:23
255 @deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2})
257 Check to see if two open file descriptors refer to the same file.
258 This is useful, for example, when we have an open file descriptor for
259 an unnamed file, and the name of a file that we believe to correspond
260 to that fd.  This can happen when we are exec'd with an already open
261 file (@code{stdout} for example) or from the SVR4 @file{/proc} calls
262 that return open file descriptors for mapped address spaces.  All we
263 have to do is open the file by name and check the two file descriptors
264 for a match, which is done by comparing major and minor device numbers
265 and inode numbers.
267 @end deftypefn
269 @c fopen_unlocked.c:49
270 @deftypefn Extension {FILE *} fdopen_unlocked (int @var{fildes}, @
271   const char * @var{mode})
273 Opens and returns a @code{FILE} pointer via @code{fdopen}.  If the
274 operating system supports it, ensure that the stream is setup to avoid
275 any multi-threaded locking.  Otherwise return the @code{FILE} pointer
276 unchanged.
278 @end deftypefn
280 @c ffs.c:3
281 @deftypefn Supplemental int ffs (int @var{valu})
283 Find the first (least significant) bit set in @var{valu}.  Bits are
284 numbered from right to left, starting with bit 1 (corresponding to the
285 value 1).  If @var{valu} is zero, zero is returned.
287 @end deftypefn
289 @c filename_cmp.c:32
290 @deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2})
292 Return zero if the two file names @var{s1} and @var{s2} are equivalent.
293 If not equivalent, the returned value is similar to what @code{strcmp}
294 would return.  In other words, it returns a negative value if @var{s1}
295 is less than @var{s2}, or a positive value if @var{s2} is greater than
296 @var{s2}.
298 This function does not normalize file names.  As a result, this function
299 will treat filenames that are spelled differently as different even in
300 the case when the two filenames point to the same underlying file.
301 However, it does handle the fact that on DOS-like file systems, forward
302 and backward slashes are equal.
304 @end deftypefn
306 @c filename_cmp.c:178
307 @deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2})
309 Return non-zero if file names @var{s1} and @var{s2} are equivalent.
310 This function is for use with hashtab.c hash tables.
312 @end deftypefn
314 @c filename_cmp.c:147
315 @deftypefn Extension hashval_t filename_hash (const void *@var{s})
317 Return the hash value for file name @var{s} that will be compared
318 using filename_cmp.
319 This function is for use with hashtab.c hash tables.
321 @end deftypefn
323 @c filename_cmp.c:89
324 @deftypefn Extension int filename_ncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
326 Return zero if the two file names @var{s1} and @var{s2} are equivalent
327 in range @var{n}.
328 If not equivalent, the returned value is similar to what @code{strncmp}
329 would return.  In other words, it returns a negative value if @var{s1}
330 is less than @var{s2}, or a positive value if @var{s2} is greater than
331 @var{s2}.
333 This function does not normalize file names.  As a result, this function
334 will treat filenames that are spelled differently as different even in
335 the case when the two filenames point to the same underlying file.
336 However, it does handle the fact that on DOS-like file systems, forward
337 and backward slashes are equal.
339 @end deftypefn
341 @c fnmatch.txh:1
342 @deftypefn Replacement int fnmatch (const char *@var{pattern}, @
343   const char *@var{string}, int @var{flags})
345 Matches @var{string} against @var{pattern}, returning zero if it
346 matches, @code{FNM_NOMATCH} if not.  @var{pattern} may contain the
347 wildcards @code{?} to match any one character, @code{*} to match any
348 zero or more characters, or a set of alternate characters in square
349 brackets, like @samp{[a-gt8]}, which match one character (@code{a}
350 through @code{g}, or @code{t}, or @code{8}, in this example) if that one
351 character is in the set.  A set may be inverted (i.e., match anything
352 except what's in the set) by giving @code{^} or @code{!} as the first
353 character in the set.  To include those characters in the set, list them
354 as anything other than the first character of the set.  To include a
355 dash in the set, list it last in the set.  A backslash character makes
356 the following character not special, so for example you could match
357 against a literal asterisk with @samp{\*}.  To match a literal
358 backslash, use @samp{\\}.
360 @code{flags} controls various aspects of the matching process, and is a
361 boolean OR of zero or more of the following values (defined in
362 @code{<fnmatch.h>}):
364 @table @code
366 @item FNM_PATHNAME
367 @itemx FNM_FILE_NAME
368 @var{string} is assumed to be a path name.  No wildcard will ever match
369 @code{/}.
371 @item FNM_NOESCAPE
372 Do not interpret backslashes as quoting the following special character.
374 @item FNM_PERIOD
375 A leading period (at the beginning of @var{string}, or if
376 @code{FNM_PATHNAME} after a slash) is not matched by @code{*} or
377 @code{?} but must be matched explicitly.
379 @item FNM_LEADING_DIR
380 Means that @var{string} also matches @var{pattern} if some initial part
381 of @var{string} matches, and is followed by @code{/} and zero or more
382 characters.  For example, @samp{foo*} would match either @samp{foobar}
383 or @samp{foobar/grill}.
385 @item FNM_CASEFOLD
386 Ignores case when performing the comparison.
388 @end table
390 @end deftypefn
392 @c fopen_unlocked.c:39
393 @deftypefn Extension {FILE *} fopen_unlocked (const char *@var{path}, @
394   const char * @var{mode})
396 Opens and returns a @code{FILE} pointer via @code{fopen}.  If the
397 operating system supports it, ensure that the stream is setup to avoid
398 any multi-threaded locking.  Otherwise return the @code{FILE} pointer
399 unchanged.
401 @end deftypefn
403 @c argv.c:90
404 @deftypefn Extension void freeargv (char **@var{vector})
406 Free an argument vector that was built using @code{buildargv}.  Simply
407 scans through @var{vector}, freeing the memory for each argument until
408 the terminating @code{NULL} is found, and then frees @var{vector}
409 itself.
411 @end deftypefn
413 @c fopen_unlocked.c:59
414 @deftypefn Extension {FILE *} freopen_unlocked (const char * @var{path}, @
415   const char * @var{mode}, FILE * @var{stream})
417 Opens and returns a @code{FILE} pointer via @code{freopen}.  If the
418 operating system supports it, ensure that the stream is setup to avoid
419 any multi-threaded locking.  Otherwise return the @code{FILE} pointer
420 unchanged.
422 @end deftypefn
424 @c getruntime.c:82
425 @deftypefn Replacement long get_run_time (void)
427 Returns the time used so far, in microseconds.  If possible, this is
428 the time used by this process, else it is the elapsed time since the
429 process started.
431 @end deftypefn
433 @c getcwd.c:6
434 @deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})
436 Copy the absolute pathname for the current working directory into
437 @var{pathname}, which is assumed to point to a buffer of at least
438 @var{len} bytes, and return a pointer to the buffer.  If the current
439 directory's path doesn't fit in @var{len} characters, the result is
440 @code{NULL} and @code{errno} is set.  If @var{pathname} is a null pointer,
441 @code{getcwd} will obtain @var{len} bytes of space using
442 @code{malloc}.
444 @end deftypefn
446 @c getpagesize.c:5
447 @deftypefn Supplemental int getpagesize (void)
449 Returns the number of bytes in a page of memory.  This is the
450 granularity of many of the system memory management routines.  No
451 guarantee is made as to whether or not it is the same as the basic
452 memory management hardware page size.
454 @end deftypefn
456 @c getpwd.c:5
457 @deftypefn Supplemental char* getpwd (void)
459 Returns the current working directory.  This implementation caches the
460 result on the assumption that the process will not call @code{chdir}
461 between calls to @code{getpwd}.
463 @end deftypefn
465 @c gettimeofday.c:12
466 @deftypefn Supplemental int gettimeofday (struct timeval *@var{tp}, void *@var{tz})
468 Writes the current time to @var{tp}.  This implementation requires
469 that @var{tz} be NULL.  Returns 0 on success, -1 on failure.
471 @end deftypefn
473 @c hex.c:33
474 @deftypefn Extension void hex_init (void)
476 Initializes the array mapping the current character set to
477 corresponding hex values.  This function must be called before any
478 call to @code{hex_p} or @code{hex_value}.  If you fail to call it, a
479 default ASCII-based table will normally be used on ASCII systems.
481 @end deftypefn
483 @c hex.c:42
484 @deftypefn Extension int hex_p (int @var{c})
486 Evaluates to non-zero if the given character is a valid hex character,
487 or zero if it is not.  Note that the value you pass will be cast to
488 @code{unsigned char} within the macro.
490 @end deftypefn
492 @c hex.c:50
493 @deftypefn Extension {unsigned int} hex_value (int @var{c})
495 Returns the numeric equivalent of the given character when interpreted
496 as a hexadecimal digit.  The result is undefined if you pass an
497 invalid hex digit.  Note that the value you pass will be cast to
498 @code{unsigned char} within the macro.
500 The @code{hex_value} macro returns @code{unsigned int}, rather than
501 signed @code{int}, to make it easier to use in parsing addresses from
502 hex dump files: a signed @code{int} would be sign-extended when
503 converted to a wider unsigned type --- like @code{bfd_vma}, on some
504 systems.
506 @end deftypefn
508 @c safe-ctype.c:25
509 @defvr Extension HOST_CHARSET
510 This macro indicates the basic character set and encoding used by the
511 host: more precisely, the encoding used for character constants in
512 preprocessor @samp{#if} statements (the C "execution character set").
513 It is defined by @file{safe-ctype.h}, and will be an integer constant
514 with one of the following values:
516 @ftable @code
517 @item HOST_CHARSET_UNKNOWN
518 The host character set is unknown - that is, not one of the next two
519 possibilities.
521 @item HOST_CHARSET_ASCII
522 The host character set is ASCII.
524 @item HOST_CHARSET_EBCDIC
525 The host character set is some variant of EBCDIC.  (Only one of the
526 nineteen EBCDIC varying characters is tested; exercise caution.)
527 @end ftable
528 @end defvr
530 @c hashtab.c:328
531 @deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size}, @
532 htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f}, @
533 htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f}, @
534 htab_free @var{free_f})
536 This function creates a hash table that uses two different allocators
537 @var{alloc_tab_f} and @var{alloc_f} to use for allocating the table itself
538 and its entries respectively.  This is useful when variables of different
539 types need to be allocated with different allocators.
541 The created hash table is slightly larger than @var{size} and it is
542 initially empty (all the hash table entries are @code{HTAB_EMPTY_ENTRY}).
543 The function returns the created hash table, or @code{NULL} if memory
544 allocation fails.
546 @end deftypefn
548 @c index.c:5
549 @deftypefn Supplemental char* index (char *@var{s}, int @var{c})
551 Returns a pointer to the first occurrence of the character @var{c} in
552 the string @var{s}, or @code{NULL} if not found.  The use of @code{index} is
553 deprecated in new programs in favor of @code{strchr}.
555 @end deftypefn
557 @c insque.c:6
558 @deftypefn Supplemental void insque (struct qelem *@var{elem}, @
559   struct qelem *@var{pred})
560 @deftypefnx Supplemental void remque (struct qelem *@var{elem})
562 Routines to manipulate queues built from doubly linked lists.  The
563 @code{insque} routine inserts @var{elem} in the queue immediately
564 after @var{pred}.  The @code{remque} routine removes @var{elem} from
565 its containing queue.  These routines expect to be passed pointers to
566 structures which have as their first members a forward pointer and a
567 back pointer, like this prototype (although no prototype is provided):
569 @example
570 struct qelem @{
571   struct qelem *q_forw;
572   struct qelem *q_back;
573   char q_data[];
575 @end example
577 @end deftypefn
579 @c safe-ctype.c:46
580 @deffn  Extension ISALPHA  (@var{c})
581 @deffnx Extension ISALNUM  (@var{c})
582 @deffnx Extension ISBLANK  (@var{c})
583 @deffnx Extension ISCNTRL  (@var{c})
584 @deffnx Extension ISDIGIT  (@var{c})
585 @deffnx Extension ISGRAPH  (@var{c})
586 @deffnx Extension ISLOWER  (@var{c})
587 @deffnx Extension ISPRINT  (@var{c})
588 @deffnx Extension ISPUNCT  (@var{c})
589 @deffnx Extension ISSPACE  (@var{c})
590 @deffnx Extension ISUPPER  (@var{c})
591 @deffnx Extension ISXDIGIT (@var{c})
593 These twelve macros are defined by @file{safe-ctype.h}.  Each has the
594 same meaning as the corresponding macro (with name in lowercase)
595 defined by the standard header @file{ctype.h}.  For example,
596 @code{ISALPHA} returns true for alphabetic characters and false for
597 others.  However, there are two differences between these macros and
598 those provided by @file{ctype.h}:
600 @itemize @bullet
601 @item These macros are guaranteed to have well-defined behavior for all 
602 values representable by @code{signed char} and @code{unsigned char}, and
603 for @code{EOF}.
605 @item These macros ignore the current locale; they are true for these
606 fixed sets of characters:
607 @multitable {@code{XDIGIT}} {yada yada yada yada yada yada yada yada}
608 @item @code{ALPHA}  @tab @kbd{A-Za-z}
609 @item @code{ALNUM}  @tab @kbd{A-Za-z0-9}
610 @item @code{BLANK}  @tab @kbd{space tab}
611 @item @code{CNTRL}  @tab @code{!PRINT}
612 @item @code{DIGIT}  @tab @kbd{0-9}
613 @item @code{GRAPH}  @tab @code{ALNUM || PUNCT}
614 @item @code{LOWER}  @tab @kbd{a-z}
615 @item @code{PRINT}  @tab @code{GRAPH ||} @kbd{space}
616 @item @code{PUNCT}  @tab @kbd{`~!@@#$%^&*()_-=+[@{]@}\|;:'",<.>/?}
617 @item @code{SPACE}  @tab @kbd{space tab \n \r \f \v}
618 @item @code{UPPER}  @tab @kbd{A-Z}
619 @item @code{XDIGIT} @tab @kbd{0-9A-Fa-f}
620 @end multitable
622 Note that, if the host character set is ASCII or a superset thereof,
623 all these macros will return false for all values of @code{char} outside
624 the range of 7-bit ASCII.  In particular, both ISPRINT and ISCNTRL return
625 false for characters with numeric values from 128 to 255.
626 @end itemize
627 @end deffn
629 @c safe-ctype.c:95
630 @deffn  Extension ISIDNUM         (@var{c})
631 @deffnx Extension ISIDST          (@var{c})
632 @deffnx Extension IS_VSPACE       (@var{c})
633 @deffnx Extension IS_NVSPACE      (@var{c})
634 @deffnx Extension IS_SPACE_OR_NUL (@var{c})
635 @deffnx Extension IS_ISOBASIC     (@var{c})
636 These six macros are defined by @file{safe-ctype.h} and provide
637 additional character classes which are useful when doing lexical
638 analysis of C or similar languages.  They are true for the following
639 sets of characters:
641 @multitable {@code{SPACE_OR_NUL}} {yada yada yada yada yada yada yada yada}
642 @item @code{IDNUM}        @tab @kbd{A-Za-z0-9_}
643 @item @code{IDST}         @tab @kbd{A-Za-z_}
644 @item @code{VSPACE}       @tab @kbd{\r \n}
645 @item @code{NVSPACE}      @tab @kbd{space tab \f \v \0}
646 @item @code{SPACE_OR_NUL} @tab @code{VSPACE || NVSPACE}
647 @item @code{ISOBASIC}     @tab @code{VSPACE || NVSPACE || PRINT}
648 @end multitable
649 @end deffn
651 @c lbasename.c:23
652 @deftypefn Replacement {const char*} lbasename (const char *@var{name})
654 Given a pointer to a string containing a typical pathname
655 (@samp{/usr/src/cmd/ls/ls.c} for example), returns a pointer to the
656 last component of the pathname (@samp{ls.c} in this case).  The
657 returned pointer is guaranteed to lie within the original
658 string.  This latter fact is not true of many vendor C
659 libraries, which return special strings or modify the passed
660 strings for particular input.
662 In particular, the empty string returns the same empty string,
663 and a path ending in @code{/} returns the empty string after it.
665 @end deftypefn
667 @c lrealpath.c:25
668 @deftypefn Replacement {const char*} lrealpath (const char *@var{name})
670 Given a pointer to a string containing a pathname, returns a canonical
671 version of the filename.  Symlinks will be resolved, and ``.'' and ``..''
672 components will be simplified.  The returned value will be allocated using
673 @code{malloc}, or @code{NULL} will be returned on a memory allocation error.
675 @end deftypefn
677 @c make-relative-prefix.c:24
678 @deftypefn Extension {const char*} make_relative_prefix (const char *@var{progname}, @
679   const char *@var{bin_prefix}, const char *@var{prefix})
681 Given three paths @var{progname}, @var{bin_prefix}, @var{prefix},
682 return the path that is in the same position relative to
683 @var{progname}'s directory as @var{prefix} is relative to
684 @var{bin_prefix}.  That is, a string starting with the directory
685 portion of @var{progname}, followed by a relative pathname of the
686 difference between @var{bin_prefix} and @var{prefix}.
688 If @var{progname} does not contain any directory separators,
689 @code{make_relative_prefix} will search @env{PATH} to find a program
690 named @var{progname}.  Also, if @var{progname} is a symbolic link,
691 the symbolic link will be resolved.
693 For example, if @var{bin_prefix} is @code{/alpha/beta/gamma/gcc/delta},
694 @var{prefix} is @code{/alpha/beta/gamma/omega/}, and @var{progname} is
695 @code{/red/green/blue/gcc}, then this function will return
696 @code{/red/green/blue/../../omega/}.
698 The return value is normally allocated via @code{malloc}.  If no
699 relative prefix can be found, return @code{NULL}.
701 @end deftypefn
703 @c make-temp-file.c:174
704 @deftypefn Replacement char* make_temp_file (const char *@var{suffix})
706 Return a temporary file name (as a string) or @code{NULL} if unable to
707 create one.  @var{suffix} is a suffix to append to the file name.  The
708 string is @code{malloc}ed, and the temporary file has been created.
710 @end deftypefn
712 @c memchr.c:3
713 @deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, @
714   size_t @var{n})
716 This function searches memory starting at @code{*@var{s}} for the
717 character @var{c}.  The search only ends with the first occurrence of
718 @var{c}, or after @var{length} characters; in particular, a null
719 character does not terminate the search.  If the character @var{c} is
720 found within @var{length} characters of @code{*@var{s}}, a pointer
721 to the character is returned.  If @var{c} is not found, then @code{NULL} is
722 returned.
724 @end deftypefn
726 @c memcmp.c:6
727 @deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, @
728   size_t @var{count})
730 Compares the first @var{count} bytes of two areas of memory.  Returns
731 zero if they are the same, a value less than zero if @var{x} is
732 lexically less than @var{y}, or a value greater than zero if @var{x}
733 is lexically greater than @var{y}.  Note that lexical order is determined
734 as if comparing unsigned char arrays.
736 @end deftypefn
738 @c memcpy.c:6
739 @deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, @
740   size_t @var{length})
742 Copies @var{length} bytes from memory region @var{in} to region
743 @var{out}.  Returns a pointer to @var{out}.
745 @end deftypefn
747 @c memmem.c:20
748 @deftypefn Supplemental void* memmem (const void *@var{haystack}, @
749   size_t @var{haystack_len} const void *@var{needle}, size_t @var{needle_len})
751 Returns a pointer to the first occurrence of @var{needle} (length
752 @var{needle_len}) in @var{haystack} (length @var{haystack_len}).
753 Returns @code{NULL} if not found.
755 @end deftypefn
757 @c memmove.c:6
758 @deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, @
759   size_t @var{count})
761 Copies @var{count} bytes from memory area @var{from} to memory area
762 @var{to}, returning a pointer to @var{to}.
764 @end deftypefn
766 @c mempcpy.c:23
767 @deftypefn Supplemental void* mempcpy (void *@var{out}, const void *@var{in}, @
768   size_t @var{length})
770 Copies @var{length} bytes from memory region @var{in} to region
771 @var{out}.  Returns a pointer to @var{out} + @var{length}.
773 @end deftypefn
775 @c memset.c:6
776 @deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, @
777   size_t @var{count})
779 Sets the first @var{count} bytes of @var{s} to the constant byte
780 @var{c}, returning a pointer to @var{s}.
782 @end deftypefn
784 @c mkstemps.c:58
785 @deftypefn Replacement int mkstemps (char *@var{pattern}, int @var{suffix_len})
787 Generate a unique temporary file name from @var{pattern}.
788 @var{pattern} has the form:
790 @example
791    @var{path}/ccXXXXXX@var{suffix}
792 @end example
794 @var{suffix_len} tells us how long @var{suffix} is (it can be zero
795 length).  The last six characters of @var{pattern} before @var{suffix}
796 must be @samp{XXXXXX}; they are replaced with a string that makes the
797 filename unique.  Returns a file descriptor open on the file for
798 reading and writing.
800 @end deftypefn
802 @c pexecute.txh:278
803 @deftypefn Extension void pex_free (struct pex_obj @var{obj})
805 Clean up and free all data associated with @var{obj}.  If you have not
806 yet called @code{pex_get_times} or @code{pex_get_status}, this will
807 try to kill the subprocesses.
809 @end deftypefn
811 @c pexecute.txh:251
812 @deftypefn Extension int pex_get_status (struct pex_obj *@var{obj}, @
813   int @var{count}, int *@var{vector})
815 Returns the exit status of all programs run using @var{obj}.
816 @var{count} is the number of results expected.  The results will be
817 placed into @var{vector}.  The results are in the order of the calls
818 to @code{pex_run}.  Returns 0 on error, 1 on success.
820 @end deftypefn
822 @c pexecute.txh:261
823 @deftypefn Extension int pex_get_times (struct pex_obj *@var{obj}, @
824   int @var{count}, struct pex_time *@var{vector})
826 Returns the process execution times of all programs run using
827 @var{obj}.  @var{count} is the number of results expected.  The
828 results will be placed into @var{vector}.  The results are in the
829 order of the calls to @code{pex_run}.  Returns 0 on error, 1 on
830 success.
832 @code{struct pex_time} has the following fields of the type
833 @code{unsigned long}: @code{user_seconds},
834 @code{user_microseconds}, @code{system_seconds},
835 @code{system_microseconds}.  On systems which do not support reporting
836 process times, all the fields will be set to @code{0}.
838 @end deftypefn
840 @c pexecute.txh:2
841 @deftypefn Extension {struct pex_obj *} pex_init (int @var{flags}, @
842   const char *@var{pname}, const char *@var{tempbase})
844 Prepare to execute one or more programs, with standard output of each
845 program fed to standard input of the next.  This is a system
846 independent interface to execute a pipeline.
848 @var{flags} is a bitwise combination of the following:
850 @table @code
852 @vindex PEX_RECORD_TIMES
853 @item PEX_RECORD_TIMES
854 Record subprocess times if possible.
856 @vindex PEX_USE_PIPES
857 @item PEX_USE_PIPES
858 Use pipes for communication between processes, if possible.
860 @vindex PEX_SAVE_TEMPS
861 @item PEX_SAVE_TEMPS
862 Don't delete temporary files used for communication between
863 processes.
865 @end table
867 @var{pname} is the name of program to be executed, used in error
868 messages.  @var{tempbase} is a base name to use for any required
869 temporary files; it may be @code{NULL} to use a randomly chosen name.
871 @end deftypefn
873 @c pexecute.txh:161
874 @deftypefn Extension {FILE *} pex_input_file (struct pex_obj *@var{obj}, @
875   int @var{flags}, const char *@var{in_name})
877 Return a stream for a temporary file to pass to the first program in
878 the pipeline as input.
880 The name of the input file is chosen according to the same rules
881 @code{pex_run} uses to choose output file names, based on
882 @var{in_name}, @var{obj} and the @code{PEX_SUFFIX} bit in @var{flags}.
884 Don't call @code{fclose} on the returned stream; the first call to
885 @code{pex_run} closes it automatically.
887 If @var{flags} includes @code{PEX_BINARY_OUTPUT}, open the stream in
888 binary mode; otherwise, open it in the default mode.  Including
889 @code{PEX_BINARY_OUTPUT} in @var{flags} has no effect on Unix.
890 @end deftypefn
892 @c pexecute.txh:179
893 @deftypefn Extension {FILE *} pex_input_pipe (struct pex_obj *@var{obj}, @
894   int @var{binary})
896 Return a stream @var{fp} for a pipe connected to the standard input of
897 the first program in the pipeline; @var{fp} is opened for writing.
898 You must have passed @code{PEX_USE_PIPES} to the @code{pex_init} call
899 that returned @var{obj}.
901 You must close @var{fp} using @code{fclose} yourself when you have
902 finished writing data to the pipeline.
904 The file descriptor underlying @var{fp} is marked not to be inherited
905 by child processes.
907 On systems that do not support pipes, this function returns
908 @code{NULL}, and sets @code{errno} to @code{EINVAL}.  If you would
909 like to write code that is portable to all systems the @code{pex}
910 functions support, consider using @code{pex_input_file} instead.
912 There are two opportunities for deadlock using
913 @code{pex_input_pipe}:
915 @itemize @bullet
916 @item
917 Most systems' pipes can buffer only a fixed amount of data; a process
918 that writes to a full pipe blocks.  Thus, if you write to @file{fp}
919 before starting the first process, you run the risk of blocking when
920 there is no child process yet to read the data and allow you to
921 continue.  @code{pex_input_pipe} makes no promises about the
922 size of the pipe's buffer, so if you need to write any data at all
923 before starting the first process in the pipeline, consider using
924 @code{pex_input_file} instead.
926 @item
927 Using @code{pex_input_pipe} and @code{pex_read_output} together
928 may also cause deadlock.  If the output pipe fills up, so that each
929 program in the pipeline is waiting for the next to read more data, and
930 you fill the input pipe by writing more data to @var{fp}, then there
931 is no way to make progress: the only process that could read data from
932 the output pipe is you, but you are blocked on the input pipe.
934 @end itemize
936 @end deftypefn
938 @c pexecute.txh:286
939 @deftypefn Extension {const char *} pex_one (int @var{flags}, @
940   const char *@var{executable}, char * const *@var{argv}, @
941   const char *@var{pname}, const char *@var{outname}, const char *@var{errname}, @
942   int *@var{status}, int *@var{err})
944 An interface to permit the easy execution of a
945 single program.  The return value and most of the parameters are as
946 for a call to @code{pex_run}.  @var{flags} is restricted to a
947 combination of @code{PEX_SEARCH}, @code{PEX_STDERR_TO_STDOUT}, and
948 @code{PEX_BINARY_OUTPUT}.  @var{outname} is interpreted as if
949 @code{PEX_LAST} were set.  On a successful return, @code{*@var{status}} will
950 be set to the exit status of the program.
952 @end deftypefn
954 @c pexecute.txh:237
955 @deftypefn Extension {FILE *} pex_read_err (struct pex_obj *@var{obj}, @
956   int @var{binary})
958 Returns a @code{FILE} pointer which may be used to read the standard
959 error of the last program in the pipeline.  When this is used,
960 @code{PEX_LAST} should not be used in a call to @code{pex_run}.  After
961 this is called, @code{pex_run} may no longer be called with the same
962 @var{obj}.  @var{binary} should be non-zero if the file should be
963 opened in binary mode.  Don't call @code{fclose} on the returned file;
964 it will be closed by @code{pex_free}.
966 @end deftypefn
968 @c pexecute.txh:224
969 @deftypefn Extension {FILE *} pex_read_output (struct pex_obj *@var{obj}, @
970   int @var{binary})
972 Returns a @code{FILE} pointer which may be used to read the standard
973 output of the last program in the pipeline.  When this is used,
974 @code{PEX_LAST} should not be used in a call to @code{pex_run}.  After
975 this is called, @code{pex_run} may no longer be called with the same
976 @var{obj}.  @var{binary} should be non-zero if the file should be
977 opened in binary mode.  Don't call @code{fclose} on the returned file;
978 it will be closed by @code{pex_free}.
980 @end deftypefn
982 @c pexecute.txh:34
983 @deftypefn Extension {const char *} pex_run (struct pex_obj *@var{obj}, @
984   int @var{flags}, const char *@var{executable}, char * const *@var{argv}, @
985   const char *@var{outname}, const char *@var{errname}, int *@var{err})
987 Execute one program in a pipeline.  On success this returns
988 @code{NULL}.  On failure it returns an error message, a statically
989 allocated string.
991 @var{obj} is returned by a previous call to @code{pex_init}.
993 @var{flags} is a bitwise combination of the following:
995 @table @code
997 @vindex PEX_LAST
998 @item PEX_LAST
999 This must be set on the last program in the pipeline.  In particular,
1000 it should be set when executing a single program.  The standard output
1001 of the program will be sent to @var{outname}, or, if @var{outname} is
1002 @code{NULL}, to the standard output of the calling program.  Do @emph{not}
1003 set this bit if you want to call @code{pex_read_output}
1004 (described below).  After a call to @code{pex_run} with this bit set,
1005 @var{pex_run} may no longer be called with the same @var{obj}.
1007 @vindex PEX_SEARCH
1008 @item PEX_SEARCH
1009 Search for the program using the user's executable search path.
1011 @vindex PEX_SUFFIX
1012 @item PEX_SUFFIX
1013 @var{outname} is a suffix.  See the description of @var{outname},
1014 below.
1016 @vindex PEX_STDERR_TO_STDOUT
1017 @item PEX_STDERR_TO_STDOUT
1018 Send the program's standard error to standard output, if possible.
1020 @vindex PEX_BINARY_INPUT
1021 @vindex PEX_BINARY_OUTPUT
1022 @vindex PEX_BINARY_ERROR
1023 @item PEX_BINARY_INPUT
1024 @itemx PEX_BINARY_OUTPUT
1025 @itemx PEX_BINARY_ERROR
1026 The standard input (output or error) of the program should be read (written) in
1027 binary mode rather than text mode.  These flags are ignored on systems
1028 which do not distinguish binary mode and text mode, such as Unix.  For
1029 proper behavior these flags should match appropriately---a call to
1030 @code{pex_run} using @code{PEX_BINARY_OUTPUT} should be followed by a
1031 call using @code{PEX_BINARY_INPUT}.
1033 @vindex PEX_STDERR_TO_PIPE
1034 @item PEX_STDERR_TO_PIPE
1035 Send the program's standard error to a pipe, if possible.  This flag
1036 cannot be specified together with @code{PEX_STDERR_TO_STDOUT}.  This
1037 flag can be specified only on the last program in pipeline.
1039 @end table
1041 @var{executable} is the program to execute.  @var{argv} is the set of
1042 arguments to pass to the program; normally @code{@var{argv}[0]} will
1043 be a copy of @var{executable}.
1045 @var{outname} is used to set the name of the file to use for standard
1046 output.  There are two cases in which no output file will be used:
1048 @enumerate
1049 @item
1050 if @code{PEX_LAST} is not set in @var{flags}, and @code{PEX_USE_PIPES}
1051 was set in the call to @code{pex_init}, and the system supports pipes
1053 @item
1054 if @code{PEX_LAST} is set in @var{flags}, and @var{outname} is
1055 @code{NULL}
1056 @end enumerate
1058 @noindent
1059 Otherwise the code will use a file to hold standard
1060 output.  If @code{PEX_LAST} is not set, this file is considered to be
1061 a temporary file, and it will be removed when no longer needed, unless
1062 @code{PEX_SAVE_TEMPS} was set in the call to @code{pex_init}.
1064 There are two cases to consider when setting the name of the file to
1065 hold standard output.
1067 @enumerate
1068 @item
1069 @code{PEX_SUFFIX} is set in @var{flags}.  In this case
1070 @var{outname} may not be @code{NULL}.  If the @var{tempbase} parameter
1071 to @code{pex_init} was not @code{NULL}, then the output file name is
1072 the concatenation of @var{tempbase} and @var{outname}.  If
1073 @var{tempbase} was @code{NULL}, then the output file name is a random
1074 file name ending in @var{outname}.
1076 @item
1077 @code{PEX_SUFFIX} was not set in @var{flags}.  In this
1078 case, if @var{outname} is not @code{NULL}, it is used as the output
1079 file name.  If @var{outname} is @code{NULL}, and @var{tempbase} was
1080 not NULL, the output file name is randomly chosen using
1081 @var{tempbase}.  Otherwise the output file name is chosen completely
1082 at random.
1083 @end enumerate
1085 @var{errname} is the file name to use for standard error output.  If
1086 it is @code{NULL}, standard error is the same as the caller's.
1087 Otherwise, standard error is written to the named file.
1089 On an error return, the code sets @code{*@var{err}} to an @code{errno}
1090 value, or to 0 if there is no relevant @code{errno}.
1092 @end deftypefn
1094 @c pexecute.txh:145
1095 @deftypefn Extension {const char *} pex_run_in_environment (struct pex_obj *@var{obj}, @
1096   int @var{flags}, const char *@var{executable}, char * const *@var{argv}, @
1097   char * const *@var{env}, int @var{env_size}, const char *@var{outname}, @
1098   const char *@var{errname}, int *@var{err})
1100 Execute one program in a pipeline, permitting the environment for the
1101 program to be specified.  Behaviour and parameters not listed below are
1102 as for @code{pex_run}.
1104 @var{env} is the environment for the child process, specified as an array of
1105 character pointers.  Each element of the array should point to a string of the
1106 form @code{VAR=VALUE}, with the exception of the last element that must be
1107 @code{NULL}.
1109 @end deftypefn
1111 @c pexecute.txh:301
1112 @deftypefn Extension int pexecute (const char *@var{program}, @
1113   char * const *@var{argv}, const char *@var{this_pname}, @
1114   const char *@var{temp_base}, char **@var{errmsg_fmt}, @
1115   char **@var{errmsg_arg}, int @var{flags})
1117 This is the old interface to execute one or more programs.  It is
1118 still supported for compatibility purposes, but is no longer
1119 documented.
1121 @end deftypefn
1123 @c strsignal.c:541
1124 @deftypefn Supplemental void psignal (int @var{signo}, char *@var{message})
1126 Print @var{message} to the standard error, followed by a colon,
1127 followed by the description of the signal specified by @var{signo},
1128 followed by a newline.
1130 @end deftypefn
1132 @c putenv.c:21
1133 @deftypefn Supplemental int putenv (const char *@var{string})
1135 Uses @code{setenv} or @code{unsetenv} to put @var{string} into
1136 the environment or remove it.  If @var{string} is of the form
1137 @samp{name=value} the string is added; if no @samp{=} is present the
1138 name is unset/removed.
1140 @end deftypefn
1142 @c pexecute.txh:312
1143 @deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags})
1145 Another part of the old execution interface.
1147 @end deftypefn
1149 @c random.c:39
1150 @deftypefn Supplement {long int} random (void)
1151 @deftypefnx Supplement void srandom (unsigned int @var{seed})
1152 @deftypefnx Supplement void* initstate (unsigned int @var{seed}, @
1153   void *@var{arg_state}, unsigned long @var{n})
1154 @deftypefnx Supplement void* setstate (void *@var{arg_state})
1156 Random number functions.  @code{random} returns a random number in the
1157 range 0 to @code{LONG_MAX}.  @code{srandom} initializes the random
1158 number generator to some starting point determined by @var{seed}
1159 (else, the values returned by @code{random} are always the same for each
1160 run of the program).  @code{initstate} and @code{setstate} allow fine-grained
1161 control over the state of the random number generator.
1163 @end deftypefn
1165 @c concat.c:160
1166 @deftypefn Extension char* reconcat (char *@var{optr}, const char *@var{s1}, @
1167   @dots{}, @code{NULL})
1169 Same as @code{concat}, except that if @var{optr} is not @code{NULL} it
1170 is freed after the string is created.  This is intended to be useful
1171 when you're extending an existing string or building up a string in a
1172 loop:
1174 @example
1175   str = reconcat (str, "pre-", str, NULL);
1176 @end example
1178 @end deftypefn
1180 @c rename.c:6
1181 @deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new})
1183 Renames a file from @var{old} to @var{new}.  If @var{new} already
1184 exists, it is removed.
1186 @end deftypefn
1188 @c rindex.c:5
1189 @deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c})
1191 Returns a pointer to the last occurrence of the character @var{c} in
1192 the string @var{s}, or @code{NULL} if not found.  The use of @code{rindex} is
1193 deprecated in new programs in favor of @code{strrchr}.
1195 @end deftypefn
1197 @c setenv.c:23
1198 @deftypefn Supplemental int setenv (const char *@var{name}, @
1199   const char *@var{value}, int @var{overwrite})
1200 @deftypefnx Supplemental void unsetenv (const char *@var{name})
1202 @code{setenv} adds @var{name} to the environment with value
1203 @var{value}.  If the name was already present in the environment,
1204 the new value will be stored only if @var{overwrite} is nonzero.
1205 The companion @code{unsetenv} function removes @var{name} from the
1206 environment.  This implementation is not safe for multithreaded code.
1208 @end deftypefn
1210 @c setproctitle.c:31
1211 @deftypefn Supplemental void setproctitle (const char *@var{fmt}, ...)
1213 Set the title of a process to @var{fmt}. va args not supported for now,
1214 but defined for compatibility with BSD. 
1216 @end deftypefn
1218 @c strsignal.c:348
1219 @deftypefn Extension int signo_max (void)
1221 Returns the maximum signal value for which a corresponding symbolic
1222 name or message is available.  Note that in the case where we use the
1223 @code{sys_siglist} supplied by the system, it is possible for there to
1224 be more symbolic names than messages, or vice versa.  In fact, the
1225 manual page for @code{psignal(3b)} explicitly warns that one should
1226 check the size of the table (@code{NSIG}) before indexing it, since
1227 new signal codes may be added to the system before they are added to
1228 the table.  Thus @code{NSIG} might be smaller than value implied by
1229 the largest signo value defined in @code{<signal.h>}.
1231 We return the maximum value that can be used to obtain a meaningful
1232 symbolic name or message.
1234 @end deftypefn
1236 @c sigsetmask.c:8
1237 @deftypefn Supplemental int sigsetmask (int @var{set})
1239 Sets the signal mask to the one provided in @var{set} and returns
1240 the old mask (which, for libiberty's implementation, will always
1241 be the value @code{1}).
1243 @end deftypefn
1245 @c simple-object.txh:96
1246 @deftypefn Extension {const char *} simple_object_attributes_compare @
1247   (simple_object_attributes *@var{attrs1}, simple_object_attributes *@var{attrs2}, @
1248    int *@var{err})
1250 Compare @var{attrs1} and @var{attrs2}.  If they could be linked
1251 together without error, return @code{NULL}.  Otherwise, return an
1252 error message and set @code{*@var{err}} to an errno value or @code{0}
1253 if there is no relevant errno.
1255 @end deftypefn
1257 @c simple-object.txh:81
1258 @deftypefn Extension {simple_object_attributes *} simple_object_fetch_attributes @
1259   (simple_object_read *@var{simple_object}, const char **@var{errmsg}, int *@var{err})
1261 Fetch the attributes of @var{simple_object}.  The attributes are
1262 internal information such as the format of the object file, or the
1263 architecture it was compiled for.  This information will persist until
1264 @code{simple_object_attributes_release} is called, even if
1265 @var{simple_object} itself is released.
1267 On error this returns @code{NULL}, sets @code{*@var{errmsg}} to an
1268 error message, and sets @code{*@var{err}} to an errno value or
1269 @code{0} if there is no relevant errno.
1271 @end deftypefn
1273 @c simple-object.txh:49
1274 @deftypefn Extension {int} simple_object_find_section @
1275   (simple_object_read *@var{simple_object} off_t *@var{offset}, @
1276   off_t *@var{length}, const char **@var{errmsg}, int *@var{err})
1278 Look for the section @var{name} in @var{simple_object}.  This returns
1279 information for the first section with that name.
1281 If found, return 1 and set @code{*@var{offset}} to the offset in the
1282 file of the section contents and set @code{*@var{length}} to the
1283 length of the section contents.  The value in @code{*@var{offset}}
1284 will be relative to the offset passed to
1285 @code{simple_object_open_read}.
1287 If the section is not found, and no error occurs,
1288 @code{simple_object_find_section} returns @code{0} and set
1289 @code{*@var{errmsg}} to @code{NULL}.
1291 If an error occurs, @code{simple_object_find_section} returns
1292 @code{0}, sets @code{*@var{errmsg}} to an error message, and sets
1293 @code{*@var{err}} to an errno value or @code{0} if there is no
1294 relevant errno.
1296 @end deftypefn
1298 @c simple-object.txh:27
1299 @deftypefn Extension {const char *} simple_object_find_sections @
1300   (simple_object_read *@var{simple_object}, int (*@var{pfn}) (void *@var{data}, @
1301   const char *@var{name}, off_t @var{offset}, off_t @var{length}), @
1302   void *@var{data}, int *@var{err})
1304 This function calls @var{pfn} for each section in @var{simple_object}.
1305 It calls @var{pfn} with the section name, the offset within the file
1306 of the section contents, and the length of the section contents.  The
1307 offset within the file is relative to the offset passed to
1308 @code{simple_object_open_read}.  The @var{data} argument to this
1309 function is passed along to @var{pfn}.
1311 If @var{pfn} returns @code{0}, the loop over the sections stops and
1312 @code{simple_object_find_sections} returns.  If @var{pfn} returns some
1313 other value, the loop continues.
1315 On success @code{simple_object_find_sections} returns.  On error it
1316 returns an error string, and sets @code{*@var{err}} to an errno value
1317 or @code{0} if there is no relevant errno.
1319 @end deftypefn
1321 @c simple-object.txh:2
1322 @deftypefn Extension {simple_object_read *} simple_object_open_read @
1323   (int @var{descriptor}, off_t @var{offset}, const char *{segment_name}, @
1324   const char **@var{errmsg}, int *@var{err})
1326 Opens an object file for reading.  Creates and returns an
1327 @code{simple_object_read} pointer which may be passed to other
1328 functions to extract data from the object file.
1330 @var{descriptor} holds a file descriptor which permits reading.
1332 @var{offset} is the offset into the file; this will be @code{0} in the
1333 normal case, but may be a different value when reading an object file
1334 in an archive file.
1336 @var{segment_name} is only used with the Mach-O file format used on
1337 Darwin aka Mac OS X.  It is required on that platform, and means to
1338 only look at sections within the segment with that name.  The
1339 parameter is ignored on other systems.
1341 If an error occurs, this functions returns @code{NULL} and sets
1342 @code{*@var{errmsg}} to an error string and sets @code{*@var{err}} to
1343 an errno value or @code{0} if there is no relevant errno.
1345 @end deftypefn
1347 @c simple-object.txh:107
1348 @deftypefn Extension {void} simple_object_release_attributes @
1349   (simple_object_attributes *@var{attrs})
1351 Release all resources associated with @var{attrs}.
1353 @end deftypefn
1355 @c simple-object.txh:73
1356 @deftypefn Extension {void} simple_object_release_read @
1357   (simple_object_read *@var{simple_object})
1359 Release all resources associated with @var{simple_object}.  This does
1360 not close the file descriptor.
1362 @end deftypefn
1364 @c simple-object.txh:184
1365 @deftypefn Extension {void} simple_object_release_write @
1366   (simple_object_write *@var{simple_object})
1368 Release all resources associated with @var{simple_object}.
1370 @end deftypefn
1372 @c simple-object.txh:114
1373 @deftypefn Extension {simple_object_write *} simple_object_start_write @
1374   (simple_object_attributes @var{attrs}, const char *@var{segment_name}, @
1375   const char **@var{errmsg}, int *@var{err})
1377 Start creating a new object file using the object file format
1378 described in @var{attrs}.  You must fetch attribute information from
1379 an existing object file before you can create a new one.  There is
1380 currently no support for creating an object file de novo.
1382 @var{segment_name} is only used with Mach-O as found on Darwin aka Mac
1383 OS X.  The parameter is required on that target.  It means that all
1384 sections are created within the named segment.  It is ignored for
1385 other object file formats.
1387 On error @code{simple_object_start_write} returns @code{NULL}, sets
1388 @code{*@var{ERRMSG}} to an error message, and sets @code{*@var{err}}
1389 to an errno value or @code{0} if there is no relevant errno.
1391 @end deftypefn
1393 @c simple-object.txh:153
1394 @deftypefn Extension {const char *} simple_object_write_add_data @
1395   (simple_object_write *@var{simple_object}, @
1396   simple_object_write_section *@var{section}, const void *@var{buffer}, @
1397   size_t @var{size}, int @var{copy}, int *@var{err})
1399 Add data @var{buffer}/@var{size} to @var{section} in
1400 @var{simple_object}.  If @var{copy} is non-zero, the data will be
1401 copied into memory if necessary.  If @var{copy} is zero, @var{buffer}
1402 must persist until @code{simple_object_write_to_file} is called.  is
1403 released.
1405 On success this returns @code{NULL}.  On error this returns an error
1406 message, and sets @code{*@var{err}} to an errno value or 0 if there is
1407 no relevant erro.
1409 @end deftypefn
1411 @c simple-object.txh:134
1412 @deftypefn Extension {simple_object_write_section *} simple_object_write_create_section @
1413   (simple_object_write *@var{simple_object}, const char *@var{name}, @
1414   unsigned int @var{align}, const char **@var{errmsg}, int *@var{err})
1416 Add a section to @var{simple_object}.  @var{name} is the name of the
1417 new section.  @var{align} is the required alignment expressed as the
1418 number of required low-order 0 bits (e.g., 2 for alignment to a 32-bit
1419 boundary).
1421 The section is created as containing data, readable, not writable, not
1422 executable, not loaded at runtime.  The section is not written to the
1423 file until @code{simple_object_write_to_file} is called.
1425 On error this returns @code{NULL}, sets @code{*@var{errmsg}} to an
1426 error message, and sets @code{*@var{err}} to an errno value or
1427 @code{0} if there is no relevant errno.
1429 @end deftypefn
1431 @c simple-object.txh:170
1432 @deftypefn Extension {const char *} simple_object_write_to_file @
1433   (simple_object_write *@var{simple_object}, int @var{descriptor}, int *@var{err})
1435 Write the complete object file to @var{descriptor}, an open file
1436 descriptor.  This writes out all the data accumulated by calls to
1437 @code{simple_object_write_create_section} and
1438 @var{simple_object_write_add_data}.
1440 This returns @code{NULL} on success.  On error this returns an error
1441 message and sets @code{*@var{err}} to an errno value or @code{0} if
1442 there is no relevant errno.
1444 @end deftypefn
1446 @c snprintf.c:28
1447 @deftypefn Supplemental int snprintf (char *@var{buf}, size_t @var{n}, @
1448   const char *@var{format}, ...)
1450 This function is similar to @code{sprintf}, but it will write to
1451 @var{buf} at most @code{@var{n}-1} bytes of text, followed by a
1452 terminating null byte, for a total of @var{n} bytes.
1453 On error the return value is -1, otherwise it returns the number of
1454 bytes, not including the terminating null byte, that would have been
1455 written had @var{n} been sufficiently large, regardless of the actual
1456 value of @var{n}.  Note some pre-C99 system libraries do not implement
1457 this correctly so users cannot generally rely on the return value if
1458 the system version of this function is used.
1460 @end deftypefn
1462 @c spaces.c:22
1463 @deftypefn Extension char* spaces (int @var{count})
1465 Returns a pointer to a memory region filled with the specified
1466 number of spaces and null terminated.  The returned pointer is
1467 valid until at least the next call.
1469 @end deftypefn
1471 @c splay-tree.c:303
1472 @deftypefn Supplemental splay_tree splay_tree_new_with_typed_alloc @
1473 (splay_tree_compare_fn @var{compare_fn}, @
1474 splay_tree_delete_key_fn @var{delete_key_fn}, @
1475 splay_tree_delete_value_fn @var{delete_value_fn}, @
1476 splay_tree_allocate_fn @var{tree_allocate_fn}, @
1477 splay_tree_allocate_fn @var{node_allocate_fn}, @
1478 splay_tree_deallocate_fn @var{deallocate_fn}, @
1479 void * @var{allocate_data})
1481 This function creates a splay tree that uses two different allocators
1482 @var{tree_allocate_fn} and @var{node_allocate_fn} to use for allocating the
1483 tree itself and its nodes respectively.  This is useful when variables of
1484 different types need to be allocated with different allocators.
1486 The splay tree will use @var{compare_fn} to compare nodes,
1487 @var{delete_key_fn} to deallocate keys, and @var{delete_value_fn} to
1488 deallocate values.
1490 @end deftypefn
1492 @c stack-limit.c:28
1493 @deftypefn Extension void stack_limit_increase (unsigned long @var{pref})
1495 Attempt to increase stack size limit to @var{pref} bytes if possible.
1497 @end deftypefn
1499 @c stpcpy.c:23
1500 @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src})
1502 Copies the string @var{src} into @var{dst}.  Returns a pointer to
1503 @var{dst} + strlen(@var{src}).
1505 @end deftypefn
1507 @c stpncpy.c:23
1508 @deftypefn Supplemental char* stpncpy (char *@var{dst}, const char *@var{src}, @
1509   size_t @var{len})
1511 Copies the string @var{src} into @var{dst}, copying exactly @var{len}
1512 and padding with zeros if necessary.  If @var{len} < strlen(@var{src})
1513 then return @var{dst} + @var{len}, otherwise returns @var{dst} +
1514 strlen(@var{src}).
1516 @end deftypefn
1518 @c strcasecmp.c:15
1519 @deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2})
1521 A case-insensitive @code{strcmp}.
1523 @end deftypefn
1525 @c strchr.c:6
1526 @deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
1528 Returns a pointer to the first occurrence of the character @var{c} in
1529 the string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
1530 null character, the results are undefined.
1532 @end deftypefn
1534 @c strdup.c:3
1535 @deftypefn Supplemental char* strdup (const char *@var{s})
1537 Returns a pointer to a copy of @var{s} in memory obtained from
1538 @code{malloc}, or @code{NULL} if insufficient memory was available.
1540 @end deftypefn
1542 @c strerror.c:670
1543 @deftypefn Replacement {const char*} strerrno (int @var{errnum})
1545 Given an error number returned from a system call (typically returned
1546 in @code{errno}), returns a pointer to a string containing the
1547 symbolic name of that error number, as found in @code{<errno.h>}.
1549 If the supplied error number is within the valid range of indices for
1550 symbolic names, but no name is available for the particular error
1551 number, then returns the string @samp{Error @var{num}}, where @var{num}
1552 is the error number.
1554 If the supplied error number is not within the range of valid
1555 indices, then returns @code{NULL}.
1557 The contents of the location pointed to are only guaranteed to be
1558 valid until the next call to @code{strerrno}.
1560 @end deftypefn
1562 @c strerror.c:603
1563 @deftypefn Supplemental char* strerror (int @var{errnoval})
1565 Maps an @code{errno} number to an error message string, the contents
1566 of which are implementation defined.  On systems which have the
1567 external variables @code{sys_nerr} and @code{sys_errlist}, these
1568 strings will be the same as the ones used by @code{perror}.
1570 If the supplied error number is within the valid range of indices for
1571 the @code{sys_errlist}, but no message is available for the particular
1572 error number, then returns the string @samp{Error @var{num}}, where
1573 @var{num} is the error number.
1575 If the supplied error number is not a valid index into
1576 @code{sys_errlist}, returns @code{NULL}.
1578 The returned string is only guaranteed to be valid only until the
1579 next call to @code{strerror}.
1581 @end deftypefn
1583 @c strncasecmp.c:15
1584 @deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2})
1586 A case-insensitive @code{strncmp}.
1588 @end deftypefn
1590 @c strncmp.c:6
1591 @deftypefn Supplemental int strncmp (const char *@var{s1}, @
1592   const char *@var{s2}, size_t @var{n})
1594 Compares the first @var{n} bytes of two strings, returning a value as
1595 @code{strcmp}.
1597 @end deftypefn
1599 @c strndup.c:23
1600 @deftypefn Extension char* strndup (const char *@var{s}, size_t @var{n})
1602 Returns a pointer to a copy of @var{s} with at most @var{n} characters
1603 in memory obtained from @code{malloc}, or @code{NULL} if insufficient
1604 memory was available.  The result is always NUL terminated.
1606 @end deftypefn
1608 @c strnlen.c:6
1609 @deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen})
1611 Returns the length of @var{s}, as with @code{strlen}, but never looks
1612 past the first @var{maxlen} characters in the string.  If there is no
1613 '\0' character in the first @var{maxlen} characters, returns
1614 @var{maxlen}.
1616 @end deftypefn
1618 @c strrchr.c:6
1619 @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
1621 Returns a pointer to the last occurrence of the character @var{c} in
1622 the string @var{s}, or @code{NULL} if not found.  If @var{c} is itself the
1623 null character, the results are undefined.
1625 @end deftypefn
1627 @c strsignal.c:383
1628 @deftypefn Supplemental {const char *} strsignal (int @var{signo})
1630 Maps an signal number to an signal message string, the contents of
1631 which are implementation defined.  On systems which have the external
1632 variable @code{sys_siglist}, these strings will be the same as the
1633 ones used by @code{psignal()}.
1635 If the supplied signal number is within the valid range of indices for
1636 the @code{sys_siglist}, but no message is available for the particular
1637 signal number, then returns the string @samp{Signal @var{num}}, where
1638 @var{num} is the signal number.
1640 If the supplied signal number is not a valid index into
1641 @code{sys_siglist}, returns @code{NULL}.
1643 The returned string is only guaranteed to be valid only until the next
1644 call to @code{strsignal}.
1646 @end deftypefn
1648 @c strsignal.c:448
1649 @deftypefn Extension {const char*} strsigno (int @var{signo})
1651 Given an signal number, returns a pointer to a string containing the
1652 symbolic name of that signal number, as found in @code{<signal.h>}.
1654 If the supplied signal number is within the valid range of indices for
1655 symbolic names, but no name is available for the particular signal
1656 number, then returns the string @samp{Signal @var{num}}, where
1657 @var{num} is the signal number.
1659 If the supplied signal number is not within the range of valid
1660 indices, then returns @code{NULL}.
1662 The contents of the location pointed to are only guaranteed to be
1663 valid until the next call to @code{strsigno}.
1665 @end deftypefn
1667 @c strstr.c:6
1668 @deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub})
1670 This function searches for the substring @var{sub} in the string
1671 @var{string}, not including the terminating null characters.  A pointer
1672 to the first occurrence of @var{sub} is returned, or @code{NULL} if the
1673 substring is absent.  If @var{sub} points to a string with zero
1674 length, the function returns @var{string}.
1676 @end deftypefn
1678 @c strtod.c:27
1679 @deftypefn Supplemental double strtod (const char *@var{string}, @
1680   char **@var{endptr})
1682 This ISO C function converts the initial portion of @var{string} to a
1683 @code{double}.  If @var{endptr} is not @code{NULL}, a pointer to the
1684 character after the last character used in the conversion is stored in
1685 the location referenced by @var{endptr}.  If no conversion is
1686 performed, zero is returned and the value of @var{string} is stored in
1687 the location referenced by @var{endptr}.
1689 @end deftypefn
1691 @c strerror.c:729
1692 @deftypefn Extension int strtoerrno (const char *@var{name})
1694 Given the symbolic name of a error number (e.g., @code{EACCES}), map it
1695 to an errno value.  If no translation is found, returns 0.
1697 @end deftypefn
1699 @c strtol.c:33
1700 @deftypefn Supplemental {long int} strtol (const char *@var{string}, @
1701   char **@var{endptr}, int @var{base})
1702 @deftypefnx Supplemental {unsigned long int} strtoul (const char *@var{string}, @
1703   char **@var{endptr}, int @var{base})
1705 The @code{strtol} function converts the string in @var{string} to a
1706 long integer value according to the given @var{base}, which must be
1707 between 2 and 36 inclusive, or be the special value 0.  If @var{base}
1708 is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x}
1709 to indicate bases 8 and 16, respectively, else default to base 10.
1710 When the base is 16 (either explicitly or implicitly), a prefix of
1711 @code{0x} is allowed.  The handling of @var{endptr} is as that of
1712 @code{strtod} above.  The @code{strtoul} function is the same, except
1713 that the converted value is unsigned.
1715 @end deftypefn
1717 @c strsignal.c:502
1718 @deftypefn Extension int strtosigno (const char *@var{name})
1720 Given the symbolic name of a signal, map it to a signal number.  If no
1721 translation is found, returns 0.
1723 @end deftypefn
1725 @c strverscmp.c:25
1726 @deftypefun int strverscmp (const char *@var{s1}, const char *@var{s2})
1727 The @code{strverscmp} function compares the string @var{s1} against
1728 @var{s2}, considering them as holding indices/version numbers.  Return
1729 value follows the same conventions as found in the @code{strverscmp}
1730 function.  In fact, if @var{s1} and @var{s2} contain no digits,
1731 @code{strverscmp} behaves like @code{strcmp}.
1733 Basically, we compare strings normally (character by character), until
1734 we find a digit in each string - then we enter a special comparison
1735 mode, where each sequence of digits is taken as a whole.  If we reach the
1736 end of these two parts without noticing a difference, we return to the
1737 standard comparison mode.  There are two types of numeric parts:
1738 "integral" and "fractional" (those  begin with a '0'). The types
1739 of the numeric parts affect the way we sort them:
1741 @itemize @bullet
1742 @item
1743 integral/integral: we compare values as you would expect.
1745 @item
1746 fractional/integral: the fractional part is less than the integral one.
1747 Again, no surprise.
1749 @item
1750 fractional/fractional: the things become a bit more complex.
1751 If the common prefix contains only leading zeroes, the longest part is less
1752 than the other one; else the comparison behaves normally.
1753 @end itemize
1755 @smallexample
1756 strverscmp ("no digit", "no digit")
1757     @result{} 0    // @r{same behavior as strcmp.}
1758 strverscmp ("item#99", "item#100")
1759     @result{} <0   // @r{same prefix, but 99 < 100.}
1760 strverscmp ("alpha1", "alpha001")
1761     @result{} >0   // @r{fractional part inferior to integral one.}
1762 strverscmp ("part1_f012", "part1_f01")
1763     @result{} >0   // @r{two fractional parts.}
1764 strverscmp ("foo.009", "foo.0")
1765     @result{} <0   // @r{idem, but with leading zeroes only.}
1766 @end smallexample
1768 This function is especially useful when dealing with filename sorting,
1769 because filenames frequently hold indices/version numbers.
1770 @end deftypefun
1772 @c timeval-utils.c:43
1773 @deftypefn Extension void timeval_add (struct timeval *@var{a}, @
1774   struct timeval *@var{b}, struct timeval *@var{result})
1776 Adds @var{a} to @var{b} and stores the result in @var{result}.
1778 @end deftypefn
1780 @c timeval-utils.c:67
1781 @deftypefn Extension void timeval_sub (struct timeval *@var{a}, @
1782   struct timeval *@var{b}, struct timeval *@var{result})
1784 Subtracts @var{b} from @var{a} and stores the result in @var{result}.
1786 @end deftypefn
1788 @c tmpnam.c:3
1789 @deftypefn Supplemental char* tmpnam (char *@var{s})
1791 This function attempts to create a name for a temporary file, which
1792 will be a valid file name yet not exist when @code{tmpnam} checks for
1793 it.  @var{s} must point to a buffer of at least @code{L_tmpnam} bytes,
1794 or be @code{NULL}.  Use of this function creates a security risk, and it must
1795 not be used in new projects.  Use @code{mkstemp} instead.
1797 @end deftypefn
1799 @c unlink-if-ordinary.c:27
1800 @deftypefn Supplemental int unlink_if_ordinary (const char*)
1802 Unlinks the named file, unless it is special (e.g. a device file).
1803 Returns 0 when the file was unlinked, a negative value (and errno set) when
1804 there was an error deleting the file, and a positive value if no attempt
1805 was made to unlink the file because it is special.
1807 @end deftypefn
1809 @c fopen_unlocked.c:31
1810 @deftypefn Extension void unlock_std_streams (void)
1812 If the OS supports it, ensure that the standard I/O streams,
1813 @code{stdin}, @code{stdout} and @code{stderr} are setup to avoid any
1814 multi-threaded locking.  Otherwise do nothing.
1816 @end deftypefn
1818 @c fopen_unlocked.c:23
1819 @deftypefn Extension void unlock_stream (FILE * @var{stream})
1821 If the OS supports it, ensure that the supplied stream is setup to
1822 avoid any multi-threaded locking.  Otherwise leave the @code{FILE}
1823 pointer unchanged.  If the @var{stream} is @code{NULL} do nothing.
1825 @end deftypefn
1827 @c vasprintf.c:47
1828 @deftypefn Extension int vasprintf (char **@var{resptr}, @
1829   const char *@var{format}, va_list @var{args})
1831 Like @code{vsprintf}, but instead of passing a pointer to a buffer,
1832 you pass a pointer to a pointer.  This function will compute the size
1833 of the buffer needed, allocate memory with @code{malloc}, and store a
1834 pointer to the allocated memory in @code{*@var{resptr}}.  The value
1835 returned is the same as @code{vsprintf} would return.  If memory could
1836 not be allocated, minus one is returned and @code{NULL} is stored in
1837 @code{*@var{resptr}}.
1839 @end deftypefn
1841 @c vfork.c:6
1842 @deftypefn Supplemental int vfork (void)
1844 Emulates @code{vfork} by calling @code{fork} and returning its value.
1846 @end deftypefn
1848 @c vprintf.c:3
1849 @deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap})
1850 @deftypefnx Supplemental int vfprintf (FILE *@var{stream}, @
1851   const char *@var{format}, va_list @var{ap})
1852 @deftypefnx Supplemental int vsprintf (char *@var{str}, @
1853   const char *@var{format}, va_list @var{ap})
1855 These functions are the same as @code{printf}, @code{fprintf}, and
1856 @code{sprintf}, respectively, except that they are called with a
1857 @code{va_list} instead of a variable number of arguments.  Note that
1858 they do not call @code{va_end}; this is the application's
1859 responsibility.  In @libib{} they are implemented in terms of the
1860 nonstandard but common function @code{_doprnt}.
1862 @end deftypefn
1864 @c vsnprintf.c:28
1865 @deftypefn Supplemental int vsnprintf (char *@var{buf}, size_t @var{n}, @
1866   const char *@var{format}, va_list @var{ap})
1868 This function is similar to @code{vsprintf}, but it will write to
1869 @var{buf} at most @code{@var{n}-1} bytes of text, followed by a
1870 terminating null byte, for a total of @var{n} bytes.  On error the
1871 return value is -1, otherwise it returns the number of characters that
1872 would have been printed had @var{n} been sufficiently large,
1873 regardless of the actual value of @var{n}.  Note some pre-C99 system
1874 libraries do not implement this correctly so users cannot generally
1875 rely on the return value if the system version of this function is
1876 used.
1878 @end deftypefn
1880 @c waitpid.c:3
1881 @deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
1883 This is a wrapper around the @code{wait} function.  Any ``special''
1884 values of @var{pid} depend on your implementation of @code{wait}, as
1885 does the return value.  The third argument is unused in @libib{}.
1887 @end deftypefn
1889 @c argv.c:286
1890 @deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file})
1892 Write each member of ARGV, handling all necessary quoting, to the file
1893 named by FILE, separated by whitespace.  Return 0 on success, non-zero
1894 if an error occurred while writing to FILE.
1896 @end deftypefn
1898 @c xatexit.c:11
1899 @deftypefun int xatexit (void (*@var{fn}) (void))
1901 Behaves as the standard @code{atexit} function, but with no limit on
1902 the number of registered functions.  Returns 0 on success, or @minus{}1 on
1903 failure.  If you use @code{xatexit} to register functions, you must use
1904 @code{xexit} to terminate your program.
1906 @end deftypefun
1908 @c xmalloc.c:38
1909 @deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize})
1911 Allocate memory without fail, and set it to zero.  This routine functions
1912 like @code{calloc}, but will behave the same as @code{xmalloc} if memory
1913 cannot be found.
1915 @end deftypefn
1917 @c xexit.c:22
1918 @deftypefn Replacement void xexit (int @var{code})
1920 Terminates the program.  If any functions have been registered with
1921 the @code{xatexit} replacement function, they will be called first.
1922 Termination is handled via the system's normal @code{exit} call.
1924 @end deftypefn
1926 @c xmalloc.c:22
1927 @deftypefn Replacement void* xmalloc (size_t)
1929 Allocate memory without fail.  If @code{malloc} fails, this will print
1930 a message to @code{stderr} (using the name set by
1931 @code{xmalloc_set_program_name},
1932 if any) and then call @code{xexit}.  Note that it is therefore safe for
1933 a program to contain @code{#define malloc xmalloc} in its source.
1935 @end deftypefn
1937 @c xmalloc.c:53
1938 @deftypefn Replacement void xmalloc_failed (size_t)
1940 This function is not meant to be called by client code, and is listed
1941 here for completeness only.  If any of the allocation routines fail, this
1942 function will be called to print an error message and terminate execution.
1944 @end deftypefn
1946 @c xmalloc.c:46
1947 @deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
1949 You can use this to set the name of the program used by
1950 @code{xmalloc_failed} when printing a failure message.
1952 @end deftypefn
1954 @c xmemdup.c:7
1955 @deftypefn Replacement void* xmemdup (void *@var{input}, @
1956   size_t @var{copy_size}, size_t @var{alloc_size})
1958 Duplicates a region of memory without fail.  First, @var{alloc_size} bytes
1959 are allocated, then @var{copy_size} bytes from @var{input} are copied into
1960 it, and the new memory is returned.  If fewer bytes are copied than were
1961 allocated, the remaining memory is zeroed.
1963 @end deftypefn
1965 @c xmalloc.c:32
1966 @deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size})
1967 Reallocate memory without fail.  This routine functions like @code{realloc},
1968 but will behave the same as @code{xmalloc} if memory cannot be found.
1970 @end deftypefn
1972 @c xstrdup.c:7
1973 @deftypefn Replacement char* xstrdup (const char *@var{s})
1975 Duplicates a character string without fail, using @code{xmalloc} to
1976 obtain memory.
1978 @end deftypefn
1980 @c xstrerror.c:7
1981 @deftypefn Replacement char* xstrerror (int @var{errnum})
1983 Behaves exactly like the standard @code{strerror} function, but
1984 will never return a @code{NULL} pointer.
1986 @end deftypefn
1988 @c xstrndup.c:23
1989 @deftypefn Replacement char* xstrndup (const char *@var{s}, size_t @var{n})
1991 Returns a pointer to a copy of @var{s} with at most @var{n} characters
1992 without fail, using @code{xmalloc} to obtain memory.  The result is
1993 always NUL terminated.
1995 @end deftypefn