aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/initialize.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/initialize.c')
-rw-r--r--gcc/ada/initialize.c224
1 files changed, 1 insertions, 223 deletions
diff --git a/gcc/ada/initialize.c b/gcc/ada/initialize.c
index 9426c9e..8282ba5 100644
--- a/gcc/ada/initialize.c
+++ b/gcc/ada/initialize.c
@@ -62,230 +62,15 @@ extern "C" {
/* __gnat_initialize (NT-mingw32 Version) */
/******************************************/
-int __gnat_wide_text_translation_required = 0;
-/* wide text translation, 0=none, 1=activated */
+extern void __gnat_install_handler(void);
#if defined (__MINGW32__)
-#include "mingw32.h"
-#include <windows.h>
-extern void __gnat_init_float (void);
extern void __gnat_install_SEH_handler (void *);
-extern int gnat_argc;
-extern char **gnat_argv;
-extern CRITICAL_SECTION ProcListCS;
-extern HANDLE ProcListEvt;
-
-#ifdef GNAT_UNICODE_SUPPORT
-
-#define EXPAND_ARGV_RATE 128
-
-static void
-append_arg (int *index, LPWSTR dir, LPWSTR value,
- char ***argv, int *last, int quoted)
-{
- int size;
- LPWSTR fullvalue;
- int vallen = _tcslen (value);
- int dirlen;
-
- if (dir == NULL)
- {
- /* no dir prefix */
- dirlen = 0;
- fullvalue = (LPWSTR) xmalloc ((vallen + 1) * sizeof(TCHAR));
- }
- else
- {
- /* Add dir first */
- dirlen = _tcslen (dir);
-
- fullvalue = (LPWSTR) xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR));
- _tcscpy (fullvalue, dir);
- }
-
- /* Append value */
-
- if (quoted)
- {
- _tcsncpy (fullvalue + dirlen, value + 1, vallen - 1);
- fullvalue [dirlen + vallen - sizeof(TCHAR)] = _T('\0');
- }
- else
- _tcscpy (fullvalue + dirlen, value);
-
- if (*last <= *index)
- {
- *last += EXPAND_ARGV_RATE;
- *argv = (char **) xrealloc (*argv, (*last) * sizeof (char *));
- }
-
- size = WS2SC (NULL, fullvalue, 0);
- (*argv)[*index] = (char *) xmalloc (size + sizeof(TCHAR));
- WS2SC ((*argv)[*index], fullvalue, size);
-
- free (fullvalue);
-
- (*index)++;
-}
-#endif
-
void
__gnat_initialize (void *eh ATTRIBUTE_UNUSED)
{
- /* Initialize floating-point coprocessor. This call is needed because
- the MS libraries default to 64-bit precision instead of 80-bit
- precision, and we require the full precision for proper operation,
- given that we have set Max_Digits etc with this in mind */
- __gnat_init_float ();
-
- /* Initialize the critical section and event handle for the win32_wait()
- implementation, see adaint.c */
- InitializeCriticalSection (&ProcListCS);
- ProcListEvt = CreateEvent (NULL, FALSE, FALSE, NULL);
-
-#ifdef GNAT_UNICODE_SUPPORT
- /* Set current code page for filenames handling. */
- {
- char *codepage = getenv ("GNAT_CODE_PAGE");
-
- /* Default code page is UTF-8. */
- CurrentCodePage = CP_UTF8;
-
- if (codepage != NULL)
- {
- if (strcmp (codepage, "CP_ACP") == 0)
- CurrentCodePage = CP_ACP;
- else if (strcmp (codepage, "CP_UTF8") == 0)
- CurrentCodePage = CP_UTF8;
- }
- }
-
- /* Set current encoding for the IO. */
- {
- char *ccsencoding = getenv ("GNAT_CCS_ENCODING");
-
- /* Default CCS Encoding. */
- CurrentCCSEncoding = _O_TEXT;
- __gnat_wide_text_translation_required = 0;
-
- if (ccsencoding != NULL)
- {
- if (strcmp (ccsencoding, "U16TEXT") == 0)
- {
- CurrentCCSEncoding = _O_U16TEXT;
- __gnat_wide_text_translation_required = 1;
- }
- else if (strcmp (ccsencoding, "TEXT") == 0)
- {
- CurrentCCSEncoding = _O_TEXT;
- __gnat_wide_text_translation_required = 0;
- }
- else if (strcmp (ccsencoding, "WTEXT") == 0)
- {
- CurrentCCSEncoding = _O_WTEXT;
- __gnat_wide_text_translation_required = 1;
- }
- else if (strcmp (ccsencoding, "U8TEXT") == 0)
- {
- CurrentCCSEncoding = _O_U8TEXT;
- __gnat_wide_text_translation_required = 1;
- }
- }
- }
-
- /* Adjust gnat_argv to support Unicode characters. */
- {
- LPWSTR *wargv;
- int wargc;
- int k;
- int last;
- int argc_expanded = 0;
- TCHAR result [MAX_PATH];
- int quoted;
-
- wargv = CommandLineToArgvW (GetCommandLineW(), &wargc);
-
- if (wargv != NULL)
- {
- /* Set gnat_argv with arguments encoded in UTF-8. */
- last = wargc + 1;
- gnat_argv = (char **) xmalloc ((last) * sizeof (char *));
-
- /* argv[0] is the executable full path-name. */
-
- SearchPath (NULL, wargv[0], _T(".exe"), MAX_PATH, result, NULL);
- append_arg (&argc_expanded, NULL, result, &gnat_argv, &last, 0);
-
- for (k=1; k<wargc; k++)
- {
- quoted = (wargv[k][0] == _T('\''));
-
- /* Check for wildcard expansion if the argument is not quoted. */
- if (!quoted
- && (_tcsstr (wargv[k], _T("?")) != 0 ||
- _tcsstr (wargv[k], _T("*")) != 0))
- {
- /* Wilcards are present, append all corresponding matches. */
- WIN32_FIND_DATA FileData;
- HANDLE hDir = FindFirstFile (wargv[k], &FileData);
- LPWSTR dir = NULL;
- LPWSTR ldir = _tcsrchr (wargv[k], _T('\\'));
-
- if (ldir == NULL)
- ldir = _tcsrchr (wargv[k], _T('/'));
-
- if (hDir == INVALID_HANDLE_VALUE)
- {
- /* No match, append arg as-is. */
- append_arg (&argc_expanded, NULL, wargv[k],
- &gnat_argv, &last, quoted);
- }
- else
- {
- if (ldir != NULL)
- {
- int n = ldir - wargv[k] + 1;
- dir = (LPWSTR) xmalloc ((n + 1) * sizeof (TCHAR));
- _tcsncpy (dir, wargv[k], n);
- dir[n] = _T('\0');
- }
-
- /* Append first match and all remaining ones. */
-
- do {
- /* Do not add . and .. special entries */
-
- if (_tcscmp (FileData.cFileName, _T(".")) != 0
- && _tcscmp (FileData.cFileName, _T("..")) != 0)
- append_arg (&argc_expanded, dir, FileData.cFileName,
- &gnat_argv, &last, 0);
- } while (FindNextFile (hDir, &FileData));
-
- FindClose (hDir);
-
- if (dir != NULL)
- free (dir);
- }
- }
- else
- {
- /* No wildcard. Store parameter as-is. Remove quote if
- needed. */
- append_arg (&argc_expanded, NULL, wargv[k],
- &gnat_argv, &last, quoted);
- }
- }
-
- LocalFree (wargv);
- gnat_argc = argc_expanded;
- gnat_argv = (char **) xrealloc
- (gnat_argv, argc_expanded * sizeof (char *));
- }
- }
-#endif
-
/* Note that we do not activate this for the compiler itself to avoid a
bootstrap path problem. Older version of gnatbind will generate a call
to __gnat_initialize() without argument. Therefore we cannot use eh in
@@ -305,12 +90,9 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
#elif defined (__Lynx__) || defined (__FreeBSD__) || defined(__NetBSD__) \
|| defined (__OpenBSD__)
-extern void __gnat_init_float (void);
-
void
__gnat_initialize (void *eh ATTRIBUTE_UNUSED)
{
- __gnat_init_float ();
}
/***************************************/
@@ -319,12 +101,9 @@ __gnat_initialize (void *eh ATTRIBUTE_UNUSED)
#elif defined(__vxworks)
-extern void __gnat_init_float (void);
-
void
__gnat_initialize (void *eh)
{
- __gnat_init_float ();
}
#elif defined(_T_HPUX10) || (!defined(IN_RTS) && defined(_X_HPUX10))
@@ -354,7 +133,6 @@ void
__gnat_initialize (void *eh ATTRIBUTE_UNUSED)
{
}
-
#endif
#ifdef __cplusplus