1/* sysdep.h -- handle host dependencies for the BFD library 2 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2007 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#include "config.h" 27 28#include "ansidecl.h" 29 30#ifdef HAVE_STDDEF_H 31#include <stddef.h> 32#endif 33 34#include <stdio.h> 35#include <sys/types.h> 36#include <sys/stat.h> 37 38#include <errno.h> 39#if !(defined(errno) || defined(_MSC_VER) && defined(_INC_ERRNO)) 40extern int errno; 41#endif 42 43#ifdef STRING_WITH_STRINGS 44#include <string.h> 45#include <strings.h> 46#else 47#ifdef HAVE_STRING_H 48#include <string.h> 49#else 50#ifdef HAVE_STRINGS_H 51#include <strings.h> 52#else 53extern char *strchr (); 54extern char *strrchr (); 55#endif 56#endif 57#endif 58 59#ifdef HAVE_STDLIB_H 60#include <stdlib.h> 61#endif 62 63#ifdef TIME_WITH_SYS_TIME 64#include <sys/time.h> 65#include <time.h> 66#else 67#ifdef HAVE_SYS_TIME_H 68#include <sys/time.h> 69#else 70#include <time.h> 71#endif 72#endif 73 74#ifdef HAVE_UNISTD_H 75#include <unistd.h> 76#endif 77 78#ifdef USE_BINARY_FOPEN 79#include "fopen-bin.h" 80#else 81#include "fopen-same.h" 82#endif 83 84#ifdef HAVE_FCNTL_H 85#include <fcntl.h> 86#else 87#ifdef HAVE_SYS_FILE_H 88#include <sys/file.h> 89#endif 90#endif 91 92#ifndef O_RDONLY 93#define O_RDONLY 0 94#endif 95#ifndef O_WRONLY 96#define O_WRONLY 1 97#endif 98#ifndef O_RDWR 99#define O_RDWR 2 100#endif 101#ifndef O_ACCMODE 102#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) 103#endif 104 105#ifndef SEEK_SET 106#define SEEK_SET 0 107#endif 108#ifndef SEEK_CUR 109#define SEEK_CUR 1 110#endif 111 112#include "filenames.h" 113 114#if !HAVE_DECL_FFS 115extern int ffs (int); 116#endif 117 118#if !HAVE_DECL_FREE 119extern void free (); 120#endif 121 122#if !HAVE_DECL_GETENV 123extern char *getenv (); 124#endif 125 126#if !HAVE_DECL_MALLOC 127extern PTR malloc (); 128#endif 129 130#if !HAVE_DECL_REALLOC 131extern PTR realloc (); 132#endif 133 134#if !HAVE_DECL_STPCPY 135extern char *stpcpy (char *__dest, const char *__src); 136#endif 137 138#if !HAVE_DECL_STRSTR 139extern char *strstr (); 140#endif 141 142#ifdef HAVE_FTELLO 143#if !HAVE_DECL_FTELLO 144extern off_t ftello (FILE *stream); 145#endif 146#endif 147 148#ifdef HAVE_FTELLO64 149#if !HAVE_DECL_FTELLO64 150extern off64_t ftello64 (FILE *stream); 151#endif 152#endif 153 154#ifdef HAVE_FSEEKO 155#if !HAVE_DECL_FSEEKO 156extern int fseeko (FILE *stream, off_t offset, int whence); 157#endif 158#endif 159 160#ifdef HAVE_FSEEKO64 161#if !HAVE_DECL_FSEEKO64 162extern int fseeko64 (FILE *stream, off64_t offset, int whence); 163#endif 164#endif 165 166/* Define offsetof for those systems which lack it */ 167 168#ifndef offsetof 169#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 170#endif 171 172#ifdef ENABLE_NLS 173#include <libintl.h> 174/* Note the use of dgetext() and PACKAGE here, rather than gettext(). 175 176 This is because the code in this directory is used to build a library which 177 will be linked with code in other directories to form programs. We want to 178 maintain a seperate translation file for this directory however, rather 179 than being forced to merge it with that of any program linked to libbfd. 180 This is a library, so it cannot depend on the catalog currently loaded. 181 182 In order to do this, we have to make sure that when we extract messages we 183 use the OPCODES domain rather than the domain of the program that included 184 the bfd library, (eg OBJDUMP). Hence we use dgettext (PACKAGE, String) 185 and define PACKAGE to be 'bfd'. (See the code in configure). */ 186#define _(String) dgettext (PACKAGE, String) 187#ifdef gettext_noop 188#define N_(String) gettext_noop (String) 189#else 190#define N_(String) (String) 191#endif 192#else 193# define gettext(Msgid) (Msgid) 194# define dgettext(Domainname, Msgid) (Msgid) 195# define dcgettext(Domainname, Msgid, Category) (Msgid) 196# define textdomain(Domainname) while (0) /* nothing */ 197# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */ 198# define _(String) (String) 199# define N_(String) (String) 200#endif 201 202#endif /* ! defined (BFD_SYSDEP_H) */ 203