[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
This commit is contained in:
parent
d23a572fca
commit
ee00428abe
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
/******************/
|
||||
|
@ -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,";
|
||||
|
Loading…
Reference in New Issue
Block a user