source: branches/libc-0.6/src/binutils/include/libiberty.h

Last change on this file was 624, checked in by bird, 22 years ago

#597: silenced compiler warning on basename() proto.

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 11.3 KB
Line 
1/* Function declarations for libiberty.
2
3 Copyright 2001, 2002 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 ((const 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 !HAVE_DECL_BASENAME
77#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__EMX__) || defined (HAVE_DECL_BASENAME)
78extern char *basename PARAMS ((const char *));
79#else
80extern char *basename ();
81#endif
82#endif
83
84/* A well-defined basename () that is always compiled in. */
85
86extern const char *lbasename PARAMS ((const char *));
87
88/* A well-defined realpath () that is always compiled in. */
89
90extern char *lrealpath PARAMS ((const char *));
91
92/* Concatenate an arbitrary number of strings. You must pass NULL as
93 the last argument of this function, to terminate the list of
94 strings. Allocates memory using xmalloc. */
95
96extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC;
97
98/* Concatenate an arbitrary number of strings. You must pass NULL as
99 the last argument of this function, to terminate the list of
100 strings. Allocates memory using xmalloc. The first argument is
101 not one of the strings to be concatenated, but if not NULL is a
102 pointer to be freed after the new string is created, similar to the
103 way xrealloc works. */
104
105extern char *reconcat PARAMS ((char *, const char *, ...)) ATTRIBUTE_MALLOC;
106
107/* Determine the length of concatenating an arbitrary number of
108 strings. You must pass NULL as the last argument of this function,
109 to terminate the list of strings. */
110
111extern unsigned long concat_length PARAMS ((const char *, ...));
112
113/* Concatenate an arbitrary number of strings into a SUPPLIED area of
114 memory. You must pass NULL as the last argument of this function,
115 to terminate the list of strings. The supplied memory is assumed
116 to be large enough. */
117
118extern char *concat_copy PARAMS ((char *, const char *, ...));
119
120/* Concatenate an arbitrary number of strings into a GLOBAL area of
121 memory. You must pass NULL as the last argument of this function,
122 to terminate the list of strings. The supplied memory is assumed
123 to be large enough. */
124
125extern char *concat_copy2 PARAMS ((const char *, ...));
126
127/* This is the global area used by concat_copy2. */
128
129extern char *libiberty_concat_ptr;
130
131/* Concatenate an arbitrary number of strings. You must pass NULL as
132 the last argument of this function, to terminate the list of
133 strings. Allocates memory using alloca. The arguments are
134 evaluated twice! */
135#define ACONCAT(ACONCAT_PARAMS) \
136 (libiberty_concat_ptr = alloca (concat_length ACONCAT_PARAMS + 1), \
137 concat_copy2 ACONCAT_PARAMS)
138
139/* Check whether two file descriptors refer to the same file. */
140
141extern int fdmatch PARAMS ((int fd1, int fd2));
142
143/* Get the working directory. The result is cached, so don't call
144 chdir() between calls to getpwd(). */
145
146extern char * getpwd PARAMS ((void));
147
148/* Get the amount of time the process has run, in microseconds. */
149
150extern long get_run_time PARAMS ((void));
151
152/* Generate a relocated path to some installation directory. Allocates
153 return value using malloc. */
154
155extern char *make_relative_prefix PARAMS ((const char *, const char *,
156 const char *));
157
158/* Choose a temporary directory to use for scratch files. */
159
160extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC;
161
162/* Return a temporary file name or NULL if unable to create one. */
163
164extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC;
165
166/* Allocate memory filled with spaces. Allocates using malloc. */
167
168extern const char *spaces PARAMS ((int count));
169
170/* Return the maximum error number for which strerror will return a
171 string. */
172
173extern int errno_max PARAMS ((void));
174
175/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
176 "EINVAL"). */
177
178extern const char *strerrno PARAMS ((int));
179
180/* Given the name of an errno value, return the value. */
181
182extern int strtoerrno PARAMS ((const char *));
183
184/* ANSI's strerror(), but more robust. */
185
186extern char *xstrerror PARAMS ((int));
187
188/* Return the maximum signal number for which strsignal will return a
189 string. */
190
191extern int signo_max PARAMS ((void));
192
193/* Return a signal message string for a signal number
194 (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
195/* This is commented out as it can conflict with one in system headers.
196 We still document its existence though. */
197
198/*extern const char *strsignal PARAMS ((int));*/
199
200/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
201 "SIGHUP"). */
202
203extern const char *strsigno PARAMS ((int));
204
205/* Given the name of a signal, return its number. */
206
207extern int strtosigno PARAMS ((const char *));
208
209/* Register a function to be run by xexit. Returns 0 on success. */
210
211extern int xatexit PARAMS ((void (*fn) (void)));
212
213/* Exit, calling all the functions registered with xatexit. */
214
215extern void xexit PARAMS ((int status)) ATTRIBUTE_NORETURN;
216
217/* Set the program name used by xmalloc. */
218
219extern void xmalloc_set_program_name PARAMS ((const char *));