1 /* lt_system.h -- system portability abstraction layer
3 Copyright (C) 2004, 2007, 2010 Free Software Foundation, Inc.
4 Written by Gary V. Vaughan, 2004
6 NOTE: The canonical source of this file is maintained with the
7 GNU Libtool package. Report bugs to bug-libtool@gnu.org.
9 GNU Libltdl is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
14 As a special exception to the GNU Lesser General Public License,
15 if you distribute this file as part of a program or library that
16 is built using GNU Libtool, you may include this file under the
17 same distribution terms that you use for the rest of that program.
19 GNU Libltdl is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU Lesser General Public License for more details.
24 You should have received a copy of the GNU Lesser General Public
25 License along with GNU Libltdl; see the file COPYING.LIB. If not, a
26 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
27 or obtained by writing to the Free Software Foundation, Inc.,
28 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 #if !defined(LT_SYSTEM_H)
36 #include <sys/types.h>
38 /* Some systems do not define EXIT_*, even with STDC_HEADERS. */
39 #if !defined(EXIT_SUCCESS)
40 # define EXIT_SUCCESS 0
42 #if !defined(EXIT_FAILURE)
43 # define EXIT_FAILURE 1
46 /* Just pick a big number... */
47 #define LT_FILENAME_MAX 2048
50 /* Saves on those hard to debug '\0' typos.... */
51 #define LT_EOS_CHAR '\0'
53 /* LTDL_BEGIN_C_DECLS should be used at the beginning of your declarations,
54 so that C++ compilers don't mangle their names. Use LTDL_END_C_DECLS at
55 the end of C declarations. */
56 #if defined(__cplusplus)
57 # define LT_BEGIN_C_DECLS extern "C" {
58 # define LT_END_C_DECLS }
60 # define LT_BEGIN_C_DECLS /* empty */
61 # define LT_END_C_DECLS /* empty */
64 /* LT_STMT_START/END are used to create macros which expand to a
65 a single compound statement in a portable way. */
66 #if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
67 # define LT_STMT_START (void)(
68 # define LT_STMT_END )
70 # if (defined (sun) || defined (__sun__))
71 # define LT_STMT_START if (1)
72 # define LT_STMT_END else (void)0
74 # define LT_STMT_START do
75 # define LT_STMT_END while (0)
79 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
80 #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
81 /* DATA imports from DLLs on WIN32 con't be const, because runtime
82 relocations are performed -- see ld's documentation on pseudo-relocs. */
83 # define LT_DLSYM_CONST
84 #elif defined(__osf__)
85 /* This system does not cope well with relocations in const data. */
86 # define LT_DLSYM_CONST
88 # define LT_DLSYM_CONST const
91 /* Canonicalise Windows and Cygwin recognition macros.
92 To match the values set by recent Cygwin compilers, make sure that if
93 __CYGWIN__ is defined (after canonicalisation), __WINDOWS__ is NOT! */
94 #if defined(__CYGWIN32__) && !defined(__CYGWIN__)
95 # define __CYGWIN__ __CYGWIN32__
97 #if defined(__CYGWIN__)
98 # if defined(__WINDOWS__)
101 #elif defined(_WIN32)
102 # define __WINDOWS__ _WIN32
104 # define __WINDOWS__ WIN32
106 #if defined(__CYGWIN__) && defined(__WINDOWS__)
111 /* DLL building support on win32 hosts; mostly to workaround their
112 ridiculous implementation of data symbol exporting. */
113 #if !defined(LT_SCOPE)
114 # if defined(__WINDOWS__) || defined(__CYGWIN__)
115 # if defined(DLL_EXPORT) /* defined by libtool (if required) */
116 # define LT_SCOPE extern __declspec(dllexport)
118 # if defined(LIBLTDL_DLL_IMPORT) /* define if linking with this dll */
119 /* note: cygwin/mingw compilers can rely instead on auto-import */
120 # define LT_SCOPE extern __declspec(dllimport)
123 # if !defined(LT_SCOPE) /* static linking or !__WINDOWS__ */
124 # define LT_SCOPE extern
128 #if defined(__WINDOWS__)
129 /* LT_DIRSEP_CHAR is accepted *in addition* to '/' as a directory
130 separator when it is set. */
131 # define LT_DIRSEP_CHAR '\\'
132 # define LT_PATHSEP_CHAR ';'
134 # define LT_PATHSEP_CHAR ':'
137 #if defined(_MSC_VER) /* Visual Studio */
141 /* fopen() mode flags for reading a text file */
142 #undef LT_READTEXT_MODE
143 #if defined(__WINDOWS__) || defined(__CYGWIN__)
144 # define LT_READTEXT_MODE "rt"
146 # define LT_READTEXT_MODE "r"
149 /* The extra indirection to the LT__STR and LT__CONC macros is required so
150 that if the arguments to LT_STR() (or LT_CONC()) are themselves macros,
151 they will be expanded before being quoted. */
153 # define LT__STR(arg) #arg
154 # define LT_STR(arg) LT__STR(arg)
158 # define LT__CONC(a, b) a##b
159 # define LT_CONC(a, b) LT__CONC(a, b)
162 # define LT__CONC3(a, b, c) a##b##c
163 # define LT_CONC3(a, b, c) LT__CONC3(a, b, c)
166 #endif /*!defined(LT_SYSTEM_H)*/