Navit SVN

/work/compile/navit/src/navit/support/libc/_mingw.h

00001 #ifndef __MINGW_H
00002 /*
00003  * _mingw.h
00004  *
00005  * Mingw specific macros included by ALL include files.
00006  *
00007  * This file is part of the Mingw32 package.
00008  *
00009  * Contributors:
00010  *  Created by Mumit Khan  <khan@xraylith.wisc.edu>
00011  *
00012  *  THIS SOFTWARE IS NOT COPYRIGHTED
00013  *
00014  *  This source code is offered for use in the public domain. You may
00015  *  use, modify or distribute it freely.
00016  *
00017  *  This code is distributed in the hope that it will be useful but
00018  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
00019  *  DISCLAIMED. This includes but is not limited to warranties of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00021  *
00022  */
00023 #define __MINGW_H
00024 
00025 #define __MINGW32_VERSION           3.16
00026 #define __MINGW32_MAJOR_VERSION     3
00027 #define __MINGW32_MINOR_VERSION     16
00028 #define __MINGW32_PATCHLEVEL        0
00029 
00030 #if __GNUC__ >= 3
00031 #pragma GCC system_header
00032 #endif
00033 
00034 /* These are defined by the user (or the compiler)
00035    to specify how identifiers are imported from a DLL.
00036 
00037    __DECLSPEC_SUPPORTED            Defined if dllimport attribute is supported.
00038    __MINGW_IMPORT                  The attribute definition to specify imported
00039                                    variables/functions.
00040    _CRTIMP                         As above.  For MS compatibility.
00041    __MINGW32_VERSION               Runtime version.
00042    __MINGW32_MAJOR_VERSION         Runtime major version.
00043    __MINGW32_MINOR_VERSION         Runtime minor version.
00044    __MINGW32_BUILD_DATE            Runtime build date.
00045 
00046    Macros to enable MinGW features which deviate from standard MSVC
00047    compatible behaviour; these may be specified directly in user code,
00048    activated implicitly, (e.g. by specifying _POSIX_C_SOURCE or such),
00049    or by inclusion in __MINGW_FEATURES__:
00050 
00051    __USE_MINGW_ANSI_STDIO          Select a more ANSI C99 compatible
00052                                    implementation of printf() and friends.
00053 
00054    Other macros:
00055 
00056    __int64                         define to be long long.  Using a typedef
00057                                    doesn't work for "unsigned __int64"
00058 
00059    All headers should include this first, and then use __DECLSPEC_SUPPORTED
00060    to choose between the old ``__imp__name'' style or __MINGW_IMPORT
00061    style declarations.  */
00062 
00063 
00064 /* Manifest definitions identifying the flag bits, controlling activation
00065  * of MinGW features, as specified by the user in __MINGW_FEATURES__.
00066  */
00067 #define __MINGW_ANSI_STDIO__            0x0000000000000001ULL
00068 /*
00069  * The following three are not yet formally supported; they are
00070  * included here, to document anticipated future usage.
00071  */
00072 #define __MINGW_LC_EXTENSIONS__         0x0000000000000050ULL
00073 #define __MINGW_LC_MESSAGES__           0x0000000000000010ULL
00074 #define __MINGW_LC_ENVVARS__            0x0000000000000040ULL
00075 
00076 /* Try to avoid problems with outdated checks for GCC __attribute__ support.  */
00077 #undef __attribute__
00078 
00079 #if defined (__PCC__)
00080 #  undef __DECLSPEC_SUPPORTED
00081 # ifndef __MINGW_IMPORT
00082 #  define __MINGW_IMPORT extern
00083 # endif
00084 # ifndef _CRTIMP
00085 #  define _CRTIMP
00086 # endif
00087 # ifndef __cdecl 
00088 #  define __cdecl  _Pragma("cdecl")
00089 # endif
00090 # ifndef __stdcall
00091 #  define __stdcall _Pragma("stdcall")
00092 # endif
00093 # ifndef __int64
00094 #  define __int64 long long
00095 # endif
00096 # ifndef __int32
00097 #  define __int32 long
00098 # endif
00099 # ifndef __int16
00100 #  define __int16 short
00101 # endif
00102 # ifndef __int8
00103 #  define __int8 char
00104 # endif
00105 # ifndef __small
00106 #  define __small char
00107 # endif
00108 # ifndef __hyper
00109 #  define __hyper long long
00110 # endif
00111 # ifndef __volatile__
00112 #  define __volatile__ volatile
00113 # endif
00114 # ifndef __restrict__
00115 #  define __restrict__ restrict
00116 # endif
00117 # define NONAMELESSUNION
00118 #elif defined(__GNUC__)
00119 # ifdef __declspec
00120 #  ifndef __MINGW_IMPORT
00121    /* Note the extern. This is needed to work around GCC's
00122       limitations in handling dllimport attribute.  */
00123 #   define __MINGW_IMPORT  extern __attribute__ ((__dllimport__))
00124 #  endif
00125 #  ifndef _CRTIMP
00126 #   ifdef __USE_CRTIMP
00127 #    define _CRTIMP  __attribute__ ((dllimport))
00128 #   else
00129 #    define _CRTIMP
00130 #   endif
00131 #  endif
00132 #  define __DECLSPEC_SUPPORTED
00133 # else /* __declspec */
00134 #  undef __DECLSPEC_SUPPORTED
00135 #  undef __MINGW_IMPORT
00136 #  ifndef _CRTIMP
00137 #   define _CRTIMP
00138 #  endif
00139 # endif /* __declspec */
00140 /*
00141  * The next two defines can cause problems if user code adds the
00142  * __cdecl attribute like so:
00143  * void __attribute__ ((__cdecl)) foo(void); 
00144  */
00145 # ifndef __cdecl 
00146 #  define __cdecl  __attribute__ ((__cdecl__))
00147 # endif
00148 # ifndef __stdcall
00149 #  define __stdcall __attribute__ ((__stdcall__))
00150 # endif
00151 # ifndef __int64
00152 #  define __int64 long long
00153 # endif
00154 # ifndef __int32
00155 #  define __int32 long
00156 # endif
00157 # ifndef __int16
00158 #  define __int16 short
00159 # endif
00160 # ifndef __int8
00161 #  define __int8 char
00162 # endif
00163 # ifndef __small
00164 #  define __small char
00165 # endif
00166 # ifndef __hyper
00167 #  define __hyper long long
00168 # endif
00169 #else /* ! __GNUC__ && ! __PCC__ */
00170 # ifndef __MINGW_IMPORT
00171 #  define __MINGW_IMPORT  __declspec(dllimport)
00172 # endif
00173 # ifndef _CRTIMP
00174 #  define _CRTIMP  __declspec(dllimport)
00175 # endif
00176 # define __DECLSPEC_SUPPORTED
00177 # define __attribute__(x) /* nothing */
00178 #endif
00179 
00180 #if defined (__GNUC__) && defined (__GNUC_MINOR__)
00181 #define __MINGW_GNUC_PREREQ(major, minor) \
00182   (__GNUC__ > (major) \
00183    || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
00184 #else
00185 #define __MINGW_GNUC_PREREQ(major, minor)  0
00186 #endif
00187 
00188 #ifdef __cplusplus
00189 # define __CRT_INLINE inline
00190 #else
00191 # if __GNUC_STDC_INLINE__
00192 #  define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
00193 # else
00194 #  ifdef __COREDLL__
00195    /* There isn't any out-of-line version of most of 
00196       these functions in coredll.dll, so we need this for -O0,
00197       or for -fno-inline.  This is still problematic if the user
00198       tries t   o take the address of these functions.  We will slowly
00199       add out-of-line copies as those cases are found.
00200       Note: We can't use static inline here, as most of these functions
00201       will be declared elsew    here with external linkage, and gcc will
00202       barf on that.  */
00203 #   define __CRT_INLINE extern __inline__ __attribute__((__always_inline__))
00204 #  else
00205 #   define __CRT_INLINE
00206 #  endif
00207 # endif
00208 #endif
00209 
00210 #ifdef __cplusplus
00211 # define __UNUSED_PARAM(x)
00212 #else
00213 # ifdef __GNUC__
00214 #  define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
00215 # else
00216 #  define __UNUSED_PARAM(x) x
00217 # endif
00218 #endif
00219 
00220 #ifdef __GNUC__
00221 #define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
00222 #define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
00223 #else
00224 #define __MINGW_ATTRIB_NORETURN
00225 #define __MINGW_ATTRIB_CONST
00226 #endif
00227 
00228 #if __MINGW_GNUC_PREREQ (3, 0)
00229 #define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
00230 #define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
00231 #else
00232 #define __MINGW_ATTRIB_MALLOC
00233 #define __MINGW_ATTRIB_PURE
00234 #endif
00235 
00236 /* Attribute `nonnull' was valid as of gcc 3.3.  We don't use GCC's
00237    variadiac macro facility, because variadic macros cause syntax
00238    errors with  --traditional-cpp.  */
00239 #if  __MINGW_GNUC_PREREQ (3, 3)
00240 #define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
00241 #else
00242 #define __MINGW_ATTRIB_NONNULL(arg)
00243 #endif /* GNUC >= 3.3 */
00244 
00245 #if defined(UNDER_CE) && defined(__arm__)
00246 /* ARM Windows CE is not underscored.  */
00247 # define __U(SYM) _ ## SYM
00248 # define __IMP(S) __imp_ ## S
00249 #elif defined(UNDER_CE) && defined(i386)
00250 /* i386 Windows CE versions are underscored.  */
00251 # define __U(SYM) SYM
00252 # define __IMP(S) _imp__ ## S
00253 #else
00254 /* Desktop i386 Windows versions are underscored.  */
00255 # define __U(SYM) SYM
00256 # define __IMP(S) _imp__ ## S
00257 #endif
00258 
00259 #if  __MINGW_GNUC_PREREQ (3, 1)
00260 #define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
00261 #else
00262 #define __MINGW_ATTRIB_DEPRECATED
00263 #endif /* GNUC >= 3.1 */
00264  
00265 #if  __MINGW_GNUC_PREREQ (3, 3)
00266 #define __MINGW_NOTHROW __attribute__ ((__nothrow__))
00267 #else
00268 #define __MINGW_NOTHROW
00269 #endif /* GNUC >= 3.3 */
00270 
00271 
00272 /* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW.  This will
00273 allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
00274 
00275 #if defined __MSVCRT__ && !defined (__MSVCRT_VERSION__)
00276 /*  High byte is the major version, low byte is the minor. */
00277 # define __MSVCRT_VERSION__ 0x0600
00278 #endif
00279 
00280 /* Activation of MinGW specific extended features:
00281  */
00282 #ifndef __USE_MINGW_ANSI_STDIO
00283 /*
00284  * If user didn't specify it explicitly...
00285  */
00286 # if   defined __STRICT_ANSI__  ||  defined _ISOC99_SOURCE \
00287    ||  defined _POSIX_SOURCE    ||  defined _POSIX_C_SOURCE \
00288    ||  defined _XOPEN_SOURCE    ||  defined _XOPEN_SOURCE_EXTENDED \
00289    ||  defined _GNU_SOURCE      ||  defined _BSD_SOURCE \
00290    ||  defined _SVID_SOURCE
00291    /*
00292     * but where any of these source code qualifiers are specified,
00293     * then assume ANSI I/O standards are preferred over Microsoft's...
00294     */
00295 #  define __USE_MINGW_ANSI_STDIO    1
00296 # else
00297    /*
00298     * otherwise use whatever __MINGW_FEATURES__ specifies...
00299     */
00300 #  define __USE_MINGW_ANSI_STDIO    (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
00301 # endif
00302 #endif
00303 
00304 #endif /* __MINGW_H */