]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* sysdep.h -- handle host dependencies for the BFD library |
fd67aa11 | 2 | Copyright (C) 1995-2024 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 | 29 | #include "config.h" |
252b5132 | 30 | #include <stdio.h> |
252b5132 | 31 | |
83c79df8 AM |
32 | #ifdef HAVE_SYS_TYPES_H |
33 | #include <sys/types.h> | |
2e0fbf77 | 34 | #endif |
252b5132 | 35 | |
252b5132 | 36 | #include <stdlib.h> |
83c79df8 AM |
37 | #include <stddef.h> |
38 | #include <string.h> | |
252b5132 RH |
39 | |
40 | #ifdef HAVE_UNISTD_H | |
41 | #include <unistd.h> | |
42 | #endif | |
43 | ||
83c79df8 AM |
44 | #include <errno.h> |
45 | #include <time.h> | |
46 | ||
9d782e8d MW |
47 | #ifdef HAVE_SYS_RESOURCE_H |
48 | #include <sys/resource.h> | |
49 | #endif /* HAVE_SYS_RESOURCE_H */ | |
50 | ||
252b5132 RH |
51 | #ifdef USE_BINARY_FOPEN |
52 | #include "fopen-bin.h" | |
53 | #else | |
54 | #include "fopen-same.h" | |
55 | #endif | |
56 | ||
57 | #ifdef HAVE_FCNTL_H | |
58 | #include <fcntl.h> | |
59 | #else | |
60 | #ifdef HAVE_SYS_FILE_H | |
61 | #include <sys/file.h> | |
62 | #endif | |
63 | #endif | |
64 | ||
65 | #ifndef O_RDONLY | |
66 | #define O_RDONLY 0 | |
67 | #endif | |
68 | #ifndef O_WRONLY | |
69 | #define O_WRONLY 1 | |
70 | #endif | |
71 | #ifndef O_RDWR | |
72 | #define O_RDWR 2 | |
73 | #endif | |
74 | #ifndef O_ACCMODE | |
75 | #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) | |
76 | #endif | |
27b07675 AM |
77 | /* Systems that don't already define this, don't need it. */ |
78 | #ifndef O_BINARY | |
79 | #define O_BINARY 0 | |
80 | #endif | |
252b5132 RH |
81 | |
82 | #ifndef SEEK_SET | |
83 | #define SEEK_SET 0 | |
84 | #endif | |
85 | #ifndef SEEK_CUR | |
86 | #define SEEK_CUR 1 | |
87 | #endif | |
88 | ||
2e384d4f L |
89 | #ifdef HAVE_MMAP |
90 | #include <sys/mman.h> | |
91 | #endif | |
92 | ||
93 | #ifndef MAP_FILE | |
94 | #define MAP_FILE 0 | |
95 | #endif | |
96 | ||
97 | #ifndef MAP_FAILED | |
98 | #define MAP_FAILED ((void *) -1) | |
99 | #endif | |
100 | ||
9ba56ace L |
101 | #ifndef MAP_ANONYMOUS |
102 | #define MAP_ANONYMOUS MAP_ANON | |
103 | #endif | |
104 | ||
5af11cab AM |
105 | #include "filenames.h" |
106 | ||
d34a2b1d | 107 | #if !HAVE_DECL_FFS |
efa9bda4 AL |
108 | extern int ffs (int); |
109 | #endif | |
110 | ||
be5cacdb | 111 | #if !HAVE_DECL_STPCPY |
4a2a2686 | 112 | extern char *stpcpy (char *__dest, const char *__src); |
be5cacdb L |
113 | #endif |
114 | ||
ec7b76fe JG |
115 | #ifdef HAVE_FTELLO |
116 | #if !HAVE_DECL_FTELLO | |
117 | extern off_t ftello (FILE *stream); | |
118 | #endif | |
119 | #endif | |
120 | ||
121 | #ifdef HAVE_FTELLO64 | |
122 | #if !HAVE_DECL_FTELLO64 | |
123 | extern off64_t ftello64 (FILE *stream); | |
124 | #endif | |
125 | #endif | |
126 | ||
127 | #ifdef HAVE_FSEEKO | |
128 | #if !HAVE_DECL_FSEEKO | |
129 | extern int fseeko (FILE *stream, off_t offset, int whence); | |
130 | #endif | |
131 | #endif | |
132 | ||
133 | #ifdef HAVE_FSEEKO64 | |
134 | #if !HAVE_DECL_FSEEKO64 | |
135 | extern int fseeko64 (FILE *stream, off64_t offset, int whence); | |
136 | #endif | |
137 | #endif | |
138 | ||
ba3ef70e AM |
139 | /* Define offsetof for those systems which lack it */ |
140 | ||
141 | #ifndef offsetof | |
142 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | |
143 | #endif | |
144 | ||
f07afc65 RO |
145 | #ifndef ENABLE_NLS |
146 | /* The Solaris version of locale.h always includes libintl.h. If we have | |
147 | been configured with --disable-nls then ENABLE_NLS will not be defined | |
148 | and the dummy definitions of bindtextdomain (et al) below will conflict | |
149 | with the defintions in libintl.h. So we define these values to prevent | |
150 | the bogus inclusion of libintl.h. */ | |
151 | # define _LIBINTL_H | |
152 | # define _LIBGETTEXT_H | |
153 | #endif | |
154 | #include <locale.h> | |
155 | ||
252b5132 | 156 | #ifdef ENABLE_NLS |
6003e27e AM |
157 | # include <libintl.h> |
158 | /* Note the redefinition of gettext and ngettext here to use PACKAGE. | |
159 | ||
160 | This is because the code in this directory is used to build a | |
161 | library which will be linked with code in other directories to form | |
07f1f3aa | 162 | programs. We want to maintain a separate translation file for this |
6003e27e AM |
163 | directory however, rather than being forced to merge it with that |
164 | of any program linked to libbfd. This is a library, so it cannot | |
165 | depend on the catalog currently loaded. | |
166 | ||
167 | In order to do this, we have to make sure that when we extract | |
168 | messages we use the BFD domain rather than the domain of the | |
169 | program that included the bfd library, (eg OBJDUMP). Hence we use | |
170 | dgettext (PACKAGE, String) and define PACKAGE to be 'bfd'. | |
171 | (See the code in configure). */ | |
172 | # undef gettext | |
173 | # define gettext(Msgid) dgettext (PACKAGE, Msgid) | |
174 | # undef ngettext | |
175 | # define ngettext(Msgid1, Msgid2, n) dngettext (PACKAGE, Msgid1, Msgid2, n) | |
176 | # define _(String) gettext (String) | |
177 | # ifdef gettext_noop | |
178 | # define N_(String) gettext_noop (String) | |
179 | # else | |
180 | # define N_(String) (String) | |
181 | # endif | |
252b5132 | 182 | #else |
5af11cab AM |
183 | # define gettext(Msgid) (Msgid) |
184 | # define dgettext(Domainname, Msgid) (Msgid) | |
185 | # define dcgettext(Domainname, Msgid, Category) (Msgid) | |
6003e27e AM |
186 | # define ngettext(Msgid1, Msgid2, n) \ |
187 | (n == 1 ? Msgid1 : Msgid2) | |
188 | # define dngettext(Domainname, Msgid1, Msgid2, n) \ | |
189 | (n == 1 ? Msgid1 : Msgid2) | |
190 | # define dcngettext(Domainname, Msgid1, Msgid2, n, Category) \ | |
191 | (n == 1 ? Msgid1 : Msgid2) | |
192 | # define textdomain(Domainname) do {} while (0) | |
193 | # define bindtextdomain(Domainname, Dirname) do {} while (0) | |
5af11cab AM |
194 | # define _(String) (String) |
195 | # define N_(String) (String) | |
252b5132 RH |
196 | #endif |
197 | ||
0dd7428d TT |
198 | #ifndef HAVE_GETUID |
199 | #define getuid() 0 | |
200 | #endif | |
201 | ||
202 | #ifndef HAVE_GETGID | |
203 | #define getgid() 0 | |
204 | #endif | |
205 | ||
0a1b45a2 AM |
206 | #define POISON_BFD_BOOLEAN 1 |
207 | ||
252b5132 | 208 | #endif /* ! defined (BFD_SYSDEP_H) */ |