diff --git a/Foundation/src/Semaphore_POSIX.cpp b/Foundation/src/Semaphore_POSIX.cpp index 68ae5fc52..fc26ad062 100644 --- a/Foundation/src/Semaphore_POSIX.cpp +++ b/Foundation/src/Semaphore_POSIX.cpp @@ -35,7 +35,12 @@ #include "Poco/Semaphore_POSIX.h" +#if defined(POCO_VXWORKS) +#include +#include +#else #include +#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); diff --git a/Foundation/src/SharedLibrary.cpp b/Foundation/src/SharedLibrary.cpp index 3a8b91fca..dd2a93e4f 100644 --- a/Foundation/src/SharedLibrary.cpp +++ b/Foundation/src/SharedLibrary.cpp @@ -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)