Pull request to merge porting to WindRiver VxWorks 6.x (#2966)

* Problem: Still need to port over more files to VxWorks 6.x

Solution: Port more files to VxWorks 6.x

* Problem: Need to port over remaining files to VxWorks 6.x. Also remove POSIX thread dependency for VxWorks (because of priority inversion problem in POSIX mutexes with VxWorks 6.x processes)

Solution: Port over remaining files to VxWorks 6.x. Also removed POSIX thread dependency for VxWorks

* Problem: Needed to modify TCP, UDP, TIPC classes with #ifdefs to be compatible with VxWorks 6.x.

Solution:  Modify TCP, UDP, TIPC classes with #ifdefs to be compatible with VxWorks 6.x
This commit is contained in:
Manuel Segura
2018-03-10 03:03:02 -08:00
committed by Luca Boccassi
parent 0d23b5ca69
commit 4726f7262d
35 changed files with 809 additions and 60 deletions

View File

@@ -170,6 +170,90 @@ class condition_variable_t
#endif
#elif defined ZMQ_HAVE_VXWORKS
#include <sysLib.h>
namespace zmq
{
class condition_variable_t
{
public:
inline condition_variable_t () {}
inline ~condition_variable_t ()
{
scoped_lock_t l (m_listenersMutex);
for (size_t i = 0; i < m_listeners.size (); i++) {
semDelete (m_listeners[i]);
}
}
inline int wait (mutex_t *mutex_, int timeout_)
{
//Atomically releases lock, blocks the current executing thread,
//and adds it to the list of threads waiting on *this. The thread
//will be unblocked when broadcast() is executed.
//It may also be unblocked spuriously. When unblocked, regardless
//of the reason, lock is reacquired and wait exits.
SEM_ID sem = semBCreate (SEM_Q_PRIORITY, SEM_EMPTY);
{
scoped_lock_t l (m_listenersMutex);
m_listeners.push_back (sem);
}
mutex_->unlock ();
int rc;
if (timeout_ < 0)
rc = semTake (sem, WAIT_FOREVER);
else {
int ticksPerSec = sysClkRateGet ();
int timeoutTicks = (timeout_ * ticksPerSec) / 1000 + 1;
rc = semTake (sem, timeoutTicks);
}
{
scoped_lock_t l (m_listenersMutex);
// remove sem from listeners
for (size_t i = 0; i < m_listeners.size (); i++) {
if (m_listeners[i] == sem) {
m_listeners.erase (m_listeners.begin () + i);
break;
}
}
semDelete (sem);
}
mutex_->lock ();
if (rc == 0)
return 0;
if (rc == S_objLib_OBJ_TIMEOUT) {
errno = EAGAIN;
return -1;
}
return -1;
}
inline void broadcast ()
{
scoped_lock_t l (m_listenersMutex);
for (size_t i = 0; i < m_listeners.size (); i++) {
semGive (m_listeners[i]);
}
}
private:
mutex_t m_listenersMutex;
std::vector<SEM_ID> m_listeners;
// Disable copy construction and assignment.
condition_variable_t (const condition_variable_t &);
const condition_variable_t &operator= (const condition_variable_t &);
};
}
#else
#include <pthread.h>