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