* linespec.c (decode_line_1): Skip argptr over a leading
[deliverable/binutils-gdb.git] / include / libiberty.h
CommitLineData
252b5132 1/* Function declarations for libiberty.
4f1d9bd8
NC
2
3 Copyright 2001 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19
252b5132
RH
20 Written by Cygnus Support, 1994.
21
22 The libiberty library provides a number of functions which are
23 missing on some operating systems. We do not declare those here,
24 to avoid conflicts with the system header files on operating
25 systems that do support those functions. In this file we only
26 declare those functions which are specific to libiberty. */
27
28#ifndef LIBIBERTY_H
29#define LIBIBERTY_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#include "ansidecl.h"
36
b13291a9
DD
37#ifdef ANSI_PROTOTYPES
38/* Get a definition for size_t. */
39#include <stddef.h>
40/* Get a definition for va_list. */
41#include <stdarg.h>
42#endif
43
252b5132
RH
44/* Build an argument vector from a string. Allocates memory using
45 malloc. Use freeargv to free the vector. */
46
cc89ffe6 47extern char **buildargv PARAMS ((char *)) ATTRIBUTE_MALLOC;
252b5132
RH
48
49/* Free a vector returned by buildargv. */
50
51extern void freeargv PARAMS ((char **));
52
53/* Duplicate an argument vector. Allocates memory using malloc. Use
54 freeargv to free the vector. */
55
cc89ffe6 56extern char **dupargv PARAMS ((char **)) ATTRIBUTE_MALLOC;
252b5132
RH
57
58
59/* Return the last component of a path name. Note that we can't use a
60 prototype here because the parameter is declared inconsistently
61 across different systems, sometimes as "char *" and sometimes as
62 "const char *" */
63
79c6de76
L
64/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
65 undefined, we haven't run the autoconf check so provide the
66 declaration without arguments. If it is 0, we checked and failed
67 to find the declaration so provide a fully prototyped one. If it
68 is 1, we found it so don't provide any declaration at all. */
69#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || (defined (HAVE_DECL_BASENAME) && !HAVE_DECL_BASENAME)
252b5132
RH
70extern char *basename PARAMS ((const char *));
71#else
79c6de76 72# if !defined (HAVE_DECL_BASENAME)
252b5132 73extern char *basename ();
79c6de76 74# endif
252b5132
RH
75#endif
76
8aa30e60
DD
77/* A well-defined basename () that is always compiled in. */
78
79extern char *lbasename PARAMS ((const char *));
80
252b5132
RH
81/* Concatenate an arbitrary number of strings, up to (char *) NULL.
82 Allocates memory using xmalloc. */
83
cc89ffe6 84extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC;
252b5132
RH
85
86/* Check whether two file descriptors refer to the same file. */
87
88extern int fdmatch PARAMS ((int fd1, int fd2));
89
cc89ffe6
ILT
90/* Get the working directory. The result is cached, so don't call
91 chdir() between calls to getpwd(). */
92
93extern char * getpwd PARAMS ((void));
94
252b5132
RH
95/* Get the amount of time the process has run, in microseconds. */
96
97extern long get_run_time PARAMS ((void));
98
99/* Choose a temporary directory to use for scratch files. */
100
cc89ffe6
ILT
101extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC;
102
103/* Return a temporary file name or NULL if unable to create one. */
104
105extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC;
252b5132
RH
106
107/* Allocate memory filled with spaces. Allocates using malloc. */
108
109extern const char *spaces PARAMS ((int count));
110
111/* Return the maximum error number for which strerror will return a
112 string. */
113
114extern int errno_max PARAMS ((void));
115
116/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
117 "EINVAL"). */
118
119extern const char *strerrno PARAMS ((int));
120
121/* Given the name of an errno value, return the value. */
122
123extern int strtoerrno PARAMS ((const char *));
124
125/* ANSI's strerror(), but more robust. */
126
127extern char *xstrerror PARAMS ((int));
128
129/* Return the maximum signal number for which strsignal will return a
130 string. */
131
132extern int signo_max PARAMS ((void));
133
134/* Return a signal message string for a signal number
135 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
136/* This is commented out as it can conflict with one in system headers.
137 We still document its existence though. */
138
139/*extern const char *strsignal PARAMS ((int));*/
140
141/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
142 "SIGHUP"). */
143
144extern const char *strsigno PARAMS ((int));
145
146/* Given the name of a signal, return its number. */
147
148extern int strtosigno PARAMS ((const char *));
149
150/* Register a function to be run by xexit. Returns 0 on success. */
151
152extern int xatexit PARAMS ((void (*fn) (void)));
153
154/* Exit, calling all the functions registered with xatexit. */
155
cc89ffe6 156extern void xexit PARAMS ((int status)) ATTRIBUTE_NORETURN;
252b5132
RH
157
158/* Set the program name used by xmalloc. */
159
160extern void xmalloc_set_program_name PARAMS ((const char *));
161
b13291a9
DD
162/* Report an allocation failure. */
163extern void xmalloc_failed PARAMS ((size_t)) ATTRIBUTE_NORETURN;
164
252b5132
RH
165/* Allocate memory without fail. If malloc fails, this will print a
166 message to stderr (using the name set by xmalloc_set_program_name,
167 if any) and then call xexit. */
168
cc89ffe6 169extern PTR xmalloc PARAMS ((size_t)) ATTRIBUTE_MALLOC;
252b5132 170
cc89ffe6
ILT
171/* Reallocate memory without fail. This works like xmalloc. Note,
172 realloc type functions are not suitable for attribute malloc since
173 they may return the same address across multiple calls. */
252b5132
RH
174
175extern PTR xrealloc PARAMS ((PTR, size_t));
176
177/* Allocate memory without fail and set it to zero. This works like
178 xmalloc. */
179
cc89ffe6 180extern PTR xcalloc PARAMS ((size_t, size_t)) ATTRIBUTE_MALLOC;
252b5132
RH
181
182/* Copy a string into a memory buffer without fail. */
183
cc89ffe6
ILT
184extern char *xstrdup PARAMS ((const char *)) ATTRIBUTE_MALLOC;
185
186/* Copy an existing memory buffer to a new memory buffer without fail. */
187
188extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC;
252b5132
RH
189
190/* hex character manipulation routines */
191
192#define _hex_array_size 256
193#define _hex_bad 99
194extern char _hex_value[_hex_array_size];
195extern void hex_init PARAMS ((void));
196#define hex_p(c) (hex_value (c) != _hex_bad)
197/* If you change this, note well: Some code relies on side effects in
198 the argument being performed exactly once. */
199#define hex_value(c) (_hex_value[(unsigned char) (c)])
200
201/* Definitions used by the pexecute routine. */
202
203#define PEXECUTE_FIRST 1
204#define PEXECUTE_LAST 2
205#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
206#define PEXECUTE_SEARCH 4
207#define PEXECUTE_VERBOSE 8
208
209/* Execute a program. */
210
211extern int pexecute PARAMS ((const char *, char * const *, const char *,
212 const char *, char **, char **, int));
213
214/* Wait for pexecute to finish. */
215
216extern int pwait PARAMS ((int, int *, int));
217
cc89ffe6
ILT
218/* Like sprintf but provides a pointer to malloc'd storage, which must
219 be freed by the caller. */
220
221extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
222
223/* Like vsprintf but provides a pointer to malloc'd storage, which
224 must be freed by the caller. */
225
226extern int vasprintf PARAMS ((char **, const char *, va_list))
227 ATTRIBUTE_PRINTF(2,0);
228
b18903cb
NC
229#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
230
30673bf5
DD
231/* Drastically simplified alloca configurator. If we're using GCC,
232 we use __builtin_alloca; otherwise we use the C alloca. The C
233 alloca is always available. You can override GCC by defining
234 USE_C_ALLOCA yourself. */
235extern PTR C_alloca PARAMS((size_t));
236#undef alloca
237#if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA
238# define alloca(x) __builtin_alloca(x)
239#else
240# define alloca(x) C_alloca(x)
241# undef USE_C_ALLOCA
242# define USE_C_ALLOCA 1
243#endif
244
252b5132
RH
245#ifdef __cplusplus
246}
247#endif
248
249
250#endif /* ! defined (LIBIBERTY_H) */
This page took 0.063809 seconds and 4 git commands to generate.