Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* sysdep.h -- handle host dependencies for the BFD library |
b3adc24a | 2 | Copyright (C) 1995-2020 Free Software Foundation, Inc. |
252b5132 RH |
3 | Written by Cygnus Support. |
4 | ||
cd123cb7 NC |
5 | This file is part of BFD, the Binary File Descriptor library. |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
20 | MA 02110-1301, USA. */ | |
252b5132 RH |
21 | |
22 | #ifndef BFD_SYSDEP_H | |
23 | #define BFD_SYSDEP_H | |
24 | ||
df7b86aa NC |
25 | #ifdef PACKAGE |
26 | #error sysdep.h must be included in lieu of config.h | |
27 | #endif | |
28 | ||
252b5132 RH |
29 | #include "config.h" |
30 | ||
31 | #ifdef HAVE_STDDEF_H | |
32 | #include <stddef.h> | |
33 | #endif | |
34 | ||
35 | #include <stdio.h> | |
36 | #include <sys/types.h> | |
252b5132 RH |
37 | |
38 | #include <errno.h> | |
39 | #if !(defined(errno) || defined(_MSC_VER) && defined(_INC_ERRNO)) | |
40 | extern int errno; | |
41 | #endif | |
42 | ||
2e0fbf77 JW |
43 | #ifdef STRING_WITH_STRINGS |
44 | #include <string.h> | |
45 | #include <strings.h> | |
46 | #else | |
252b5132 RH |
47 | #ifdef HAVE_STRING_H |
48 | #include <string.h> | |
49 | #else | |
50 | #ifdef HAVE_STRINGS_H | |
51 | #include <strings.h> | |
52 | #else | |
53 | extern char *strchr (); | |
54 | extern char *strrchr (); | |
55 | #endif | |
56 | #endif | |
2e0fbf77 | 57 | #endif |
252b5132 RH |
58 | |
59 | #ifdef HAVE_STDLIB_H | |
60 | #include <stdlib.h> | |
61 | #endif | |
62 | ||
63 | #ifdef TIME_WITH_SYS_TIME | |
64 | #include <sys/time.h> | |
65 | #include <time.h> | |
66 | #else | |
67 | #ifdef HAVE_SYS_TIME_H | |
68 | #include <sys/time.h> | |
69 | #else | |
70 | #include <time.h> | |
71 | #endif | |
72 | #endif | |
73 | ||
74 | #ifdef HAVE_UNISTD_H | |
75 | #include <unistd.h> | |
76 | #endif | |
77 | ||
9d782e8d MW |
78 | #ifdef HAVE_SYS_RESOURCE_H |
79 | #include <sys/resource.h> | |
80 | #endif /* HAVE_SYS_RESOURCE_H */ | |
81 | ||
252b5132 RH |
82 | #ifdef USE_BINARY_FOPEN |
83 | #include "fopen-bin.h" | |
84 | #else | |
85 | #include "fopen-same.h" | |
86 | #endif | |
87 | ||
88 | #ifdef HAVE_FCNTL_H | |
89 | #include <fcntl.h> | |
90 | #else | |
91 | #ifdef HAVE_SYS_FILE_H | |
92 | #include <sys/file.h> | |
93 | #endif | |
94 | #endif | |
95 | ||
96 | #ifndef O_RDONLY | |
97 | #define O_RDONLY 0 | |
98 | #endif | |
99 | #ifndef O_WRONLY | |
100 | #define O_WRONLY 1 | |
101 | #endif | |
102 | #ifndef O_RDWR | |
103 | #define O_RDWR 2 | |
104 | #endif | |
105 | #ifndef O_ACCMODE | |
106 | #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) | |
107 | #endif | |
27b07675 AM |
108 | /* Systems that don't already define this, don't need it. */ |
109 | #ifndef O_BINARY | |
110 | #define O_BINARY 0 | |
111 | #endif | |
252b5132 RH |
112 | |
113 | #ifndef SEEK_SET | |
114 | #define SEEK_SET 0 | |
115 | #endif | |
116 | #ifndef SEEK_CUR | |
117 | #define SEEK_CUR 1 | |
118 | #endif | |
119 | ||
5af11cab AM |
120 | #include "filenames.h" |
121 | ||
d34a2b1d | 122 | #if !HAVE_DECL_FFS |
efa9bda4 AL |
123 | extern int ffs (int); |
124 | #endif | |
125 | ||
d34a2b1d | 126 | #if !HAVE_DECL_FREE |
efa9bda4 AL |
127 | extern void free (); |
128 | #endif | |
129 | ||
d34a2b1d | 130 | #if !HAVE_DECL_GETENV |
efa9bda4 | 131 | extern char *getenv (); |
252b5132 RH |
132 | #endif |
133 | ||
d34a2b1d | 134 | #if !HAVE_DECL_MALLOC |
252b5132 RH |
135 | extern PTR malloc (); |
136 | #endif | |
137 | ||
d34a2b1d | 138 | #if !HAVE_DECL_REALLOC |
252b5132 RH |
139 | extern PTR realloc (); |
140 | #endif | |
141 | ||
be5cacdb | 142 | #if !HAVE_DECL_STPCPY |
4a2a2686 | 143 | extern char *stpcpy (char *__dest, const char *__src); |
be5cacdb L |
144 | #endif |
145 | ||
d34a2b1d | 146 | #if !HAVE_DECL_STRSTR |
efa9bda4 | 147 | extern char *strstr (); |
252b5132 RH |
148 | #endif |
149 | ||
ec7b76fe JG |
150 | #ifdef HAVE_FTELLO |
151 | #if !HAVE_DECL_FTELLO | |
152 | extern off_t ftello (FILE *stream); | |
153 | #endif | |
154 | #endif | |
155 | ||
156 | #ifdef HAVE_FTELLO64 | |
157 | #if !HAVE_DECL_FTELLO64 | |
158 | extern off64_t ftello64 (FILE *stream); | |
159 | #endif | |
160 | #endif | |
161 | ||
162 | #ifdef HAVE_FSEEKO | |
163 | #if !HAVE_DECL_FSEEKO | |
164 | extern int fseeko (FILE *stream, off_t offset, int whence); | |
165 | #endif | |
166 | #endif | |
167 | ||
168 | #ifdef HAVE_FSEEKO64 | |
169 | #if !HAVE_DECL_FSEEKO64 | |
170 | extern int fseeko64 (FILE *stream, off64_t offset, int whence); | |
171 | #endif | |
172 | #endif | |
173 | ||
5a026fc9 NC |
174 | #if !HAVE_DECL_STRNLEN |
175 | size_t strnlen (const char *, size_t); | |
176 | #endif | |
177 | ||
ba3ef70e AM |
178 | /* Define offsetof for those systems which lack it */ |
179 | ||
180 | #ifndef offsetof | |
181 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | |
182 | #endif | |
183 | ||
252b5132 | 184 | #ifdef ENABLE_NLS |
6003e27e AM |
185 | # include <libintl.h> |
186 | /* Note the redefinition of gettext and ngettext here to use PACKAGE. | |
187 | ||
188 | This is because the code in this directory is used to build a | |
189 | library which will be linked with code in other directories to form | |
190 | programs. We want to maintain a seperate translation file for this | |
191 | directory however, rather than being forced to merge it with that | |
192 | of any program linked to libbfd. This is a library, so it cannot | |
193 | depend on the catalog currently loaded. | |
194 | ||
195 | In order to do this, we have to make sure that when we extract | |
196 | messages we use the BFD domain rather than the domain of the | |
197 | program that included the bfd library, (eg OBJDUMP). Hence we use | |
198 | dgettext (PACKAGE, String) and define PACKAGE to be 'bfd'. | |
199 | (See the code in configure). */ | |
200 | # undef gettext | |
201 | # define gettext(Msgid) dgettext (PACKAGE, Msgid) | |
202 | # undef ngettext | |
203 | # define ngettext(Msgid1, Msgid2, n) dngettext (PACKAGE, Msgid1, Msgid2, n) | |
204 | # define _(String) gettext (String) | |
205 | # ifdef gettext_noop | |
206 | # define N_(String) gettext_noop (String) | |
207 | # else | |
208 | # define N_(String) (String) | |
209 | # endif | |
252b5132 | 210 | #else |
5af11cab AM |
211 | # define gettext(Msgid) (Msgid) |
212 | # define dgettext(Domainname, Msgid) (Msgid) | |
213 | # define dcgettext(Domainname, Msgid, Category) (Msgid) | |
6003e27e AM |
214 | # define ngettext(Msgid1, Msgid2, n) \ |
215 | (n == 1 ? Msgid1 : Msgid2) | |
216 | # define dngettext(Domainname, Msgid1, Msgid2, n) \ | |
217 | (n == 1 ? Msgid1 : Msgid2) | |
218 | # define dcngettext(Domainname, Msgid1, Msgid2, n, Category) \ | |
219 | (n == 1 ? Msgid1 : Msgid2) | |
220 | # define textdomain(Domainname) do {} while (0) | |
221 | # define bindtextdomain(Domainname, Dirname) do {} while (0) | |
5af11cab AM |
222 | # define _(String) (String) |
223 | # define N_(String) (String) | |
252b5132 RH |
224 | #endif |
225 | ||
226 | #endif /* ! defined (BFD_SYSDEP_H) */ |