start defining codes for instructions
[oota-llvm.git] / tools / llvm-stub / llvm-stub.c
index 7009c8dee1a1ff85e949ce455d715e6510e8094e..10b025633f8a3d9c2401688a47e9ec0972b48be7 100644 (file)
@@ -15,7 +15,7 @@
 //
 // This allows the end user to just say ./<program> and have the JIT executed
 // automatically.  On unix, the stub executable emitted is actually a bourne
-// shell script that does the forwarding.  Windows doesn't not like #!/bin/sh
+// shell script that does the forwarding.  Windows does not like #!/bin/sh
 // programs in .exe files, so we make it an actual program, defined here.
 //
 //===----------------------------------------------------------------------===*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "Config/unistd.h"  /* provides definition of execve */
+
+#include "llvm/Config/config.h"
+
+#if defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
+#include <unistd.h>
+#endif
+
+#ifdef _WIN32
+#include <process.h>
+#include <io.h>
+#endif
 
 int main(int argc, char** argv) {
   const char *Interp = getenv("LLVMINTERP");
@@ -34,6 +44,14 @@ int main(int argc, char** argv) {
   Args = (const char**)malloc(sizeof(char*) * (argc+2));
   /* argv[0] is the JIT */
   Args[0] = Interp;
+
+#ifdef __CYGWIN32__
+  /* Cygwin strips the .exe suffix off of argv[0] to "help" us.  Put it back 
+   * on.
+   */
+  argv[0] = strcat(strcpy((char*)malloc(strlen(argv[0])+5), argv[0]), ".exe");
+#endif
+
   /* argv[1] is argv[0] + ".bc". */
   Args[1] = strcat(strcpy((char*)malloc(strlen(argv[0])+4), argv[0]), ".bc");