[Lldb-commits] [lldb] r189934 - Remove <windows.h> from lldb-types.h.
Virgile Bello
virgile.bello at gmail.com
Wed Sep 4 06:56:12 PDT 2013
Author: xen2
Date: Wed Sep 4 08:56:11 2013
New Revision: 189934
URL: http://llvm.org/viewvc/llvm-project?rev=189934&view=rev
Log:
Remove <windows.h> from lldb-types.h.
Modified:
lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
lldb/trunk/include/lldb/DataFormatters/FormatManager.h
lldb/trunk/include/lldb/Host/TimeValue.h
lldb/trunk/include/lldb/Utility/RefCounter.h
lldb/trunk/include/lldb/Utility/SharingPtr.h
lldb/trunk/include/lldb/lldb-defines.h
lldb/trunk/include/lldb/lldb-types.h
lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
lldb/trunk/source/Core/Log.cpp
lldb/trunk/source/Host/common/TimeValue.cpp
lldb/trunk/source/Host/windows/Condition.cpp
lldb/trunk/source/Host/windows/Mutex.cpp
lldb/trunk/source/Host/windows/ProcessRunLock.cpp
Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h (original)
+++ lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h Wed Sep 4 08:56:11 2013
@@ -20,15 +20,18 @@ typedef unsigned short in_port_t;
#endif
// C++ Includes
+#include <memory>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Connection.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
-#include "lldb/Host/SocketAddress.h"
namespace lldb_private {
+class SocketAddress;
+
class ConnectionFileDescriptor :
public Connection
{
@@ -113,7 +116,7 @@ protected:
int m_fd_recv;
FDType m_fd_send_type;
FDType m_fd_recv_type;
- SocketAddress m_udp_send_sockaddr;
+ std::unique_ptr<SocketAddress> m_udp_send_sockaddr;
bool m_should_close_fd; // True if this class should close the file descriptor when it goes away.
uint32_t m_socket_timeout_usec;
int m_pipe_read; // A pipe that we select on the reading end of along with
Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Wed Sep 4 08:56:11 2013
@@ -23,6 +23,8 @@
#include "lldb/DataFormatters/TypeCategory.h"
#include "lldb/DataFormatters/TypeCategoryMap.h"
+#include "llvm/Support/Atomic.h"
+
namespace lldb_private {
// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
@@ -191,7 +193,7 @@ public:
void
Changed ()
{
- __sync_add_and_fetch(&m_last_revision, +1);
+ llvm::sys::AtomicIncrement(&m_last_revision);
m_format_cache.Clear ();
}
@@ -209,7 +211,7 @@ private:
FormatCache m_format_cache;
ValueNavigator m_value_nav;
NamedSummariesMap m_named_summaries_map;
- uint32_t m_last_revision;
+ llvm::sys::cas_flag m_last_revision;
TypeCategoryMap m_categories_map;
ConstString m_default_category_name;
Modified: lldb/trunk/include/lldb/Host/TimeValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/TimeValue.h (original)
+++ lldb/trunk/include/lldb/Host/TimeValue.h Wed Sep 4 08:56:11 2013
@@ -40,7 +40,7 @@ public:
TimeValue();
TimeValue(const TimeValue& rhs);
TimeValue(const struct timespec& ts);
- TimeValue(const struct timeval& tv);
+ explicit TimeValue(uint32_t seconds, uint32_t nanos = 0);
~TimeValue();
//------------------------------------------------------------------
@@ -64,9 +64,6 @@ public:
struct timespec
GetAsTimeSpec () const;
- struct timeval
- GetAsTimeVal () const;
-
bool
IsValid () const;
@@ -85,6 +82,23 @@ public:
void
Dump (Stream *s, uint32_t width = 0) const;
+ /// Returns only the seconds component of the TimeValue. The nanoseconds
+ /// portion is ignored. No rounding is performed.
+ /// @brief Retrieve the seconds component
+ uint32_t seconds() const { return m_nano_seconds / NanoSecPerSec; }
+
+ /// Returns only the nanoseconds component of the TimeValue. The seconds
+ /// portion is ignored.
+ /// @brief Retrieve the nanoseconds component.
+ uint32_t nanoseconds() const { return m_nano_seconds % NanoSecPerSec; }
+
+ /// Returns only the fractional portion of the TimeValue rounded down to the
+ /// nearest microsecond (divide by one thousand).
+ /// @brief Retrieve the fractional part as microseconds;
+ uint32_t microseconds() const {
+ return (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec;
+ }
+
protected:
//------------------------------------------------------------------
// Classes that inherit from TimeValue can see and modify these
Modified: lldb/trunk/include/lldb/Utility/RefCounter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/RefCounter.h?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/RefCounter.h (original)
+++ lldb/trunk/include/lldb/Utility/RefCounter.h Wed Sep 4 08:56:11 2013
@@ -11,6 +11,7 @@
#define liblldb_RefCounter_h_
#include "lldb/lldb-public.h"
+#include "llvm/Support/Atomic.h"
namespace lldb_utility {
@@ -39,14 +40,14 @@ private:
inline T
increment(T* t)
{
- return __sync_fetch_and_add(t, 1);
+ return llvm::sys::AtomicIncrement((llvm::sys::cas_flag*)&t);
}
template <class T>
inline T
decrement(T* t)
{
- return __sync_fetch_and_add(t, -1);
+ return llvm::sys::AtomicDecrement((llvm::sys::cas_flag*)&t);
}
};
Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharingPtr.h (original)
+++ lldb/trunk/include/lldb/Utility/SharingPtr.h Wed Sep 4 08:56:11 2013
@@ -12,6 +12,7 @@
#include <algorithm>
#include <memory>
+#include "llvm/Support/Atomic.h"
//#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT
#if defined (ENABLE_SP_LOGGING)
@@ -28,14 +29,14 @@ template <class T>
inline T
increment(T& t)
{
- return __sync_add_and_fetch(&t, 1);
+ return llvm::sys::AtomicIncrement((llvm::sys::cas_flag*)&t);
}
template <class T>
inline T
decrement(T& t)
{
- return __sync_add_and_fetch(&t, -1);
+ return llvm::sys::AtomicDecrement((llvm::sys::cas_flag*)&t);
}
class shared_count
Modified: lldb/trunk/include/lldb/lldb-defines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-defines.h (original)
+++ lldb/trunk/include/lldb/lldb-defines.h Wed Sep 4 08:56:11 2013
@@ -110,6 +110,10 @@
#define LLDB_OPT_SET_10 (1U << 9)
#define LLDB_OPT_SET_FROM_TO(A, B) (((1U << (B)) - 1) ^ (((1U << (A))-1) >> 1))
+#ifdef _WIN32
+#define MAX_PATH 260
+#endif
+
#if defined(__cplusplus)
//----------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/lldb-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-types.h (original)
+++ lldb/trunk/include/lldb/lldb-types.h Wed Sep 4 08:56:11 2013
@@ -40,16 +40,15 @@
#ifdef _WIN32
-#include "lldb/Host/windows/windows.h"
#include <process.h>
namespace lldb
{
- typedef CRITICAL_SECTION mutex_t;
- typedef CONDITION_VARIABLE condition_t;
+ typedef void* mutex_t;
+ typedef void* condition_t;
typedef void* rwlock_t;
typedef uintptr_t thread_t; // Host thread type
- typedef DWORD thread_key_t;
+ typedef uint32_t thread_key_t;
typedef void * thread_arg_t; // Host thread argument type
typedef unsigned thread_result_t; // Host thread result type
typedef thread_result_t (*thread_func_t)(void *); // Host thread function type
Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Wed Sep 4 08:56:11 2013
@@ -16,6 +16,7 @@
#include "lldb/Core/ConnectionFileDescriptor.h"
#include "lldb/Host/Config.h"
+#include "lldb/Host/SocketAddress.h"
// C Includes
#include <errno.h>
@@ -33,6 +34,11 @@
#include <termios.h>
#include <unistd.h>
#endif
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include <winsock2.h>
+#include <WS2tcpip.h>
+#endif
// C++ Includes
// Other libraries and framework includes
@@ -87,7 +93,7 @@ ConnectionFileDescriptor::ConnectionFile
m_fd_recv (-1),
m_fd_send_type (eFDTypeFile),
m_fd_recv_type (eFDTypeFile),
- m_udp_send_sockaddr (),
+ m_udp_send_sockaddr (new SocketAddress()),
m_should_close_fd (false),
m_socket_timeout_usec(0),
m_pipe_read(-1),
@@ -106,7 +112,7 @@ ConnectionFileDescriptor::ConnectionFile
m_fd_recv (fd),
m_fd_send_type (eFDTypeFile),
m_fd_recv_type (eFDTypeFile),
- m_udp_send_sockaddr (),
+ m_udp_send_sockaddr (new SocketAddress()),
m_should_close_fd (owns_fd),
m_socket_timeout_usec(0),
m_pipe_read(-1),
@@ -568,15 +574,15 @@ ConnectionFileDescriptor::Write (const v
break;
case eFDTypeSocketUDP: // Unconnected UDP socket requiring sendto/recvfrom
- assert (m_udp_send_sockaddr.GetFamily() != 0);
+ assert (m_udp_send_sockaddr->GetFamily() != 0);
do
{
bytes_sent = ::sendto (m_fd_send,
(char*)src,
src_len,
0,
- m_udp_send_sockaddr,
- m_udp_send_sockaddr.GetLength());
+ *m_udp_send_sockaddr,
+ m_udp_send_sockaddr->GetLength());
} while (bytes_sent < 0 && errno == EINTR);
break;
}
@@ -686,7 +692,8 @@ ConnectionFileDescriptor::BytesAvailable
{
TimeValue time_value;
time_value.OffsetWithMicroSeconds (timeout_usec);
- tv = time_value.GetAsTimeVal();
+ tv.tv_sec = time_value.seconds();
+ tv.tv_usec = time_value.microseconds();
tv_ptr = &tv;
}
@@ -836,7 +843,8 @@ ConnectionFileDescriptor::BytesAvailable
{
TimeValue time_value;
time_value.OffsetWithMicroSeconds (timeout_usec);
- tv = time_value.GetAsTimeVal();
+ tv.tv_sec = time_value.seconds();
+ tv.tv_usec = time_value.microseconds();
tv_ptr = &tv;
}
@@ -1446,7 +1454,7 @@ ConnectionFileDescriptor::ConnectUDP (co
if (m_fd_send != -1)
{
- m_udp_send_sockaddr = service_info_ptr;
+ *m_udp_send_sockaddr = service_info_ptr;
break;
}
else
Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Wed Sep 4 08:56:11 2013
@@ -99,8 +99,8 @@ Log::PrintfWithFlagsVarArg (uint32_t fla
// Timestamp if requested
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
{
- struct timeval tv = TimeValue::Now().GetAsTimeVal();
- header.Printf ("%9ld.%6.6d ", tv.tv_sec, (int32_t)tv.tv_usec);
+ TimeValue now = TimeValue::Now();
+ header.Printf ("%9ld.%6.6d ", now.seconds(), now.nanoseconds());
}
// Add the process and thread if requested
Modified: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Wed Sep 4 08:56:11 2013
@@ -43,8 +43,8 @@ TimeValue::TimeValue(const struct timesp
{
}
-TimeValue::TimeValue(const struct timeval& tv) :
- m_nano_seconds ((uint64_t) tv.tv_sec * NanoSecPerSec + (uint64_t) tv.tv_usec * NanoSecPerMicroSec)
+TimeValue::TimeValue(uint32_t seconds, uint32_t nanos) :
+ m_nano_seconds((uint64_t) seconds * NanoSecPerSec + nanos)
{
}
@@ -85,15 +85,6 @@ TimeValue::GetAsTimeSpec () const
return ts;
}
-struct timeval
-TimeValue::GetAsTimeVal () const
-{
- struct timeval tv;
- tv.tv_sec = m_nano_seconds / NanoSecPerSec;
- tv.tv_usec = (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec;
- return tv;
-}
-
void
TimeValue::Clear ()
{
@@ -127,9 +118,12 @@ TimeValue::OffsetWithNanoSeconds (uint64
TimeValue
TimeValue::Now()
{
+ uint32_t seconds, nanoseconds;
struct timeval tv;
gettimeofday(&tv, NULL);
- TimeValue now(tv);
+ seconds = tv.tv_sec;
+ nanoseconds = tv.tv_usec * NanoSecPerMicroSec;
+ TimeValue now(seconds, nanoseconds);
return now;
}
Modified: lldb/trunk/source/Host/windows/Condition.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Condition.cpp?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/Condition.cpp (original)
+++ lldb/trunk/source/Host/windows/Condition.cpp Wed Sep 4 08:56:11 2013
@@ -11,6 +11,7 @@
#include "lldb/Host/Condition.h"
#include "lldb/Host/TimeValue.h"
+#include "lldb/Host/windows/windows.h"
using namespace lldb_private;
@@ -24,7 +25,8 @@ using namespace lldb_private;
Condition::Condition () :
m_condition()
{
- InitializeConditionVariable(&m_condition);
+ m_condition = static_cast<PCONDITION_VARIABLE>(malloc(sizeof(CONDITION_VARIABLE)));
+ InitializeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
}
//----------------------------------------------------------------------
@@ -34,6 +36,7 @@ Condition::Condition () :
//----------------------------------------------------------------------
Condition::~Condition ()
{
+ free(m_condition);
}
//----------------------------------------------------------------------
@@ -42,7 +45,7 @@ Condition::~Condition ()
int
Condition::Broadcast ()
{
- WakeAllConditionVariable(&m_condition);
+ WakeAllConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
return 0;
}
@@ -52,7 +55,7 @@ Condition::Broadcast ()
int
Condition::Signal ()
{
- WakeConditionVariable(&m_condition);
+ WakeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
return 0;
}
@@ -80,7 +83,7 @@ Condition::Wait (Mutex &mutex, const Tim
wait = wval;
}
- int err = SleepConditionVariableCS(&m_condition, &mutex.m_mutex, wait);
+ int err = SleepConditionVariableCS(static_cast<PCONDITION_VARIABLE>(m_condition), static_cast<PCRITICAL_SECTION>(mutex.m_mutex), wait);
if (timed_out != NULL)
{
Modified: lldb/trunk/source/Host/windows/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Mutex.cpp?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/Mutex.cpp (original)
+++ lldb/trunk/source/Host/windows/Mutex.cpp Wed Sep 4 08:56:11 2013
@@ -9,6 +9,7 @@
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/windows/windows.h"
#include <string.h>
#include <stdio.h>
@@ -33,7 +34,8 @@ using namespace lldb_private;
Mutex::Mutex () :
m_mutex()
{
- InitializeCriticalSection(&m_mutex);
+ m_mutex = static_cast<PCRITICAL_SECTION>(malloc(sizeof(CRITICAL_SECTION)));
+ InitializeCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
}
//----------------------------------------------------------------------
@@ -44,7 +46,8 @@ Mutex::Mutex () :
Mutex::Mutex (Mutex::Type type) :
m_mutex()
{
- InitializeCriticalSection(&m_mutex);
+ m_mutex = static_cast<PCRITICAL_SECTION>(malloc(sizeof(CRITICAL_SECTION)));
+ InitializeCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
}
//----------------------------------------------------------------------
@@ -54,7 +57,8 @@ Mutex::Mutex (Mutex::Type type) :
//----------------------------------------------------------------------
Mutex::~Mutex()
{
- DeleteCriticalSection(&m_mutex);
+ DeleteCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
+ free(m_mutex);
}
//----------------------------------------------------------------------
@@ -68,9 +72,9 @@ Mutex::~Mutex()
int
Mutex::Lock()
{
- DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), &m_mutex);
+ DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), m_mutex);
- EnterCriticalSection(&m_mutex);
+ EnterCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
return 0;
}
@@ -85,7 +89,7 @@ Mutex::Lock()
int
Mutex::TryLock(const char *failure_message)
{
- return TryEnterCriticalSection(&m_mutex) == 0;
+ return TryEnterCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex)) == 0;
}
//----------------------------------------------------------------------
@@ -100,6 +104,6 @@ Mutex::TryLock(const char *failure_messa
int
Mutex::Unlock()
{
- LeaveCriticalSection(&m_mutex);
+ LeaveCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
return 0;
}
Modified: lldb/trunk/source/Host/windows/ProcessRunLock.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessRunLock.cpp?rev=189934&r1=189933&r2=189934&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/ProcessRunLock.cpp (original)
+++ lldb/trunk/source/Host/windows/ProcessRunLock.cpp Wed Sep 4 08:56:11 2013
@@ -1,6 +1,7 @@
#ifdef _WIN32
#include "lldb/Host/ProcessRunLock.h"
+#include "lldb/Host/windows/windows.h"
namespace lldb_private {
More information about the lldb-commits
mailing list