diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-17 10:51:43 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-17 10:51:43 +0200 |
commit | ee00428abe9c842a945773db80cf00471184e9c8 (patch) | |
tree | d2d00eb089777564d8460482a6172c033e79d9df /gcc/ada | |
parent | d23a572fca4b29667c9758192d769ff5e34efe33 (diff) | |
download | gcc-ee00428abe9c842a945773db80cf00471184e9c8.zip gcc-ee00428abe9c842a945773db80cf00471184e9c8.tar.gz gcc-ee00428abe9c842a945773db80cf00471184e9c8.tar.bz2 |
[multiple changes]
2009-04-17 Pascal Obry <obry@adacore.com>
* adaint.h, argv.c (__gnat_init_args): New routine used to initialize
command line arguments.
* bindgen.adb: Call __gnat_init_args instead of simple assignments of
argc, argv and envp parameters.
* init.c: Fix minor typo and style fix.
2009-04-17 Nicolas Setton <setton@adacore.com>
* link.c: Add darwin section
From-SVN: r146224
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/ada/adaint.h | 1 | ||||
-rw-r--r-- | gcc/ada/argv.c | 52 | ||||
-rw-r--r-- | gcc/ada/bindgen.adb | 37 | ||||
-rw-r--r-- | gcc/ada/init.c | 3 | ||||
-rw-r--r-- | gcc/ada/link.c | 9 |
6 files changed, 104 insertions, 12 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 4280b92..b6f23cd 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,17 @@ +2009-04-17 Pascal Obry <obry@adacore.com> + + * adaint.h, argv.c (__gnat_init_args): New routine used to initialize + command line arguments. + + * bindgen.adb: Call __gnat_init_args instead of simple assignments of + argc, argv and envp parameters. + + * init.c: Fix minor typo and style fix. + +2009-04-17 Nicolas Setton <setton@adacore.com> + + * link.c: Add darwin section + 2009-04-16 Robert Dewar <dewar@adacore.com> * g-pehage.adb: Minor reformatting diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h index 5ed4d76..1501e99 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -142,6 +142,7 @@ extern FILE *__gnat_constant_stdin (void); extern FILE *__gnat_constant_stdout (void); extern char *__gnat_full_name (char *, char *); +extern void __gnat_init_args (int, char **, char **); extern int __gnat_arg_count (void); extern int __gnat_len_arg (int); extern void __gnat_fill_arg (char *, int); diff --git a/gcc/ada/argv.c b/gcc/ada/argv.c index b827b03..6420967 100644 --- a/gcc/ada/argv.c +++ b/gcc/ada/argv.c @@ -46,29 +46,73 @@ #include "tconfig.h" #include "tsystem.h" #include <sys/stat.h> +/* We don't have libiberty, so use malloc. */ +#define xmalloc(S) malloc (S) #else #include "config.h" #include "system.h" #endif -#include "adaint.h" - /* argc and argv of the main program are saved under gnat_argc and gnat_argv, envp of the main program is saved under gnat_envp. */ int gnat_argc = 0; -const char **gnat_argv = (const char **) 0; +char **gnat_argv = (char **) 0; const char **gnat_envp = (const char **) 0; #if defined (_WIN32) && !defined (RTX) /* Note that on Windows environment the environ point to a buffer that could be reallocated if needed. It means that gnat_envp needs to be updated - before using gnat_envp to point to the right environment space */ + before using gnat_envp to point to the right environment space. */ +#include "mingw32.h" +#include <windows.h> #include <stdlib.h> /* for the environ variable definition */ #define gnat_envp (environ) #endif +#include "adaint.h" + +void +__gnat_init_args (int argc, char **argv ATTRIBUTE_UNUSED, char **envp) +{ +#if defined (_WIN32) && ! defined (__vxworks) && ! defined (CROSS_COMPILE) + char arg_utf8[MAX_PATH]; + LPWSTR *wargv; + int wargc; + int k; + + wargv = CommandLineToArgvW (GetCommandLineW(), &wargc); + + if (wargv == NULL) + { + /* CommandLineToArgvW was not successful, use standard argc/argv. */ + gnat_argv = argv; + gnat_argc = argc; + } + else + { + /* Set gnat_argv with arguments encoded in UTF-8. */ + gnat_argv = (char **) xmalloc ((wargc + 1) * sizeof (char *)); + + for (k=0; k<wargc; k++) + { + WS2SU (arg_utf8, wargv[k], MAX_PATH); + gnat_argv[k] = (char *) xmalloc (strlen (arg_utf8) + 1); + strcpy (gnat_argv[k], arg_utf8); + } + + LocalFree (wargv); + gnat_argc = wargc; + } +#else + gnat_argv = argv; + gnat_argc = argc; +#endif + + gnat_envp = envp; +} + int __gnat_arg_count (void) { diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index ce81c7a..ef90c6c 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -1456,6 +1456,17 @@ package body Bindgen is WBI (" is"); + -- ??? the following code needs commenting + + if not Configurable_Run_Time_Mode then + WBI (" procedure Init_Args"); + WBI (" (argc : Integer;"); + WBI (" argv : System.Address;"); + WBI (" envp : System.Address);"); + WBI (" pragma Import (C, Init_Args, ""__gnat_init_args"");"); + WBI (""); + end if; + else if Exit_Status_Supported_On_Target then Set_String (" return Integer is"); @@ -1569,9 +1580,16 @@ package body Bindgen is -- Acquire command line arguments if present on target if Command_Line_Args_On_Target then - WBI (" gnat_argc := argc;"); - WBI (" gnat_argv := argv;"); - WBI (" gnat_envp := envp;"); + if Configurable_Run_Time_Mode then + WBI (" gnat_argc := argc;"); + WBI (" gnat_argv := argv;"); + WBI (" gnat_envp := envp;"); + + -- ??? this else needs a comment + else + WBI (" Init_Args (argc, argv, envp);"); + end if; + WBI (""); -- If configurable run time and no command line args, then nothing @@ -1732,9 +1750,16 @@ package body Bindgen is -- arguments are present on target if Command_Line_Args_On_Target then - WBI (" gnat_argc = argc;"); - WBI (" gnat_argv = argv;"); - WBI (" gnat_envp = envp;"); + if Configurable_Run_Time_Mode then + WBI (" gnat_argc = argc;"); + WBI (" gnat_argv = argv;"); + WBI (" gnat_envp = envp;"); + + -- ??? this call must be commented + else + WBI (" __gnat_init_args (argc, argv, envp);"); + end if; + WBI (" "); -- If configurable run-time, then nothing to do, since in this case diff --git a/gcc/ada/init.c b/gcc/ada/init.c index fab0942..7ac5a26 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -53,7 +53,7 @@ #include "tsystem.h" #include <sys/stat.h> -/* We don't have libiberty, so us malloc. */ +/* We don't have libiberty, so use malloc. */ #define xmalloc(S) malloc (S) #else #include "config.h" @@ -1964,7 +1964,6 @@ __gnat_init_float (void) checking is not used. */ void (*__gnat_set_stack_limit_hook)(void) = (void (*)(void))0; - /******************/ /* NetBSD Section */ /******************/ diff --git a/gcc/ada/link.c b/gcc/ada/link.c index 5d8ab86..e1d86fc 100644 --- a/gcc/ada/link.c +++ b/gcc/ada/link.c @@ -152,6 +152,15 @@ unsigned char __gnat_objlist_file_supported = 1; unsigned char __gnat_using_gnu_linker = 1; const char *__gnat_object_library_extension = ".a"; +#elif defined (__APPLE__) +const char *__gnat_object_file_option = ""; +const char *__gnat_run_path_option = "-Wl,-rpath,"; +char __gnat_shared_libgnat_default = STATIC; +int __gnat_link_max = 262144; +unsigned char __gnat_objlist_file_supported = 1; +unsigned char __gnat_using_gnu_linker = 1; +const char *__gnat_object_library_extension = ".a"; + #elif defined (linux) || defined(__GLIBC__) const char *__gnat_object_file_option = ""; const char *__gnat_run_path_option = "-Wl,-rpath,"; |