xref: /netbsd/external/gpl3/binutils/dist/ld/sysdep.h (revision 05caefcf)
12a6b7db3Sskrll /* sysdep.h -- handle host dependencies for the GNU linker
2*05caefcfSchristos    Copyright 1995, 1996, 1997, 1999, 2002, 2003, 2005, 2007, 2012
32a6b7db3Sskrll    Free Software Foundation, Inc.
42a6b7db3Sskrll 
52a6b7db3Sskrll    This file is part of the GNU Binutils.
62a6b7db3Sskrll 
72a6b7db3Sskrll    This program is free software; you can redistribute it and/or modify
82a6b7db3Sskrll    it under the terms of the GNU General Public License as published by
92a6b7db3Sskrll    the Free Software Foundation; either version 3 of the License, or
102a6b7db3Sskrll    (at your option) any later version.
112a6b7db3Sskrll 
122a6b7db3Sskrll    This program is distributed in the hope that it will be useful,
132a6b7db3Sskrll    but WITHOUT ANY WARRANTY; without even the implied warranty of
142a6b7db3Sskrll    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
152a6b7db3Sskrll    GNU General Public License for more details.
162a6b7db3Sskrll 
172a6b7db3Sskrll    You should have received a copy of the GNU General Public License
182a6b7db3Sskrll    along with this program; if not, write to the Free Software
192a6b7db3Sskrll    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
202a6b7db3Sskrll    MA 02110-1301, USA.  */
212a6b7db3Sskrll 
222a6b7db3Sskrll #ifndef LD_SYSDEP_H
232a6b7db3Sskrll #define LD_SYSDEP_H
242a6b7db3Sskrll 
25*05caefcfSchristos #ifdef PACKAGE
26*05caefcfSchristos #error sysdep.h must be included in lieu of config.h
27*05caefcfSchristos #endif
28*05caefcfSchristos 
292a6b7db3Sskrll #include "config.h"
302a6b7db3Sskrll 
312a6b7db3Sskrll #include <stdio.h>
322a6b7db3Sskrll #include <sys/types.h>
332a6b7db3Sskrll #include <sys/stat.h>
34b3ac4aedSchristos #include <stdarg.h>
352a6b7db3Sskrll 
36*05caefcfSchristos #ifdef STRING_WITH_STRINGS
37*05caefcfSchristos #include <string.h>
38*05caefcfSchristos #include <strings.h>
39*05caefcfSchristos #else
402a6b7db3Sskrll #ifdef HAVE_STRING_H
412a6b7db3Sskrll #include <string.h>
422a6b7db3Sskrll #else
432a6b7db3Sskrll #ifdef HAVE_STRINGS_H
442a6b7db3Sskrll #include <strings.h>
452a6b7db3Sskrll #else
462a6b7db3Sskrll extern char *strchr ();
472a6b7db3Sskrll extern char *strrchr ();
482a6b7db3Sskrll #endif
492a6b7db3Sskrll #endif
50*05caefcfSchristos #endif
512a6b7db3Sskrll 
522a6b7db3Sskrll #ifdef HAVE_STDLIB_H
532a6b7db3Sskrll #include <stdlib.h>
542a6b7db3Sskrll #endif
552a6b7db3Sskrll 
562a6b7db3Sskrll #ifdef HAVE_UNISTD_H
572a6b7db3Sskrll #include <unistd.h>
582a6b7db3Sskrll #endif
592a6b7db3Sskrll 
602a6b7db3Sskrll /* for PATH_MAX */
612a6b7db3Sskrll #ifdef HAVE_LIMITS_H
622a6b7db3Sskrll #include <limits.h>
632a6b7db3Sskrll #endif
642a6b7db3Sskrll /* for MAXPATHLEN */
652a6b7db3Sskrll #ifdef HAVE_SYS_PARAM_H
662a6b7db3Sskrll #include <sys/param.h>
672a6b7db3Sskrll #endif
682a6b7db3Sskrll #ifdef PATH_MAX
692a6b7db3Sskrll # define LD_PATHMAX PATH_MAX
702a6b7db3Sskrll #else
712a6b7db3Sskrll # ifdef MAXPATHLEN
722a6b7db3Sskrll #  define LD_PATHMAX MAXPATHLEN
732a6b7db3Sskrll # else
742a6b7db3Sskrll #  define LD_PATHMAX 1024
752a6b7db3Sskrll # endif
762a6b7db3Sskrll #endif
772a6b7db3Sskrll 
782a6b7db3Sskrll #ifdef HAVE_REALPATH
792a6b7db3Sskrll # define REALPATH(a,b) realpath (a, b)
802a6b7db3Sskrll #else
812a6b7db3Sskrll # define REALPATH(a,b) NULL
822a6b7db3Sskrll #endif
832a6b7db3Sskrll 
84b3ac4aedSchristos #ifdef HAVE_UNISTD_H
85b3ac4aedSchristos #include <unistd.h>
86b3ac4aedSchristos #endif
87b3ac4aedSchristos 
882a6b7db3Sskrll #ifdef USE_BINARY_FOPEN
892a6b7db3Sskrll #include "fopen-bin.h"
902a6b7db3Sskrll #else
912a6b7db3Sskrll #include "fopen-same.h"
922a6b7db3Sskrll #endif
932a6b7db3Sskrll 
94b3ac4aedSchristos #ifdef HAVE_FCNTL_H
95b3ac4aedSchristos #include <fcntl.h>
96b3ac4aedSchristos #else
97b3ac4aedSchristos #ifdef HAVE_SYS_FILE_H
98b3ac4aedSchristos #include <sys/file.h>
99b3ac4aedSchristos #endif
100b3ac4aedSchristos #endif
101b3ac4aedSchristos 
102b3ac4aedSchristos #ifdef HAVE_DLFCN_H
103b3ac4aedSchristos #include <dlfcn.h>
104b3ac4aedSchristos #endif
105b3ac4aedSchristos 
106b3ac4aedSchristos #ifndef O_RDONLY
107b3ac4aedSchristos #define O_RDONLY 0
108b3ac4aedSchristos #endif
109b3ac4aedSchristos #ifndef O_WRONLY
110b3ac4aedSchristos #define O_WRONLY 1
111b3ac4aedSchristos #endif
112b3ac4aedSchristos #ifndef O_RDWR
113b3ac4aedSchristos #define O_RDWR 2
114b3ac4aedSchristos #endif
115b3ac4aedSchristos #ifndef O_ACCMODE
116b3ac4aedSchristos #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
117b3ac4aedSchristos #endif
118b3ac4aedSchristos /* Systems that don't already define this, don't need it.  */
119b3ac4aedSchristos #ifndef O_BINARY
120b3ac4aedSchristos #define O_BINARY 0
121b3ac4aedSchristos #endif
122b3ac4aedSchristos 
123b3ac4aedSchristos #ifndef SEEK_SET
124b3ac4aedSchristos #define SEEK_SET 0
125b3ac4aedSchristos #endif
126b3ac4aedSchristos #ifndef SEEK_CUR
127b3ac4aedSchristos #define SEEK_CUR 1
128b3ac4aedSchristos #endif
129b3ac4aedSchristos #ifndef SEEK_END
130b3ac4aedSchristos #define SEEK_END 2
131b3ac4aedSchristos #endif
132b3ac4aedSchristos 
1332a6b7db3Sskrll #if !HAVE_DECL_STRSTR
1342a6b7db3Sskrll extern char *strstr ();
1352a6b7db3Sskrll #endif
1362a6b7db3Sskrll 
1372a6b7db3Sskrll #if !HAVE_DECL_FREE
1382a6b7db3Sskrll extern void free ();
1392a6b7db3Sskrll #endif
1402a6b7db3Sskrll 
1412a6b7db3Sskrll #if !HAVE_DECL_GETENV
1422a6b7db3Sskrll extern char *getenv ();
1432a6b7db3Sskrll #endif
1442a6b7db3Sskrll 
1452a6b7db3Sskrll #if !HAVE_DECL_ENVIRON
1462a6b7db3Sskrll extern char **environ;
1472a6b7db3Sskrll #endif
1482a6b7db3Sskrll 
1492a6b7db3Sskrll #endif /* ! defined (LD_SYSDEP_H) */
150