#else
#include "config.h"
#include "system.h"
+#include "version.h"
#endif
#ifdef __MINGW32__
return;
}
+FILE *
+__gnat_fopen (char *path, char *mode)
+{
+#if defined (_WIN32) && ! defined (__vxworks) && ! defined (CROSS_COMPILE)
+ TCHAR wpath[GNAT_MAX_PATH_LEN];
+ TCHAR wmode[10];
+
+ S2WS (wpath, path, GNAT_MAX_PATH_LEN);
+ S2WS (wmode, mode, 10);
+ return _tfopen (wpath, wmode);
+#else
+ return fopen (path, mode);
+#endif
+}
+
+
+FILE *
+__gnat_freopen (char *path, char *mode, FILE *stream)
+{
+#if defined (_WIN32) && ! defined (__vxworks) && ! defined (CROSS_COMPILE)
+ TCHAR wpath[GNAT_MAX_PATH_LEN];
+ TCHAR wmode[10];
+
+ S2WS (wpath, path, GNAT_MAX_PATH_LEN);
+ S2WS (wmode, mode, 10);
+ return _tfreopen (wpath, wmode, stream);
+#else
+ return freopen (path, mode, stream);
+#endif
+}
+
int
__gnat_open_read (char *path, int fmode)
{
return (OS_Time)ret;
#elif defined (_WIN32)
- time_t ret = 0;
+ time_t ret = -1;
TCHAR wname[GNAT_MAX_PATH_LEN];
S2WS (wname, name, GNAT_MAX_PATH_LEN);
for (index = 0; res == ERROR_SUCCESS; index++)
{
value_size = name_size = 256;
- res = RegEnumValue (reg_key, index, (TCHAR*)name, &name_size, 0,
- &type, (LPBYTE)value, &value_size);
+ res = RegEnumValueA (reg_key, index, (TCHAR*)name, &name_size, 0,
+ &type, (LPBYTE)value, &value_size);
if (res == ERROR_SUCCESS && type == REG_SZ)
{
#else
char *path_val = getenv ("PATH");
#endif
+ if (path_val == NULL) return NULL;
apath_val = alloca (strlen (path_val) + 1);
strcpy (apath_val, path_val);
return __gnat_locate_exec (exec_name, apath_val);
return (int) lseek (fd, offset, whence);
}
-/* This function returns the version of GCC being used. Here it's GCC 3. */
+/* This function returns the major version number of GCC being used. */
int
get_gcc_version (void)
{
- return 3;
+#ifdef IN_RTS
+ return __GNUC__;
+#else
+ return (int) (version_string[0] - '0');
+#endif
}
int
extern int __gnat_mkdir (char *);
extern int __gnat_stat (char *,
struct stat *);
+extern FILE *__gnat_fopen (char *, char *);
+extern FILE *__gnat_freopen (char *, char *, FILE *);
extern int __gnat_open_read (char *, int);
extern int __gnat_open_rw (char *, int);
extern int __gnat_open_create (char *, int);
****************************************************************************/
/* This file provides some macros used for the MINGW32 platform. The main
- goal is to be able to build GNAT with a standard MINGW32 C header set */
+ goal is to be able to build GNAT with a standard MINGW32 C header
+ set. This files contains also the circuitry for the unicode support. */
#ifndef _MINGW32_H
#define _MINGW32_H
+/* The unicode support is activated by default starting with the 3.9 MingW
+ version. It is not possible to use it with previous version due to a bug
+ in the MingW runtime. */
+#if ((__MINGW32_MAJOR_VERSION == 3 \
+ && __MINGW32_MINOR_VERSION >= 9) \
+ || (__MINGW32_MAJOR_VERSION >= 4))
+#define GNAT_UNICODE_SUPPORT
-/* Uncomment to activate the GNAT Unicode support. */
-/*#define GNAT_UNICODE_SUPPORT */
+#else
+
+/* Older MingW versions have no defintion for _tfreopen, add it here to have a
+ proper build without unicode support. */
+#ifndef _tfreopen
+#define _tfreopen freopen
+#endif
+
+#endif
#ifdef GNAT_UNICODE_SUPPORT
#define _UNICODE /* For C runtime */
/* After including this file it is possible to use the character t as prefix
to routines. If GNAT_UNICODE_SUPPORT is defined then the unicode enabled
- versions will be used. */
+ versions will be used. */
/* Copy to/from wide-string, if GNAT_UNICODE_SUPPORT activated this will do
the proper translations using the UTF-8 encoding. */
version instead of the previous enhanced version to ease building GNAT on
Windows platforms. By using STD_MINGW or OLD_MINGW it is possible to build
GNAT using both MingW include files (Old MingW + ACT changes and standard
- MingW starting with version 1.3. */
+ MingW starting with version 1.3. */
#define STD_MINGW ((__MINGW32_MAJOR_VERSION == 1 \
&& __MINGW32_MINOR_VERSION >= 3) \
|| (__MINGW32_MAJOR_VERSION >= 2))
pragma Import (C, fgets, "fgets");
function fopen (filename : chars; Mode : chars) return FILEs;
- pragma Import (C, fopen, "fopen");
+ pragma Import (C, fopen, "__gnat_fopen");
function fputc (C : int; stream : FILEs) return int;
pragma Import (C, fputc, "fputc");
mode : chars;
stream : FILEs)
return FILEs;
- pragma Import (C, freopen, "freopen");
+ pragma Import (C, freopen, "__gnat_freopen");
function fseek
(stream : FILEs;