Daily bump.
[official-gcc.git] / include / libiberty.h
blobcf313662ef42be870bdab23023d09506d6eb0ea3
1 /* Function declarations for libiberty.
2 Written by Cygnus Support, 1994.
4 The libiberty library provides a number of functions which are
5 missing on some operating systems. We do not declare those here,
6 to avoid conflicts with the system header files on operating
7 systems that do support those functions. In this file we only
8 declare those functions which are specific to libiberty. */
10 #ifndef LIBIBERTY_H
11 #define LIBIBERTY_H
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
17 #include "ansidecl.h"
19 /* Build an argument vector from a string. Allocates memory using
20 malloc. Use freeargv to free the vector. */
22 extern char **buildargv PARAMS ((char *));
24 /* Free a vector returned by buildargv. */
26 extern void freeargv PARAMS ((char **));
28 /* Duplicate an argument vector. Allocates memory using malloc. Use
29 freeargv to free the vector. */
31 extern char **dupargv PARAMS ((char **));
34 /* Return the last component of a path name. Note that we can't use a
35 prototype here because the parameter is declared inconsistently
36 across different systems, sometimes as "char *" and sometimes as
37 "const char *" */
39 #if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__)
40 extern char *basename PARAMS ((const char *));
41 #else
42 extern char *basename ();
43 #endif
45 /* Concatenate an arbitrary number of strings, up to (char *) NULL.
46 Allocates memory using xmalloc. */
48 extern char *concat PARAMS ((const char *, ...));
50 /* Check whether two file descriptors refer to the same file. */
52 extern int fdmatch PARAMS ((int fd1, int fd2));
54 /* Get the amount of time the process has run, in microseconds. */
56 extern long get_run_time PARAMS ((void));
58 /* Choose a temporary directory to use for scratch files. */
60 extern char *choose_temp_base PARAMS ((void));
62 /* Allocate memory filled with spaces. Allocates using malloc. */
64 extern const char *spaces PARAMS ((int count));
66 /* Return the maximum error number for which strerror will return a
67 string. */
69 extern int errno_max PARAMS ((void));
71 /* Return the name of an errno value (e.g., strerrno (EINVAL) returns
72 "EINVAL"). */
74 extern const char *strerrno PARAMS ((int));
76 /* Given the name of an errno value, return the value. */
78 extern int strtoerrno PARAMS ((const char *));
80 /* ANSI's strerror(), but more robust. */
82 extern char *xstrerror PARAMS ((int));
84 /* Return the maximum signal number for which strsignal will return a
85 string. */
87 extern int signo_max PARAMS ((void));
89 /* Return a signal message string for a signal number
90 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
91 /* This is commented out as it can conflict with one in system headers.
92 We still document its existence though. */
94 /*extern const char *strsignal PARAMS ((int));*/
96 /* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
97 "SIGHUP"). */
99 extern const char *strsigno PARAMS ((int));
101 /* Given the name of a signal, return its number. */
103 extern int strtosigno PARAMS ((const char *));
105 /* Register a function to be run by xexit. Returns 0 on success. */
107 extern int xatexit PARAMS ((void (*fn) (void)));
109 /* Exit, calling all the functions registered with xatexit. */
111 #ifndef __GNUC__
112 extern void xexit PARAMS ((int status));
113 #else
114 void xexit PARAMS ((int status)) __attribute__ ((noreturn));
115 #endif
117 /* Set the program name used by xmalloc. */
119 extern void xmalloc_set_program_name PARAMS ((const char *));
121 /* Allocate memory without fail. If malloc fails, this will print a
122 message to stderr (using the name set by xmalloc_set_program_name,
123 if any) and then call xexit. */
125 #ifdef ANSI_PROTOTYPES
126 /* Get a definition for size_t. */
127 #include <stddef.h>
128 #endif
129 extern PTR xmalloc PARAMS ((size_t));
131 /* Reallocate memory without fail. This works like xmalloc.
133 FIXME: We do not declare the parameter types for the same reason as
134 xmalloc. */
136 extern PTR xrealloc PARAMS ((PTR, size_t));
138 /* Allocate memory without fail and set it to zero. This works like
139 xmalloc. */
141 extern PTR xcalloc PARAMS ((size_t, size_t));
143 /* Copy a string into a memory buffer without fail. */
145 extern char *xstrdup PARAMS ((const char *));
147 /* hex character manipulation routines */
149 #define _hex_array_size 256
150 #define _hex_bad 99
151 extern char _hex_value[_hex_array_size];
152 extern void hex_init PARAMS ((void));
153 #define hex_p(c) (hex_value (c) != _hex_bad)
154 /* If you change this, note well: Some code relies on side effects in
155 the argument being performed exactly once. */
156 #define hex_value(c) (_hex_value[(unsigned char) (c)])
158 /* Definitions used by the pexecute routine. */
160 #define PEXECUTE_FIRST 1
161 #define PEXECUTE_LAST 2
162 #define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
163 #define PEXECUTE_SEARCH 4
164 #define PEXECUTE_VERBOSE 8
166 /* Execute a program. */
168 extern int pexecute PARAMS ((const char *, char * const *, const char *,
169 const char *, char **, char **, int));
171 /* Wait for pexecute to finish. */
173 extern int pwait PARAMS ((int, int *, int));
175 #ifdef __cplusplus
177 #endif
180 #endif /* ! defined (LIBIBERTY_H) */