summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2007-07-17 14:20:50 +0000
committerIan Lynagh <igloo@earth.li>2007-07-17 14:20:50 +0000
commit8bac478832e0cf9fa7ad1cfc81c08b0b9f13938e (patch)
treeab0e7316f2e4bbb58b5ed9942c8798866e4530b5 /rts
parent1d708730ee5d0882c59f3d90422ff04fa0e5f39b (diff)
downloadhaskell-8bac478832e0cf9fa7ad1cfc81c08b0b9f13938e.tar.gz
Implement the RTS side of GHC.Environment.getFullArgs
Diffstat (limited to 'rts')
-rw-r--r--rts/Linker.c1
-rw-r--r--rts/RtsFlags.c28
-rw-r--r--rts/RtsStartup.c1
3 files changed, 30 insertions, 0 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index d8d61a07af..243eae1b76 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -523,6 +523,7 @@ typedef struct _RtsSymbolVal {
SymX(genSymZh) \
SymX(genericRaise) \
SymX(getProgArgv) \
+ SymX(getFullProgArgv) \
SymX(getStablePtr) \
SymX(hs_init) \
SymX(hs_exit) \
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 9dd6b19312..a2d699daf7 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -28,6 +28,8 @@ RTS_FLAGS RtsFlags;
*/
int prog_argc = 0; /* an "int" so as to match normal "argc" */
char **prog_argv = NULL;
+int full_prog_argc = 0; /* an "int" so as to match normal "argc" */
+char **full_prog_argv = NULL;
char *prog_name = NULL; /* 'basename' of prog_argv[0] */
int rts_argc = 0; /* ditto */
char *rts_argv[MAX_RTS_ARGS];
@@ -2411,3 +2413,29 @@ setProgArgv(int argc, char *argv[])
prog_argv = argv;
setProgName(prog_argv);
}
+
+/* These functions record and recall the full arguments, including the
+ +RTS ... -RTS options. The reason for adding them was so that the
+ ghc-inplace program can pass /all/ the arguments on to the real ghc. */
+void
+getFullProgArgv(int *argc, char **argv[])
+{
+ if (argc) { *argc = full_prog_argc; }
+ if (argv) { *argv = full_prog_argv; }
+}
+
+void
+setFullProgArgv(int argc, char *argv[])
+{
+ int i;
+ full_prog_argc = argc;
+ full_prog_argv = stgCallocBytes(argc + 1, sizeof (char *),
+ "setFullProgArgv 1");
+ for (i = 0; i < argc; i++) {
+ full_prog_argv[i] = stgMallocBytes(strlen(argv[i]) + 1,
+ "setFullProgArgv 2");
+ strcpy(full_prog_argv[i], argv[i]);
+ }
+ full_prog_argv[argc] = NULL;
+}
+
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
index 7dce06e640..a363c133f4 100644
--- a/rts/RtsStartup.c
+++ b/rts/RtsStartup.c
@@ -199,6 +199,7 @@ hs_init(int *argc, char **argv[])
/* Parse the flags, separating the RTS flags from the programs args */
if (argc != NULL && argv != NULL) {
+ setFullProgArgv(*argc,*argv);
setupRtsFlags(argc, *argv, &rts_argc, rts_argv);
setProgArgv(*argc,*argv);
}