From 900dd8405fbd327023aa24f856b4535033ebbef0 Mon Sep 17 00:00:00 2001 From: Nicolas Roche Date: Mon, 8 Jul 2019 08:14:06 +0000 Subject: [PATCH] [Ada] Remove dependency on Win32 GDI (Graphical Interface) CommandLineToArgvW drags a dependency on SHELL32.DLL and thus GDI32.DLL. By loading GDI32.DLL some default GDI objects are allocated. On some Windows versions this cause the use of a lock on the graphical interface during process termination. This can impact parallelism significantly as termination of processes is serialized. 2019-07-08 Nicolas Roche gcc/ada/ * rtinit.c (__gnat_runtime_initialize): Remove dependency on CommandLineToArgvW. From-SVN: r273214 --- gcc/ada/ChangeLog | 5 ++ gcc/ada/rtinit.c | 200 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 197 insertions(+), 8 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 288c60487c6..57869d32bda 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-08 Nicolas Roche + + * rtinit.c (__gnat_runtime_initialize): Remove dependency on + CommandLineToArgvW. + 2019-07-08 Doug Rupp * Makefile.rtl: Handle vxworks7r2 in x86_64 and x86 vxworks7. diff --git a/gcc/ada/rtinit.c b/gcc/ada/rtinit.c index 13bd595b668..1df98f81cf2 100644 --- a/gcc/ada/rtinit.c +++ b/gcc/ada/rtinit.c @@ -62,7 +62,7 @@ extern "C" { /* __gnat_runtime_initialize (NT-mingw32 Version) */ /**************************************************/ -extern void __gnat_install_handler(void); +extern void __gnat_install_handler (void); int __gnat_wide_text_translation_required = 0; /* wide text translation, 0=none, 1=activated */ @@ -89,6 +89,189 @@ extern HANDLE ProcListEvt; int __gnat_do_argv_expansion = 1; #pragma weak __gnat_do_argv_expansion +/* Assuming we are pointing to the beginning of a quoted part of an +argument, skip until the end of the quoted part. */ +static void skip_quoted_string (const WCHAR **current_in, + WCHAR **current_out) +{ + /* Number of backslashes buffered. */ + int qbs_count = 0; + + /* Pointer to current input character. */ + const WCHAR *ci = *current_in; + + /* Pointer to next output character. */ + WCHAR *co = *current_out; + + /* Skip initial quote. */ + ci++; + + while (*ci) + { + if (*ci == '\\') + { + /* Buffer incoming backslashes. */ + qbs_count++; + } + else if (*ci == '"') + { + /* Append qbs_count / 2 backslahes. */ + for (int i=0; i