[llvm-commits] CVS: llvm/tools/lli/JIT/JIT.cpp VM.h

John Criswell criswell at cs.uiuc.edu
Thu Aug 21 16:13:21 PDT 2003


Changes in directory llvm/tools/lli/JIT:

JIT.cpp updated: 1.12 -> 1.13
VM.h updated: 1.9 -> 1.10

---
Log message:

The JIT now passes the environment pointer to the main() function when it
starts a program.  This allows the GNU env program to compile and JIT under
LLVM.


---
Diffs of the changes:

Index: llvm/tools/lli/JIT/JIT.cpp
diff -u llvm/tools/lli/JIT/JIT.cpp:1.12 llvm/tools/lli/JIT/JIT.cpp:1.13
--- llvm/tools/lli/JIT/JIT.cpp:1.12	Wed Jul 23 15:21:06 2003
+++ llvm/tools/lli/JIT/JIT.cpp	Thu Aug 21 16:12:30 2003
@@ -11,6 +11,8 @@
 #include "llvm/Module.h"
 #include "Support/CommandLine.h"
 
+#include "Config/stdlib.h"
+
 // FIXME: REMOVE THIS
 #include "llvm/PassManager.h"
 
@@ -101,21 +103,43 @@
   emitGlobals();
 }
 
-int VM::run(const std::string &FnName, const std::vector<std::string> &Args) {
+//
+// Method: run()
+//
+// Description:
+//	This method begins the execution of a program beginning at the
+//	specified function name.  The function is called with the
+//	specified arguments and array of environment variables (a la main()).
+//
+// Inputs:
+//	FnName - The name of the function as a C++ string.
+//	Args   - A vector of C++ strings containing the arguments.
+//	envp   - An array of C strings containing the environment.
+//
+// Outputs:
+//	None.
+//
+// Return value:
+//	1 - An error occurred.
+//	Otherwise, the return value from the specified function is returned.
+//
+int VM::run(const std::string &FnName,
+            const std::vector<std::string> &Args,
+            const char ** envp) {
   Function *F = getModule().getNamedFunction(FnName);
   if (F == 0) {
     std::cerr << "Could not find function '" << FnName << "' in module!\n";
     return 1;
   }
 
-  int(*PF)(int, char**) = (int(*)(int, char**))getPointerToFunction(F);
+  int(*PF)(int, char**, const char**) = (int(*)(int, char**, const char**))getPointerToFunction(F);
   assert(PF != 0 && "Null pointer to function?");
 
   // Build an argv vector...
   char **Argv = (char**)CreateArgv(Args);
 
   // Call the main function...
-  int Result = PF(Args.size(), Argv);
+  int Result = PF(Args.size(), Argv, envp);
 
   // Run any atexit handlers now!
   runAtExitHandlers();


Index: llvm/tools/lli/JIT/VM.h
diff -u llvm/tools/lli/JIT/VM.h:1.9 llvm/tools/lli/JIT/VM.h:1.10
--- llvm/tools/lli/JIT/VM.h:1.9	Wed Aug 13 13:16:50 2003
+++ llvm/tools/lli/JIT/VM.h	Thu Aug 21 16:12:30 2003
@@ -29,7 +29,8 @@
   /// run - Start execution with the specified function and arguments.
   ///
   virtual int run(const std::string &FnName,
-		  const std::vector<std::string> &Args);
+                  const std::vector<std::string> &Args,
+                  const char ** envp);
 
   /// getPointerToNamedFunction - This method returns the address of the
   /// specified function by using the dlsym function call.  As such it is only





More information about the llvm-commits mailing list