1214571Sdim/* sysdep.h -- handle host dependencies for binutils
2214571Sdim   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3214571Sdim   2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
4214571Sdim
5214571Sdim   This file is part of GNU Binutils.
6214571Sdim
7214571Sdim   This program is free software; you can redistribute it and/or modify
8214571Sdim   it under the terms of the GNU General Public License as published by
9214571Sdim   the Free Software Foundation; either version 2 of the License, or
10214571Sdim   (at your option) any later version.
11214571Sdim
12214571Sdim   This program is distributed in the hope that it will be useful,
13214571Sdim   but WITHOUT ANY WARRANTY; without even the implied warranty of
14214571Sdim   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15214571Sdim   GNU General Public License for more details.
16214571Sdim
17214571Sdim   You should have received a copy of the GNU General Public License
18214571Sdim   along with this program; if not, write to the Free Software
19214571Sdim   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
20214571Sdim
21214571Sdim#ifndef _BIN_SYSDEP_H
22214571Sdim#define _BIN_SYSDEP_H
23214571Sdim
24214571Sdim#include "ansidecl.h"
25214571Sdim#include <stdio.h>
26214571Sdim#include <sys/types.h>
27214571Sdim
28214571Sdim#include "bfdver.h"
29214571Sdim#include "config.h"
30214571Sdim
31214571Sdim#include <stdarg.h>
32214571Sdim
33214571Sdim#ifdef USE_BINARY_FOPEN
34214571Sdim#include "fopen-bin.h"
35214571Sdim#else
36214571Sdim#include "fopen-same.h"
37214571Sdim#endif
38214571Sdim
39214571Sdim#include <errno.h>
40214571Sdim#ifndef errno
41214571Sdimextern int errno;
42214571Sdim#endif
43214571Sdim
44214571Sdim#ifdef HAVE_UNISTD_H
45214571Sdim#include <unistd.h>
46214571Sdim#endif
47214571Sdim
48214571Sdim#ifdef HAVE_STRING_H
49214571Sdim#include <string.h>
50214571Sdim#else
51214571Sdim#ifdef HAVE_STRINGS_H
52214571Sdim#include <strings.h>
53214571Sdim#else
54214571Sdimextern char *strchr ();
55214571Sdimextern char *strrchr ();
56214571Sdim#endif
57214571Sdim#endif
58214571Sdim
59214571Sdim#ifdef HAVE_STDLIB_H
60214571Sdim#include <stdlib.h>
61214571Sdim#endif
62214571Sdim
63214571Sdim#ifdef HAVE_FCNTL_H
64214571Sdim#include <fcntl.h>
65214571Sdim#else
66214571Sdim#ifdef HAVE_SYS_FILE_H
67214571Sdim#include <sys/file.h>
68214571Sdim#endif
69214571Sdim#endif
70214571Sdim
71214571Sdim#if !HAVE_DECL_STPCPY
72214571Sdimextern char *stpcpy (char *, const char *);
73214571Sdim#endif
74214571Sdim
75214571Sdim#if !HAVE_DECL_STRSTR
76214571Sdimextern char *strstr ();
77214571Sdim#endif
78214571Sdim
79214571Sdim#ifdef HAVE_SBRK
80214571Sdim#if !HAVE_DECL_SBRK
81214571Sdimextern char *sbrk ();
82214571Sdim#endif
83214571Sdim#endif
84214571Sdim
85214571Sdim#if !HAVE_DECL_GETENV
86214571Sdimextern char *getenv ();
87214571Sdim#endif
88214571Sdim
89214571Sdim#if !HAVE_DECL_ENVIRON
90214571Sdimextern char **environ;
91214571Sdim#endif
92214571Sdim
93214571Sdim#if !HAVE_DECL_FPRINTF
94214571Sdimextern int fprintf (FILE *, const char *, ...);
95214571Sdim#endif
96214571Sdim
97214571Sdim#if !HAVE_DECL_SNPRINTF
98214571Sdimextern int snprintf(char *, size_t, const char *, ...);
99214571Sdim#endif
100214571Sdim
101214571Sdim#if !HAVE_DECL_VSNPRINTF
102214571Sdimextern int vsnprintf(char *, size_t, const char *, va_list);
103214571Sdim#endif
104214571Sdim
105214571Sdim#ifndef O_RDONLY
106214571Sdim#define O_RDONLY 0
107214571Sdim#endif
108214571Sdim
109214571Sdim#ifndef O_RDWR
110214571Sdim#define O_RDWR 2
111214571Sdim#endif
112214571Sdim
113214571Sdim#ifndef SEEK_SET
114214571Sdim#define SEEK_SET 0
115214571Sdim#endif
116214571Sdim#ifndef SEEK_CUR
117214571Sdim#define SEEK_CUR 1
118214571Sdim#endif
119214571Sdim#ifndef SEEK_END
120214571Sdim#define SEEK_END 2
121214571Sdim#endif
122214571Sdim
123214571Sdim#if defined(__GNUC__) && !defined(C_ALLOCA)
124214571Sdim# undef alloca
125214571Sdim# define alloca __builtin_alloca
126214571Sdim#else
127214571Sdim# if defined(HAVE_ALLOCA_H) && !defined(C_ALLOCA)
128214571Sdim#  include <alloca.h>
129214571Sdim# else
130214571Sdim#  ifndef alloca /* predefined by HP cc +Olibcalls */
131214571Sdim#   if !defined (__STDC__) && !defined (__hpux)
132214571Sdimchar *alloca ();
133214571Sdim#   else
134214571Sdimvoid *alloca ();
135214571Sdim#   endif /* __STDC__, __hpux */
136214571Sdim#  endif /* alloca */
137214571Sdim# endif /* HAVE_ALLOCA_H */
138214571Sdim#endif
139214571Sdim
140214571Sdim#ifdef HAVE_LOCALE_H
141214571Sdim# ifndef ENABLE_NLS
142214571Sdim   /* The Solaris version of locale.h always includes libintl.h.  If we have
143214571Sdim      been configured with --disable-nls then ENABLE_NLS will not be defined
144214571Sdim      and the dummy definitions of bindtextdomain (et al) below will conflict
145214571Sdim      with the defintions in libintl.h.  So we define these values to prevent
146214571Sdim      the bogus inclusion of libintl.h.  */
147214571Sdim#  define _LIBINTL_H
148214571Sdim#  define _LIBGETTEXT_H
149214571Sdim# endif
150214571Sdim# include <locale.h>
151214571Sdim#endif
152214571Sdim
153214571Sdim#ifdef ENABLE_NLS
154214571Sdim# include <libintl.h>
155214571Sdim# define _(String) gettext (String)
156214571Sdim# ifdef gettext_noop
157214571Sdim#  define N_(String) gettext_noop (String)
158214571Sdim# else
159214571Sdim#  define N_(String) (String)
160214571Sdim# endif
161214571Sdim#else
162214571Sdim# define gettext(Msgid) (Msgid)
163214571Sdim# define dgettext(Domainname, Msgid) (Msgid)
164214571Sdim# define dcgettext(Domainname, Msgid, Category) (Msgid)
165214571Sdim# define textdomain(Domainname) while (0) /* nothing */
166214571Sdim# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
167214571Sdim# define _(String) (String)
168214571Sdim# define N_(String) (String)
169214571Sdim#endif
170214571Sdim
171214571Sdim/* Used by ar.c and objcopy.c.  */
172214571Sdim#define BUFSIZE 8192
173214571Sdim
174214571Sdim#endif /* _BIN_SYSDEP_H */
175