Eliminate ARCH_NUM_REGS.
[deliverable/binutils-gdb.git] / include / libiberty.h
CommitLineData
252b5132
RH
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
14extern "C" {
15#endif
16
17#include "ansidecl.h"
18
b13291a9
DD
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
252b5132
RH
26/* Build an argument vector from a string. Allocates memory using
27 malloc. Use freeargv to free the vector. */
28
cc89ffe6 29extern char **buildargv PARAMS ((char *)) ATTRIBUTE_MALLOC;
252b5132
RH
30
31/* Free a vector returned by buildargv. */
32
33extern void freeargv PARAMS ((char **));
34
35/* Duplicate an argument vector. Allocates memory using malloc. Use
36 freeargv to free the vector. */
37
cc89ffe6 38extern char **dupargv PARAMS ((char **)) ATTRIBUTE_MALLOC;
252b5132
RH
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
79c6de76
L
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)
252b5132
RH
52extern char *basename PARAMS ((const char *));
53#else
79c6de76 54# if !defined (HAVE_DECL_BASENAME)
252b5132 55extern char *basename ();
79c6de76 56# endif
252b5132
RH
57#endif
58
8aa30e60
DD
59/* A well-defined basename () that is always compiled in. */
60
61extern char *lbasename PARAMS ((const char *));
62
252b5132
RH
63/* Concatenate an arbitrary number of strings, up to (char *) NULL.
64 Allocates memory using xmalloc. */
65
cc89ffe6 66extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC;
252b5132
RH
67
68/* Check whether two file descriptors refer to the same file. */
69
70extern int fdmatch PARAMS ((int fd1, int fd2));
71
cc89ffe6
ILT
72/* Get the working directory. The result is cached, so don't call
73 chdir() between calls to getpwd(). */
74
75extern char * getpwd PARAMS ((void));
76
252b5132
RH
77/* Get the amount of time the process has run, in microseconds. */
78
79extern long get_run_time PARAMS ((void));
80
81/* Choose a temporary directory to use for scratch files. */
82
cc89ffe6
ILT
83extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC;
84
85/* Return a temporary file name or NULL if unable to create one. */
86
87extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC;
252b5132
RH
88
89/* Allocate memory filled with spaces. Allocates using malloc. */
90
91extern const char *spaces PARAMS ((int count));
92
93/* Return the maximum error number for which strerror will return a
94 string. */
95
96extern int errno_max PARAMS ((void));
97
98/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
99 "EINVAL"). */
100
101extern const char *strerrno PARAMS ((int));
102
103/* Given the name of an errno value, return the value. */
104
105extern int strtoerrno PARAMS ((const char *));
106
107/* ANSI's strerror(), but more robust. */
108
109extern char *xstrerror PARAMS ((int));
110
111/* Return the maximum signal number for which strsignal will return a
112 string. */
113
114extern int signo_max PARAMS ((void));
115
116/* Return a signal message string for a signal number
117 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
118/* This is commented out as it can conflict with one in system headers.
119 We still document its existence though. */
120
121/*extern const char *strsignal PARAMS ((int));*/
122
123/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
124 "SIGHUP"). */
125
126extern const char *strsigno PARAMS ((int));
127
128/* Given the name of a signal, return its number. */
129
130extern int strtosigno PARAMS ((const char *));
131
132/* Register a function to be run by xexit. Returns 0 on success. */
133
134extern int xatexit PARAMS ((void (*fn) (void)));
135
136/* Exit, calling all the functions registered with xatexit. */
137
cc89ffe6 138extern void xexit PARAMS ((int status)) ATTRIBUTE_NORETURN;
252b5132
RH
139
140/* Set the program name used by xmalloc. */
141
142extern void xmalloc_set_program_name PARAMS ((const char *));
143
b13291a9
DD
144/* Report an allocation failure. */
145extern void xmalloc_failed PARAMS ((size_t)) ATTRIBUTE_NORETURN;
146
252b5132
RH
147/* Allocate memory without fail. If malloc fails, this will print a
148 message to stderr (using the name set by xmalloc_set_program_name,
149 if any) and then call xexit. */
150
cc89ffe6 151extern PTR xmalloc PARAMS ((size_t)) ATTRIBUTE_MALLOC;
252b5132 152
cc89ffe6
ILT
153/* Reallocate memory without fail. This works like xmalloc. Note,
154 realloc type functions are not suitable for attribute malloc since
155 they may return the same address across multiple calls. */
252b5132
RH
156
157extern PTR xrealloc PARAMS ((PTR, size_t));
158
159/* Allocate memory without fail and set it to zero. This works like
160 xmalloc. */
161
cc89ffe6 162extern PTR xcalloc PARAMS ((size_t, size_t)) ATTRIBUTE_MALLOC;
252b5132
RH
163
164/* Copy a string into a memory buffer without fail. */
165
cc89ffe6
ILT
166extern char *xstrdup PARAMS ((const char *)) ATTRIBUTE_MALLOC;
167
168/* Copy an existing memory buffer to a new memory buffer without fail. */
169
170extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC;
252b5132
RH
171
172/* hex character manipulation routines */
173
174#define _hex_array_size 256
175#define _hex_bad 99
176extern char _hex_value[_hex_array_size];
177extern void hex_init PARAMS ((void));
178#define hex_p(c) (hex_value (c) != _hex_bad)
179/* If you change this, note well: Some code relies on side effects in
180 the argument being performed exactly once. */
181#define hex_value(c) (_hex_value[(unsigned char) (c)])
182
183/* Definitions used by the pexecute routine. */
184
185#define PEXECUTE_FIRST 1
186#define PEXECUTE_LAST 2
187#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
188#define PEXECUTE_SEARCH 4
189#define PEXECUTE_VERBOSE 8
190
191/* Execute a program. */
192
193extern int pexecute PARAMS ((const char *, char * const *, const char *,
194 const char *, char **, char **, int));
195
196/* Wait for pexecute to finish. */
197
198extern int pwait PARAMS ((int, int *, int));
199
cc89ffe6
ILT
200/* Like sprintf but provides a pointer to malloc'd storage, which must
201 be freed by the caller. */
202
203extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
204
205/* Like vsprintf but provides a pointer to malloc'd storage, which
206 must be freed by the caller. */
207
208extern int vasprintf PARAMS ((char **, const char *, va_list))
209 ATTRIBUTE_PRINTF(2,0);
210
b18903cb
NC
211#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
212
30673bf5
DD
213/* Drastically simplified alloca configurator. If we're using GCC,
214 we use __builtin_alloca; otherwise we use the C alloca. The C
215 alloca is always available. You can override GCC by defining
216 USE_C_ALLOCA yourself. */
217extern PTR C_alloca PARAMS((size_t));
218#undef alloca
219#if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA
220# define alloca(x) __builtin_alloca(x)
221#else
222# define alloca(x) C_alloca(x)
223# undef USE_C_ALLOCA
224# define USE_C_ALLOCA 1
225#endif
226
252b5132
RH
227#ifdef __cplusplus
228}
229#endif
230
231
232#endif /* ! defined (LIBIBERTY_H) */
This page took 0.068455 seconds and 4 git commands to generate.