Update concepts branch to revision 131834
[official-gcc.git] / gcc / ada / mingw32.h
blobe8d95558d0d09026681681708c6cf4c2d5d65742
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-2007, 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 2, 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. See the GNU General Public License *
17 * for more details. You should have received a copy of the GNU General *
18 * Public License distributed with GNAT; see file COPYING. If not, write *
19 * to the Free Software Foundation, 51 Franklin Street, Fifth Floor, *
20 * Boston, MA 02110-1301, USA. *
21 * *
22 * As a special exception, if you link this file with other files to *
23 * produce an executable, this file does not by itself cause the resulting *
24 * executable to be covered by the GNU General Public License. This except- *
25 * ion does not however invalidate any other reasons why the executable *
26 * file might be covered by the GNU Public License. *
27 * *
28 * GNAT was originally developed by the GNAT team at New York University. *
29 * Extensive contributions were provided by Ada Core Technologies Inc. *
30 * *
31 ****************************************************************************/
33 /* This file provides some macros used for the MINGW32 platform. The main
34 goal is to be able to build GNAT with a standard MINGW32 C header
35 set. This files contains also the circuitry for the unicode support. */
37 #ifndef _MINGW32_H
38 #define _MINGW32_H
40 /* The unicode support is activated by default starting with the 3.9 MingW
41 version. It is not possible to use it with previous version due to a bug
42 in the MingW runtime. */
44 #if (((__MINGW32_MAJOR_VERSION == 3 \
45 && __MINGW32_MINOR_VERSION >= 9) \
46 || (__MINGW32_MAJOR_VERSION >= 4)) \
47 && !defined (RTX))
48 #define GNAT_UNICODE_SUPPORT
50 #else
52 /* Older MingW versions have no definition for _tfreopen, add it here to have a
53 proper build without unicode support. */
54 #ifndef _tfreopen
55 #define _tfreopen freopen
56 #endif
58 #endif
60 #ifdef GNAT_UNICODE_SUPPORT
61 #define _UNICODE /* For C runtime */
62 #define UNICODE /* For Win32 API */
63 #endif
65 #include <tchar.h>
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
75 #define S2WSU(wstr,str,len) \
76 MultiByteToWideChar (CP_UTF8,0,str,-1,wstr,len)
77 #define WS2SU(str,wstr,len) \
78 WideCharToMultiByte (CP_UTF8,0,wstr,-1,str,len,NULL,NULL)
79 #define S2WS(wstr,str,len) \
80 MultiByteToWideChar (CP_ACP,0,str,-1,wstr,len)
81 #define WS2S(str,wstr,len) \
82 WideCharToMultiByte (CP_ACP,0,wstr,-1,str,len,NULL,NULL)
83 #else
84 #define S2WSU(wstr,str,len) strncpy(wstr,str,len)
85 #define WS2SU(str,wstr,len) strncpy(str,wstr,len)
86 #define S2WS(wstr,str,len) strncpy(wstr,str,len)
87 #define WS2S(str,wstr,len) strncpy(str,wstr,len)
88 #endif
90 #include <stdlib.h>
92 /* STD_MINGW: standard if MINGW32 version > 1.3, we have switched to this
93 version instead of the previous enhanced version to ease building GNAT on
94 Windows platforms. By using STD_MINGW or OLD_MINGW it is possible to build
95 GNAT using both MingW include files (Old MingW + ACT changes and standard
96 MingW starting with version 1.3.
97 For w64 Mingw the define STD_MINGW is always set to value 1, because
98 there is no old header set present. */
99 #ifdef _WIN64
100 #define STD_MINGW 1
101 #else
102 #define STD_MINGW ((__MINGW32_MAJOR_VERSION == 1 \
103 && __MINGW32_MINOR_VERSION >= 3) \
104 || (__MINGW32_MAJOR_VERSION >= 2))
105 #endif
107 #define OLD_MINGW (!(STD_MINGW))
109 #ifndef MAXPATHLEN
110 #define MAXPATHLEN MAX_PATH
111 #endif
113 #endif /* _MINGW32_H */