mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10643] Update the ACE part we use to 5.8.2
Signed-off-by: Neo2003 <Neo.2003@Hotmail.fr>
This commit is contained in:
parent
8f71d95c0d
commit
23c920ca4b
739 changed files with 22031 additions and 40373 deletions
|
|
@ -1,8 +1,6 @@
|
|||
#include "ace/OS_NS_Thread.h"
|
||||
// $Id: OS_NS_Thread.cpp 91523 2010-08-27 14:18:02Z johnnyw $
|
||||
|
||||
ACE_RCSID (ace,
|
||||
OS_NS_Thread,
|
||||
"$Id: OS_NS_Thread.cpp 81345 2008-04-13 07:28:11Z johnnyw $")
|
||||
#include "ace/OS_NS_Thread.h"
|
||||
|
||||
#if !defined (ACE_HAS_INLINED_OSCALLS)
|
||||
# include "ace/OS_NS_Thread.inl"
|
||||
|
|
@ -33,9 +31,9 @@ ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME (void *args)
|
|||
#if !defined(ACE_WIN32) && defined (__IBMCPP__) && (__IBMCPP__ >= 400)
|
||||
# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \
|
||||
(*THR_ID = ::_beginthreadex ((void(_Optlink*)(void*))ENTRY_POINT, STACK, STACKSIZE, ARGS), *THR_ID)
|
||||
#elif defined (ACE_HAS_WINCE) && defined (UNDER_CE) && (UNDER_CE >= 211)
|
||||
#elif defined (ACE_HAS_WINCE)
|
||||
# define ACE_BEGINTHREADEX(STACK, STACKSIZE, ENTRY_POINT, ARGS, FLAGS, THR_ID) \
|
||||
CreateThread (0, STACKSIZE, (unsigned long (__stdcall *) (void *)) ENTRY_POINT, ARGS, (FLAGS) & CREATE_SUSPENDED, (unsigned long *) THR_ID)
|
||||
CreateThread (0, STACKSIZE, (unsigned long (__stdcall *) (void *)) ENTRY_POINT, ARGS, (FLAGS) & (CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION), (unsigned long *) THR_ID)
|
||||
#elif defined(ACE_HAS_WTHREADS)
|
||||
// Green Hills compiler gets confused when __stdcall is imbedded in
|
||||
// parameter list, so we define the type ACE_WIN32THRFUNC_T and use it
|
||||
|
|
@ -117,17 +115,15 @@ ACE_OS_thread_key_t ACE_TSS_Emulation::native_tss_key_;
|
|||
# if defined (ACE_HAS_THR_C_FUNC)
|
||||
extern "C"
|
||||
void
|
||||
ACE_TSS_Emulation_cleanup (void *ptr)
|
||||
ACE_TSS_Emulation_cleanup (void *)
|
||||
{
|
||||
ACE_UNUSED_ARG (ptr);
|
||||
// Really this must be used for ACE_TSS_Emulation code to make the TSS
|
||||
// cleanup
|
||||
}
|
||||
# else
|
||||
void
|
||||
ACE_TSS_Emulation_cleanup (void *ptr)
|
||||
ACE_TSS_Emulation_cleanup (void *)
|
||||
{
|
||||
ACE_UNUSED_ARG (ptr);
|
||||
// Really this must be used for ACE_TSS_Emulation code to make the TSS
|
||||
// cleanup
|
||||
}
|
||||
|
|
@ -711,7 +707,7 @@ TSS_Cleanup_Instance::~TSS_Cleanup_Instance (void)
|
|||
|
||||
// scope the guard
|
||||
{
|
||||
ACE_Guard<ACE_Thread_Mutex> guard (*mutex_);
|
||||
ACE_GUARD (ACE_Thread_Mutex, guard, *mutex_);
|
||||
if (ptr_ != 0)
|
||||
{
|
||||
if (ACE_BIT_ENABLED (flags_, FLAG_DELETING))
|
||||
|
|
@ -1142,25 +1138,6 @@ ACE_OS::cleanup_tss (const u_int main_thread)
|
|||
/*****************************************************************************/
|
||||
|
||||
#if defined (ACE_LACKS_COND_T)
|
||||
// NOTE: The ACE_OS::cond_* functions for some non-Unix platforms are
|
||||
// defined here either because they're too big to be inlined, or
|
||||
// to avoid use before definition if they were inline.
|
||||
|
||||
// @@ The following functions could be inlined if i could figure where
|
||||
// to put it among the #ifdefs!
|
||||
int
|
||||
ACE_OS::condattr_init (ACE_condattr_t &attributes, int type)
|
||||
{
|
||||
attributes.type = type;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ACE_OS::condattr_destroy (ACE_condattr_t &)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ACE_OS::cond_broadcast (ACE_cond_t *cv)
|
||||
{
|
||||
|
|
@ -1170,8 +1147,12 @@ ACE_OS::cond_broadcast (ACE_cond_t *cv)
|
|||
|
||||
// This is needed to ensure that <waiters_> and <was_broadcast_> are
|
||||
// consistent relative to each other.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
int have_waiters = 0;
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool have_waiters = false;
|
||||
|
||||
if (cv->waiters_ > 0)
|
||||
{
|
||||
|
|
@ -1180,9 +1161,15 @@ ACE_OS::cond_broadcast (ACE_cond_t *cv)
|
|||
// cond_wait() method know how to optimize itself. Be sure to
|
||||
// set this with the <waiters_lock_> held.
|
||||
cv->was_broadcast_ = 1;
|
||||
have_waiters = 1;
|
||||
have_waiters = true;
|
||||
}
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
{
|
||||
// This is really bad, we have the lock but can't release it anymore
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
if (have_waiters)
|
||||
{
|
||||
|
|
@ -1218,8 +1205,14 @@ ACE_OS::cond_destroy (ACE_cond_t *cv)
|
|||
# elif defined (ACE_VXWORKS)
|
||||
ACE_OS::sema_destroy (&cv->waiters_done_);
|
||||
# endif /* ACE_VXWORKS */
|
||||
ACE_OS::thread_mutex_destroy (&cv->waiters_lock_);
|
||||
return ACE_OS::sema_destroy (&cv->sema_);
|
||||
int result = 0;
|
||||
if (ACE_OS::thread_mutex_destroy (&cv->waiters_lock_) != 0)
|
||||
result = -1;
|
||||
|
||||
if (ACE_OS::sema_destroy (&cv->sema_) != 0)
|
||||
result = -1;
|
||||
|
||||
return result;
|
||||
# else
|
||||
ACE_UNUSED_ARG (cv);
|
||||
ACE_NOTSUP_RETURN (-1);
|
||||
|
|
@ -1317,11 +1310,13 @@ ACE_OS::cond_signal (ACE_cond_t *cv)
|
|||
// lost wakeup bug... This is needed to ensure that the <waiters_>
|
||||
// value is not in an inconsistent internal state while being
|
||||
// updated by another thread.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
int have_waiters = cv->waiters_ > 0;
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
bool const have_waiters = cv->waiters_ > 0;
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
if (have_waiters != 0)
|
||||
if (have_waiters)
|
||||
return ACE_OS::sema_post (&cv->sema_);
|
||||
else
|
||||
return 0; // No-op
|
||||
|
|
@ -1338,19 +1333,27 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
|
|||
ACE_OS_TRACE ("ACE_OS::cond_wait");
|
||||
# if defined (ACE_HAS_THREADS)
|
||||
// Prevent race conditions on the <waiters_> count.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
++cv->waiters_;
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
int result = 0;
|
||||
|
||||
# if defined (ACE_HAS_SIGNAL_OBJECT_AND_WAIT)
|
||||
if (external_mutex->type_ == USYNC_PROCESS)
|
||||
// This call will automatically release the mutex and wait on the semaphore.
|
||||
ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (external_mutex->proc_mutex_,
|
||||
cv->sema_, INFINITE, FALSE),
|
||||
result),
|
||||
int, -1, result);
|
||||
{
|
||||
// This call will automatically release the mutex and wait on the semaphore.
|
||||
ACE_WIN32CALL (ACE_ADAPT_RETVAL (::SignalObjectAndWait (external_mutex->proc_mutex_,
|
||||
cv->sema_, INFINITE, FALSE),
|
||||
result),
|
||||
int, -1, result);
|
||||
if (result == -1)
|
||||
return result;
|
||||
}
|
||||
else
|
||||
# endif /* ACE_HAS_SIGNAL_OBJECT_AND_WAIT */
|
||||
{
|
||||
|
|
@ -1367,16 +1370,18 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
|
|||
}
|
||||
|
||||
// Reacquire lock to avoid race conditions on the <waiters_> count.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
// We're ready to return, so there's one less waiter.
|
||||
--cv->waiters_;
|
||||
|
||||
int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
bool const last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
|
||||
// Release the lock so that other collaborating threads can make
|
||||
// progress.
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
if (result == -1)
|
||||
// Bad things happened, so let's just return below.
|
||||
|
|
@ -1398,7 +1403,8 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
|
|||
// We must always regain the <external_mutex>, even when
|
||||
// errors occur because that's the guarantee that we give to
|
||||
// our callers.
|
||||
ACE_OS::mutex_lock (external_mutex);
|
||||
if (ACE_OS::mutex_lock (external_mutex) != 0)
|
||||
return -1;
|
||||
|
||||
return result;
|
||||
/* NOTREACHED */
|
||||
|
|
@ -1438,17 +1444,19 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
# if defined (ACE_HAS_WTHREADS) || defined (ACE_VXWORKS)
|
||||
|
||||
// Prevent race conditions on the <waiters_> count.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
cv->waiters_++;
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
++cv->waiters_;
|
||||
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
int result = 0;
|
||||
ACE_Errno_Guard error (errno, 0);
|
||||
int msec_timeout;
|
||||
int msec_timeout = 0;
|
||||
|
||||
if (timeout->sec () == 0 && timeout->usec () == 0)
|
||||
msec_timeout = 0; // Do a "poll."
|
||||
else
|
||||
if (timeout != 0 && *timeout != ACE_Time_Value::zero)
|
||||
{
|
||||
// Note that we must convert between absolute time (which is
|
||||
// passed as a parameter) and relative time (which is what
|
||||
|
|
@ -1457,9 +1465,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
|
||||
// Watchout for situations where a context switch has caused the
|
||||
// current time to be > the timeout.
|
||||
if (relative_time < ACE_Time_Value::zero)
|
||||
msec_timeout = 0;
|
||||
else
|
||||
if (relative_time > ACE_Time_Value::zero)
|
||||
msec_timeout = relative_time.msec ();
|
||||
}
|
||||
|
||||
|
|
@ -1501,12 +1507,15 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
}
|
||||
|
||||
// Reacquire lock to avoid race conditions.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
cv->waiters_--;
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
--cv->waiters_;
|
||||
|
||||
int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
bool const last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
# if defined (ACE_WIN32)
|
||||
if (result != WAIT_OBJECT_0)
|
||||
|
|
@ -1554,10 +1563,13 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
result),
|
||||
int, -1, result);
|
||||
else
|
||||
// We must always regain the <external_Mutex>, even when
|
||||
// errors occur because that's the guarantee that we give to
|
||||
// our callers.
|
||||
ACE_OS::mutex_lock (external_mutex);
|
||||
{
|
||||
// We must always regain the <external_Mutex>, even when
|
||||
// errors occur because that's the guarantee that we give to
|
||||
// our callers.
|
||||
if (ACE_OS::mutex_lock (external_mutex) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
/* NOTREACHED */
|
||||
|
|
@ -1567,16 +1579,20 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
// if" statement since the caller may have timed out and hence the
|
||||
// result would have been -1 above.
|
||||
if (last_waiter)
|
||||
// Release the signaler/broadcaster if we're the last waiter.
|
||||
{
|
||||
// Release the signaler/broadcaster if we're the last waiter.
|
||||
# if defined (ACE_WIN32)
|
||||
ACE_OS::event_signal (&cv->waiters_done_);
|
||||
if (ACE_OS::event_signal (&cv->waiters_done_) != 0)
|
||||
# else
|
||||
ACE_OS::sema_post (&cv->waiters_done_);
|
||||
if (ACE_OS::sema_post (&cv->waiters_done_) != 0)
|
||||
# endif /* ACE_WIN32 */
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We must always regain the <external_mutex>, even when errors
|
||||
// occur because that's the guarantee that we give to our callers.
|
||||
ACE_OS::mutex_lock (external_mutex);
|
||||
if (ACE_OS::mutex_lock (external_mutex) != 0)
|
||||
return -1;
|
||||
|
||||
return result;
|
||||
# endif /* ACE_HAS_WTHREADS || ACE_HAS_VXWORKS */
|
||||
|
|
@ -1587,8 +1603,22 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
ACE_NOTSUP_RETURN (-1);
|
||||
# endif /* ACE_HAS_THREADS */
|
||||
}
|
||||
#else
|
||||
int
|
||||
ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg)
|
||||
{
|
||||
ACE_condattr_t attributes;
|
||||
if (ACE_OS::condattr_init (attributes, type) == 0
|
||||
&& ACE_OS::cond_init (cv, attributes, name, arg) == 0)
|
||||
{
|
||||
(void) ACE_OS::condattr_destroy (attributes);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif /* ACE_LACKS_COND_T */
|
||||
|
||||
# if defined (ACE_HAS_WTHREADS)
|
||||
#if defined (ACE_WIN32) && defined (ACE_HAS_WTHREADS)
|
||||
int
|
||||
ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
||||
ACE_thread_mutex_t *external_mutex,
|
||||
|
|
@ -1600,18 +1630,35 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
if (timeout == 0)
|
||||
return ACE_OS::cond_wait (cv, external_mutex);
|
||||
|
||||
# if defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
|
||||
int msec_timeout = 0;
|
||||
int result = 0;
|
||||
|
||||
ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ());
|
||||
// Watchout for situations where a context switch has caused the
|
||||
// current time to be > the timeout.
|
||||
if (relative_time > ACE_Time_Value::zero)
|
||||
msec_timeout = relative_time.msec ();
|
||||
|
||||
ACE_OSCALL (ACE_ADAPT_RETVAL (::SleepConditionVariableCS (cv, external_mutex, msec_timeout),
|
||||
result),
|
||||
int, -1, result);
|
||||
return result;
|
||||
#else
|
||||
// Prevent race conditions on the <waiters_> count.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
cv->waiters_++;
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
++cv->waiters_;
|
||||
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
int result = 0;
|
||||
int error = 0;
|
||||
int msec_timeout;
|
||||
int msec_timeout = 0;
|
||||
|
||||
if (timeout->sec () == 0 && timeout->usec () == 0)
|
||||
msec_timeout = 0; // Do a "poll."
|
||||
else
|
||||
if (timeout != 0 && *timeout != ACE_Time_Value::zero)
|
||||
{
|
||||
// Note that we must convert between absolute time (which is
|
||||
// passed as a parameter) and relative time (which is what
|
||||
|
|
@ -1620,9 +1667,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
|
||||
// Watchout for situations where a context switch has caused the
|
||||
// current time to be > the timeout.
|
||||
if (relative_time < ACE_Time_Value::zero)
|
||||
msec_timeout = 0;
|
||||
else
|
||||
if (relative_time > ACE_Time_Value::zero)
|
||||
msec_timeout = relative_time.msec ();
|
||||
}
|
||||
|
||||
|
|
@ -1646,13 +1691,15 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
# endif /* ACE_USES_WINCE_SEMA_SIMULATION */
|
||||
|
||||
// Reacquire lock to avoid race conditions.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
cv->waiters_--;
|
||||
--cv->waiters_;
|
||||
|
||||
int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
bool const last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
if (result != WAIT_OBJECT_0)
|
||||
{
|
||||
|
|
@ -1669,14 +1716,26 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
|
|||
}
|
||||
|
||||
if (last_waiter)
|
||||
// Release the signaler/broadcaster if we're the last waiter.
|
||||
ACE_OS::event_signal (&cv->waiters_done_);
|
||||
|
||||
{
|
||||
// Release the signaler/broadcaster if we're the last waiter.
|
||||
if (ACE_OS::event_signal (&cv->waiters_done_) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We must always regain the <external_mutex>, even when errors
|
||||
// occur because that's the guarantee that we give to our callers.
|
||||
ACE_OS::thread_mutex_lock (external_mutex);
|
||||
errno = error;
|
||||
if (ACE_OS::thread_mutex_lock (external_mutex) != 0)
|
||||
result = -1;
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
/* This assignment must only be done if error != 0,
|
||||
* since writing 0 to errno violates the POSIX specification.
|
||||
*/
|
||||
errno = error;
|
||||
}
|
||||
return result;
|
||||
# endif
|
||||
# else
|
||||
ACE_NOTSUP_RETURN (-1);
|
||||
# endif /* ACE_HAS_THREADS */
|
||||
|
|
@ -1688,9 +1747,17 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
|
|||
{
|
||||
ACE_OS_TRACE ("ACE_OS::cond_wait");
|
||||
# if defined (ACE_HAS_THREADS)
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
cv->waiters_++;
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
# if defined (ACE_HAS_WTHREADS_CONDITION_VARIABLE)
|
||||
int result;
|
||||
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::SleepConditionVariableCS (cv, external_mutex, INFINITE), result),
|
||||
int, -1);
|
||||
#else
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
++cv->waiters_;
|
||||
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
int result = 0;
|
||||
int error = 0;
|
||||
|
|
@ -1716,13 +1783,15 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
|
|||
# endif /* ACE_USES_WINCE_SEMA_SIMULATION */
|
||||
|
||||
// Reacquire lock to avoid race conditions.
|
||||
ACE_OS::thread_mutex_lock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
cv->waiters_--;
|
||||
|
||||
int last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
bool const last_waiter = cv->was_broadcast_ && cv->waiters_ == 0;
|
||||
|
||||
ACE_OS::thread_mutex_unlock (&cv->waiters_lock_);
|
||||
if (ACE_OS::thread_mutex_unlock (&cv->waiters_lock_) != 0)
|
||||
return -1;
|
||||
|
||||
if (result != WAIT_OBJECT_0)
|
||||
{
|
||||
|
|
@ -1737,35 +1806,32 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
|
|||
}
|
||||
}
|
||||
else if (last_waiter)
|
||||
// Release the signaler/broadcaster if we're the last waiter.
|
||||
ACE_OS::event_signal (&cv->waiters_done_);
|
||||
{
|
||||
// Release the signaler/broadcaster if we're the last waiter.
|
||||
if (ACE_OS::event_signal (&cv->waiters_done_) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We must always regain the <external_mutex>, even when errors
|
||||
// occur because that's the guarantee that we give to our callers.
|
||||
ACE_OS::thread_mutex_lock (external_mutex);
|
||||
if (ACE_OS::thread_mutex_lock (external_mutex) != 0)
|
||||
result = -1;
|
||||
|
||||
// Reset errno in case mutex_lock() also fails...
|
||||
errno = error;
|
||||
if (error != 0)
|
||||
{
|
||||
/* This assignment must only be done if error != 0,
|
||||
* since writing 0 to errno violates the POSIX specification.
|
||||
*/
|
||||
errno = error;
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
# else
|
||||
ACE_NOTSUP_RETURN (-1);
|
||||
# endif /* ACE_HAS_THREADS */
|
||||
}
|
||||
# endif /* ACE_HAS_WTHREADS */
|
||||
#else
|
||||
int
|
||||
ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg)
|
||||
{
|
||||
ACE_condattr_t attributes;
|
||||
if (ACE_OS::condattr_init (attributes, type) == 0
|
||||
&& ACE_OS::cond_init (cv, attributes, name, arg) == 0)
|
||||
{
|
||||
(void) ACE_OS::condattr_destroy (attributes);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif /* ACE_LACKS_COND_T */
|
||||
|
||||
/*****************************************************************************/
|
||||
// CONDITIONS END
|
||||
|
|
@ -1789,7 +1855,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m,
|
|||
ACE_UNUSED_ARG (name);
|
||||
ACE_UNUSED_ARG (sa);
|
||||
|
||||
# if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
|
||||
# if defined (ACE_PTHREAD_MUTEXATTR_T_INITIALIZE)
|
||||
/* Tests show that VxWorks 6.x pthread lib does not only
|
||||
* require zeroing of mutex/condition objects to function correctly
|
||||
* but also of the attribute objects.
|
||||
|
|
@ -1839,7 +1905,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m,
|
|||
|
||||
if (result == 0)
|
||||
{
|
||||
# if defined (ACE_VXWORKS)&& (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
|
||||
# if defined (ACE_PTHREAD_MUTEX_T_INITIALIZE)
|
||||
/* VxWorks 6.x API reference states:
|
||||
* If the memory for the mutex variable object has been allocated
|
||||
* dynamically, it is a good policy to always zero out the
|
||||
|
|
@ -1897,7 +1963,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m,
|
|||
ACE_FAIL_RETURN (-1);
|
||||
else
|
||||
{
|
||||
// Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
|
||||
// Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
|
||||
ACE_OS::set_errno_to_last_error ();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1990,7 +2056,11 @@ ACE_OS::mutex_init (ACE_mutex_t *m,
|
|||
if (m->proc_mutex_ == 0)
|
||||
ACE_FAIL_RETURN (-1);
|
||||
else
|
||||
return 0;
|
||||
{
|
||||
// Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
|
||||
ACE_OS::set_errno_to_last_error ();
|
||||
return 0;
|
||||
}
|
||||
case USYNC_THREAD:
|
||||
return ACE_OS::thread_mutex_init (&m->thr_mutex_,
|
||||
lock_type,
|
||||
|
|
@ -2395,7 +2465,8 @@ ACE_OS::event_destroy (ACE_event_t *event)
|
|||
&& errno == EBUSY)
|
||||
{
|
||||
event->eventdata_->is_signaled_ = 1;
|
||||
ACE_OS::cond_broadcast (&event->eventdata_->condition_);
|
||||
if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
|
||||
return -1;
|
||||
ACE_OS::thr_yield ();
|
||||
}
|
||||
# else
|
||||
|
|
@ -2454,7 +2525,8 @@ ACE_OS::event_destroy (ACE_event_t *event)
|
|||
&& errno == EBUSY)
|
||||
{
|
||||
event->eventdata_->is_signaled_ = 1;
|
||||
ACE_OS::cond_broadcast (&event->eventdata_->condition_);
|
||||
if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
|
||||
return -1;
|
||||
ACE_OS::thr_yield ();
|
||||
}
|
||||
# else
|
||||
|
|
@ -2503,7 +2575,11 @@ ACE_OS::event_init (ACE_event_t *event,
|
|||
if (*event == 0)
|
||||
ACE_FAIL_RETURN (-1);
|
||||
else
|
||||
return 0;
|
||||
{
|
||||
// Make sure to set errno to ERROR_ALREADY_EXISTS if necessary.
|
||||
ACE_OS::set_errno_to_last_error ();
|
||||
return 0;
|
||||
}
|
||||
#elif defined (ACE_HAS_THREADS)
|
||||
ACE_UNUSED_ARG (sa);
|
||||
event->eventdata_ = 0;
|
||||
|
|
@ -2809,9 +2885,11 @@ ACE_OS::event_pulse (ACE_event_t *event)
|
|||
(!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
|
||||
(!defined (ACE_USES_FIFO_SEM) && \
|
||||
(!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
|
||||
ACE_OS::mutex_unlock (&event->eventdata_->lock_);
|
||||
if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
|
||||
return -1;
|
||||
# else
|
||||
ACE_OS::sema_post (&event->lock_);
|
||||
if (ACE_OS::sema_post (&event->lock_) != 0)
|
||||
return -1;
|
||||
# endif
|
||||
if (result == -1)
|
||||
// Reset errno in case mutex_unlock() also fails...
|
||||
|
|
@ -2853,9 +2931,11 @@ ACE_OS::event_reset (ACE_event_t *event)
|
|||
(!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
|
||||
(!defined (ACE_USES_FIFO_SEM) && \
|
||||
(!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
|
||||
ACE_OS::mutex_unlock (&event->eventdata_->lock_);
|
||||
if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
|
||||
return -1;
|
||||
# else
|
||||
ACE_OS::sema_post (&event->lock_);
|
||||
if (ACE_OS::sema_post (&event->lock_) != 0)
|
||||
return -1;
|
||||
# endif
|
||||
}
|
||||
else
|
||||
|
|
@ -2937,9 +3017,11 @@ ACE_OS::event_signal (ACE_event_t *event)
|
|||
(!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
|
||||
(!defined (ACE_USES_FIFO_SEM) && \
|
||||
(!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
|
||||
ACE_OS::mutex_unlock (&event->eventdata_->lock_);
|
||||
if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
|
||||
return -1;
|
||||
# else
|
||||
ACE_OS::sema_post (&event->lock_);
|
||||
if (ACE_OS::sema_post (&event->lock_) != 0)
|
||||
return -1;
|
||||
# endif
|
||||
|
||||
if (result == -1)
|
||||
|
|
@ -2968,7 +3050,7 @@ ACE_OS::event_timedwait (ACE_event_t *event,
|
|||
#if defined (ACE_WIN32)
|
||||
DWORD result;
|
||||
|
||||
if (timeout->sec () == 0 && timeout->usec () == 0)
|
||||
if (*timeout == ACE_Time_Value::zero)
|
||||
// Do a "poll".
|
||||
result = ::WaitForSingleObject (*event, 0);
|
||||
else
|
||||
|
|
@ -2979,7 +3061,7 @@ ACE_OS::event_timedwait (ACE_event_t *event,
|
|||
// WaitForSingleObjects() expects).
|
||||
// <timeout> parameter is given in absolute or relative value
|
||||
// depending on parameter <use_absolute_time>.
|
||||
int msec_timeout;
|
||||
int msec_timeout = 0;
|
||||
if (use_absolute_time)
|
||||
{
|
||||
// Time is given in absolute time, we should use
|
||||
|
|
@ -2989,9 +3071,7 @@ ACE_OS::event_timedwait (ACE_event_t *event,
|
|||
// Watchout for situations where a context switch has caused
|
||||
// the current time to be > the timeout. Thanks to Norbert
|
||||
// Rapp <NRapp@nexus-informatics.de> for pointing this.
|
||||
if (relative_time < ACE_Time_Value::zero)
|
||||
msec_timeout = 0;
|
||||
else
|
||||
if (relative_time > ACE_Time_Value::zero)
|
||||
msec_timeout = relative_time.msec ();
|
||||
}
|
||||
else
|
||||
|
|
@ -3137,9 +3217,11 @@ ACE_OS::event_timedwait (ACE_event_t *event,
|
|||
(!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
|
||||
(!defined (ACE_USES_FIFO_SEM) && \
|
||||
(!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
|
||||
ACE_OS::mutex_unlock (&event->eventdata_->lock_);
|
||||
if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
|
||||
return -1;
|
||||
# else
|
||||
ACE_OS::sema_post (&event->lock_);
|
||||
if (ACE_OS::sema_post (&event->lock_) != 0)
|
||||
return -1;
|
||||
# endif
|
||||
|
||||
if (result == -1)
|
||||
|
|
@ -3279,9 +3361,11 @@ ACE_OS::event_wait (ACE_event_t *event)
|
|||
(!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
|
||||
(!defined (ACE_USES_FIFO_SEM) && \
|
||||
(!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
|
||||
ACE_OS::mutex_unlock (&event->eventdata_->lock_);
|
||||
if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
|
||||
return -1;
|
||||
# else
|
||||
ACE_OS::sema_post (&event->lock_);
|
||||
if (ACE_OS::sema_post (&event->lock_) != 0)
|
||||
return -1;
|
||||
# endif
|
||||
|
||||
if (result == -1)
|
||||
|
|
@ -3422,7 +3506,7 @@ ACE_OS::rwlock_init (ACE_rwlock_t *rw,
|
|||
rw->ref_count_ = 0;
|
||||
rw->num_waiting_writers_ = 0;
|
||||
rw->num_waiting_readers_ = 0;
|
||||
rw->important_writer_ = 0;
|
||||
rw->important_writer_ = false;
|
||||
result = 0;
|
||||
}
|
||||
ACE_OS::condattr_destroy (attributes);
|
||||
|
|
@ -3432,10 +3516,14 @@ ACE_OS::rwlock_init (ACE_rwlock_t *rw,
|
|||
{
|
||||
// Save/restore errno.
|
||||
ACE_Errno_Guard error (errno);
|
||||
ACE_OS::mutex_destroy (&rw->lock_);
|
||||
ACE_OS::cond_destroy (&rw->waiting_readers_);
|
||||
ACE_OS::cond_destroy (&rw->waiting_writers_);
|
||||
ACE_OS::cond_destroy (&rw->waiting_important_writer_);
|
||||
|
||||
/* We're about to return -1 anyway, so
|
||||
* no need to check return values of these clean-up calls:
|
||||
*/
|
||||
(void)ACE_OS::mutex_destroy (&rw->lock_);
|
||||
(void)ACE_OS::cond_destroy (&rw->waiting_readers_);
|
||||
(void)ACE_OS::cond_destroy (&rw->waiting_writers_);
|
||||
(void)ACE_OS::cond_destroy (&rw->waiting_important_writer_);
|
||||
}
|
||||
return result;
|
||||
# else
|
||||
|
|
@ -3826,7 +3914,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
|
|||
|
||||
# if defined (ACE_HAS_PTHREADS)
|
||||
int result;
|
||||
# if defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600) && (ACE_VXWORKS <= 0x620)
|
||||
# if defined (ACE_PTHREAD_ATTR_T_INITIALIZE)
|
||||
/* Tests show that VxWorks 6.x pthread lib does not only
|
||||
* require zeroing of mutex/condition objects to function correctly
|
||||
* but also of the attribute objects.
|
||||
|
|
@ -4318,10 +4406,15 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
|
|||
// Set the priority of the new thread and then let it
|
||||
// continue, but only if the user didn't start it suspended
|
||||
// in the first place!
|
||||
ACE_OS::thr_setprio (*thr_handle, priority);
|
||||
if (ACE_OS::thr_setprio (*thr_handle, priority) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (start_suspended == 0)
|
||||
ACE_OS::thr_continue (*thr_handle);
|
||||
{
|
||||
ACE_OS::thr_continue (*thr_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
# if 0
|
||||
|
|
@ -4624,6 +4717,14 @@ ACE_OS::thr_get_affinity (ACE_hthread_t thr_id,
|
|||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#elif defined (ACE_HAS_TASKCPUAFFINITYSET)
|
||||
ACE_UNUSED_ARG (cpu_set_size);
|
||||
int result = 0;
|
||||
if (ACE_ADAPT_RETVAL (::taskCpuAffinitySet (thr_id, *cpu_mask), result) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
ACE_UNUSED_ARG (thr_id);
|
||||
ACE_UNUSED_ARG (cpu_set_size);
|
||||
|
|
@ -4666,6 +4767,13 @@ ACE_OS::thr_set_affinity (ACE_hthread_t thr_id,
|
|||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#elif defined (ACE_HAS_TASKCPUAFFINITYSET)
|
||||
int result = 0;
|
||||
if (ACE_ADAPT_RETVAL (::taskCpuAffinitySet (thr_id, *cpu_mask), result) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
ACE_UNUSED_ARG (thr_id);
|
||||
ACE_UNUSED_ARG (cpu_set_size);
|
||||
|
|
@ -5121,59 +5229,62 @@ add_to_argv (int& argc, char** argv, int max_args, char* string)
|
|||
size_t previous = 0;
|
||||
size_t length = ACE_OS::strlen (string);
|
||||
|
||||
// We use <= to make sure that we get the last argument
|
||||
for (size_t i = 0; i <= length; i++)
|
||||
if (length > 0)
|
||||
{
|
||||
// Is it a double quote that hasn't been escaped?
|
||||
if (string[i] == '\"' && (i == 0 || string[i - 1] != '\\'))
|
||||
// We use <= to make sure that we get the last argument
|
||||
for (size_t i = 0; i <= length; i++)
|
||||
{
|
||||
indouble ^= 1;
|
||||
if (indouble)
|
||||
// Is it a double quote that hasn't been escaped?
|
||||
if (string[i] == '\"' && (i == 0 || string[i - 1] != '\\'))
|
||||
{
|
||||
// We have just entered a double quoted string, so
|
||||
// save the starting position of the contents.
|
||||
previous = i + 1;
|
||||
indouble ^= 1;
|
||||
if (indouble)
|
||||
{
|
||||
// We have just entered a double quoted string, so
|
||||
// save the starting position of the contents.
|
||||
previous = i + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have just left a double quoted string, so
|
||||
// zero out the ending double quote.
|
||||
string[i] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (string[i] == '\\') // Escape the next character
|
||||
{
|
||||
// The next character is automatically skipped because
|
||||
// of the memmove().
|
||||
ACE_OS::memmove (string + i, string + i + 1, length);
|
||||
--length;
|
||||
}
|
||||
else if (!indouble &&
|
||||
(ACE_OS::ace_isspace (string[i]) || string[i] == '\0'))
|
||||
{
|
||||
// We have just left a double quoted string, so
|
||||
// zero out the ending double quote.
|
||||
string[i] = '\0';
|
||||
}
|
||||
}
|
||||
else if (string[i] == '\\') // Escape the next character
|
||||
{
|
||||
// The next character is automatically
|
||||
// skipped because of the strcpy
|
||||
ACE_OS::strcpy (string + i, string + i + 1);
|
||||
length--;
|
||||
}
|
||||
else if (!indouble &&
|
||||
(ACE_OS::ace_isspace (string[i]) || string[i] == '\0'))
|
||||
{
|
||||
string[i] = '\0';
|
||||
if (argc < max_args)
|
||||
{
|
||||
argv[argc] = string + previous;
|
||||
argc++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ACE_OS::fprintf (stderr, "spae(): number of arguments "
|
||||
"limited to %d\n", max_args);
|
||||
}
|
||||
if (argc < max_args)
|
||||
{
|
||||
argv[argc] = string + previous;
|
||||
++argc;
|
||||
}
|
||||
else
|
||||
{
|
||||
ACE_OS::fprintf (stderr, "spae(): number of arguments "
|
||||
"limited to %d\n", max_args);
|
||||
}
|
||||
|
||||
// Skip over whitespace in between arguments
|
||||
for(++i; i < length && ACE_OS::ace_isspace (string[i]); ++i)
|
||||
{
|
||||
// Skip over whitespace in between arguments
|
||||
for(++i; i < length && ACE_OS::ace_isspace (string[i]); ++i)
|
||||
{
|
||||
}
|
||||
|
||||
// Save the starting point for the next time around
|
||||
previous = i;
|
||||
|
||||
// Make sure we don't skip over a character due
|
||||
// to the above loop to skip over whitespace
|
||||
--i;
|
||||
}
|
||||
|
||||
// Save the starting point for the next time around
|
||||
previous = i;
|
||||
|
||||
// Make sure we don't skip over a character due
|
||||
// to the above loop to skip over whitespace
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5299,9 +5410,10 @@ vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...)
|
|||
int argc = 1;
|
||||
|
||||
// Peel off arguments to run_main () and put into argv.
|
||||
|
||||
if (arg)
|
||||
add_to_argv(argc, argv, ACE_MAX_ARGS, arg);
|
||||
{
|
||||
add_to_argv(argc, argv, ACE_MAX_ARGS, arg);
|
||||
}
|
||||
|
||||
// fill unused argv slots with 0 to get rid of leftovers
|
||||
// from previous invocations
|
||||
|
|
@ -5330,4 +5442,18 @@ vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...)
|
|||
// successful
|
||||
return ret > 0 ? _vx_call_rc : 255;
|
||||
}
|
||||
|
||||
#if defined(ACE_AS_STATIC_LIBS) && defined (ACE_VXWORKS_DEBUGGING_HELPER)
|
||||
/** Wind River workbench allows the user to spawn a kernel task as a
|
||||
"Debug Configuration". Use this function as the entrypoint so that
|
||||
the arguments are translated into the form that ace_main() requires.
|
||||
*/
|
||||
int ace_wb_exec (int arg0, int arg1, int arg2, int arg3, int arg4,
|
||||
int arg5, int arg6, int arg7, int arg8, int arg9)
|
||||
{
|
||||
return spaef ((FUNCPTR) ace_main, arg0, arg1, arg2, arg3, arg4,
|
||||
arg5, arg6, arg7, arg8, arg9);
|
||||
}
|
||||
#endif /* ACE_AS_STATIC_LIBS && ... */
|
||||
|
||||
#endif /* ACE_VXWORKS && !__RTP__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue