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