source: trunk/src/binutils/include/libiberty.h@ 101

Last change on this file since 101 was 10, checked in by bird, 22 years ago

Initial revision

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