Patch from Kirk Beitz to make things compile on MinGW minus the putenv part.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125199 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Core/ConnectionFileDescriptor.cpp b/source/Core/ConnectionFileDescriptor.cpp
index e928901..4d8d123 100644
--- a/source/Core/ConnectionFileDescriptor.cpp
+++ b/source/Core/ConnectionFileDescriptor.cpp
@@ -10,15 +10,17 @@
 #include "lldb/Core/ConnectionFileDescriptor.h"
 
 // C Includes
-#include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>
+#ifdef __APPLE__
+#include <arpa/inet.h>
 #include <netdb.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <sys/socket.h>
-#include <sys/types.h>
 #include <sys/un.h>
+#endif
+#include <sys/types.h>
 #include <string.h>
 #include <stdlib.h>
 
@@ -616,7 +618,13 @@
 int
 ConnectionFileDescriptor::SetSocketOption(int fd, int level, int option_name, int option_value)
 {
-    return ::setsockopt(fd, level, option_name, &option_value, sizeof(option_value));
+#if defined(__MINGW32__) || defined(__MINGW64__)
+    const char* option_value_p = static_cast<const char*>(&option_value);
+#else // #if defined(__MINGW32__) || defined(__MINGW64__)
+    const void* option_value_p = &option_name;
+#endif // #if defined(__MINGW32__) || defined(__MINGW64__)
+
+	return ::setsockopt(fd, level, option_name, option_value_p, sizeof(option_value));
 }
 
 
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index af2f361..93f004a 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -10,9 +10,10 @@
 #include "EmulateInstructionARM.h"
 #include "lldb/Core/ConstString.h"
 
-#include "ARMDefines.h"
-#include "ARMUtils.h"
-#include "ARM_DWARF_Registers.h"
+#include "Plugins/Process/Utility/ARMDefines.h"
+#include "Plugins/Process/Utility/ARMUtils.h"
+#include "Utility/ARM_DWARF_Registers.h"
+
 #include "llvm/Support/MathExtras.h" // for SignExtend32 template function
                                      // and CountTrailingZeros_32 function
 
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 378b634..3708407 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -23,8 +23,8 @@
 
 #include "ProcessGDBRemote.h"
 #include "ProcessGDBRemoteLog.h"
+#include "Plugins/Process/Utility/UnwindLLDB.h"
 #include "Utility/StringExtractorGDBRemote.h"
-#include "UnwindLLDB.h"
 
 #ifdef __APPLE__
 #include "UnwindMacOSXFrameBackchain.h"
diff --git a/source/Utility/PseudoTerminal.cpp b/source/Utility/PseudoTerminal.cpp
index 382bf41..e4b444c 100644
--- a/source/Utility/PseudoTerminal.cpp
+++ b/source/Utility/PseudoTerminal.cpp
@@ -13,7 +13,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#if defined(TIOCSCTTY)
 #include <sys/ioctl.h>
+#endif
 
 using namespace lldb_utility;
 
@@ -237,7 +239,7 @@
                 // We are done with the master in the child process so lets close it
                 CloseMasterFileDescriptor ();
 
-#if defined (TIOCSCTTY)
+#if defined(TIOCSCTTY)
                 // Acquire the controlling terminal
                 if (::ioctl (m_slave_fd, TIOCSCTTY, (char *)0) < 0)
                 {
diff --git a/test/threads/main.cpp b/test/threads/main.cpp
index ae0ccfe..9216f7e 100644
--- a/test/threads/main.cpp
+++ b/test/threads/main.cpp
@@ -60,7 +60,7 @@
     while (mask_access(eGet) & thread_mask)
     {
         // random micro second sleep from zero to 3 seconds
-        long usec = ::random() % 3000000;
+        int usec = ::rand() % 3000000;
         printf ("%s (thread = %u) doing a usleep (%li)...\n", __FUNCTION__, thread_index, usec);
         ::usleep (usec);
         printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line.