mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-16 15:01:15 +02:00
trunk/branch integration: VxWorks
This commit is contained in:
parent
abeb31a9c8
commit
bcb342bd00
@ -35,7 +35,12 @@
|
||||
|
||||
|
||||
#include "Poco/Semaphore_POSIX.h"
|
||||
#if defined(POCO_VXWORKS)
|
||||
#include <timers.h>
|
||||
#include <cstring>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -45,6 +50,13 @@ SemaphoreImpl::SemaphoreImpl(int n, int max): _n(n), _max(max)
|
||||
{
|
||||
poco_assert (n >= 0 && max > 0 && n <= max);
|
||||
|
||||
#if defined(POCO_VXWORKS)
|
||||
// This workaround is for VxWorks 5.x where
|
||||
// pthread_mutex_init() won't properly initialize the mutex
|
||||
// resulting in a subsequent freeze in pthread_mutex_destroy()
|
||||
// if the mutex has never been used.
|
||||
std::memset(&_mutex, 0, sizeof(_mutex));
|
||||
#endif
|
||||
if (pthread_mutex_init(&_mutex, NULL))
|
||||
throw SystemException("cannot create semaphore (mutex)");
|
||||
if (pthread_cond_init(&_cond, NULL))
|
||||
@ -86,6 +98,15 @@ bool SemaphoreImpl::waitImpl(long milliseconds)
|
||||
delta.tv_sec = milliseconds / 1000;
|
||||
delta.tv_nsec = (milliseconds % 1000)*1000000;
|
||||
pthread_get_expiration_np(&delta, &abstime);
|
||||
#elif defined(POCO_VXWORKS)
|
||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||
abstime.tv_sec += milliseconds / 1000;
|
||||
abstime.tv_nsec += (milliseconds % 1000)*1000000;
|
||||
if (abstime.tv_nsec >= 1000000000)
|
||||
{
|
||||
abstime.tv_nsec -= 1000000000;
|
||||
abstime.tv_sec++;
|
||||
}
|
||||
#else
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
@ -40,6 +40,8 @@
|
||||
|
||||
#if defined(hpux) || defined(_hpux)
|
||||
#include "SharedLibrary_HPUX.cpp"
|
||||
#elif defined(POCO_VXWORKS)
|
||||
#include "SharedLibrary_VX.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "SharedLibrary_UNIX.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
|
Loading…
x
Reference in New Issue
Block a user