[Lldb-commits] [lldb] r105928 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Host/macosx/Condition.cpp source/Host/macosx/Mutex.cpp source/Host/posix/ source/Host/posix/Condition.cpp source/Host/posix/Mutex.cpp
Greg Clayton
gclayton at apple.com
Sun Jun 13 21:30:13 PDT 2010
Author: gclayton
Date: Sun Jun 13 23:30:13 2010
New Revision: 105928
URL: http://llvm.org/viewvc/llvm-project?rev=105928&view=rev
Log:
Move posix specific files into posix subdirectory so they can
be shared with linux.
Updated Xcode project.
Added:
lldb/trunk/source/Host/posix/
lldb/trunk/source/Host/posix/Condition.cpp
- copied unchanged from r105926, lldb/trunk/source/Host/macosx/Condition.cpp
lldb/trunk/source/Host/posix/Mutex.cpp
- copied, changed from r105926, lldb/trunk/source/Host/macosx/Mutex.cpp
Removed:
lldb/trunk/source/Host/macosx/Condition.cpp
lldb/trunk/source/Host/macosx/Mutex.cpp
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=105928&r1=105927&r2=105928&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Jun 13 23:30:13 2010
@@ -794,9 +794,9 @@
26BC7ED610F1B86700F91463 /* ClangExpressionVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionVariable.cpp; path = source/Expression/ClangExpressionVariable.cpp; sourceTree = "<group>"; };
26BC7ED710F1B86700F91463 /* ClangStmtVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangStmtVisitor.cpp; path = source/Expression/ClangStmtVisitor.cpp; sourceTree = "<group>"; };
26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DWARFExpression.cpp; path = source/Expression/DWARFExpression.cpp; sourceTree = "<group>"; };
- 26BC7EE710F1B88F00F91463 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Condition.cpp; path = source/Host/macosx/Condition.cpp; sourceTree = "<group>"; };
+ 26BC7EE710F1B88F00F91463 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Condition.cpp; path = source/Host/posix/Condition.cpp; sourceTree = "<group>"; };
26BC7EE810F1B88F00F91463 /* Host.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Host.mm; path = source/Host/macosx/Host.mm; sourceTree = "<group>"; };
- 26BC7EE910F1B88F00F91463 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mutex.cpp; path = source/Host/macosx/Mutex.cpp; sourceTree = "<group>"; };
+ 26BC7EE910F1B88F00F91463 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mutex.cpp; path = source/Host/posix/Mutex.cpp; sourceTree = "<group>"; };
26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCBundle.cpp; path = source/Host/macosx/cfcpp/CFCBundle.cpp; sourceTree = "<group>"; };
26BC7EEE10F1B8AD00F91463 /* CFCBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCBundle.h; path = source/Host/macosx/cfcpp/CFCBundle.h; sourceTree = "<group>"; };
26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCData.cpp; path = source/Host/macosx/cfcpp/CFCData.cpp; sourceTree = "<group>"; };
@@ -1860,6 +1860,7 @@
isa = PBXGroup;
children = (
26BC7EE510F1B88100F91463 /* MacOSX */,
+ 26F62BB211C5E6C300358180 /* posix */,
26BC7DD210F1B7D500F91463 /* Condition.h */,
26BC7DD310F1B7D500F91463 /* Endian.h */,
26BC7DD410F1B7D500F91463 /* Host.h */,
@@ -1985,9 +1986,7 @@
26BC7EF710F1B8AD00F91463 /* CFCReleaser.h */,
26BC7EF810F1B8AD00F91463 /* CFCString.cpp */,
26BC7EF910F1B8AD00F91463 /* CFCString.h */,
- 26BC7EE710F1B88F00F91463 /* Condition.cpp */,
26BC7EE810F1B88F00F91463 /* Host.mm */,
- 26BC7EE910F1B88F00F91463 /* Mutex.cpp */,
2689B0B5113EE47E00A4AEDB /* Symbols.cpp */,
26B4E28B112F5DCD00AB3F64 /* TimeValue.cpp */,
);
@@ -2039,6 +2038,15 @@
sourceTree = "<group>";
usesTabs = 0;
};
+ 26F62BB211C5E6C300358180 /* posix */ = {
+ isa = PBXGroup;
+ children = (
+ 26BC7EE710F1B88F00F91463 /* Condition.cpp */,
+ 26BC7EE910F1B88F00F91463 /* Mutex.cpp */,
+ );
+ name = posix;
+ sourceTree = "<group>";
+ };
493C63D711891A8000914D5E /* ABI */ = {
isa = PBXGroup;
children = (
Removed: lldb/trunk/source/Host/macosx/Condition.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Condition.cpp?rev=105927&view=auto
==============================================================================
--- lldb/trunk/source/Host/macosx/Condition.cpp (original)
+++ lldb/trunk/source/Host/macosx/Condition.cpp (removed)
@@ -1,106 +0,0 @@
-//===-- 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()
-{
- ::pthread_cond_init (&m_condition, NULL);
-}
-
-//----------------------------------------------------------------------
-// Destructor
-//
-// Destroys the pthread condition that the object owns.
-//----------------------------------------------------------------------
-Condition::~Condition ()
-{
- ::pthread_cond_destroy (&m_condition);
-}
-
-//----------------------------------------------------------------------
-// Unblock all threads waiting for a condition variable
-//----------------------------------------------------------------------
-int
-Condition::Broadcast ()
-{
- return ::pthread_cond_broadcast (&m_condition);
-}
-
-//----------------------------------------------------------------------
-// Get accessor to the pthread condition object
-//----------------------------------------------------------------------
-pthread_cond_t *
-Condition::GetCondition ()
-{
- return &m_condition;
-}
-
-//----------------------------------------------------------------------
-// Unblocks one thread waiting for the condition variable
-//----------------------------------------------------------------------
-int
-Condition::Signal ()
-{
- return ::pthread_cond_signal (&m_condition);
-}
-
-//----------------------------------------------------------------------
-// The Wait() function atomically blocks the current thread
-// waiting on the owend 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 (pthread_mutex_t *mutex, const TimeValue *abstime, bool *timed_out)
-{
- int err = 0;
- do
- {
- if (abstime && abstime->IsValid())
- {
- struct timespec abstime_ts = abstime->GetAsTimeSpec();
- err = ::pthread_cond_timedwait (&m_condition, mutex, &abstime_ts);
- }
- else
- err = ::pthread_cond_wait (&m_condition, mutex);
- } while (err == EINTR);
-
- if (timed_out != NULL)
- {
- if (err == ETIMEDOUT)
- *timed_out = true;
- else
- *timed_out = false;
- }
-
-
- return err;
-}
-
Removed: lldb/trunk/source/Host/macosx/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Mutex.cpp?rev=105927&view=auto
==============================================================================
--- lldb/trunk/source/Host/macosx/Mutex.cpp (original)
+++ lldb/trunk/source/Host/macosx/Mutex.cpp (removed)
@@ -1,244 +0,0 @@
-//===-- 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/Core/Log.h"
-
-#if 0
-#include "lldb/Host/Host.h"
-#define DEBUG_LOG(fmt, ...) printf(fmt, ## __VA_ARGS__)
-#else
-#define DEBUG_LOG(fmt, ...)
-#endif
-
-using namespace lldb_private;
-
-//----------------------------------------------------------------------
-// Default constructor.
-//
-// This will create a scoped mutex locking object that doesn't have
-// a mutex to lock. One will need to be provided using the Reset()
-// method.
-//----------------------------------------------------------------------
-Mutex::Locker::Locker () :
- m_mutex_ptr(NULL)
-{
-}
-
-//----------------------------------------------------------------------
-// Constructor with a Mutex object.
-//
-// This will create a scoped mutex locking object that extracts the
-// mutex owned by "m" and locks it.
-//----------------------------------------------------------------------
-Mutex::Locker::Locker (Mutex& m) :
- m_mutex_ptr(m.GetMutex())
-{
- if (m_mutex_ptr)
- Mutex::Lock (m_mutex_ptr);
-}
-
-//----------------------------------------------------------------------
-// Constructor with a Mutex object pointer.
-//
-// This will create a scoped mutex locking object that extracts the
-// mutex owned by "m" and locks it.
-//----------------------------------------------------------------------
-Mutex::Locker::Locker (Mutex* m) :
- m_mutex_ptr(m ? m->GetMutex() : NULL)
-{
- if (m_mutex_ptr)
- Mutex::Lock (m_mutex_ptr);
-}
-
-//----------------------------------------------------------------------
-// Constructor with a raw pthread mutex object pointer.
-//
-// This will create a scoped mutex locking object that locks "mutex"
-//----------------------------------------------------------------------
-Mutex::Locker::Locker (pthread_mutex_t *mutex_ptr) :
- m_mutex_ptr(mutex_ptr)
-{
- if (m_mutex_ptr)
- Mutex::Lock (m_mutex_ptr);
-}
-
-//----------------------------------------------------------------------
-// Desstructor
-//
-// Unlocks any owned mutex object (if it is valid).
-//----------------------------------------------------------------------
-Mutex::Locker::~Locker ()
-{
- if (m_mutex_ptr)
- Mutex::Unlock (m_mutex_ptr);
-}
-
-//----------------------------------------------------------------------
-// Unlock the current mutex in this object (if this owns a valid
-// mutex) and lock the new "mutex" object if it is non-NULL.
-//----------------------------------------------------------------------
-void
-Mutex::Locker::Reset (pthread_mutex_t *mutex_ptr)
-{
- if (m_mutex_ptr)
- Mutex::Unlock (m_mutex_ptr);
-
- m_mutex_ptr = mutex_ptr;
- if (m_mutex_ptr)
- Mutex::Lock (m_mutex_ptr);
-}
-
-bool
-Mutex::Locker::TryLock (pthread_mutex_t *mutex_ptr)
-{
- if (m_mutex_ptr)
- Mutex::Unlock (m_mutex_ptr);
- m_mutex_ptr = NULL;
- if (mutex_ptr)
- {
- if (Mutex::TryLock (mutex_ptr) == 0)
- m_mutex_ptr = mutex_ptr;
- }
- return m_mutex_ptr != NULL;
-}
-
-//----------------------------------------------------------------------
-// Default constructor.
-//
-// Creates a pthread mutex with no attributes.
-//----------------------------------------------------------------------
-Mutex::Mutex () :
- m_mutex()
-{
- int err;
- err = ::pthread_mutex_init (&m_mutex, NULL);
- assert(err == 0);
-}
-
-//----------------------------------------------------------------------
-// Default constructor.
-//
-// Creates a pthread mutex with "type" as the mutex type.
-//----------------------------------------------------------------------
-Mutex::Mutex (Mutex::Type type) :
- m_mutex()
-{
- int err;
- ::pthread_mutexattr_t attr;
- err = ::pthread_mutexattr_init (&attr);
- assert(err == 0);
- switch (type)
- {
- case eMutexTypeNormal:
- err = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL);
- break;
-
- case eMutexTypeRecursive:
- err = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
- break;
-
- default:
- err = -1;
- break;
- }
- assert(err == 0);
- err = ::pthread_mutex_init (&m_mutex, &attr);
- assert(err == 0);
- err = ::pthread_mutexattr_destroy (&attr);
- assert(err == 0);
-}
-
-//----------------------------------------------------------------------
-// Destructor.
-//
-// Destroys the mutex owned by this object.
-//----------------------------------------------------------------------
-Mutex::~Mutex()
-{
- int err;
- err = ::pthread_mutex_destroy (&m_mutex);
-}
-
-//----------------------------------------------------------------------
-// Mutex get accessor.
-//----------------------------------------------------------------------
-pthread_mutex_t *
-Mutex::GetMutex()
-{
- return &m_mutex;
-}
-
-int
-Mutex::Lock (pthread_mutex_t *mutex_ptr)
-{
- DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr);
- int err = ::pthread_mutex_lock (mutex_ptr);
- DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_lock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err);
- return err;
-}
-
-int
-Mutex::TryLock (pthread_mutex_t *mutex_ptr)
-{
- int err = ::pthread_mutex_trylock (mutex_ptr);
- DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_trylock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err);
- return err;
-}
-
-int
-Mutex::Unlock (pthread_mutex_t *mutex_ptr)
-{
- int err = ::pthread_mutex_unlock (mutex_ptr);
- DEBUG_LOG ("[%4.4x/%4.4x] pthread_mutex_unlock (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), mutex_ptr, err);
- return err;
-}
-
-//----------------------------------------------------------------------
-// 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()
-{
- return Mutex::Lock (&m_mutex);
-}
-
-//----------------------------------------------------------------------
-// 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()
-{
- return Mutex::TryLock (&m_mutex);
-}
-
-//----------------------------------------------------------------------
-// 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()
-{
- return Mutex::Unlock (&m_mutex);
-}
Copied: lldb/trunk/source/Host/posix/Mutex.cpp (from r105926, lldb/trunk/source/Host/macosx/Mutex.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/Mutex.cpp?p2=lldb/trunk/source/Host/posix/Mutex.cpp&p1=lldb/trunk/source/Host/macosx/Mutex.cpp&r1=105926&r2=105928&rev=105928&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Mutex.cpp (original)
+++ lldb/trunk/source/Host/posix/Mutex.cpp Sun Jun 13 23:30:13 2010
@@ -8,10 +8,12 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/Mutex.h"
-#include "lldb/Core/Log.h"
#if 0
-#include "lldb/Host/Host.h"
+// 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, ...)
More information about the lldb-commits
mailing list