]> gcc.gnu.org Git - gcc.git/blob - include/libiberty.h
Makefile.in, [...]: Expunge remaining traces of facility for running MD files through...
[gcc.git] / include / libiberty.h
1 /* Function declarations for libiberty.
2 Written by Cygnus Support, 1994.
3
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. */
9
10 #ifndef LIBIBERTY_H
11 #define LIBIBERTY_H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #include "ansidecl.h"
18
19 #ifdef ANSI_PROTOTYPES
20 /* Get a definition for size_t. */
21 #include <stddef.h>
22 /* Get a definition for va_list. */
23 #include <stdarg.h>
24 #endif
25
26 /* Build an argument vector from a string. Allocates memory using
27 malloc. Use freeargv to free the vector. */
28
29 extern char **buildargv PARAMS ((char *)) ATTRIBUTE_MALLOC;
30
31 /* Free a vector returned by buildargv. */
32
33 extern void freeargv PARAMS ((char **));
34
35 /* Duplicate an argument vector. Allocates memory using malloc. Use
36 freeargv to free the vector. */
37
38 extern char **dupargv PARAMS ((char **)) ATTRIBUTE_MALLOC;
39
40
41 /* Return the last component of a path name. Note that we can't use a
42 prototype here because the parameter is declared inconsistently
43 across different systems, sometimes as "char *" and sometimes as
44 "const char *" */
45
46 /* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
47 undefined, we haven't run the autoconf check so provide the
48 declaration without arguments. If it is 0, we checked and failed
49 to find the declaration so provide a fully prototyped one. If it
50 is 1, we found it so don't provide any declaration at all. */
51 #if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || (defined (HAVE_DECL_BASENAME) && !HAVE_DECL_BASENAME)
52 extern char *basename PARAMS ((const char *));
53 #else
54 # if !defined (HAVE_DECL_BASENAME)
55 extern char *basename ();
56 # endif
57 #endif
58
59 /* Concatenate an arbitrary number of strings, up to (char *) NULL.
60 Allocates memory using xmalloc. */
61
62 extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC;
63
64 /* Check whether two file descriptors refer to the same file. */
65
66 extern int fdmatch PARAMS ((int fd1, int fd2));
67
68 /* Get the working directory. The result is cached, so don't call
69 chdir() between calls to getpwd(). */
70
71 extern char * getpwd PARAMS ((void));
72
73 /* Get the amount of time the process has run, in microseconds. */
74
75 extern long get_run_time PARAMS ((void));
76
77 /* Choose a temporary directory to use for scratch files. */
78
79 extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC;
80
81 /* Return a temporary file name or NULL if unable to create one. */
82
83 extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC;
84
85 /* Allocate memory filled with spaces. Allocates using malloc. */
86
87 extern const char *spaces PARAMS ((int count));
88
89 /* Return the maximum error number for which strerror will return a
90 string. */
91
92 extern int errno_max PARAMS ((void));
93
94 /* Return the name of an errno value (e.g., strerrno (EINVAL) returns
95 "EINVAL"). */
96
97 extern const char *strerrno PARAMS ((int));
98
99 /* Given the name of an errno value, return the value. */
100
101 extern int strtoerrno PARAMS ((const char *));
102
103 /* ANSI's strerror(), but more robust. */
104
105 extern char *xstrerror PARAMS ((int));
106
107 /* Return the maximum signal number for which strsignal will return a
108 string. */
109
110 extern int signo_max PARAMS ((void));
111
112 /* Return a signal message string for a signal number
113 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
114 /* This is commented out as it can conflict with one in system headers.
115 We still document its existence though. */
116
117 /*extern const char *strsignal PARAMS ((int));*/
118
119 /* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
120 "SIGHUP"). */
121
122 extern const char *strsigno PARAMS ((int));
123
124 /* Given the name of a signal, return its number. */
125
126 extern int strtosigno PARAMS ((const char *));
127
128 /* Register a function to be run by xexit. Returns 0 on success. */
129
130 extern int xatexit PARAMS ((void (*fn) (void)));
131
132 /* Exit, calling all the functions registered with xatexit. */
133
134 extern void xexit PARAMS ((int status)) ATTRIBUTE_NORETURN;
135
136 /* Set the program name used by xmalloc. */
137
138 extern void xmalloc_set_program_name PARAMS ((const char *));
139
140 /* Report an allocation failure. */
141 extern void xmalloc_failed PARAMS ((size_t)) ATTRIBUTE_NORETURN;
142
143 /* Allocate memory without fail. If malloc fails, this will print a
144 message to stderr (using the name set by xmalloc_set_program_name,
145 if any) and then call xexit. */
146
147 extern PTR xmalloc PARAMS ((size_t)) ATTRIBUTE_MALLOC;
148
149 /* Reallocate memory without fail. This works like xmalloc. Note,
150 realloc type functions are not suitable for attribute malloc since
151 they may return the same address across multiple calls. */
152
153 extern PTR xrealloc PARAMS ((PTR, size_t));
154
155 /* Allocate memory without fail and set it to zero. This works like
156 xmalloc. */
157
158 extern PTR xcalloc PARAMS ((size_t, size_t)) ATTRIBUTE_MALLOC;
159
160 /* Copy a string into a memory buffer without fail. */
161
162 extern char *xstrdup PARAMS ((const char *)) ATTRIBUTE_MALLOC;
163
164 /* Copy an existing memory buffer to a new memory buffer without fail. */
165
166 extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC;
167
168 /* hex character manipulation routines */
169
170 #define _hex_array_size 256
171 #define _hex_bad 99
172 extern char _hex_value[_hex_array_size];
173 extern void hex_init PARAMS ((void));
174 #define hex_p(c) (hex_value (c) != _hex_bad)
175 /* If you change this, note well: Some code relies on side effects in
176 the argument being performed exactly once. */
177 #define hex_value(c) (_hex_value[(unsigned char) (c)])
178
179 /* Definitions used by the pexecute routine. */
180
181 #define PEXECUTE_FIRST 1
182 #define PEXECUTE_LAST 2
183 #define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
184 #define PEXECUTE_SEARCH 4
185 #define PEXECUTE_VERBOSE 8
186
187 /* Execute a program. */
188
189 extern int pexecute PARAMS ((const char *, char * const *, const char *,
190 const char *, char **, char **, int));
191
192 /* Wait for pexecute to finish. */
193
194 extern int pwait PARAMS ((int, int *, int));
195
196 /* Like sprintf but provides a pointer to malloc'd storage, which must
197 be freed by the caller. */
198
199 extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
200
201 /* Like vsprintf but provides a pointer to malloc'd storage, which
202 must be freed by the caller. */
203
204 extern int vasprintf PARAMS ((char **, const char *, va_list))
205 ATTRIBUTE_PRINTF(2,0);
206
207 #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
208
209 #ifdef __cplusplus
210 }
211 #endif
212
213
214 #endif /* ! defined (LIBIBERTY_H) */
This page took 0.046338 seconds and 5 git commands to generate.