2015-01-19 Bernd Edlinger <bernd.edlinger@hotmail.de>
[official-gcc.git] / gcc / ada / mingw32.h
blob09343066dfcbc7f14df734f3c8541318cda7fb19
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-2014, 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 ****************************************************************************/
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. */
36 #ifndef _MINGW32_H
37 #define _MINGW32_H
39 #include <_mingw.h>
41 #ifndef RTX
42 #define GNAT_UNICODE_SUPPORT
43 #define _UNICODE /* For C runtime */
44 #define UNICODE /* For Win32 API */
45 #endif
47 /* We need functionality available only starting with Windows XP */
48 #ifndef _WIN32_WINNT
49 #define _WIN32_WINNT 0x0501
50 #endif
52 #ifndef __CYGWIN__
53 #include <tchar.h>
54 #endif
55 #include <windows.h>
57 #ifndef _O_U8TEXT
58 #define _O_U8TEXT _O_TEXT
59 #endif
60 #ifndef _O_U16TEXT
61 #define _O_U16TEXT _O_TEXT
62 #endif
63 #ifndef _O_WTEXT
64 #define _O_WTEXT _O_TEXT
65 #endif
67 /* After including this file it is possible to use the character t as prefix
68 to routines. If GNAT_UNICODE_SUPPORT is defined then the unicode enabled
69 versions will be used. */
71 /* Copy to/from wide-string, if GNAT_UNICODE_SUPPORT activated this will do
72 the proper translations using the UTF-8 encoding. */
74 #ifdef GNAT_UNICODE_SUPPORT
76 extern UINT CurrentCodePage;
77 extern UINT CurrentCCSEncoding;
79 /* Macros to convert to/from the code page specified in CurrentCodePage. */
80 #define S2WSC(wstr,str,len) \
81 MultiByteToWideChar (CurrentCodePage,0,str,-1,wstr,len)
82 #define WS2SC(str,wstr,len) \
83 WideCharToMultiByte (CurrentCodePage,0,wstr,-1,str,len,NULL,NULL)
85 /* Macros to convert to/from UTF-8 code page. */
86 #define S2WSU(wstr,str,len) \
87 MultiByteToWideChar (CP_UTF8,0,str,-1,wstr,len)
88 #define WS2SU(str,wstr,len) \
89 WideCharToMultiByte (CP_UTF8,0,wstr,-1,str,len,NULL,NULL)
91 /* Macros to convert to/from Windows default code page. */
92 #define S2WS(wstr,str,len) \
93 MultiByteToWideChar (CP_ACP,0,str,-1,wstr,len)
94 #define WS2S(str,wstr,len) \
95 WideCharToMultiByte (CP_ACP,0,wstr,-1,str,len,NULL,NULL)
96 #else
97 #define S2WSC(wstr,str,len) strncpy(wstr,str,len)
98 #define WS2SC(str,wstr,len) strncpy(str,wstr,len)
99 #define S2WSU(wstr,str,len) strncpy(wstr,str,len)
100 #define WS2SU(str,wstr,len) strncpy(str,wstr,len)
101 #define S2WS(wstr,str,len) strncpy(wstr,str,len)
102 #define WS2S(str,wstr,len) strncpy(str,wstr,len)
103 #endif
105 #include <stdlib.h>
107 /* STD_MINGW: standard if MINGW32 version > 1.3, we have switched to this
108 version instead of the previous enhanced version to ease building GNAT on
109 Windows platforms. By using STD_MINGW or OLD_MINGW it is possible to build
110 GNAT using both MingW include files (Old MingW + ACT changes and standard
111 MingW starting with version 1.3.
112 For w64 Mingw the define STD_MINGW is always set to value 1, because
113 there is no old header set present. */
114 #ifdef _WIN64
115 #define STD_MINGW 1
116 #else
117 #define STD_MINGW ((__MINGW32_MAJOR_VERSION == 1 \
118 && __MINGW32_MINOR_VERSION >= 3) \
119 || (__MINGW32_MAJOR_VERSION >= 2))
120 #endif
122 #define OLD_MINGW (!(STD_MINGW))
124 #ifndef MAXPATHLEN
125 #define MAXPATHLEN MAX_PATH
126 #endif
128 #endif /* _MINGW32_H */