]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/functions.texi
rs6000.md (cr_logical): Swap order of CODE and MODE arguments to
[thirdparty/gcc.git] / libiberty / functions.texi
CommitLineData
aaa5f039
DD
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 and let gather-docs build you a new copy.
5
6@c alloca.c:26
7f8fa05d 7@deftypefn Replacement void* alloca (size_t @var{size})
aaa5f039
DD
8
9This function allocates memory which will be automatically reclaimed
10after the procedure exits. The @libib{} implementation does not free
11the memory immediately but will do so eventually during subsequent
12calls to this function. Memory is allocated using @code{xmalloc} under
13normal circumstances.
14
15The header file @file{alloca-conf.h} can be used in conjunction with the
16GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make
17available this function. The @code{AC_FUNC_ALLOCA} test requires that
18client code use a block of preprocessor code to be safe (see the Autoconf
19manual for more); this header incorporates that logic and more, including
7f8fa05d 20the possibility of a GCC built-in function.
aaa5f039
DD
21
22@end deftypefn
23
24@c atexit.c:6
25@deftypefn Supplemental int atexit (void (*@var{f})())
26
27Causes function @var{f} to be called at exit. Returns 0.
28
29@end deftypefn
30
31@c basename.c:6
32@deftypefn Supplemental char* basename (const char *@var{name})
33
34Returns a pointer to the last component of pathname @var{name}.
35Behavior is undefined if the pathname ends in a directory separator.
36
37@end deftypefn
38
39@c bcmp.c:6
40@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})
41
42Compares the first @var{count} bytes of two areas of memory. Returns
0e4e9e8f
JM
43zero if they are the same, nonzero otherwise. Returns zero if
44@var{count} is zero. A nonzero result only indicates a difference,
aaa5f039
DD
45it does not indicate any sorting order (say, by having a positive
46result mean @var{x} sorts before @var{y}).
47
48@end deftypefn
49
50@c bcopy.c:3
51@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
52
53Copies @var{length} bytes from memory region @var{in} to region
54@var{out}. The use of @code{bcopy} is deprecated in new programs.
55
56@end deftypefn
57
58@c bsearch.c:33
59@deftypefn Supplemental void* bsearch (const void *@var{key}, const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, int (*@var{compar})(const void *, const void *))
60
61Performs a search over an array of @var{nmemb} elements pointed to by
62@var{base} for a member that matches the object pointed to by @var{key}.
63The size of each member is specified by @var{size}. The array contents
64should be sorted in ascending order according to the @var{compar}
65comparison function. This routine should take two arguments pointing to
66the @var{key} and to an array member, in that order, and should return an
67integer less than, equal to, or greater than zero if the @var{key} object
ae9092da 68is respectively less than, matching, or greater than the array member.
aaa5f039
DD
69
70@end deftypefn
71
72@c bzero.c:6
73@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})
74
ae9092da 75Zeros @var{count} bytes starting at @var{mem}. Use of this function
aaa5f039
DD
76is deprecated in favor of @code{memset}.
77
78@end deftypefn
79
80@c calloc.c:6
81@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
82
83Uses @code{malloc} to allocate storage for @var{nelem} objects of
84@var{elsize} bytes each, then zeros the memory.
85
86@end deftypefn
87
88@c clock.c:27
7f8fa05d 89@deftypefn Supplemental long clock (void)
aaa5f039
DD
90
91Returns an approximation of the CPU time used by the process as a
92@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the
93number of seconds used.
94
95@end deftypefn
96
97@c strerror.c:566
98@deftypefn Replacement int errno_max (void)
99
100Returns the maximum @code{errno} value for which a corresponding
101symbolic name or message is available. Note that in the case where we
102use the @code{sys_errlist} supplied by the system, it is possible for
103there to be more symbolic names than messages, or vice versa. In
104fact, the manual page for @code{perror(3C)} explicitly warns that one
105should check the size of the table (@code{sys_nerr}) before indexing
106it, since new error codes may be added to the system before they are
107added to the table. Thus @code{sys_nerr} might be smaller than value
7f8fa05d 108implied by the largest @code{errno} value defined in @code{<errno.h>}.
aaa5f039
DD
109
110We return the maximum value that can be used to obtain a meaningful
111symbolic name or message.
112
113@end deftypefn
114
115@c getcwd.c:6
7f8fa05d 116@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})
aaa5f039
DD
117
118Copy the absolute pathname for the current working directory into
119@var{pathname}, which is assumed to point to a buffer of at least
120@var{len} bytes, and return a pointer to the buffer. If the current
121directory's path doesn't fit in @var{len} characters, the result is
7f8fa05d 122@code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer,
aaa5f039
DD
123@code{getcwd} will obtain @var{len} bytes of space using
124@code{malloc}.
125
126@end deftypefn
127
128@c getpagesize.c:5
7f8fa05d 129@deftypefn Supplemental int getpagesize (void)
aaa5f039
DD
130
131Returns the number of bytes in a page of memory. This is the
132granularity of many of the system memory management routines. No
133guarantee is made as to whether or not it is the same as the basic
134memory management hardware page size.
135
136@end deftypefn
137
138@c getpwd.c:5
7f8fa05d 139@deftypefn Supplemental char* getpwd (void)
aaa5f039
DD
140
141Returns the current working directory. This implementation caches the
142result on the assumption that the process will not call @code{chdir}
143between calls to @code{getpwd}.
144
145@end deftypefn
146
147@c index.c:5
148@deftypefn Supplemental char* index (char *@var{s}, int @var{c})
149
e922f978 150Returns a pointer to the first occurrence of the character @var{c} in
7f8fa05d 151the string @var{s}, or @code{NULL} if not found. The use of @code{index} is
aaa5f039
DD
152deprecated in new programs in favor of @code{strchr}.
153
154@end deftypefn
155
156@c memchr.c:3
157@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
158
7f8fa05d 159This function searches memory starting at @code{*@var{s}} for the
aaa5f039
DD
160character @var{c}. The search only ends with the first occurrence of
161@var{c}, or after @var{length} characters; in particular, a null
162character does not terminate the search. If the character @var{c} is
7f8fa05d
JM
163found within @var{length} characters of @code{*@var{s}}, a pointer
164to the character is returned. If @var{c} is not found, then @code{NULL} is
aaa5f039
DD
165returned.
166
167@end deftypefn
168
169@c memcmp.c:6
170@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count})
171
172Compares the first @var{count} bytes of two areas of memory. Returns
173zero if they are the same, a value less than zero if @var{x} is
174lexically less than @var{y}, or a value greater than zero if @var{x}
175is lexically greater than @var{y}. Note that lexical order is determined
176as if comparing unsigned char arrays.
177
178@end deftypefn
179
180@c memcpy.c:6
181@deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length})
182
183Copies @var{length} bytes from memory region @var{in} to region
184@var{out}. Returns a pointer to @var{out}.
185
186@end deftypefn
187
188@c memmove.c:6
189@deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count})
190
191Copies @var{count} bytes from memory area @var{from} to memory area
192@var{to}, returning a pointer to @var{to}.
193
194@end deftypefn
195
196@c memset.c:6
197@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
198
199Sets the first @var{count} bytes of @var{s} to the constant byte
200@var{c}, returning a pointer to @var{s}.
201
202@end deftypefn
203
204@c putenv.c:21
205@deftypefn Supplemental int putenv (const char *@var{string})
206
207Uses @code{setenv} or @code{unsetenv} to put @var{string} into
208the environment or remove it. If @var{string} is of the form
7f8fa05d 209@samp{name=value} the string is added; if no @samp{=} is present the
aaa5f039
DD
210name is unset/removed.
211
212@end deftypefn
213
214@c rename.c:6
215@deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new})
216
217Renames a file from @var{old} to @var{new}. If @var{new} already
218exists, it is removed.
219
220@end deftypefn
221
222@c rindex.c:5
223@deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c})
224
e922f978 225Returns a pointer to the last occurrence of the character @var{c} in
7f8fa05d 226the string @var{s}, or @code{NULL} if not found. The use of @code{rindex} is
aaa5f039
DD
227deprecated in new programs in favor of @code{strrchr}.
228
229@end deftypefn
230
231@c setenv.c:22
232@deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite})
233@deftypefnx Supplemental void unsetenv (const char *@var{name})
234
235@code{setenv} adds @var{name} to the environment with value
236@var{value}. If the name was already present in the environment,
0e4e9e8f 237the new value will be stored only if @var{overwrite} is nonzero.
aaa5f039
DD
238The companion @code{unsetenv} function removes @var{name} from the
239environment. This implementation is not safe for multithreaded code.
240
241@end deftypefn
242
243@c sigsetmask.c:8
244@deftypefn Supplemental int sigsetmask (int @var{set})
245
246Sets the signal mask to the one provided in @var{set} and returns
247the old mask (which, for libiberty's implementation, will always
248be the value @code{1}).
249
250@end deftypefn
251
252@c strcasecmp.c:15
253@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2})
254
255A case-insensitive @code{strcmp}.
256
257@end deftypefn
258
259@c strchr.c:6
260@deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
261
e922f978 262Returns a pointer to the first occurrence of the character @var{c} in
7f8fa05d 263the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
aaa5f039
DD
264null character, the results are undefined.
265
266@end deftypefn
267
268@c strdup.c:3
269@deftypefn Supplemental char* strdup (const char *@var{s})
270
271Returns a pointer to a copy of @var{s} in memory obtained from
7f8fa05d 272@code{malloc}, or @code{NULL} if insufficient memory was available.
aaa5f039
DD
273
274@end deftypefn
275
276@c strerror.c:670
277@deftypefn Replacement const char* strerrno (int @var{errnum})
278
279Given an error number returned from a system call (typically returned
280in @code{errno}), returns a pointer to a string containing the
7f8fa05d 281symbolic name of that error number, as found in @code{<errno.h>}.
aaa5f039
DD
282
283If the supplied error number is within the valid range of indices for
284symbolic names, but no name is available for the particular error
e922f978
EZ
285number, then returns the string @samp{"Error @var{num}"}, where @var{num}
286is the error number.
aaa5f039
DD
287
288If the supplied error number is not within the range of valid
7f8fa05d 289indices, then returns @code{NULL}.
aaa5f039
DD
290
291The contents of the location pointed to are only guaranteed to be
e922f978 292valid until the next call to @code{strerrno}.
aaa5f039
DD
293
294@end deftypefn
295
296@c strerror.c:602
297@deftypefn Replacement char* strerror (int @var{errnoval})
298
299Maps an @code{errno} number to an error message string, the contents
300of which are implementation defined. On systems which have the
301external variables @code{sys_nerr} and @code{sys_errlist}, these
302strings will be the same as the ones used by @code{perror}.
303
304If the supplied error number is within the valid range of indices for
305the @code{sys_errlist}, but no message is available for the particular
e922f978
EZ
306error number, then returns the string @samp{"Error @var{num}"}, where
307@var{num} is the error number.
aaa5f039
DD
308
309If the supplied error number is not a valid index into
7f8fa05d 310@code{sys_errlist}, returns @code{NULL}.
aaa5f039
DD
311
312The returned string is only guaranteed to be valid only until the
313next call to @code{strerror}.
314
315@end deftypefn
316
317@c strncasecmp.c:15
318@deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2})
319
320A case-insensitive @code{strncmp}.
321
322@end deftypefn
323
324@c strncmp.c:6
325@deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
326
327Compares the first @var{n} bytes of two strings, returning a value as
328@code{strcmp}.
329
330@end deftypefn
331
332@c strrchr.c:6
333@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
334
e922f978 335Returns a pointer to the last occurrence of the character @var{c} in
7f8fa05d 336the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
aaa5f039
DD
337null character, the results are undefined.
338
339@end deftypefn
340
341@c strstr.c:6
342@deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub})
343
344This function searches for the substring @var{sub} in the string
e922f978 345@var{string}, not including the terminating null characters. A pointer
7f8fa05d 346to the first occurrence of @var{sub} is returned, or @code{NULL} if the
aaa5f039
DD
347substring is absent. If @var{sub} points to a string with zero
348length, the function returns @var{string}.
349
350@end deftypefn
351
352@c strtod.c:27
353@deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr})
354
0e4e9e8f 355This ISO C function converts the initial portion of @var{string} to a
7f8fa05d 356@code{double}. If @var{endptr} is not @code{NULL}, a pointer to the
aaa5f039
DD
357character after the last character used in the conversion is stored in
358the location referenced by @var{endptr}. If no conversion is
359performed, zero is returned and the value of @var{string} is stored in
360the location referenced by @var{endptr}.
361
362@end deftypefn
363
364@c strerror.c:730
365@deftypefn Replacement int strtoerrno (const char *@var{name})
366
7f8fa05d 367Given the symbolic name of a error number (e.g., @code{EACCES}), map it
aaa5f039
DD
368to an errno value. If no translation is found, returns 0.
369
370@end deftypefn
371
372@c strtol.c:33
373@deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base})
374
375The @code{strtol} function converts the string in @var{string} to a
376long integer value according to the given @var{base}, which must be
377between 2 and 36 inclusive, or be the special value 0. If @var{base}
378is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x}
379to indicate bases 8 and 16, respectively, else default to base 10.
380When the base is 16 (either explicitly or implicitly), a prefix of
e922f978 381@code{0x} is allowed. The handling of @var{endptr} is as that of
aaa5f039
DD
382@code{strtod} above.
383
384@end deftypefn
385
386@c tmpnam.c:3
387@deftypefn Supplemental char* tmpnam (char *@var{s})
388
389This function attempts to create a name for a temporary file, which
390will be a valid file name yet not exist when @code{tmpnam} checks for
391it. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes,
7f8fa05d 392or be @code{NULL}. Use of this function creates a security risk, and it must
aaa5f039
DD
393not be used in new projects. Use @code{mkstemp} instead.
394
395@end deftypefn
396
397@c vfork.c:6
7f8fa05d 398@deftypefn Supplemental int vfork (void)
aaa5f039
DD
399
400Emulates @code{vfork} by calling @code{fork} and returning its value.
401
402@end deftypefn
403
404@c vprintf.c:3
405@deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap})
406@deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap})
407@deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap})
408
409These functions are the same as @code{printf}, @code{fprintf}, and
410@code{sprintf}, respectively, except that they are called with a
411@code{va_list} instead of a variable number of arguments. Note that
412they do not call @code{va_end}; this is the application's
413responsibility. In @libib{} they are implemented in terms of the
414nonstandard but common function @code{_doprnt}.
415
416@end deftypefn
417
418@c waitpid.c:3
419@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
420
421This is a wrapper around the @code{wait} function. Any ``special''
422values of @var{pid} depend on your implementation of @code{wait}, as
423does the return value. The third argument is unused in @libib{}.
424
425@end deftypefn
426
427@c xatexit.c:11
428@deftypefun int xatexit (void (*@var{fn}) (void))
429
430Behaves as the standard @code{atexit} function, but with no limit on
7f8fa05d 431the number of registered functions. Returns 0 on success, or @minus{}1 on
aaa5f039
DD
432failure. If you use @code{xatexit} to register functions, you must use
433@code{xexit} to terminate your program.
434
435@end deftypefun
436
e922f978 437@c xmalloc.c:38
7f8fa05d 438@deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize})
aaa5f039
DD
439
440Allocate memory without fail, and set it to zero. This routine functions
441like @code{calloc}, but will behave the same as @code{xmalloc} if memory
442cannot be found.
443
444@end deftypefn
445
446@c xexit.c:22
447@deftypefn Replacement void xexit (int @var{code})
448
449Terminates the program. If any functions have been registered with
e922f978 450the @code{xatexit} replacement function, they will be called first.
aaa5f039
DD
451Termination is handled via the system's normal @code{exit} call.
452
453@end deftypefn
454
455@c xmalloc.c:22
456@deftypefn Replacement void* xmalloc (size_t)
457
458Allocate memory without fail. If @code{malloc} fails, this will print
e922f978
EZ
459a message to @code{stderr} (using the name set by
460@code{xmalloc_set_program_name},
aaa5f039
DD
461if any) and then call @code{xexit}. Note that it is therefore safe for
462a program to contain @code{#define malloc xmalloc} in its source.
463
464@end deftypefn
465
e922f978 466@c xmalloc.c:53
aaa5f039
DD
467@deftypefn Replacement void xmalloc_failed (size_t)
468
469This function is not meant to be called by client code, and is listed
470here for completeness only. If any of the allocation routines fail, this
471function will be called to print an error message and terminate execution.
472
473@end deftypefn
474
e922f978 475@c xmalloc.c:46
aaa5f039
DD
476@deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
477
478You can use this to set the name of the program used by
479@code{xmalloc_failed} when printing a failure message.
480
481@end deftypefn
482
483@c xmemdup.c:7
484@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
485
486Duplicates a region of memory without fail. First, @var{alloc_size} bytes
487are allocated, then @var{copy_size} bytes from @var{input} are copied into
488it, and the new memory is returned. If fewer bytes are copied than were
489allocated, the remaining memory is zeroed.
490
491@end deftypefn
492
e922f978 493@c xmalloc.c:32
7f8fa05d 494@deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size})
aaa5f039
DD
495Reallocate memory without fail. This routine functions like @code{realloc},
496but will behave the same as @code{xmalloc} if memory cannot be found.
497
498@end deftypefn
499
500@c xstrdup.c:7
501@deftypefn Replacement char* xstrdup (const char *@var{s})
502
503Duplicates a character string without fail, using @code{xmalloc} to
504obtain memory.
505
506@end deftypefn
507
508@c xstrerror.c:7
509@deftypefn Replacement char* xstrerror (int @var{errnum})
510
511Behaves exactly like the standard @code{strerror} function, but
7f8fa05d 512will never return a @code{NULL} pointer.
aaa5f039
DD
513
514@end deftypefn
515
516