| 1 | /* sysdep.h -- handle host dependencies for the BFD library |
| 2 | Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007, 2009 |
| 3 | Free Software Foundation, Inc. |
| 4 | Written by Cygnus Support. |
| 5 | |
| 6 | This file is part of BFD, the Binary File Descriptor library. |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
| 21 | MA 02110-1301, USA. */ |
| 22 | |
| 23 | #ifndef BFD_SYSDEP_H |
| 24 | #define BFD_SYSDEP_H |
| 25 | |
| 26 | #ifdef PACKAGE |
| 27 | #error sysdep.h must be included in lieu of config.h |
| 28 | #endif |
| 29 | |
| 30 | #include "config.h" |
| 31 | |
| 32 | #include "ansidecl.h" |
| 33 | |
| 34 | #ifdef HAVE_STDDEF_H |
| 35 | #include <stddef.h> |
| 36 | #endif |
| 37 | |
| 38 | #include <stdio.h> |
| 39 | #include <sys/types.h> |
| 40 | #include <sys/stat.h> |
| 41 | |
| 42 | #include <errno.h> |
| 43 | #if !(defined(errno) || defined(_MSC_VER) && defined(_INC_ERRNO)) |
| 44 | extern int errno; |
| 45 | #endif |
| 46 | |
| 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 |
| 62 | |
| 63 | #ifdef HAVE_STDLIB_H |
| 64 | #include <stdlib.h> |
| 65 | #endif |
| 66 | |
| 67 | #ifdef TIME_WITH_SYS_TIME |
| 68 | #include <sys/time.h> |
| 69 | #include <time.h> |
| 70 | #else |
| 71 | #ifdef HAVE_SYS_TIME_H |
| 72 | #include <sys/time.h> |
| 73 | #else |
| 74 | #include <time.h> |
| 75 | #endif |
| 76 | #endif |
| 77 | |
| 78 | #ifdef HAVE_UNISTD_H |
| 79 | #include <unistd.h> |
| 80 | #endif |
| 81 | |
| 82 | #ifdef HAVE_SYS_RESOURCE_H |
| 83 | #include <sys/resource.h> |
| 84 | #endif /* HAVE_SYS_RESOURCE_H */ |
| 85 | |
| 86 | #ifdef USE_BINARY_FOPEN |
| 87 | #include "fopen-bin.h" |
| 88 | #else |
| 89 | #include "fopen-same.h" |
| 90 | #endif |
| 91 | |
| 92 | #ifdef HAVE_FCNTL_H |
| 93 | #include <fcntl.h> |
| 94 | #else |
| 95 | #ifdef HAVE_SYS_FILE_H |
| 96 | #include <sys/file.h> |
| 97 | #endif |
| 98 | #endif |
| 99 | |
| 100 | #ifndef O_RDONLY |
| 101 | #define O_RDONLY 0 |
| 102 | #endif |
| 103 | #ifndef O_WRONLY |
| 104 | #define O_WRONLY 1 |
| 105 | #endif |
| 106 | #ifndef O_RDWR |
| 107 | #define O_RDWR 2 |
| 108 | #endif |
| 109 | #ifndef O_ACCMODE |
| 110 | #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) |
| 111 | #endif |
| 112 | |
| 113 | #ifndef SEEK_SET |
| 114 | #define SEEK_SET 0 |
| 115 | #endif |
| 116 | #ifndef SEEK_CUR |
| 117 | #define SEEK_CUR 1 |
| 118 | #endif |
| 119 | |
| 120 | #include "filenames.h" |
| 121 | |
| 122 | #if !HAVE_DECL_FFS |
| 123 | extern int ffs (int); |
| 124 | #endif |
| 125 | |
| 126 | #if !HAVE_DECL_FREE |
| 127 | extern void free (); |
| 128 | #endif |
| 129 | |
| 130 | #if !HAVE_DECL_GETENV |
| 131 | extern char *getenv (); |
| 132 | #endif |
| 133 | |
| 134 | #if !HAVE_DECL_MALLOC |
| 135 | extern PTR malloc (); |
| 136 | #endif |
| 137 | |
| 138 | #if !HAVE_DECL_REALLOC |
| 139 | extern PTR realloc (); |
| 140 | #endif |
| 141 | |
| 142 | #if !HAVE_DECL_STPCPY |
| 143 | extern char *stpcpy (char *__dest, const char *__src); |
| 144 | #endif |
| 145 | |
| 146 | #if !HAVE_DECL_STRSTR |
| 147 | extern char *strstr (); |
| 148 | #endif |
| 149 | |
| 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 | |
| 174 | /* Define offsetof for those systems which lack it */ |
| 175 | |
| 176 | #ifndef offsetof |
| 177 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) |
| 178 | #endif |
| 179 | |
| 180 | #ifdef ENABLE_NLS |
| 181 | #include <libintl.h> |
| 182 | /* Note the use of dgetext() and PACKAGE here, rather than gettext(). |
| 183 | |
| 184 | This is because the code in this directory is used to build a library which |
| 185 | will be linked with code in other directories to form programs. We want to |
| 186 | maintain a seperate translation file for this directory however, rather |
| 187 | than being forced to merge it with that of any program linked to libbfd. |
| 188 | This is a library, so it cannot depend on the catalog currently loaded. |
| 189 | |
| 190 | In order to do this, we have to make sure that when we extract messages we |
| 191 | use the OPCODES domain rather than the domain of the program that included |
| 192 | the bfd library, (eg OBJDUMP). Hence we use dgettext (PACKAGE, String) |
| 193 | and define PACKAGE to be 'bfd'. (See the code in configure). */ |
| 194 | #define _(String) dgettext (PACKAGE, String) |
| 195 | #ifdef gettext_noop |
| 196 | #define N_(String) gettext_noop (String) |
| 197 | #else |
| 198 | #define N_(String) (String) |
| 199 | #endif |
| 200 | #else |
| 201 | # define gettext(Msgid) (Msgid) |
| 202 | # define dgettext(Domainname, Msgid) (Msgid) |
| 203 | # define dcgettext(Domainname, Msgid, Category) (Msgid) |
| 204 | # define textdomain(Domainname) while (0) /* nothing */ |
| 205 | # define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ |
| 206 | # define _(String) (String) |
| 207 | # define N_(String) (String) |
| 208 | #endif |
| 209 | |
| 210 | #endif /* ! defined (BFD_SYSDEP_H) */ |