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