From ee00428abe9c842a945773db80cf00471184e9c8 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 17 Apr 2009 10:51:43 +0200 Subject: [multiple changes] 2009-04-17 Pascal Obry * 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 * link.c: Add darwin section From-SVN: r146224 --- gcc/ada/ChangeLog | 14 ++++++++++++++ gcc/ada/adaint.h | 1 + gcc/ada/argv.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- gcc/ada/bindgen.adb | 37 +++++++++++++++++++++++++++++++------ gcc/ada/init.c | 3 +-- gcc/ada/link.c | 9 +++++++++ 6 files changed, 104 insertions(+), 12 deletions(-) (limited to 'gcc') 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 + + * 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 + + * link.c: Add darwin section + 2009-04-16 Robert Dewar * 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 +/* 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 #include /* 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 -/* 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,"; -- cgit v1.1