Fix "maint selftest" regression, add struct scoped_mock_context
[binutils-gdb.git] / binutils / sysdep.h
blobbb7d4db4e82b4792e4dcc4970085ac6486d8d45d
1 /* sysdep.h -- handle host dependencies for binutils
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20 #ifndef _BIN_SYSDEP_H
21 #define _BIN_SYSDEP_H
23 #include "alloca-conf.h"
24 #include "ansidecl.h"
25 #include <stdio.h>
26 #include <sys/types.h>
28 #include "bfdver.h"
30 #include <stdarg.h>
32 #ifdef USE_BINARY_FOPEN
33 #include "fopen-bin.h"
34 #else
35 #include "fopen-same.h"
36 #endif
38 #include <errno.h>
39 #ifndef errno
40 extern int errno;
41 #endif
43 #ifdef HAVE_UNISTD_H
44 #include <unistd.h>
45 #endif
47 #ifdef STRING_WITH_STRINGS
48 #include <string.h>
49 #include <strings.h>
50 #else
51 #ifdef HAVE_STRING_H
52 #include <string.h>
53 #else
54 #ifdef HAVE_STRINGS_H
55 #include <strings.h>
56 #else
57 extern char *strchr ();
58 extern char *strrchr ();
59 #endif
60 #endif
61 #endif
63 #ifdef HAVE_STDLIB_H
64 #include <stdlib.h>
65 #endif
67 #ifdef HAVE_FCNTL_H
68 #include <fcntl.h>
69 #else
70 #ifdef HAVE_SYS_FILE_H
71 #include <sys/file.h>
72 #endif
73 #endif
75 #ifdef HAVE_SYS_STAT_H
76 #include <sys/stat.h>
77 #endif
79 #include "binary-io.h"
81 #if !HAVE_DECL_STPCPY
82 extern char *stpcpy (char *, const char *);
83 #endif
85 #if !HAVE_DECL_STRSTR
86 extern char *strstr ();
87 #endif
89 #ifdef HAVE_SBRK
90 #if !HAVE_DECL_SBRK
91 extern char *sbrk ();
92 #endif
93 #endif
95 #if !HAVE_DECL_GETENV
96 extern char *getenv ();
97 #endif
99 #if !HAVE_DECL_ENVIRON
100 extern char **environ;
101 #endif
103 #if !HAVE_DECL_FPRINTF
104 extern int fprintf (FILE *, const char *, ...);
105 #endif
107 #if !HAVE_DECL_SNPRINTF
108 extern int snprintf(char *, size_t, const char *, ...);
109 #endif
111 #if !HAVE_DECL_VSNPRINTF
112 extern int vsnprintf(char *, size_t, const char *, va_list);
113 #endif
115 #if !HAVE_DECL_STRNLEN
116 size_t strnlen (const char *, size_t);
117 #endif
119 #ifndef O_RDONLY
120 #define O_RDONLY 0
121 #endif
123 #ifndef O_RDWR
124 #define O_RDWR 2
125 #endif
127 #ifndef SEEK_SET
128 #define SEEK_SET 0
129 #endif
130 #ifndef SEEK_CUR
131 #define SEEK_CUR 1
132 #endif
133 #ifndef SEEK_END
134 #define SEEK_END 2
135 #endif
137 #ifdef HAVE_LOCALE_H
138 # ifndef ENABLE_NLS
139 /* The Solaris version of locale.h always includes libintl.h. If we have
140 been configured with --disable-nls then ENABLE_NLS will not be defined
141 and the dummy definitions of bindtextdomain (et al) below will conflict
142 with the defintions in libintl.h. So we define these values to prevent
143 the bogus inclusion of libintl.h. */
144 # define _LIBINTL_H
145 # define _LIBGETTEXT_H
146 # endif
147 # include <locale.h>
148 #endif
150 #ifdef ENABLE_NLS
151 # include <libintl.h>
152 # define _(String) gettext (String)
153 # ifdef gettext_noop
154 # define N_(String) gettext_noop (String)
155 # else
156 # define N_(String) (String)
157 # endif
158 #else
159 # define gettext(Msgid) (Msgid)
160 # define dgettext(Domainname, Msgid) (Msgid)
161 # define dcgettext(Domainname, Msgid, Category) (Msgid)
162 # define ngettext(Msgid1, Msgid2, n) \
163 (n == 1 ? Msgid1 : Msgid2)
164 # define dngettext(Domainname, Msgid1, Msgid2, n) \
165 (n == 1 ? Msgid1 : Msgid2)
166 # define dcngettext(Domainname, Msgid1, Msgid2, n, Category) \
167 (n == 1 ? Msgid1 : Msgid2)
168 # define textdomain(Domainname) do {} while (0)
169 # define bindtextdomain(Domainname, Dirname) do {} while (0)
170 # define _(String) (String)
171 # define N_(String) (String)
172 #endif
174 /* Used by ar.c and objcopy.c. */
175 #define BUFSIZE 8192
177 /* For PATH_MAX. */
178 #ifdef HAVE_LIMITS_H
179 #include <limits.h>
180 #endif
182 #ifndef PATH_MAX
183 /* For MAXPATHLEN. */
184 # ifdef HAVE_SYS_PARAM_H
185 # include <sys/param.h>
186 # endif
187 # ifndef PATH_MAX
188 # ifdef MAXPATHLEN
189 # define PATH_MAX MAXPATHLEN
190 # else
191 # define PATH_MAX 1024
192 # endif
193 # endif
194 #endif
196 #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
197 /* We can't use any bfd types here since readelf may define BFD64 and
198 objdump may not. */
199 #define HOST_WIDEST_INT long long
200 #else
201 #define HOST_WIDEST_INT long
202 #endif
204 #endif /* _BIN_SYSDEP_H */