Automatic date update in version.in
[binutils-gdb.git] / bfd / sysdep.h
blobb907bc26a09b5d62f3fb0d608ec13d2656a24ef6
1 /* sysdep.h -- handle host dependencies for the BFD library
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3 Written by Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
22 #ifndef BFD_SYSDEP_H
23 #define BFD_SYSDEP_H
25 #ifdef PACKAGE
26 #error sysdep.h must be included in lieu of config.h
27 #endif
29 #include "config.h"
30 #include <stdio.h>
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
36 #include <stdlib.h>
37 #include <stddef.h>
38 #include <string.h>
40 #ifdef HAVE_UNISTD_H
41 #include <unistd.h>
42 #endif
44 #include <errno.h>
45 #include <time.h>
47 #ifdef HAVE_SYS_RESOURCE_H
48 #include <sys/resource.h>
49 #endif /* HAVE_SYS_RESOURCE_H */
51 #ifdef USE_BINARY_FOPEN
52 #include "fopen-bin.h"
53 #else
54 #include "fopen-same.h"
55 #endif
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
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
77 /* Systems that don't already define this, don't need it. */
78 #ifndef O_BINARY
79 #define O_BINARY 0
80 #endif
82 #ifndef SEEK_SET
83 #define SEEK_SET 0
84 #endif
85 #ifndef SEEK_CUR
86 #define SEEK_CUR 1
87 #endif
89 #ifdef HAVE_MMAP
90 #include <sys/mman.h>
91 #endif
93 #ifndef MAP_FILE
94 #define MAP_FILE 0
95 #endif
97 #ifndef MAP_FAILED
98 #define MAP_FAILED ((void *) -1)
99 #endif
101 #include "filenames.h"
103 #if !HAVE_DECL_FFS
104 extern int ffs (int);
105 #endif
107 #if !HAVE_DECL_STPCPY
108 extern char *stpcpy (char *__dest, const char *__src);
109 #endif
111 #ifdef HAVE_FTELLO
112 #if !HAVE_DECL_FTELLO
113 extern off_t ftello (FILE *stream);
114 #endif
115 #endif
117 #ifdef HAVE_FTELLO64
118 #if !HAVE_DECL_FTELLO64
119 extern off64_t ftello64 (FILE *stream);
120 #endif
121 #endif
123 #ifdef HAVE_FSEEKO
124 #if !HAVE_DECL_FSEEKO
125 extern int fseeko (FILE *stream, off_t offset, int whence);
126 #endif
127 #endif
129 #ifdef HAVE_FSEEKO64
130 #if !HAVE_DECL_FSEEKO64
131 extern int fseeko64 (FILE *stream, off64_t offset, int whence);
132 #endif
133 #endif
135 /* Define offsetof for those systems which lack it */
137 #ifndef offsetof
138 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
139 #endif
141 #ifndef ENABLE_NLS
142 /* The Solaris version of locale.h always includes libintl.h. If we have
143 been configured with --disable-nls then ENABLE_NLS will not be defined
144 and the dummy definitions of bindtextdomain (et al) below will conflict
145 with the defintions in libintl.h. So we define these values to prevent
146 the bogus inclusion of libintl.h. */
147 # define _LIBINTL_H
148 # define _LIBGETTEXT_H
149 #endif
150 #include <locale.h>
152 #ifdef ENABLE_NLS
153 # include <libintl.h>
154 /* Note the redefinition of gettext and ngettext here to use PACKAGE.
156 This is because the code in this directory is used to build a
157 library which will be linked with code in other directories to form
158 programs. We want to maintain a separate translation file for this
159 directory however, rather than being forced to merge it with that
160 of any program linked to libbfd. This is a library, so it cannot
161 depend on the catalog currently loaded.
163 In order to do this, we have to make sure that when we extract
164 messages we use the BFD domain rather than the domain of the
165 program that included the bfd library, (eg OBJDUMP). Hence we use
166 dgettext (PACKAGE, String) and define PACKAGE to be 'bfd'.
167 (See the code in configure). */
168 # undef gettext
169 # define gettext(Msgid) dgettext (PACKAGE, Msgid)
170 # undef ngettext
171 # define ngettext(Msgid1, Msgid2, n) dngettext (PACKAGE, Msgid1, Msgid2, n)
172 # define _(String) gettext (String)
173 # ifdef gettext_noop
174 # define N_(String) gettext_noop (String)
175 # else
176 # define N_(String) (String)
177 # endif
178 #else
179 # define gettext(Msgid) (Msgid)
180 # define dgettext(Domainname, Msgid) (Msgid)
181 # define dcgettext(Domainname, Msgid, Category) (Msgid)
182 # define ngettext(Msgid1, Msgid2, n) \
183 (n == 1 ? Msgid1 : Msgid2)
184 # define dngettext(Domainname, Msgid1, Msgid2, n) \
185 (n == 1 ? Msgid1 : Msgid2)
186 # define dcngettext(Domainname, Msgid1, Msgid2, n, Category) \
187 (n == 1 ? Msgid1 : Msgid2)
188 # define textdomain(Domainname) do {} while (0)
189 # define bindtextdomain(Domainname, Dirname) do {} while (0)
190 # define _(String) (String)
191 # define N_(String) (String)
192 #endif
194 #ifndef HAVE_GETUID
195 #define getuid() 0
196 #endif
198 #ifndef HAVE_GETGID
199 #define getgid() 0
200 #endif
202 #define POISON_BFD_BOOLEAN 1
204 #endif /* ! defined (BFD_SYSDEP_H) */