OSDN Git Service

Update comments.
[pf3gnuchains/gcc-fork.git] / gcc / ada / mingw32.h
1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                               M I N G W 3 2                              *
6  *                                                                          *
7  *                              C Header File                               *
8  *                                                                          *
9  *          Copyright (C) 2002-2009, Free Software Foundation, Inc.         *
10  *                                                                          *
11  * GNAT is free software;  you can  redistribute it  and/or modify it under *
12  * terms of the  GNU General Public License as published  by the Free Soft- *
13  * ware  Foundation;  either version 3,  or (at your option) any later ver- *
14  * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
15  * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
16  * or FITNESS FOR A PARTICULAR PURPOSE.                                     *
17  *                                                                          *
18  * As a special exception under Section 7 of GPL version 3, you are granted *
19  * additional permissions described in the GCC Runtime Library Exception,   *
20  * version 3.1, as published by the Free Software Foundation.               *
21  *                                                                          *
22  * You should have received a copy of the GNU General Public License and    *
23  * a copy of the GCC Runtime Library Exception along with this program;     *
24  * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    *
25  * <http://www.gnu.org/licenses/>.                                          *
26  *                                                                          *
27  * GNAT was originally developed  by the GNAT team at  New York University. *
28  * Extensive contributions were provided by Ada Core Technologies Inc.      *
29  *                                                                          *
30  ****************************************************************************/
31
32 /*  This file provides some macros used for the MINGW32 platform. The main
33     goal is to be able to build GNAT with a standard MINGW32 C header
34     set. This files contains also the circuitry for the unicode support.   */
35
36 #ifndef _MINGW32_H
37 #define _MINGW32_H
38
39 /* The unicode support is activated by default starting with the 3.9 MingW
40    version. It is not possible to use it with previous version due to a bug
41    in the MingW runtime.  */
42
43 #if (((__MINGW32_MAJOR_VERSION == 3 \
44                    && __MINGW32_MINOR_VERSION >= 9) \
45      || (__MINGW32_MAJOR_VERSION >= 4)) \
46      && !defined (RTX))
47 #define GNAT_UNICODE_SUPPORT
48
49 #else
50
51 /*  Older MingW versions have no definition for _tfreopen, add it here to have a
52     proper build without unicode support.  */
53 #ifndef _tfreopen
54 #define _tfreopen   freopen
55 #endif
56
57 #endif
58
59 #ifdef GNAT_UNICODE_SUPPORT
60 #define _UNICODE /* For C runtime */
61 #define UNICODE  /* For Win32 API */
62 #endif
63
64 /* We need functionality available only starting with Windows XP */
65 #define _WIN32_WINNT 0x0501
66
67 #include <tchar.h>
68 #include <windows.h>
69
70 /* After including this file it is possible to use the character t as prefix
71    to routines. If GNAT_UNICODE_SUPPORT is defined then the unicode enabled
72    versions will be used.  */
73
74 /* Copy to/from wide-string, if GNAT_UNICODE_SUPPORT activated this will do
75    the proper translations using the UTF-8 encoding.  */
76
77 #ifdef GNAT_UNICODE_SUPPORT
78
79 extern UINT CurrentCodePage;
80
81 /*  Macros to convert to/from the code page speficied in CurrentCodePage.  */
82 #define S2WSC(wstr,str,len) \
83    MultiByteToWideChar (CurrentCodePage,0,str,-1,wstr,len)
84 #define WS2SC(str,wstr,len) \
85    WideCharToMultiByte (CurrentCodePage,0,wstr,-1,str,len,NULL,NULL)
86
87 /*  Macros to convert to/from UTF-8 code page.  */
88 #define S2WSU(wstr,str,len) \
89    MultiByteToWideChar (CP_UTF8,0,str,-1,wstr,len)
90 #define WS2SU(str,wstr,len) \
91    WideCharToMultiByte (CP_UTF8,0,wstr,-1,str,len,NULL,NULL)
92
93 /*  Macros to convert to/from Windows default code page.  */
94 #define S2WS(wstr,str,len) \
95    MultiByteToWideChar (CP_ACP,0,str,-1,wstr,len)
96 #define WS2S(str,wstr,len) \
97    WideCharToMultiByte (CP_ACP,0,wstr,-1,str,len,NULL,NULL)
98 #else
99 #define S2WSC(wstr,str,len) strncpy(wstr,str,len)
100 #define WS2SC(str,wstr,len) strncpy(str,wstr,len)
101 #define S2WSU(wstr,str,len) strncpy(wstr,str,len)
102 #define WS2SU(str,wstr,len) strncpy(str,wstr,len)
103 #define S2WS(wstr,str,len) strncpy(wstr,str,len)
104 #define WS2S(str,wstr,len) strncpy(str,wstr,len)
105 #endif
106
107 #include <stdlib.h>
108
109 /* STD_MINGW: standard if MINGW32 version > 1.3, we have switched to this
110    version instead of the previous enhanced version to ease building GNAT on
111    Windows platforms. By using STD_MINGW or OLD_MINGW it is possible to build
112    GNAT using both MingW include files (Old MingW + ACT changes and standard
113    MingW starting with version 1.3.
114    For w64 Mingw the define STD_MINGW is always set to value 1, because
115    there is no old header set present.  */
116 #ifdef _WIN64
117 #define STD_MINGW 1
118 #else
119 #define STD_MINGW ((__MINGW32_MAJOR_VERSION == 1 \
120                    && __MINGW32_MINOR_VERSION >= 3) \
121      || (__MINGW32_MAJOR_VERSION >= 2))
122 #endif
123
124 #define OLD_MINGW (!(STD_MINGW))
125
126 #ifndef MAXPATHLEN
127 #define MAXPATHLEN MAX_PATH
128 #endif
129
130 #endif /* _MINGW32_H */