MingW compilation (windows). Includes various refactoring to improve portability.

llvm-svn: 189107
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index f5e71d5..4ff0999 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -480,7 +480,7 @@
 const char *
 SBDebugger::GetVersionString ()
 {
-    return GetVersion();
+    return lldb_private::GetVersion();
 }
 
 const char *
diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp
index a8f7db9..1664031 100644
--- a/lldb/source/API/SBHostOS.cpp
+++ b/lldb/source/API/SBHostOS.cpp
@@ -42,7 +42,7 @@
 SBHostOS::ThreadCreate
 (
     const char *name,
-    void *(*thread_function)(void *),
+    thread_func_t thread_function,
     void *thread_arg,
     SBError *error_ptr
 )
@@ -77,7 +77,7 @@
 }
 
 bool
-SBHostOS::ThreadJoin (lldb::thread_t thread, void **result, SBError *error_ptr)
+SBHostOS::ThreadJoin (lldb::thread_t thread, thread_result_t *result, SBError *error_ptr)
 {
     return Host::ThreadJoin (thread, result, error_ptr ? error_ptr->get() : NULL);
 }
diff --git a/lldb/source/CMakeLists.txt b/lldb/source/CMakeLists.txt
index 57543e0..eddd8cb 100644
--- a/lldb/source/CMakeLists.txt
+++ b/lldb/source/CMakeLists.txt
@@ -78,9 +78,9 @@
 # Windows-only libraries

 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )

   list(APPEND LLDB_USED_LIBS

-    #lldbHostWindows

+    lldbHostWindows

     #lldbPluginPlatformWindows

-    #Ws2_32

+    Ws2_32

     )

 endif ()

 

@@ -137,10 +137,12 @@
   clangSerialization

   )  

   

-set( LLDB_SYSTEM_LIBS

-  edit

-  python2.7

-  )

+if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")

+  set( LLDB_SYSTEM_LIBS

+    edit

+    python2.7

+    )

+endif()

 

 set( LLVM_LINK_COMPONENTS

   ${LLVM_TARGETS_TO_BUILD}

@@ -164,10 +166,14 @@
 set_source_files_properties(${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp PROPERTIES GENERATED 1)

 set(SHARED_LIBRARY 1)

 

+if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")

+  set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)

+endif()

+

 add_lldb_library(liblldb

   lldb.cpp

   lldb-log.cpp

-  ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp

+  ${LLDB_WRAP_PYTHON}

   ${LLDB_VERS_GENERATED_FILE}

   )

 set_target_properties(liblldb

@@ -175,10 +181,12 @@
   OUTPUT_NAME lldb

   VERSION ${LLDB_VERSION}

   )

-add_dependencies(liblldb

-  ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp

-  ${LLDB_VERS_GENERATED_FILE}

-  )

+if (LLDB_WRAP_PYTHON OR LLDB_VERS_GENERATED_FILE)

+  add_dependencies(liblldb

+    ${LLDB_WRAP_PYTHON}

+    ${LLDB_VERS_GENERATED_FILE}

+    )

+endif()

 target_link_libraries(liblldb ${LLDB_SYSTEM_LIBS})

 

 # Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as

@@ -209,4 +217,5 @@
 

 

 install(TARGETS liblldb

+  RUNTIME DESTINATION bin

   LIBRARY DESTINATION lib)

diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index a9d2f21..138fdfe 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -11,7 +11,6 @@
 
 // C Includes
 #include <sys/stat.h>
-#include <dirent.h>
 #if defined(__APPLE__) || defined(__linux__)
 #include <pwd.h>
 #endif
@@ -121,6 +120,72 @@
     return matches.GetSize();
 }
 
+typedef struct DiskFilesOrDirectoriesBaton
+{
+    const char *remainder;
+    char *partial_name_copy;
+    bool only_directories;
+    bool *saw_directory;
+    StringList *matches;
+    char *end_ptr;
+    size_t baselen;
+};
+
+FileSpec::EnumerateDirectoryResult DiskFilesOrDirectoriesCallback(void *baton, FileSpec::FileType file_type, const FileSpec &spec)
+{
+    const char *name = spec.GetFilename().AsCString();
+
+    const DiskFilesOrDirectoriesBaton *parameters = (DiskFilesOrDirectoriesBaton*)baton;
+    char *end_ptr = parameters->end_ptr;
+    char *partial_name_copy = parameters->partial_name_copy;
+    size_t baselen = end_ptr - partial_name_copy;
+    const char *remainder = parameters->remainder;
+
+    // Omit ".", ".." and any . files if the match string doesn't start with .
+    if (name[0] == '.')
+    {
+        if (name[1] == '\0')
+            return FileSpec::eEnumerateDirectoryResultNext;
+        else if (name[1] == '.' && name[2] == '\0')
+            return FileSpec::eEnumerateDirectoryResultNext;
+        else if (remainder[0] != '.')
+            return FileSpec::eEnumerateDirectoryResultNext;
+    }
+
+    // If we found a directory, we put a "/" at the end of the name.
+
+    if (remainder[0] == '\0' || strstr(name, remainder) == name)
+    {
+        if (strlen(name) + parameters->baselen >= PATH_MAX)
+            return FileSpec::eEnumerateDirectoryResultNext;
+
+        strcpy(end_ptr, name);
+
+        bool isa_directory = false;
+        if (file_type == FileSpec::eFileTypeDirectory)
+            isa_directory = true;
+        else if (file_type == FileSpec::eFileTypeSymbolicLink)
+        {
+            struct stat stat_buf;
+            if ((stat(partial_name_copy, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode))
+                isa_directory = true;
+        }
+
+        if (isa_directory)
+        {
+            *parameters->saw_directory = true;
+            size_t len = strlen(parameters->partial_name_copy);
+            partial_name_copy[len] = '/';
+            partial_name_copy[len + 1] = '\0';
+        }
+        if (parameters->only_directories && !isa_directory)
+            return FileSpec::eEnumerateDirectoryResultNext;
+        parameters->matches->AppendString(partial_name_copy);
+    }
+
+    return FileSpec::eEnumerateDirectoryResultNext;
+}
+
 static int
 DiskFilesOrDirectories 
 (
@@ -239,60 +304,18 @@
 
     // Okay, containing_part is now the directory we want to open and look for files:
 
-    lldb_utility::CleanUp <DIR *, int> dir_stream (opendir(containing_part), NULL, closedir);
-    if (!dir_stream.is_valid())
-        return matches.GetSize();
-    
-    struct dirent *dirent_buf;
-    
     size_t baselen = end_ptr - partial_name_copy;
     
-    while ((dirent_buf = readdir(dir_stream.get())) != NULL) 
-    {
-        char *name = dirent_buf->d_name;
-        
-        // Omit ".", ".." and any . files if the match string doesn't start with .
-        if (name[0] == '.')
-        {
-            if (name[1] == '\0')
-                continue;
-            else if (name[1] == '.' && name[2] == '\0')
-                continue;
-            else if (remainder[0] != '.')
-                continue;
-        }
-        
-        // If we found a directory, we put a "/" at the end of the name.
-        
-        if (remainder[0] == '\0' || strstr(dirent_buf->d_name, remainder) == name)
-        {
-            if (strlen(name) + baselen >= PATH_MAX)
-                continue;
-                
-            strcpy(end_ptr, name);
-            
-            bool isa_directory = false;
-            if (dirent_buf->d_type & DT_DIR)
-                isa_directory = true;
-            else if (dirent_buf->d_type & DT_LNK)
-            { 
-                struct stat stat_buf;
-                if ((stat(partial_name_copy, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode))
-                    isa_directory = true;
-            }
-            
-            if (isa_directory)
-            {
-                saw_directory = true;
-                size_t len = strlen(partial_name_copy);
-                partial_name_copy[len] = '/';
-                partial_name_copy[len + 1] = '\0';
-            }
-            if (only_directories && !isa_directory)
-                continue;
-            matches.AppendString(partial_name_copy);
-        }
-    }
+    DiskFilesOrDirectoriesBaton parameters;
+    parameters.remainder = remainder;
+    parameters.partial_name_copy = partial_name_copy;
+    parameters.only_directories = only_directories;
+    parameters.saw_directory = &saw_directory;
+    parameters.matches = &matches;
+    parameters.end_ptr = end_ptr;
+    parameters.baselen = baselen;
+
+    FileSpec::EnumerateDirectory(containing_part, true, true, true, DiskFilesOrDirectoriesCallback, &parameters);
     
     return matches.GetSize();
 }
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index 3b8f864..f2946ce 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -71,6 +71,5 @@
   ValueObjectSyntheticFilter.cpp

   ValueObjectVariable.cpp

   VMRange.cpp

-  #Windows.cpp

   )

 

diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index 7f40e65..6ea7a11 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -333,8 +333,8 @@
     return m_read_thread_enabled;
 }
 
-void *
-Communication::ReadThread (void *p)
+lldb::thread_result_t
+Communication::ReadThread (lldb::thread_arg_t p)
 {
     Communication *comm = (Communication *)p;
 
diff --git a/lldb/source/Core/ConnectionFileDescriptor.cpp b/lldb/source/Core/ConnectionFileDescriptor.cpp
index e320bda2..77645d2 100644
--- a/lldb/source/Core/ConnectionFileDescriptor.cpp
+++ b/lldb/source/Core/ConnectionFileDescriptor.cpp
@@ -15,10 +15,15 @@
 #endif
 
 #include "lldb/Core/ConnectionFileDescriptor.h"
+#include "lldb/Host/Config.h"
 
 // C Includes
 #include <errno.h>
 #include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#ifndef LLDB_DISABLE_POSIX
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <netinet/in.h>
@@ -26,10 +31,8 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <termios.h>
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
 #include <unistd.h>
+#endif
 
 // C++ Includes
 // Other libraries and framework includes
@@ -135,7 +138,11 @@
     Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     // Make the command file descriptor here:
     int filedes[2];
+#ifndef LLDB_DISABLE_POSIX
     int result = pipe (filedes);
+#else
+    int result = -1;
+#endif
     if (result != 0)
     {
         if (log)
@@ -223,7 +230,11 @@
                 // get the flags from the file descriptor and making sure it 
                 // isn't a bad fd.
                 errno = 0;
+#ifndef LLDB_DISABLE_POSIX
                 int flags = ::fcntl (m_fd_send, F_GETFL, 0);
+#else
+                int flags = -1;
+#endif
                 if (flags == -1 || errno == EBADF)
                 {
                     if (error_ptr)
@@ -262,6 +273,7 @@
         {
             // file:///PATH
             const char *path = s + strlen("file://");
+#ifndef LLDB_DISABLE_POSIX
             do
             {
                 m_fd_send = m_fd_recv = ::open (path, O_RDWR);
@@ -304,6 +316,9 @@
             }
             m_should_close_fd = true;
             return eConnectionStatusSuccess;
+#else
+            return eConnectionStatusError;
+#endif
         }
         if (error_ptr)
             error_ptr->SetErrorStringWithFormat ("unsupported connection URL: '%s'", s);
@@ -420,7 +435,21 @@
     {
         do
         {
+#ifndef LLDB_DISABLE_POSIX
             bytes_read = ::read (m_fd_recv, dst, dst_len);
+#else
+            switch (m_fd_send_type) {
+            case eFDTypeSocket:
+            case eFDTypeSocketUDP:
+                bytes_read = ::recv (m_fd_recv, (char*)dst, dst_len, 0);
+                break;
+            default:
+                bytes_read = -1;
+                break;
+
+            }
+
+#endif
         } while (bytes_read < 0 && errno == EINTR);
     }
 
@@ -523,17 +552,18 @@
 
     switch (m_fd_send_type)
     {
+#ifndef LLDB_DISABLE_POSIX
         case eFDTypeFile:       // Other FD requireing read/write
             do
             {
                 bytes_sent = ::write (m_fd_send, src, src_len);
             } while (bytes_sent < 0 && errno == EINTR);
             break;
-            
+#endif
         case eFDTypeSocket:     // Socket requiring send/recv
             do
             {
-                bytes_sent = ::send (m_fd_send, src, src_len, 0);
+                bytes_sent = ::send (m_fd_send, (char*)src, src_len, 0);
             } while (bytes_sent < 0 && errno == EINTR);
             break;
             
@@ -542,7 +572,7 @@
             do
             {
                 bytes_sent = ::sendto (m_fd_send, 
-                                       src, 
+                                       (char*)src, 
                                        src_len, 
                                        0, 
                                        m_udp_send_sockaddr, 
@@ -1115,6 +1145,7 @@
 ConnectionStatus
 ConnectionFileDescriptor::NamedSocketAccept (const char *socket_name, Error *error_ptr)
 {
+#ifndef LLDB_DISABLE_POSIX
     ConnectionStatus result = eConnectionStatusError;
     struct sockaddr_un saddr_un;
 
@@ -1159,11 +1190,15 @@
     // We are done with the listen port
     Close (listen_socket, NULL);
     return result;
+#else
+    return eConnectionStatusError;
+#endif
 }
 
 ConnectionStatus
 ConnectionFileDescriptor::NamedSocketConnect (const char *socket_name, Error *error_ptr)
 {
+#ifndef LLDB_DISABLE_POSIX
     Disconnect (NULL);
     m_fd_send_type = m_fd_recv_type = eFDTypeSocket;
 
@@ -1194,6 +1229,9 @@
     if (error_ptr)
         error_ptr->Clear();
     return eConnectionStatusSuccess;
+#else
+    return eConnectionStatusError;
+#endif
 }
 
 ConnectionStatus
@@ -1430,18 +1468,18 @@
     return eConnectionStatusSuccess;
 }
 
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(_WIN32)
 typedef const char * set_socket_option_arg_type;
 typedef char * get_socket_option_arg_type;
-#else // #if defined(__MINGW32__) || defined(__MINGW64__)
+#else // #if defined(_WIN32)
 typedef const void * set_socket_option_arg_type;
 typedef void * get_socket_option_arg_type;
-#endif // #if defined(__MINGW32__) || defined(__MINGW64__)
+#endif // #if defined(_WIN32)
 
 int
 ConnectionFileDescriptor::GetSocketOption(int fd, int level, int option_name, int &option_value)
 {
-    get_socket_option_arg_type option_value_p = static_cast<get_socket_option_arg_type>(&option_value);
+    get_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
     socklen_t option_value_size = sizeof(int);
 	return ::getsockopt(fd, level, option_name, option_value_p, &option_value_size);
 }
@@ -1449,7 +1487,7 @@
 int
 ConnectionFileDescriptor::SetSocketOption(int fd, int level, int option_name, int option_value)
 {
-    set_socket_option_arg_type option_value_p = static_cast<get_socket_option_arg_type>(&option_value);
+    set_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
 	return ::setsockopt(fd, level, option_name, option_value_p, sizeof(option_value));
 }
 
@@ -1487,7 +1525,7 @@
                 timeout.tv_sec = timeout_usec / TimeValue::MicroSecPerSec;
                 timeout.tv_usec = timeout_usec % TimeValue::MicroSecPerSec;
             }
-            if (::setsockopt (m_fd_recv, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) == 0)
+            if (::setsockopt (m_fd_recv, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<get_socket_option_arg_type>(&timeout), sizeof(timeout)) == 0)
             {
                 m_socket_timeout_usec = timeout_usec;
                 return true;
diff --git a/lldb/source/Core/ConnectionSharedMemory.cpp b/lldb/source/Core/ConnectionSharedMemory.cpp
index 625f17a..cd708c4 100644
--- a/lldb/source/Core/ConnectionSharedMemory.cpp
+++ b/lldb/source/Core/ConnectionSharedMemory.cpp
@@ -11,12 +11,15 @@
 
 // C Includes
 #include <errno.h>
-#include <pthread.h>
 #include <stdlib.h>
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#else
 #include <sys/file.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#endif
 
 // C++ Includes
 // Other libraries and framework includes
@@ -73,7 +76,12 @@
     m_mmap.Clear();
     if (!m_name.empty())
     {
+#ifdef _WIN32
+        close(m_fd);
+        m_fd = -1;
+#else
         shm_unlink (m_name.c_str());
+#endif
         m_name.clear();
     }
     return eConnectionStatusSuccess;
@@ -114,6 +122,16 @@
     }
     
     m_name.assign (name);
+
+#ifdef _WIN32
+    HANDLE handle;
+    if (create)
+        handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, (DWORD)(size >> 32), (DWORD)(size), name);
+    else
+        handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name);
+
+    m_fd = _open_osfhandle((intptr_t)handle, 0);
+#else
     int oflag = O_RDWR;
     if (create)
         oflag |= O_CREAT;
@@ -121,6 +139,7 @@
 
     if (create)
         ::ftruncate (m_fd, size);
+#endif
 
     if (m_mmap.MemoryMapFromFileDescriptor(m_fd, 0, size, true, false) == size)
         return eConnectionStatusSuccess;
diff --git a/lldb/source/Core/DataBufferMemoryMap.cpp b/lldb/source/Core/DataBufferMemoryMap.cpp
index a4382a0..374834a 100644
--- a/lldb/source/Core/DataBufferMemoryMap.cpp
+++ b/lldb/source/Core/DataBufferMemoryMap.cpp
@@ -12,7 +12,11 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <sys/stat.h>
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#else
 #include <sys/mman.h>
+#endif
 
 #include "lldb/Core/DataBufferMemoryMap.h"
 #include "lldb/Core/Error.h"
@@ -86,7 +90,11 @@
         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
         if (log)
             log->Printf("DataBufferMemoryMap::Clear() m_mmap_addr = %p, m_mmap_size = %zu", m_mmap_addr, m_mmap_size);
+#ifdef _WIN32
+        UnmapViewOfFile(m_mmap_addr);
+#else
         ::munmap((void *)m_mmap_addr, m_mmap_size);
+#endif
         m_mmap_addr = NULL;
         m_mmap_size = 0;
         m_data = NULL;
@@ -166,13 +174,49 @@
         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP|LIBLLDB_LOG_VERBOSE));
         if (log)
         {
+#ifdef _WIN32
+            log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%p, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)",
+#else
             log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%i, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)",
+#endif
                         fd,
                         offset,
                         length,
                         writeable,
                         fd_is_file);
         }
+#ifdef _WIN32
+        HANDLE handle = (HANDLE)_get_osfhandle(fd);
+        DWORD file_size_low, file_size_high;
+        file_size_low = GetFileSize(handle, &file_size_high);
+        const size_t file_size = (file_size_high << 32) | file_size_low;
+        const size_t max_bytes_available = file_size - offset;
+        if (length == SIZE_MAX)
+        {
+            length = max_bytes_available;
+        }
+        else if (length > max_bytes_available)
+        {
+            // Cap the length if too much data was requested
+            length = max_bytes_available;
+        }
+
+        if (length > 0)
+        {
+            HANDLE fileMapping = CreateFileMapping(handle, NULL, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, NULL);
+            if (fileMapping != NULL)
+            {
+                m_mmap_addr = (uint8_t*)MapViewOfFile(fileMapping, writeable ? FILE_MAP_ALL_ACCESS : FILE_MAP_READ, (DWORD)(offset >> 32), (DWORD)(offset), length);
+                if (m_mmap_addr != NULL)
+                {
+                    m_mmap_size = length;
+                    m_data = m_mmap_addr;
+                    m_size = length;
+                }
+                CloseHandle(fileMapping);
+            }
+        }
+#else
         struct stat stat;
         if (::fstat(fd, &stat) == 0)
         {
@@ -253,6 +297,7 @@
                 }
             }
         }
+#endif
     }
     return GetByteSize ();
 }
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index d73ab15..9200fe1 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -10,7 +10,6 @@
 #include "lldb/lldb-python.h"
 
 // C Includes
-#include <pthread.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
diff --git a/lldb/source/Core/Timer.cpp b/lldb/source/Core/Timer.cpp
index b1416bd..bbd9900 100644
--- a/lldb/source/Core/Timer.cpp
+++ b/lldb/source/Core/Timer.cpp
@@ -14,6 +14,7 @@
 
 #include "lldb/Core/Stream.h"
 #include "lldb/Host/Mutex.h"
+#include "lldb/Host/Host.h"
 
 #include <stdio.h>
 
@@ -26,7 +27,7 @@
 FILE * Timer::g_file = NULL;
 typedef std::vector<Timer *> TimerStack;
 typedef std::map<const char *, uint64_t> TimerCategoryMap;
-static pthread_key_t g_key;
+static lldb::thread_key_t g_key;
 
 static Mutex &
 GetCategoryMutex()
@@ -46,11 +47,11 @@
 static TimerStack *
 GetTimerStackForCurrentThread ()
 {
-    void *timer_stack = ::pthread_getspecific (g_key);
+    void *timer_stack = Host::ThreadLocalStorageGet(g_key);
     if (timer_stack == NULL)
     {
-        ::pthread_setspecific (g_key, new TimerStack);
-        timer_stack = ::pthread_getspecific (g_key);
+        Host::ThreadLocalStorageSet(g_key, new TimerStack);
+        timer_stack = Host::ThreadLocalStorageGet(g_key);
     }
     return (TimerStack *)timer_stack;
 }
@@ -71,8 +72,7 @@
 Timer::Initialize ()
 {
     Timer::g_file = stdout;
-    ::pthread_key_create (&g_key, ThreadSpecificCleanup);
-
+    g_key = Host::ThreadLocalStorageCreate(ThreadSpecificCleanup);
 }
 
 Timer::Timer (const char *category, const char *format, ...) :
diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp
index fba9217..43a935c 100644
--- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp
+++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp
@@ -1237,6 +1237,7 @@
     static time_t epoch = 0;
     if (!epoch)
     {
+#ifndef _WIN32
         tzset();
         tm tm_epoch;
         tm_epoch.tm_sec = 0;
@@ -1249,6 +1250,7 @@
         tm_epoch.tm_gmtoff = 0;
         tm_epoch.tm_zone = NULL;
         epoch = timegm(&tm_epoch);
+#endif
     }
     return epoch;
 }
diff --git a/lldb/source/Expression/IRMemoryMap.cpp b/lldb/source/Expression/IRMemoryMap.cpp
index ef362ba..53f74ae 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -74,15 +74,15 @@
         {
         case 4:
             {
-                uint32_t random_data = random();
+                uint32_t random_data = rand();
                 candidate = random_data;
                 candidate &= ~0xfffull;
                 break;
             }
         case 8:
             {
-                uint32_t random_low = random();
-                uint32_t random_high = random();
+                uint32_t random_low = rand();
+                uint32_t random_high = rand();
                 candidate = random_high;
                 candidate <<= 32ull;
                 candidate |= random_low;
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index d990f3f..6c92a6c 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -6,6 +6,6 @@
   add_subdirectory(linux)

 elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")

   add_subdirectory(freebsd)

-#elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")

-#  add_subdirectory(windows)

+elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")

+  add_subdirectory(windows)

 endif()

diff --git a/lldb/source/Host/Makefile b/lldb/source/Host/Makefile
index 72155ce..0a4e8ac 100644
--- a/lldb/source/Host/Makefile
+++ b/lldb/source/Host/Makefile
@@ -25,4 +25,8 @@
 DIRS += freebsd
 endif
 
+ifeq ($(HOST_OS),MingW)
+DIRS += windows
+endif
+
 include $(LLDB_LEVEL)/Makefile
diff --git a/lldb/source/Host/common/CMakeLists.txt b/lldb/source/Host/common/CMakeLists.txt
index cad9c07..d079d4a 100644
--- a/lldb/source/Host/common/CMakeLists.txt
+++ b/lldb/source/Host/common/CMakeLists.txt
@@ -7,6 +7,7 @@
   FileSpec.cpp

   Host.cpp

   Mutex.cpp

+  ProcessRunLock.cpp

   SocketAddress.cpp

   Symbols.cpp

   Terminal.cpp

diff --git a/lldb/source/Host/common/Condition.cpp b/lldb/source/Host/common/Condition.cpp
index daa729c..7bc6b65 100644
--- a/lldb/source/Host/common/Condition.cpp
+++ b/lldb/source/Host/common/Condition.cpp
@@ -15,6 +15,8 @@
 
 using namespace lldb_private;
 
+#ifndef _WIN32
+
 //----------------------------------------------------------------------
 // Default constructor
 //
@@ -47,15 +49,6 @@
 }
 
 //----------------------------------------------------------------------
-// Get accessor to the pthread condition object
-//----------------------------------------------------------------------
-pthread_cond_t *
-Condition::GetCondition ()
-{
-    return &m_condition;
-}
-
-//----------------------------------------------------------------------
 // Unblocks one thread waiting for the condition variable
 //----------------------------------------------------------------------
 int
@@ -64,6 +57,11 @@
     return ::pthread_cond_signal (&m_condition);
 }
 
+/* convert struct timeval to ms(milliseconds) */
+static unsigned long int tv2ms(struct timeval a) {
+    return ((a.tv_sec * 1000) + (a.tv_usec / 1000));
+}
+
 //----------------------------------------------------------------------
 // The Wait() function atomically blocks the current thread
 // waiting on the owned condition variable, and unblocks the mutex
@@ -100,7 +98,16 @@
             *timed_out = false;
     }
 
-
     return err;
 }
 
+#endif
+
+//----------------------------------------------------------------------
+// Get accessor to the pthread condition object
+//----------------------------------------------------------------------
+lldb::condition_t *
+Condition::GetCondition()
+{
+    return &m_condition;
+}
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index c0d3c29..343312f 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -16,6 +16,10 @@
 #include <stdarg.h>
 #include <sys/stat.h>
 
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#endif
+
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Host/Config.h"
@@ -167,7 +171,11 @@
 
     if (rhs.DescriptorIsValid())
     {
+#ifdef _WIN32
+        m_descriptor = ::_dup(rhs.GetDescriptor());
+#else
         m_descriptor = ::fcntl(rhs.GetDescriptor(), F_DUPFD);
+#endif
         if (!DescriptorIsValid())
             error.SetErrorToErrno();
         else
@@ -217,8 +225,12 @@
         oflag |= O_RDONLY;
     }
     
+#ifndef _WIN32
     if (options & eOpenOptionNonBlocking)
         oflag |= O_NONBLOCK;
+#else
+    oflag |= O_BINARY;
+#endif
 
     mode_t mode = 0;
     if (oflag & O_CREAT)
@@ -226,12 +238,14 @@
         if (permissions & ePermissionsUserRead)     mode |= S_IRUSR;
         if (permissions & ePermissionsUserWrite)    mode |= S_IWUSR;
         if (permissions & ePermissionsUserExecute)  mode |= S_IXUSR;
+#ifndef _WIN32
         if (permissions & ePermissionsGroupRead)    mode |= S_IRGRP;
         if (permissions & ePermissionsGroupWrite)   mode |= S_IWGRP;
         if (permissions & ePermissionsGroupExecute) mode |= S_IXGRP;
         if (permissions & ePermissionsWorldRead)    mode |= S_IROTH;
         if (permissions & ePermissionsWorldWrite)   mode |= S_IWOTH;
         if (permissions & ePermissionsWorldExecute) mode |= S_IXOTH;
+#endif
     }
 
     do
@@ -452,6 +466,11 @@
     Error error;
     if (DescriptorIsValid())
     {
+#ifdef _WIN32
+        int err = FlushFileBuffers((HANDLE)_get_osfhandle(m_descriptor));
+        if (err == 0)
+            error.SetErrorToGenericError();
+#else
         int err = 0;
         do
         {
@@ -460,6 +479,7 @@
         
         if (err == -1)
             error.SetErrorToErrno();
+#endif
     }
     else 
     {
@@ -559,6 +579,7 @@
 Error
 File::Read (void *buf, size_t &num_bytes, off_t &offset)
 {
+#ifndef _WIN32
     Error error;
     int fd = GetDescriptor();
     if (fd != kInvalidDescriptor)
@@ -586,6 +607,14 @@
         error.SetErrorString("invalid file handle");
     }
     return error;
+#else
+    long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+    SeekFromStart(offset);
+    Error error = Read(buf, num_bytes);
+    if (!error.Fail())
+        SeekFromStart(cur);
+    return error;
+#endif
 }
 
 Error
@@ -648,6 +677,7 @@
     int fd = GetDescriptor();
     if (fd != kInvalidDescriptor)
     {
+#ifndef _WIN32
         ssize_t bytes_written = -1;
         do
         {
@@ -664,6 +694,17 @@
             offset += bytes_written;
             num_bytes = bytes_written;
         }
+#else
+        long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+        error = Write(buf, num_bytes);
+        long after = ::lseek(m_descriptor, 0, SEEK_CUR);
+
+        if (!error.Fail())
+            SeekFromStart(cur);
+
+        ssize_t bytes_written = after - cur;
+        offset = after;
+#endif
     }
     else 
     {
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp
index 08d626e..0bf7681 100644
--- a/lldb/source/Host/common/FileSpec.cpp
+++ b/lldb/source/Host/common/FileSpec.cpp
@@ -8,7 +8,11 @@
 //===----------------------------------------------------------------------===//
 
 
+#ifndef _WIN32
 #include <dirent.h>
+#else
+#include "lldb/Host/windows/windows.h"
+#endif
 #include <fcntl.h>
 #include <libgen.h>
 #include <sys/stat.h>
@@ -616,10 +620,12 @@
         switch (file_type)
         {
         case S_IFDIR:   return eFileTypeDirectory;
-        case S_IFIFO:   return eFileTypePipe;
         case S_IFREG:   return eFileTypeRegular;
+#ifndef _WIN32
+        case S_IFIFO:   return eFileTypePipe;
         case S_IFSOCK:  return eFileTypeSocket;
         case S_IFLNK:   return eFileTypeSymbolicLink;
+#endif
         default:
             break;
         }
@@ -907,7 +913,94 @@
 {
     if (dir_path && dir_path[0])
     {
-        lldb_utility::CleanUp <DIR *, int> dir_path_dir (opendir(dir_path), NULL, closedir);
+#if _WIN32
+        char szDir[MAX_PATH];
+        strcpy_s(szDir, MAX_PATH, dir_path);
+        strcat_s(szDir, MAX_PATH, "\\*");
+
+        WIN32_FIND_DATA ffd;
+        HANDLE hFind = FindFirstFile(szDir, &ffd);
+
+        if (hFind == INVALID_HANDLE_VALUE)
+        {
+            return eEnumerateDirectoryResultNext;
+        }
+
+        do
+        {
+            bool call_callback = false;
+            FileSpec::FileType file_type = eFileTypeUnknown;
+            if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+            {
+                size_t len = strlen(ffd.cFileName);
+
+                if (len == 1 && ffd.cFileName[0] == '.')
+                    continue;
+
+                if (len == 2 && ffd.cFileName[0] == '.' && ffd.cFileName[1] == '.')
+                    continue;
+
+                file_type = eFileTypeDirectory;
+                call_callback = find_directories;
+            }
+            else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE)
+            {
+                file_type = eFileTypeOther;
+                call_callback = find_other;
+            }
+            else
+            {
+                file_type = eFileTypeRegular;
+                call_callback = find_files;
+            }
+            if (call_callback)
+            {
+                char child_path[MAX_PATH];
+                const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s\\%s", dir_path, ffd.cFileName);
+                if (child_path_len < (int)(sizeof(child_path) - 1))
+                {
+                    // Don't resolve the file type or path
+                    FileSpec child_path_spec (child_path, false);
+
+                    EnumerateDirectoryResult result = callback (callback_baton, file_type, child_path_spec);
+
+                    switch (result)
+                    {
+                    case eEnumerateDirectoryResultNext:
+                        // Enumerate next entry in the current directory. We just
+                        // exit this switch and will continue enumerating the
+                        // current directory as we currently are...
+                        break;
+
+                    case eEnumerateDirectoryResultEnter: // Recurse into the current entry if it is a directory or symlink, or next if not
+                        if (FileSpec::EnumerateDirectory(child_path,
+                            find_directories,
+                            find_files,
+                            find_other,
+                            callback,
+                            callback_baton) == eEnumerateDirectoryResultQuit)
+                        {
+                            // The subdirectory returned Quit, which means to 
+                            // stop all directory enumerations at all levels.
+                            return eEnumerateDirectoryResultQuit;
+                        }
+                        break;
+
+                    case eEnumerateDirectoryResultExit:  // Exit from the current directory at the current level.
+                        // Exit from this directory level and tell parent to 
+                        // keep enumerating.
+                        return eEnumerateDirectoryResultNext;
+
+                    case eEnumerateDirectoryResultQuit:  // Stop directory enumerations at any level
+                        return eEnumerateDirectoryResultQuit;
+                    }
+                }
+            }
+        } while (FindNextFile(hFind, &ffd) != 0);
+
+        FindClose(hFind);
+#else
+        lldb_utility::CleanUp <DIR *, int> dir_path_dir(opendir(dir_path), NULL, closedir);
         if (dir_path_dir.is_valid())
         {
             long path_max = fpathconf (dirfd (dir_path_dir.get()), _PC_NAME_MAX);
@@ -1006,6 +1099,7 @@
                 free (buf);
             }
         }
+#endif
     }
     // By default when exiting a directory, we tell the parent enumeration
     // to continue enumerating.
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index a7bad00..826069b 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -10,15 +10,21 @@
 #include "lldb/lldb-python.h"
 
 // C includes
-#include <dlfcn.h>
 #include <errno.h>
-#include <grp.h>
 #include <limits.h>
+#include <sys/types.h>
+#include <unistd.h>
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include <winsock2.h>
+#include <WS2tcpip.h>
+#else
+#include <dlfcn.h>
+#include <grp.h>
 #include <netdb.h>
 #include <pwd.h>
-#include <sys/types.h>
 #include <sys/sysctl.h>
-#include <unistd.h>
+#endif
 
 #if defined (__APPLE__)
 
@@ -66,7 +72,7 @@
 using namespace lldb_private;
 
 
-#if !defined (__APPLE__)
+#if !defined (__APPLE__) && !defined (_WIN32)
 struct MonitorInfo
 {
     lldb::pid_t pid;                            // The process ID to monitor
@@ -75,7 +81,7 @@
     bool monitor_signals;                       // If true, call the callback when "pid" gets signaled.
 };
 
-static void *
+static thread_result_t
 MonitorChildProcessThreadFunction (void *arg);
 
 lldb::thread_t
@@ -133,7 +139,7 @@
     int m_old_state;    // Save the old cancelability state.
 };
 
-static void *
+static thread_result_t
 MonitorChildProcessThreadFunction (void *arg)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
@@ -259,6 +265,9 @@
     return NULL;
 }
 
+#endif // #if !defined (__APPLE__) && !defined (_WIN32)
+
+#if !defined (__APPLE__)
 
 void
 Host::SystemLog (SystemLogType type, const char *format, va_list args)
@@ -266,7 +275,7 @@
     vfprintf (stderr, format, args);
 }
 
-#endif // #if !defined (__APPLE__)
+#endif
 
 void
 Host::SystemLog (SystemLogType type, const char *format, ...)
@@ -277,12 +286,6 @@
     va_end (args);
 }
 
-size_t
-Host::GetPageSize()
-{
-    return ::getpagesize();
-}
-
 const ArchSpec &
 Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
 {
@@ -445,6 +448,8 @@
     return ::getpid();
 }
 
+#ifndef _WIN32
+
 lldb::tid_t
 Host::GetCurrentThreadID()
 {
@@ -521,6 +526,8 @@
     return NULL;
 }
 
+#endif
+
 void
 Host::WillTerminate ()
 {
@@ -563,6 +570,9 @@
 };
 
 static thread_result_t
+#ifdef _WIN32
+__stdcall
+#endif
 ThreadCreateTrampoline (thread_arg_t arg)
 {
     HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg;
@@ -592,7 +602,12 @@
     // Host::ThreadCreateTrampoline will delete this pointer for us.
     HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg);
     
+#ifdef _WIN32
+    thread = ::_beginthreadex(0, 0, ThreadCreateTrampoline, info_ptr, 0, NULL);
+    int err = thread <= 0 ? GetLastError() : 0;
+#else
     int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr);
+#endif
     if (err == 0)
     {
         if (error)
@@ -606,6 +621,8 @@
     return LLDB_INVALID_HOST_THREAD;
 }
 
+#ifndef _WIN32
+
 bool
 Host::ThreadCancel (lldb::thread_t thread, Error *error)
 {
@@ -633,6 +650,26 @@
     return err == 0;
 }
 
+lldb::thread_key_t
+Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback)
+{
+    pthread_key_t key;
+    ::pthread_key_create (&key, callback);
+    return key;
+}
+
+void*
+Host::ThreadLocalStorageGet(lldb::thread_key_t key)
+{
+    return ::pthread_getspecific (key);
+}
+
+void
+Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value)
+{
+   ::pthread_setspecific (key, value);
+}
+
 bool
 Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
 {
@@ -726,6 +763,8 @@
     return false;
 }
 
+#endif
+
 FileSpec
 Host::GetProgramFileSpec ()
 {
@@ -771,19 +810,6 @@
     return g_program_filespec;
 }
 
-FileSpec
-Host::GetModuleFileSpecForHostAddress (const void *host_addr)
-{
-    FileSpec module_filespec;
-    Dl_info info;
-    if (::dladdr (host_addr, &info))
-    {
-        if (info.dli_fname)
-            module_filespec.SetFile(info.dli_fname, true);
-    }
-    return module_filespec;
-}
-
 #if !defined (__APPLE__) // see Host.mm
 
 bool
@@ -800,6 +826,8 @@
 }
 #endif
 
+#ifndef _WIN32
+
 // Opaque info that tracks a dynamic library that was loaded
 struct DynamicLibraryInfo
 {
@@ -924,6 +952,21 @@
     return NULL;
 }
 
+FileSpec
+Host::GetModuleFileSpecForHostAddress (const void *host_addr)
+{
+    FileSpec module_filespec;
+    Dl_info info;
+    if (::dladdr (host_addr, &info))
+    {
+        if (info.dli_fname)
+            module_filespec.SetFile(info.dli_fname, true);
+    }
+    return module_filespec;
+}
+
+#endif
+
 bool
 Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
 {
@@ -1175,6 +1218,8 @@
     return false;
 }
 
+#ifndef _WIN32
+
 const char *
 Host::GetUserName (uint32_t uid, std::string &user_name)
 {
@@ -1234,22 +1279,6 @@
     return NULL;
 }
 
-#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) // see macosx/Host.mm
-bool
-Host::GetOSBuildString (std::string &s)
-{
-    s.clear();
-    return false;
-}
-
-bool
-Host::GetOSKernelDescription (std::string &s)
-{
-    s.clear();
-    return false;
-}
-#endif
-
 uint32_t
 Host::GetUserID ()
 {
@@ -1274,6 +1303,24 @@
     return getegid();
 }
 
+#endif
+
+#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) // see macosx/Host.mm
+bool
+Host::GetOSBuildString (std::string &s)
+{
+    s.clear();
+    return false;
+}
+
+bool
+Host::GetOSKernelDescription (std::string &s)
+{
+    s.clear();
+    return false;
+}
+#endif
+
 #if !defined (__APPLE__) && !defined(__linux__)
 uint32_t
 Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
@@ -1441,7 +1488,7 @@
             error.SetErrorString("timed out waiting for shell command to complete");
             
             // Kill the process since it didn't complete withint the timeout specified
-            ::kill (pid, SIGKILL);
+            Kill (pid, SIGKILL);
             // Wait for the monitor callback to get the message
             timeout_time = TimeValue::Now();
             timeout_time.OffsetWithSeconds(1);
@@ -1490,6 +1537,13 @@
     return error;
 }
 
+#ifndef _WIN32
+
+size_t
+Host::GetPageSize()
+{
+    return ::getpagesize();
+}
 
 uint32_t
 Host::GetNumberCPUS ()
@@ -1500,14 +1554,7 @@
 #if defined(__APPLE__) or defined (__linux__) or defined (__FreeBSD__) or defined (__FreeBSD_kernel__)
 
         g_num_cores = ::sysconf(_SC_NPROCESSORS_ONLN);
-        
-#elif defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-        
-        // Header file for this might need to be included at the top of this file
-        SYSTEM_INFO system_info;
-        ::GetSystemInfo (&system_info);
-        g_num_cores = system_info.dwNumberOfProcessors;
-        
+
 #else
         
         // Assume POSIX support if a host specific case has not been supplied above
@@ -1540,7 +1587,13 @@
     return g_num_cores;
 }
 
+void
+Host::Kill(lldb::pid_t pid, int signo)
+{
+    ::kill(pid, signo);
+}
 
+#endif
 
 #if !defined (__APPLE__)
 bool
diff --git a/lldb/source/Host/common/Mutex.cpp b/lldb/source/Host/common/Mutex.cpp
index 39cd8c6..3733100 100644
--- a/lldb/source/Host/common/Mutex.cpp
+++ b/lldb/source/Host/common/Mutex.cpp
@@ -10,6 +10,9 @@
 #include "lldb/Host/Mutex.h"
 #include "lldb/Host/Host.h"
 
+#ifndef _WIN32
+#include <pthread.h>
+#endif
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -177,6 +180,8 @@
     return m_mutex_ptr != NULL;
 }
 
+#ifndef _WIN32
+
 //----------------------------------------------------------------------
 // Default constructor.
 //
@@ -253,15 +258,6 @@
 }
 
 //----------------------------------------------------------------------
-// Mutex get accessor.
-//----------------------------------------------------------------------
-pthread_mutex_t *
-Mutex::GetMutex()
-{
-    return &m_mutex;
-}
-
-//----------------------------------------------------------------------
 // Locks the mutex owned by this object, if the mutex is already
 // locked, the calling thread will block until the mutex becomes
 // available.
@@ -341,6 +337,17 @@
     return err;
 }
 
+#endif
+
+//----------------------------------------------------------------------
+// Mutex get accessor.
+//----------------------------------------------------------------------
+lldb::mutex_t *
+Mutex::GetMutex()
+{
+    return &m_mutex;
+}
+
 #ifdef LLDB_CONFIGURATION_DEBUG
 int
 TrackingMutex::Unlock ()
diff --git a/lldb/source/Host/common/ProcessRunLock.cpp b/lldb/source/Host/common/ProcessRunLock.cpp
new file mode 100644
index 0000000..669a96d
--- /dev/null
+++ b/lldb/source/Host/common/ProcessRunLock.cpp
@@ -0,0 +1,71 @@
+#ifndef _WIN32
+
+#include "lldb/Host/ProcessRunLock.h"
+
+namespace lldb_private {
+
+    ProcessRunLock::ProcessRunLock()
+        : m_running(false)
+    {
+        int err = ::pthread_rwlock_init(&m_rwlock, NULL); (void) err;
+        //#if LLDB_CONFIGURATION_DEBUG
+        //        assert(err == 0);
+        //#endif
+    }
+
+    ProcessRunLock::~ProcessRunLock()
+    {
+        int err = ::pthread_rwlock_destroy(&m_rwlock); (void) err;
+        //#if LLDB_CONFIGURATION_DEBUG
+        //        assert(err == 0);
+        //#endif
+    }
+
+    bool ProcessRunLock::ReadTryLock()
+    {
+        ::pthread_rwlock_rdlock(&m_rwlock);
+        if (m_running == false)
+        {
+            return true;
+        }
+        ::pthread_rwlock_unlock(&m_rwlock);
+        return false;
+    }
+
+    bool ProcessRunLock::ReadUnlock()
+    {
+        return ::pthread_rwlock_unlock(&m_rwlock) == 0;
+    }
+
+    bool ProcessRunLock::SetRunning()
+    {
+        ::pthread_rwlock_wrlock(&m_rwlock);
+        m_running = true;
+        ::pthread_rwlock_unlock(&m_rwlock);
+        return true;
+    }
+
+    bool ProcessRunLock::TrySetRunning()
+    {
+        bool r;
+
+        if (::pthread_rwlock_trywrlock(&m_rwlock) == 0)
+        {
+            r = !m_running;
+            m_running = true;
+            ::pthread_rwlock_unlock(&m_rwlock);
+            return r;
+        }
+        return false;
+    }
+
+    bool ProcessRunLock::SetStopped()
+    {
+        ::pthread_rwlock_wrlock(&m_rwlock);
+        m_running = false;
+        ::pthread_rwlock_unlock(&m_rwlock);
+        return true;
+    }
+}
+
+#endif
diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp
index 89d21cf..08a5455 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -8,7 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Host/Terminal.h"
-#include "lldb/Host/Config.h"
 
 #include <fcntl.h>
 #include <unistd.h>
@@ -24,6 +23,7 @@
 bool
 Terminal::IsATerminal () const
 {
+
     return m_fd >= 0 && ::isatty (m_fd);
 }
     
@@ -108,7 +108,9 @@
 TerminalState::TerminalState() :
     m_tty(),
     m_tflags(-1),
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
     m_termios_ap(),
+#endif
     m_process_group(-1)
 {
 }
@@ -125,7 +127,9 @@
 {
     m_tty.Clear();
     m_tflags = -1;
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
     m_termios_ap.reset();
+#endif
     m_process_group = -1;
 }
 
@@ -140,7 +144,9 @@
     m_tty.SetFileDescriptor(fd);
     if (m_tty.IsATerminal())
     {
+#ifndef LLDB_DISABLE_POSIX
         m_tflags = ::fcntl (fd, F_GETFL, 0);
+#endif
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
         if (m_termios_ap.get() == NULL)
             m_termios_ap.reset (new struct termios);
@@ -148,16 +154,20 @@
         if (err != 0)
             m_termios_ap.reset();
 #endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#ifndef LLDB_DISABLE_POSIX
         if (save_process_group)
             m_process_group = ::tcgetpgrp (0);
         else
             m_process_group = -1;
+#endif
     }
     else
     {
         m_tty.Clear();
         m_tflags = -1;
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
         m_termios_ap.reset();
+#endif
         m_process_group = -1;
     }
     return IsValid();
@@ -173,14 +183,17 @@
     if (IsValid())
     {
         const int fd = m_tty.GetFileDescriptor();
+#ifndef LLDB_DISABLE_POSIX
         if (TFlagsIsValid())
             fcntl (fd, F_SETFL, m_tflags);
+#endif
 
 #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
         if (TTYStateIsValid())
             tcsetattr (fd, TCSANOW, m_termios_ap.get());
 #endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
 
+#ifndef LLDB_DISABLE_POSIX
         if (ProcessGroupIsValid())
         {
             // Save the original signal handler.
@@ -191,6 +204,7 @@
             // Restore the original signal handler.
             signal (SIGTTOU, saved_sigttou_callback);
         }
+#endif
         return true;
     }
     return false;
@@ -224,7 +238,11 @@
 bool
 TerminalState::TTYStateIsValid() const
 {
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
     return m_termios_ap.get() != 0;
+#else
+    return false;
+#endif
 }
 
 //----------------------------------------------------------------------
diff --git a/lldb/source/Host/common/TimeValue.cpp b/lldb/source/Host/common/TimeValue.cpp
index 303ac94..0858255 100644
--- a/lldb/source/Host/common/TimeValue.cpp
+++ b/lldb/source/Host/common/TimeValue.cpp
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Host/TimeValue.h"
+#include "lldb/Host/Config.h"
 
 // C Includes
 #include <stddef.h>
@@ -148,6 +149,7 @@
     if (s == NULL)
         return;
 
+#ifndef LLDB_DISABLE_POSIX
     char time_buf[32];
     time_t time = GetAsSecondsSinceJan1_1970();
     char *time_cstr = ::ctime_r(&time, time_buf);
@@ -163,6 +165,7 @@
     }
     else if (width > 0)
         s->Printf("%-*s", width, "");
+#endif
 }
 
 bool
diff --git a/lldb/source/Host/windows/CMakeLists.txt b/lldb/source/Host/windows/CMakeLists.txt
new file mode 100644
index 0000000..0ffe734
--- /dev/null
+++ b/lldb/source/Host/windows/CMakeLists.txt
@@ -0,0 +1,9 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbHostWindows
+  Host.cpp
+  ProcessRunLock.cpp
+  Mutex.cpp
+  Condition.cpp
+  Windows.cpp
+  )
diff --git a/lldb/source/Host/windows/Condition.cpp b/lldb/source/Host/windows/Condition.cpp
new file mode 100644
index 0000000..efece6d
--- /dev/null
+++ b/lldb/source/Host/windows/Condition.cpp
@@ -0,0 +1,95 @@
+//===-- Condition.cpp -------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <errno.h>
+
+#include "lldb/Host/Condition.h"
+#include "lldb/Host/TimeValue.h"
+
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// Default constructor
+//
+// The default constructor will initialize a new pthread condition
+// and maintain the condition in the object state.
+//----------------------------------------------------------------------
+Condition::Condition () :
+    m_condition()
+{
+    InitializeConditionVariable(&m_condition);
+}
+
+//----------------------------------------------------------------------
+// Destructor
+//
+// Destroys the pthread condition that the object owns.
+//----------------------------------------------------------------------
+Condition::~Condition ()
+{
+}
+
+//----------------------------------------------------------------------
+// Unblock all threads waiting for a condition variable
+//----------------------------------------------------------------------
+int
+Condition::Broadcast ()
+{
+    WakeAllConditionVariable(&m_condition);
+    return 0;
+}
+
+//----------------------------------------------------------------------
+// Unblocks one thread waiting for the condition variable
+//----------------------------------------------------------------------
+int
+Condition::Signal ()
+{
+    WakeConditionVariable(&m_condition);
+    return 0;
+}
+
+//----------------------------------------------------------------------
+// The Wait() function atomically blocks the current thread
+// waiting on the owned condition variable, and unblocks the mutex
+// specified by "mutex".  The waiting thread unblocks only after
+// another thread calls Signal(), or Broadcast() with the same
+// condition variable, or if "abstime" is valid (non-NULL) this
+// function will return when the system time reaches the time
+// specified in "abstime". If "abstime" is NULL this function will
+// wait for an infinite amount of time for the condition variable
+// to be signaled or broadcasted.
+//
+// The current thread re-acquires the lock on "mutex".
+//----------------------------------------------------------------------
+int
+Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out)
+{
+    DWORD wait = INFINITE;
+    if (abstime != NULL) {
+        int wval = (*abstime - TimeValue::Now()) / 1000000;
+        if (wval < 0) wval = 0;
+
+        wait = wval;
+    }
+
+    int err = SleepConditionVariableCS(&m_condition, &mutex.m_mutex, wait);
+
+    if (timed_out != NULL)
+    {
+        if ((err == 0) && GetLastError() == ERROR_TIMEOUT)
+            *timed_out = true;
+        else
+            *timed_out = false;
+    }
+
+    return err != 0;
+}
+
diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp
new file mode 100644
index 0000000..24f7e4b
--- /dev/null
+++ b/lldb/source/Host/windows/Host.cpp
@@ -0,0 +1,245 @@
+//===-- source/Host/windows/Host.cpp ----------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <stdio.h>
+#include "lldb/Host/windows/windows.h"
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Target/Process.h"
+
+#include "lldb/Host/Host.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool
+Host::GetOSVersion(uint32_t &major,
+                   uint32_t &minor,
+                   uint32_t &update)
+{
+    OSVERSIONINFOEX info;
+
+    ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
+    info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+
+    if (GetVersionEx((LPOSVERSIONINFO) &info) == 0) {
+        return false;
+    }
+
+    major = (uint32_t) info.dwMajorVersion;
+    minor = (uint32_t) info.dwMinorVersion;
+    update = (uint32_t) info.wServicePackMajor;
+
+    return true;
+}
+
+Error
+Host::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+    Error error;
+    assert(!"Not implemented yet!!!");
+    return error;
+}
+
+lldb::DataBufferSP
+Host::GetAuxvData(lldb_private::Process *process)
+{
+    return 0;
+}
+
+std::string
+Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
+{
+    return std::string();
+}
+
+lldb::tid_t
+Host::GetCurrentThreadID()
+{
+    return lldb::tid_t(::GetCurrentThreadId());
+}
+
+lldb::thread_t
+Host::GetCurrentThread ()
+{
+    return lldb::thread_t(::GetCurrentThread());
+}
+
+bool
+Host::ThreadCancel (lldb::thread_t thread, Error *error)
+{
+    int err = ::TerminateThread((HANDLE)thread, 0);
+    return err == 0;
+}
+
+bool
+Host::ThreadDetach (lldb::thread_t thread, Error *error)
+{
+    return ThreadCancel(thread, error);
+}
+
+bool
+Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error)
+{
+    WaitForSingleObject((HANDLE) thread, INFINITE);
+    return true;
+}
+
+lldb::thread_key_t
+Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback)
+{
+    return TlsAlloc();
+}
+
+void*
+Host::ThreadLocalStorageGet(lldb::thread_key_t key)
+{
+    return ::TlsGetValue (key);
+}
+
+void
+Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value)
+{
+   ::TlsSetValue (key, value);
+}
+
+bool
+Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
+{
+    return false;
+}
+
+bool
+Host::SetShortThreadName (lldb::pid_t pid, lldb::tid_t tid,
+                          const char *thread_name, size_t len)
+{
+    return false;
+}
+
+void
+Host::Kill(lldb::pid_t pid, int signo)
+{
+    TerminateProcess((HANDLE) pid, 1);
+}
+
+uint32_t
+Host::GetNumberCPUS()
+{
+    static uint32_t g_num_cores = UINT32_MAX;
+    if (g_num_cores == UINT32_MAX)
+    {
+        SYSTEM_INFO system_info;
+        ::GetSystemInfo(&system_info);
+        g_num_cores = system_info.dwNumberOfProcessors;
+    }
+    return g_num_cores;
+}
+
+size_t
+Host::GetPageSize()
+{
+    static long g_pagesize = 0;
+    if (!g_pagesize)
+    {
+        SYSTEM_INFO systemInfo;
+        GetNativeSystemInfo(&systemInfo);
+        g_pagesize = systemInfo.dwPageSize;
+    }
+    return g_pagesize;
+}
+
+const char *
+Host::GetSignalAsCString(int signo)
+{
+    return NULL;
+}
+
+FileSpec
+Host::GetModuleFileSpecForHostAddress (const void *host_addr)
+{
+    FileSpec module_filespec;
+    return module_filespec;
+}
+
+void *
+Host::DynamicLibraryOpen(const FileSpec &file_spec, uint32_t options, Error &error)
+{
+    error.SetErrorString("not implemented");
+    return NULL;
+}
+
+Error
+Host::DynamicLibraryClose (void *opaque)
+{
+    Error error;
+    error.SetErrorString("not implemented");
+    return error;
+}
+
+void *
+Host::DynamicLibraryGetSymbol(void *opaque, const char *symbol_name, Error &error)
+{
+    error.SetErrorString("not implemented");
+    return NULL;
+}
+
+const char *
+Host::GetUserName (uint32_t uid, std::string &user_name)
+{
+    return NULL;
+}
+
+const char *
+Host::GetGroupName (uint32_t gid, std::string &group_name)
+{
+    return NULL;
+}
+
+uint32_t
+Host::GetUserID ()
+{
+    return 0;
+}
+
+uint32_t
+Host::GetGroupID ()
+{
+    return 0;
+}
+
+uint32_t
+Host::GetEffectiveUserID ()
+{
+    return 0;
+}
+
+uint32_t
+Host::GetEffectiveGroupID ()
+{
+    return 0;
+}
+
+lldb::thread_t
+Host::StartMonitoringChildProcess
+(
+    Host::MonitorChildProcessCallback callback,
+    void *callback_baton,
+    lldb::pid_t pid,
+    bool monitor_signals
+)
+{
+    return LLDB_INVALID_HOST_THREAD;
+}
\ No newline at end of file
diff --git a/lldb/source/Host/windows/Makefile b/lldb/source/Host/windows/Makefile
new file mode 100644
index 0000000..f85327a
--- /dev/null
+++ b/lldb/source/Host/windows/Makefile
@@ -0,0 +1,14 @@
+##===- source/Host/windows/Makefile ------------------------*- Makefile -*-===##
+# 
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+# 
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../../..
+LIBRARYNAME := lldbHostWindows
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile
diff --git a/lldb/source/Host/windows/Mutex.cpp b/lldb/source/Host/windows/Mutex.cpp
new file mode 100644
index 0000000..6a74506
--- /dev/null
+++ b/lldb/source/Host/windows/Mutex.cpp
@@ -0,0 +1,106 @@
+//===-- Mutex.cpp -----------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Mutex.h"
+#include "lldb/Host/Host.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#if 0
+// This logging is way too verbose to enable even for a log channel.
+// This logging can be enabled by changing the "#if 0", but should be
+// reverted prior to checking in.
+#include <cstdio>
+#define DEBUG_LOG(fmt, ...) printf(fmt, ## __VA_ARGS__)
+#else
+#define DEBUG_LOG(fmt, ...)
+#endif
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// Default constructor.
+//
+// Creates a pthread mutex with no attributes.
+//----------------------------------------------------------------------
+Mutex::Mutex () :
+    m_mutex()
+{
+    InitializeCriticalSection(&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Default constructor.
+//
+// Creates a pthread mutex with "type" as the mutex type.
+//----------------------------------------------------------------------
+Mutex::Mutex (Mutex::Type type) :
+    m_mutex()
+{
+    InitializeCriticalSection(&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Destructor.
+//
+// Destroys the mutex owned by this object.
+//----------------------------------------------------------------------
+Mutex::~Mutex()
+{
+    DeleteCriticalSection(&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Locks the mutex owned by this object, if the mutex is already
+// locked, the calling thread will block until the mutex becomes
+// available.
+//
+// RETURNS
+//  The error code from the pthread_mutex_lock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::Lock()
+{
+    DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), &m_mutex);
+
+    EnterCriticalSection(&m_mutex);
+    return 0;
+}
+
+//----------------------------------------------------------------------
+// Attempts to lock the mutex owned by this object without blocking.
+// If the mutex is already locked, TryLock() will not block waiting
+// for the mutex, but will return an error condition.
+//
+// RETURNS
+//  The error code from the pthread_mutex_trylock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::TryLock(const char *failure_message)
+{
+    return TryEnterCriticalSection(&m_mutex) == 0;
+}
+
+//----------------------------------------------------------------------
+// If the current thread holds the lock on the owned mutex, then
+// Unlock() will unlock the mutex. Calling Unlock() on this object
+// that the calling thread does not hold will result in undefined
+// behavior.
+//
+// RETURNS
+//  The error code from the pthread_mutex_unlock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::Unlock()
+{
+    LeaveCriticalSection(&m_mutex);
+    return 0;
+}
diff --git a/lldb/source/Host/windows/ProcessRunLock.cpp b/lldb/source/Host/windows/ProcessRunLock.cpp
new file mode 100644
index 0000000..ae9a973
--- /dev/null
+++ b/lldb/source/Host/windows/ProcessRunLock.cpp
@@ -0,0 +1,240 @@
+#ifdef _WIN32
+
+#include "lldb/Host/ProcessRunLock.h"
+
+namespace lldb_private {
+
+    // Windows has slim read-writer lock support on Vista and higher, so we
+    // will attempt to load the APIs.  If they exist, we will use them, and
+    // if not, we will fall back on critical sections.  When we drop support
+    // for XP, we can stop lazy-loading these APIs and just use them directly.
+#if defined(__MINGW32__)
+    // Taken from WinNT.h
+    typedef struct _RTL_SRWLOCK {
+        PVOID Ptr;
+    } RTL_SRWLOCK, *PRTL_SRWLOCK;
+
+    // Taken from WinBase.h
+    typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
+#endif
+
+
+    typedef struct Win32RWLOCK
+    {
+        unsigned long int readlockcount;
+        HANDLE writable;
+        CRITICAL_SECTION writelock;
+        unsigned long int writelocked;
+    } Win32RWLOCK;
+
+    typedef Win32RWLOCK* PWin32RWLOCK;
+
+    static VOID (WINAPI *fpInitializeSRWLock)(PSRWLOCK lock) = NULL;
+    static VOID (WINAPI *fpAcquireSRWLockExclusive)(PSRWLOCK lock) = NULL;
+    static VOID (WINAPI *fpAcquireSRWLockShared)(PSRWLOCK lock) = NULL;
+    static VOID (WINAPI *fpReleaseSRWLockExclusive)(PSRWLOCK lock) = NULL;
+    static VOID (WINAPI *fpReleaseSRWLockShared)(PSRWLOCK lock) = NULL;
+    static BOOL (WINAPI *fpTryAcquireSRWLockExclusive)(PSRWLOCK lock) = NULL;
+    static BOOL (WINAPI *fpTryAcquireSRWLockShared)(PSRWLOCK lock) = NULL;
+
+    static bool sHasSRW = false;
+
+    static bool loadSRW()
+    {
+        static bool sChecked = false;
+        if (!sChecked)
+        {
+            sChecked = true;
+            return false;
+
+            HMODULE hLib = ::LoadLibrary(TEXT("Kernel32"));
+            if (hLib)
+            {
+                fpInitializeSRWLock =
+                    (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+                    "InitializeSRWLock");
+                fpAcquireSRWLockExclusive =
+                    (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+                    "AcquireSRWLockExclusive");
+                fpAcquireSRWLockShared =
+                    (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+                    "AcquireSRWLockShared");
+                fpReleaseSRWLockExclusive =
+                    (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+                    "ReleaseSRWLockExclusive");
+                fpReleaseSRWLockShared =
+                    (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+                    "ReleaseSRWLockShared");
+                fpTryAcquireSRWLockExclusive =
+                    (BOOL (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+                    "TryAcquireSRWLockExclusive");
+                fpTryAcquireSRWLockShared =
+                    (BOOL (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+                    "TryAcquireSRWLockShared");
+
+                ::FreeLibrary(hLib);
+
+                if (fpInitializeSRWLock != NULL) {
+                    sHasSRW = true;
+                }
+            }
+        }
+        return sHasSRW;
+    }
+
+    ProcessRunLock::ProcessRunLock ()
+        : m_running(false)
+    {
+        if (loadSRW())
+        {
+            m_rwlock = calloc(1, sizeof(SRWLOCK));
+            fpInitializeSRWLock(static_cast<PSRWLOCK>(m_rwlock));
+        }
+        else
+        {
+            m_rwlock = calloc(1, sizeof(Win32RWLOCK));
+            static_cast<PWin32RWLOCK>(m_rwlock)->readlockcount = 0;
+            static_cast<PWin32RWLOCK>(m_rwlock)->writable = CreateEvent(NULL, true, true, NULL);
+            InitializeCriticalSection(&static_cast<PWin32RWLOCK>(m_rwlock)->writelock);
+        }
+    }
+
+    ProcessRunLock::~ProcessRunLock ()
+    {
+        if (!sHasSRW)
+        {
+            CloseHandle(static_cast<PWin32RWLOCK>(m_rwlock)->writable);
+            DeleteCriticalSection(&static_cast<PWin32RWLOCK>(m_rwlock)->writelock);
+        }
+        free(m_rwlock);
+    }
+
+    bool ReadLock (lldb::rwlock_t rwlock)
+    {
+        if (sHasSRW)
+        {
+            fpAcquireSRWLockShared(static_cast<PSRWLOCK>(rwlock));
+            return true;
+        }
+        else
+        {
+            EnterCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+            InterlockedIncrement(&static_cast<PWin32RWLOCK>(rwlock)->readlockcount);
+            ResetEvent(static_cast<PWin32RWLOCK>(rwlock)->writable);
+            LeaveCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+            return true;
+        }
+    }
+
+    bool ProcessRunLock::ReadTryLock ()
+    {
+        ReadLock(m_rwlock);
+        if (m_running == false)
+            return true;
+        ReadUnlock();
+        return false;
+    }
+
+    bool ProcessRunLock::ReadUnlock ()
+    {
+        if (sHasSRW)
+        {
+            fpReleaseSRWLockShared(static_cast<PSRWLOCK>(m_rwlock));
+            return true;
+        }
+        else
+        {
+            unsigned long int value = InterlockedDecrement(&static_cast<PWin32RWLOCK>(m_rwlock)->readlockcount);
+            assert(((int)value) >= 0);
+            if (value == 0)
+                SetEvent(static_cast<PWin32RWLOCK>(m_rwlock)->writable);
+            return true;
+        }
+    }
+
+    bool WriteLock(lldb::rwlock_t rwlock)
+    {
+        if (sHasSRW)
+        {
+            fpAcquireSRWLockExclusive(static_cast<PSRWLOCK>(rwlock));
+            return true;
+        }
+        else
+        {
+            EnterCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+            WaitForSingleObject(static_cast<PWin32RWLOCK>(rwlock)->writable, INFINITE);
+            int res = InterlockedExchange(&static_cast<PWin32RWLOCK>(rwlock)->writelocked, 1);
+            assert(res == 0);
+            return true;
+        }
+    }
+
+    bool WriteTryLock(lldb::rwlock_t rwlock)
+    {
+        if (sHasSRW)
+        {
+            return fpTryAcquireSRWLockExclusive(static_cast<PSRWLOCK>(rwlock)) != 0;
+        }
+        else
+        {
+            if (TryEnterCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock)) {
+                if (WaitForSingleObject(static_cast<PWin32RWLOCK>(rwlock)->writable, 0)) {
+                    LeaveCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+                    return false;
+                }
+                int res = InterlockedExchange(&static_cast<PWin32RWLOCK>(rwlock)->writelocked, 1);
+                assert(res == 0);
+                return true;
+            }
+            return false;
+        }
+    }
+
+    bool WriteUnlock(lldb::rwlock_t rwlock)
+    {
+        if (sHasSRW)
+        {
+            fpReleaseSRWLockExclusive(static_cast<PSRWLOCK>(rwlock));
+            return true;
+        }
+        else
+        {
+            int res = InterlockedExchange(&static_cast<PWin32RWLOCK>(rwlock)->writelocked, 0);
+            if (res == 1) {
+                LeaveCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+                return true;
+            }
+            return false;
+        }
+    }
+
+    bool ProcessRunLock::SetRunning ()
+    {
+        WriteLock(m_rwlock);
+        m_running = true;
+        WriteUnlock(m_rwlock);
+        return true;
+    }
+
+    bool ProcessRunLock::TrySetRunning ()
+    {
+        if (WriteTryLock(m_rwlock))
+        {
+            bool r = !m_running;
+            m_running = true;
+            WriteUnlock(m_rwlock);
+            return r;
+        }
+        return false;
+    }
+
+    bool ProcessRunLock::SetStopped ()
+    {
+        WriteLock(m_rwlock);
+        m_running = false;
+        WriteUnlock(m_rwlock);
+        return true;
+    }
+}
+
+#endif
diff --git a/lldb/source/Host/windows/Windows.cpp b/lldb/source/Host/windows/Windows.cpp
new file mode 100644
index 0000000..34dbc23
--- /dev/null
+++ b/lldb/source/Host/windows/Windows.cpp
@@ -0,0 +1,146 @@
+//===-- Windows.cpp ---------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// This file provides Windows support functions
+
+#include "lldb/Host/windows/windows.h"
+#include "lldb/Host/windows/win32.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <io.h>
+#include <cerrno>
+
+int vasprintf(char **ret, const char *fmt, va_list ap)
+{
+    char *buf;
+    int len;
+    size_t buflen;
+    va_list ap2;
+
+#if defined(_MSC_VER) || defined(__MINGW64)
+    ap2 = ap;
+    len = _vscprintf(fmt, ap2);
+#else
+    va_copy(ap2, ap);
+    len = vsnprintf(NULL, 0, fmt, ap2);
+#endif
+
+    if (len >= 0 && (buf = (char*) malloc ((buflen = (size_t) (len + 1)))) != NULL) {
+        len = vsnprintf(buf, buflen, fmt, ap);
+        *ret = buf;
+    } else {
+        *ret = NULL;
+        len = -1;
+    }
+
+    va_end(ap2);
+    return len;
+}
+
+char * strcasestr(const char *s, const char* find)
+{
+    char c, sc;
+    size_t len;
+
+    if ((c = *find++) != 0) {
+        c = tolower((unsigned char) c);
+        len = strlen(find);
+        do {
+            do {
+                if ((sc = *s++) == 0)
+                    return 0;
+            } while ((char) tolower((unsigned char) sc) != c);
+        } while (strncasecmp(s, find, len) != 0);
+        s--;
+    }
+    return ((char *) s);
+}
+
+char* __cdecl realpath(const char * name, char * resolved)
+{
+    char *retname = NULL;  /* we will return this, if we fail */
+
+    /* SUSv3 says we must set `errno = EINVAL', and return NULL,
+    * if `name' is passed as a NULL pointer.
+    */
+
+    if (name == NULL)
+        errno = EINVAL;
+
+    /* Otherwise, `name' must refer to a readable filesystem object,
+    * if we are going to resolve its absolute path name.
+    */
+
+    else if (access(name, 4) == 0)
+    {
+        /* If `name' didn't point to an existing entity,
+        * then we don't get to here; we simply fall past this block,
+        * returning NULL, with `errno' appropriately set by `access'.
+        *
+        * When we _do_ get to here, then we can use `_fullpath' to
+        * resolve the full path for `name' into `resolved', but first,
+        * check that we have a suitable buffer, in which to return it.
+        */
+
+        if ((retname = resolved) == NULL)
+        {
+            /* Caller didn't give us a buffer, so we'll exercise the
+            * option granted by SUSv3, and allocate one.
+            *
+            * `_fullpath' would do this for us, but it uses `malloc', and
+            * Microsoft's implementation doesn't set `errno' on failure.
+            * If we don't do this explicitly ourselves, then we will not
+            * know if `_fullpath' fails on `malloc' failure, or for some
+            * other reason, and we want to set `errno = ENOMEM' for the
+            * `malloc' failure case.
+            */
+
+            retname = (char*) malloc(_MAX_PATH);
+        }
+
+        /* By now, we should have a valid buffer.
+        * If we don't, then we know that `malloc' failed,
+        * so we can set `errno = ENOMEM' appropriately.
+        */
+
+        if (retname == NULL)
+            errno = ENOMEM;
+
+        /* Otherwise, when we do have a valid buffer,
+        * `_fullpath' should only fail if the path name is too long.
+        */
+
+        else if ((retname = _fullpath(retname, name, _MAX_PATH)) == NULL)
+            errno = ENAMETOOLONG;
+    }
+
+    /* By the time we get to here,
+    * `retname' either points to the required resolved path name,
+    * or it is NULL, with `errno' set appropriately, either of which
+    * is our required return condition.
+    */
+
+    if (retname != NULL)
+    {
+        // Do a LongPath<->ShortPath roundtrip so that case is resolved by OS
+        int initialLength = strlen(retname);
+        TCHAR buffer[MAX_PATH];
+        GetShortPathName(retname, buffer, MAX_PATH);
+        GetLongPathName(buffer, retname, initialLength + 1);
+
+        // Force drive to be upper case
+        if (retname[1] == ':')
+            retname[0] = toupper(retname[0]);
+    }
+
+    return retname;
+}
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index e6d2043..833afd6 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -10,6 +10,9 @@
 #include "lldb/lldb-python.h"
 
 // C Includes
+#ifdef _WIN32
+#define _BSD_SOURCE // Required so that getopt.h defines optreset
+#endif
 #include <getopt.h>
 #include <cstdlib>
 // C++ Includes
diff --git a/lldb/source/Interpreter/Makefile b/lldb/source/Interpreter/Makefile
index 24ee394..d69d51c 100644
--- a/lldb/source/Interpreter/Makefile
+++ b/lldb/source/Interpreter/Makefile
@@ -11,7 +11,9 @@
 LIBRARYNAME := lldbInterpreter
 BUILD_ARCHIVE = 1
 
+ifeq (,$(findstring -DLLDB_DISABLE_PYTHON,$(CXXFLAGS)))
 BUILT_SOURCES := LLDBWrapPython.cpp
+endif
 
 include $(LLDB_LEVEL)/Makefile
 -include $(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.d
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
index e920d70..59f9ad7 100644
--- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
@@ -38,7 +38,7 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/StackFrame.h"
 
-#include <regex.h>
+#include "lldb/Core/RegularExpression.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -369,20 +369,17 @@
                 }
             }
             
-            if (!s_regex_compiled)
+            if (!s_regex.IsValid())
             {
-                ::regcomp(&s_regex, "[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
-                s_regex_compiled = true;
+                s_regex.Compile("[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
             }
             
-            ::regmatch_t matches[3];
+            RegularExpression::Match matches(3);
             
-            if (!::regexec(&s_regex, out_string, sizeof(matches) / sizeof(::regmatch_t), matches, 0))
+            if (s_regex.Execute(out_string, &matches))
             {
-                if (matches[1].rm_so != -1)
-                    m_opcode_name.assign(out_string + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
-                if (matches[2].rm_so != -1)
-                    m_mnemonics.assign(out_string + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
+                matches.GetMatchAtIndex(out_string, 1, m_opcode_name);
+                matches.GetMatchAtIndex(out_string, 2, m_mnemonics);
             }
         }
     }
@@ -416,12 +413,10 @@
     bool                    m_is_valid;
     bool                    m_using_file_addr;
     
-    static bool             s_regex_compiled;
-    static ::regex_t        s_regex;
+    static RegularExpression s_regex;
 };
 
-bool InstructionLLVMC::s_regex_compiled = false;
-::regex_t InstructionLLVMC::s_regex;
+RegularExpression InstructionLLVMC::s_regex;
 
 DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, unsigned flavor, DisassemblerLLVMC &owner):
     m_is_valid(true)
@@ -796,7 +791,7 @@
     default:
         break;
     case 1:
-        bzero (tag_bug, sizeof(::LLVMOpInfo1));
+        memset (tag_bug, 0, sizeof(::LLVMOpInfo1));
         break;
     }
     return 0;
diff --git a/lldb/source/Plugins/Makefile b/lldb/source/Plugins/Makefile
index 3694f31..1fc5024 100644
--- a/lldb/source/Plugins/Makefile
+++ b/lldb/source/Plugins/Makefile
@@ -22,6 +22,10 @@
 	DynamicLoader/POSIX-DYLD \
 	OperatingSystem/Python
 
+ifeq ($(HOST_OS),MingW)
+DIRS += SymbolVendor/ELF
+endif
+
 ifeq ($(HOST_OS),Darwin)
 DIRS += Process/MacOSX-Kernel
 DIRS += DynamicLoader/MacOSX-DYLD DynamicLoader/Darwin-Kernel
diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 1ec5f3d..8260555 100644
--- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -9,7 +9,24 @@
 
 #include "ObjectContainerBSDArchive.h"
 
+#ifdef _WIN32
+// Defines from ar, missing on Windows
+#define ARMAG   "!<arch>\n"
+#define SARMAG  8
+#define ARFMAG  "`\n"
+
+typedef struct ar_hdr
+{
+    char ar_name[16];
+    char ar_date[12];
+    char ar_uid[6], ar_gid[6];
+    char ar_mode[8];
+    char ar_size[10];
+    char ar_fmag[2];
+} ar_hdr;
+#else
 #include <ar.h>
+#endif
 
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 178c0a0..88213c7 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1545,7 +1545,7 @@
             function_starts_load_command.cmd = lc.cmd;
             function_starts_load_command.cmdsize = lc.cmdsize;
             if (m_data.GetU32(&offset, &function_starts_load_command.dataoff, 2) == NULL) // fill in symoff, nsyms, stroff, strsize fields
-                bzero (&function_starts_load_command, sizeof(function_starts_load_command));
+                memset (&function_starts_load_command, 0, sizeof(function_starts_load_command));
             break;
 
         default:
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index dc09172..cdca446 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -10,10 +10,13 @@
 #include "lldb/lldb-python.h"
 
 #include "PlatformFreeBSD.h"
+#include "lldb/Host/Config.h"
 
 // C Includes
 #include <stdio.h>
+#ifndef LLDB_DISABLE_POSIX
 #include <sys/utsname.h>
+#endif
 
 // C++ Includes
 // Other libraries and framework includes
@@ -636,6 +639,7 @@
 void
 PlatformFreeBSD::GetStatus (Stream &strm)
 {
+#ifndef LLDB_DISABLE_POSIX
     struct utsname un;
 
     if (uname(&un)) {
@@ -644,5 +648,7 @@
     }
 
     strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version << '\n';
+#endif
+
     Platform::GetStatus(strm);
 }
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 4bf4cf8..1456a7c 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -10,10 +10,13 @@
 #include "lldb/lldb-python.h"
 
 #include "PlatformLinux.h"
+#include "lldb/Host/Config.h"
 
 // C Includes
 #include <stdio.h>
+#ifndef LLDB_DISABLE_POSIX
 #include <sys/utsname.h>
+#endif
 
 // C++ Includes
 // Other libraries and framework includes
@@ -357,16 +360,18 @@
 void
 PlatformLinux::GetStatus (Stream &strm)
 {
-    struct utsname un;
-
     Platform::GetStatus(strm);
 
+#ifndef LLDB_DISABLE_POSIX
+    struct utsname un;
+
     if (uname(&un))
         return;
 
     strm.Printf ("    Kernel: %s\n", un.sysname);
     strm.Printf ("   Release: %s\n", un.release);
     strm.Printf ("   Version: %s\n", un.version);
+#endif
 }
 
 size_t
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 16bcafd..3b0e159 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -8,9 +8,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "PlatformMacOSX.h"
+#include "lldb/Host/Config.h"
 
 // C Includes
+#ifndef LLDB_DISABLE_POSIX
 #include <sys/sysctl.h>
+#endif
 
 // C++ Includes
 // Other libraries and framework includes
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 684d192..5d15db5 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -10,9 +10,12 @@
 #include "lldb/lldb-python.h"
 
 #include "PlatformRemoteGDBServer.h"
+#include "lldb/Host/Config.h"
 
 // C Includes
+#ifndef LLDB_DISABLE_POSIX
 #include <sys/sysctl.h>
+#endif
 
 // C++ Includes
 // Other libraries and framework includes
diff --git a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
index 499d6d7..8b22d64 100644
--- a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
+++ b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
@@ -17,8 +17,19 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadPlanCallFunction.h"
+#include "lldb/Host/Config.h"
 
+#ifndef LLDB_DISABLE_POSIX
 #include <sys/mman.h>
+#else
+// define them
+#define PROT_NONE 0
+#define PROT_READ 1
+#define PROT_WRITE 2
+#define PROT_EXEC 4
+#define MAP_PRIVATE 2
+#define MAP_ANON 0x1000
+#endif
 
 using namespace lldb;
 using namespace lldb_private;
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index ca594a8..6a6e063 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -29,10 +29,15 @@
 #include "Utility/StringExtractorGDBRemote.h"
 #include "ProcessGDBRemote.h"
 #include "ProcessGDBRemoteLog.h"
+#include "lldb/Host/Config.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
+#ifdef LLDB_DISABLE_POSIX
+#define SIGSTOP 17
+#endif
+
 //----------------------------------------------------------------------
 // GDBRemoteCommunicationClient constructor
 //----------------------------------------------------------------------
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index 3a14e9f..050ed00 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -668,6 +668,10 @@
 bool
 GDBRemoteCommunicationServer::Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet)
 {
+#ifdef _WIN32
+    // No unix sockets on windows
+    return false;
+#else
     // Spawn a local debugserver as a platform so we can then attach or launch
     // a process...
 
@@ -731,6 +735,7 @@
         }
     }
     return SendErrorResponse (13);
+#endif
 }
 
 bool
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index d27207f..4a3bd04 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -8,13 +8,16 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/lldb-python.h"
+#include "lldb/Host/Config.h"
 
 // C Includes
 #include <errno.h>
-#include <spawn.h>
 #include <stdlib.h>
+#ifndef LLDB_DISABLE_POSIX
+#include <spawn.h>
 #include <netinet/in.h>
 #include <sys/mman.h>       // for mmap
+#endif
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <time.h>
@@ -2687,7 +2690,7 @@
 {
     if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
     {
-        ::kill (m_debugserver_pid, SIGINT);
+        Host::Kill (m_debugserver_pid, SIGINT);
         m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
     }
 }
@@ -2794,7 +2797,7 @@
 }
 
 
-void *
+thread_result_t
 ProcessGDBRemote::AsyncThread (void *arg)
 {
     ProcessGDBRemote *process = (ProcessGDBRemote*) arg;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index e104b71..c8bd42b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -340,7 +340,7 @@
     void
     StopAsyncThread ();
 
-    static void *
+    static lldb::thread_result_t
     AsyncThread (void *arg);
 
     static bool
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 0c61591..5cddb0b 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -501,7 +501,7 @@
                 uint64_t section_dst_len = dst_len;
                 if (section_dst_len > section_bytes_left)
                     section_dst_len = section_bytes_left;
-                bzero(dst, section_dst_len);
+                memset(dst, 0, section_dst_len);
                 return section_dst_len;
             }
         }
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6edb939..c93d7da 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -663,6 +663,7 @@
 
 
 
+#ifndef LLDB_DISABLE_POSIX
 bool
 ProcessLaunchInfo::FileAction::AddPosixSpawnFileAction (posix_spawn_file_actions_t *file_actions,
                                                         const FileAction *info,
@@ -733,6 +734,7 @@
     }
     return error.Success();
 }
+#endif
 
 Error
 ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
@@ -3968,15 +3970,15 @@
     m_currently_handling_event.SetValue(false, eBroadcastAlways);
 }
 
-void *
+thread_result_t
 Process::PrivateStateThread (void *arg)
 {
     Process *proc = static_cast<Process*> (arg);
-    void *result = proc->RunPrivateStateThread ();
+    thread_result_t result = proc->RunPrivateStateThread();
     return result;
 }
 
-void *
+thread_result_t
 Process::RunPrivateStateThread ()
 {
     bool control_only = true;
diff --git a/lldb/source/Utility/PseudoTerminal.cpp b/lldb/source/Utility/PseudoTerminal.cpp
index e4b444c..98d581d 100644
--- a/lldb/source/Utility/PseudoTerminal.cpp
+++ b/lldb/source/Utility/PseudoTerminal.cpp
@@ -17,6 +17,21 @@
 #include <sys/ioctl.h>
 #endif
 
+#ifdef _WIN32
+#include "lldb/Host/windows/win32.h"
+// empty functions
+int posix_openpt(int flag) { return 0; }
+
+int strerror_r(int errnum, char *buf, size_t buflen) { return 0; }
+
+int unlockpt(int fd) { return 0; }
+int grantpt(int fd) { return 0; }
+char *ptsname(int fd) { return 0; }
+
+pid_t fork(void) { return 0; }
+pid_t setsid(void) { return 0; }
+#endif
+
 using namespace lldb_utility;
 
 //----------------------------------------------------------------------