diff options
author | Pascal Obry <obry@adacore.com> | 2006-10-31 18:47:20 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2006-10-31 18:47:20 +0100 |
commit | 18f2228492d64fae05e14707919e62b6a8f535b5 (patch) | |
tree | 55ea2708d17acf16323af0332d2a2f211874f3cb /gcc/ada/adaint.c | |
parent | d1fa78e300ffbcc515c6d644d664f8a58c6f23c3 (diff) | |
download | gcc-18f2228492d64fae05e14707919e62b6a8f535b5.zip gcc-18f2228492d64fae05e14707919e62b6a8f535b5.tar.gz gcc-18f2228492d64fae05e14707919e62b6a8f535b5.tar.bz2 |
adaint.c (__gnat_get_libraries_from_registry): Call explicitly the ASCII version of the registry API.
2006-10-31 Pascal Obry <obry@adacore.com>
Eric Botcazou <ebotcazou@adacore.com>
Vincent Celier <celier@adacore.com>
* adaint.c (__gnat_get_libraries_from_registry): Call explicitly the
ASCII version of the registry API. This is needed as the GNAT runtime
is now UNICODE by default.
Include version.h.
(get_gcc_version): Do not hardcode the return value.
(__gnat_file_time_name): On Windows properly set the default returned
value to -1 which corresponds to Invalid_Time.
(__gnat_fopen): New routine. A simple wrapper on all plateforms
except on Windows where it does conversion for unicode support.
(__gnat_freopen): Idem.
(__gnat_locate_exec_on_path): If environment variable PATH does not
exist, return a NULL pointer
* adaint.h: (__gnat_fopen): Declare.
(__gnat_freopen): Likewise.
* mingw32.h (_tfreopen): Define this macro here for older MingW
version.
Activate the unicode support on platforms using a MingW runtime
version 3.9 or newer.
* s-crtl.ads (fopen): Is now an import to the wrapper __gnat_freopen.
This is needed for proper unicode support on Windows.
(freopen): Idem.
From-SVN: r118240
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r-- | gcc/ada/adaint.c | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 674df69..8705a93 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -73,6 +73,7 @@ #else #include "config.h" #include "system.h" +#include "version.h" #endif #ifdef __MINGW32__ @@ -610,6 +611,37 @@ __gnat_get_debuggable_suffix_ptr (int *len, const char **value) 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) { @@ -1023,7 +1055,7 @@ __gnat_file_time_name (char *name) 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); @@ -1398,8 +1430,8 @@ __gnat_get_libraries_from_registry (void) 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) { @@ -2123,6 +2155,7 @@ __gnat_locate_exec_on_path (char *exec_name) #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); @@ -2675,11 +2708,15 @@ __gnat_lseek (int fd, long offset, int whence) 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 |