reset errno to zero on entry to the application's main function. This fixes
authorChris Lattner <sabre@nondot.org>
Fri, 27 Apr 2007 17:02:33 +0000 (17:02 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 27 Apr 2007 17:02:33 +0000 (17:02 +0000)
MultiSource/Applications/minisat in the JIT.

Note that the libsystem stuff should ideally never modify errno.  :(

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36508 91177308-0d34-0410-b5e6-96231b3b80d8

tools/lli/lli.cpp

index 225180b8caed3ba94ca68b3da8f9156fa1686dc4..89e4be6b5f98f62356fb93313ca634e50ac1ffa4 100644 (file)
@@ -28,7 +28,7 @@
 #include "llvm/System/Process.h"
 #include "llvm/System/Signals.h"
 #include <iostream>
-
+#include <cerrno>
 using namespace llvm;
 
 namespace {
@@ -128,6 +128,10 @@ int main(int argc, char **argv, char * const *envp) {
     // function later on to make an explicit call, so get the function now. 
     Constant *Exit = Mod->getOrInsertFunction("exit", Type::VoidTy,
                                                           Type::Int32Ty, NULL);
+    
+    // Reset errno to zero on entry to main.
+    errno = 0;
+   
     // Run static constructors.
     EE->runStaticConstructorsDestructors(false);