74 |
to find the declaration so provide a fully prototyped one. If it |
to find the declaration so provide a fully prototyped one. If it |
75 |
is 1, we found it so don't provide any declaration at all. */ |
is 1, we found it so don't provide any declaration at all. */ |
76 |
#if !HAVE_DECL_BASENAME |
#if !HAVE_DECL_BASENAME |
77 |
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (HAVE_DECL_BASENAME) |
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME) |
78 |
extern char *basename PARAMS ((const char *)); |
extern char *basename PARAMS ((const char *)); |
79 |
#else |
#else |
80 |
extern char *basename (); |
extern char *basename (); |
85 |
|
|
86 |
extern const char *lbasename PARAMS ((const char *)); |
extern const char *lbasename PARAMS ((const char *)); |
87 |
|
|
88 |
|
/* A well-defined realpath () that is always compiled in. */ |
89 |
|
|
90 |
|
extern char *lrealpath PARAMS ((const char *)); |
91 |
|
|
92 |
/* Concatenate an arbitrary number of strings. You must pass NULL as |
/* Concatenate an arbitrary number of strings. You must pass NULL as |
93 |
the last argument of this function, to terminate the list of |
the last argument of this function, to terminate the list of |
94 |
strings. Allocates memory using xmalloc. */ |
strings. Allocates memory using xmalloc. */ |
95 |
|
|
96 |
extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC; |
extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL; |
97 |
|
|
98 |
/* Concatenate an arbitrary number of strings. You must pass NULL as |
/* Concatenate an arbitrary number of strings. You must pass NULL as |
99 |
the last argument of this function, to terminate the list of |
the last argument of this function, to terminate the list of |
102 |
pointer to be freed after the new string is created, similar to the |
pointer to be freed after the new string is created, similar to the |
103 |
way xrealloc works. */ |
way xrealloc works. */ |
104 |
|
|
105 |
extern char *reconcat PARAMS ((char *, const char *, ...)) ATTRIBUTE_MALLOC; |
extern char *reconcat PARAMS ((char *, const char *, ...)) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL; |
106 |
|
|
107 |
/* Determine the length of concatenating an arbitrary number of |
/* Determine the length of concatenating an arbitrary number of |
108 |
strings. You must pass NULL as the last argument of this function, |
strings. You must pass NULL as the last argument of this function, |
109 |
to terminate the list of strings. */ |
to terminate the list of strings. */ |
110 |
|
|
111 |
extern unsigned long concat_length PARAMS ((const char *, ...)); |
extern unsigned long concat_length PARAMS ((const char *, ...)) ATTRIBUTE_SENTINEL; |
112 |
|
|
113 |
/* Concatenate an arbitrary number of strings into a SUPPLIED area of |
/* Concatenate an arbitrary number of strings into a SUPPLIED area of |
114 |
memory. You must pass NULL as the last argument of this function, |
memory. You must pass NULL as the last argument of this function, |
115 |
to terminate the list of strings. The supplied memory is assumed |
to terminate the list of strings. The supplied memory is assumed |
116 |
to be large enough. */ |
to be large enough. */ |
117 |
|
|
118 |
extern char *concat_copy PARAMS ((char *, const char *, ...)); |
extern char *concat_copy PARAMS ((char *, const char *, ...)) ATTRIBUTE_SENTINEL; |
119 |
|
|
120 |
/* Concatenate an arbitrary number of strings into a GLOBAL area of |
/* Concatenate an arbitrary number of strings into a GLOBAL area of |
121 |
memory. You must pass NULL as the last argument of this function, |
memory. You must pass NULL as the last argument of this function, |
122 |
to terminate the list of strings. The supplied memory is assumed |
to terminate the list of strings. The supplied memory is assumed |
123 |
to be large enough. */ |
to be large enough. */ |
124 |
|
|
125 |
extern char *concat_copy2 PARAMS ((const char *, ...)); |
extern char *concat_copy2 PARAMS ((const char *, ...)) ATTRIBUTE_SENTINEL; |
126 |
|
|
127 |
/* This is the global area used by concat_copy2. */ |
/* This is the global area used by concat_copy2. */ |
128 |
|
|
149 |
|
|
150 |
extern long get_run_time PARAMS ((void)); |
extern long get_run_time PARAMS ((void)); |
151 |
|
|
152 |
|
/* Generate a relocated path to some installation directory. Allocates |
153 |
|
return value using malloc. */ |
154 |
|
|
155 |
|
extern char *make_relative_prefix PARAMS ((const char *, const char *, |
156 |
|
const char *)); |
157 |
|
|
158 |
/* Choose a temporary directory to use for scratch files. */ |
/* Choose a temporary directory to use for scratch files. */ |
159 |
|
|
160 |
extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC; |
extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC; |
163 |
|
|
164 |
extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC; |
extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC; |
165 |
|
|
166 |
|
/* Remove a link to a file unless it is special. */ |
167 |
|
|
168 |
|
extern int unlink_if_ordinary PARAMS((const char *)); |
169 |
|
|
170 |
/* Allocate memory filled with spaces. Allocates using malloc. */ |
/* Allocate memory filled with spaces. Allocates using malloc. */ |
171 |
|
|
172 |
extern const char *spaces PARAMS ((int count)); |
extern const char *spaces PARAMS ((int count)); |
250 |
|
|
251 |
extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC; |
extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC; |
252 |
|
|
253 |
|
/* Physical memory routines. Return values are in BYTES. */ |
254 |
|
extern double physmem_total PARAMS ((void)); |
255 |
|
extern double physmem_available PARAMS ((void)); |
256 |
|
|
257 |
|
|
258 |
|
/* These macros provide a K&R/C89/C++-friendly way of allocating structures |
259 |
|
with nice encapsulation. The XDELETE*() macros are technically |
260 |
|
superfluous, but provided here for symmetry. Using them consistently |
261 |
|
makes it easier to update client code to use different allocators such |
262 |
|
as new/delete and new[]/delete[]. */ |
263 |
|
|
264 |
|
/* Scalar allocators. */ |
265 |
|
|
266 |
|
#define XNEW(T) ((T *) xmalloc (sizeof (T))) |
267 |
|
#define XCNEW(T) ((T *) xcalloc (1, sizeof (T))) |
268 |
|
#define XDELETE(P) free ((void*) (P)) |
269 |
|
|
270 |
|
/* Array allocators. */ |
271 |
|
|
272 |
|
#define XNEWVEC(T, N) ((T *) xmalloc (sizeof (T) * (N))) |
273 |
|
#define XCNEWVEC(T, N) ((T *) xcalloc ((N), sizeof (T))) |
274 |
|
#define XRESIZEVEC(T, P, N) ((T *) xrealloc ((void *) (P), sizeof (T) * (N))) |
275 |
|
#define XDELETEVEC(P) free ((void*) (P)) |
276 |
|
|
277 |
|
/* Allocators for variable-sized structures and raw buffers. */ |
278 |
|
|
279 |
|
#define XNEWVAR(T, S) ((T *) xmalloc ((S))) |
280 |
|
#define XCNEWVAR(T, S) ((T *) xcalloc (1, (S))) |
281 |
|
#define XRESIZEVAR(T, P, S) ((T *) xrealloc ((P), (S))) |
282 |
|
|
283 |
|
/* Type-safe obstack allocator. */ |
284 |
|
|
285 |
|
#define XOBNEW(O, T) ((T *) obstack_alloc ((O), sizeof (T))) |
286 |
|
|
287 |
|
|
288 |
/* hex character manipulation routines */ |
/* hex character manipulation routines */ |
289 |
|
|
290 |
#define _hex_array_size 256 |
#define _hex_array_size 256 |
291 |
#define _hex_bad 99 |
#define _hex_bad 99 |
292 |
extern const char _hex_value[_hex_array_size]; |
extern const unsigned char _hex_value[_hex_array_size]; |
293 |
extern void hex_init PARAMS ((void)); |
extern void hex_init PARAMS ((void)); |
294 |
#define hex_p(c) (hex_value (c) != _hex_bad) |
#define hex_p(c) (hex_value (c) != _hex_bad) |
295 |
/* If you change this, note well: Some code relies on side effects in |
/* If you change this, note well: Some code relies on side effects in |
296 |
the argument being performed exactly once. */ |
the argument being performed exactly once. */ |
297 |
#define hex_value(c) (_hex_value[(unsigned char) (c)]) |
#define hex_value(c) ((unsigned int) _hex_value[(unsigned char) (c)]) |
298 |
|
|
299 |
/* Definitions used by the pexecute routine. */ |
/* Definitions used by the pexecute routine. */ |
300 |
|
|
313 |
|
|
314 |
extern int pwait PARAMS ((int, int *, int)); |
extern int pwait PARAMS ((int, int *, int)); |
315 |
|
|
316 |
|
#if !HAVE_DECL_ASPRINTF |
317 |
/* Like sprintf but provides a pointer to malloc'd storage, which must |
/* Like sprintf but provides a pointer to malloc'd storage, which must |
318 |
be freed by the caller. */ |
be freed by the caller. */ |
319 |
|
|
320 |
extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2; |
extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2; |
321 |
|
#endif |
322 |
|
|
323 |
|
#if !HAVE_DECL_VASPRINTF |
324 |
/* Like vsprintf but provides a pointer to malloc'd storage, which |
/* Like vsprintf but provides a pointer to malloc'd storage, which |
325 |
must be freed by the caller. */ |
must be freed by the caller. */ |
326 |
|
|
327 |
extern int vasprintf PARAMS ((char **, const char *, va_list)) |
extern int vasprintf PARAMS ((char **, const char *, va_list)) |
328 |
ATTRIBUTE_PRINTF(2,0); |
ATTRIBUTE_PRINTF(2,0); |
329 |
|
#endif |
330 |
|
|
331 |
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) |
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) |
332 |
|
|
344 |
# define ASTRDUP(X) \ |
# define ASTRDUP(X) \ |
345 |
(__extension__ ({ const char *const libiberty_optr = (X); \ |
(__extension__ ({ const char *const libiberty_optr = (X); \ |
346 |
const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \ |
const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \ |
347 |
char *const libiberty_nptr = alloca (libiberty_len); \ |
char *const libiberty_nptr = (char *const) alloca (libiberty_len); \ |
348 |
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); })) |
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); })) |
349 |
#else |
#else |
350 |
# define alloca(x) C_alloca(x) |
# define alloca(x) C_alloca(x) |
358 |
# define ASTRDUP(X) \ |
# define ASTRDUP(X) \ |
359 |
(libiberty_optr = (X), \ |
(libiberty_optr = (X), \ |
360 |
libiberty_len = strlen (libiberty_optr) + 1, \ |
libiberty_len = strlen (libiberty_optr) + 1, \ |
361 |
libiberty_nptr = alloca (libiberty_len), \ |
libiberty_nptr = (char *) alloca (libiberty_len), \ |
362 |
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len)) |
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len)) |
363 |
#endif |
#endif |
364 |
|
|