VxWorks ports from Dirk

This commit is contained in:
Matej Sekoranja
2012-09-03 23:48:31 +02:00
parent e73c6b1548
commit 929387cf80
15 changed files with 113 additions and 29 deletions
+4 -4
View File
@@ -477,12 +477,12 @@ namespace epics {
float beaconInterval, epics::pvData::int16 priority);
public:
static BlockingClientTCPTransport::shared_pointer create(Context::shared_pointer const & context, SOCKET channel,
static shared_pointer create(Context::shared_pointer const & context, SOCKET channel,
std::auto_ptr<ResponseHandler>& responseHandler, int receiveBufferSize,
TransportClient::shared_pointer client, epics::pvData::int8 remoteTransportRevision,
float beaconInterval, epics::pvData::int16 priority)
{
BlockingClientTCPTransport::shared_pointer thisPointer(
shared_pointer thisPointer(
new BlockingClientTCPTransport(context, channel, responseHandler, receiveBufferSize,
client, remoteTransportRevision, beaconInterval, priority)
);
@@ -657,10 +657,10 @@ namespace epics {
BlockingServerTCPTransport(Context::shared_pointer const & context, SOCKET channel,
std::auto_ptr<ResponseHandler>& responseHandler, int receiveBufferSize);
public:
static BlockingServerTCPTransport::shared_pointer create(Context::shared_pointer const & context, SOCKET channel,
static shared_pointer create(Context::shared_pointer const & context, SOCKET channel,
std::auto_ptr<ResponseHandler>& responseHandler, int receiveBufferSize)
{
BlockingServerTCPTransport::shared_pointer thisPointer(
shared_pointer thisPointer(
new BlockingServerTCPTransport(context, channel, responseHandler, receiveBufferSize)
);
thisPointer->start();
@@ -31,6 +31,10 @@
typedef SSIZE_T ssize_t;
#endif
#ifdef __vxworks
#define INT64_MAX (0x7fffffffffffffffLL)
#endif
using namespace epics::pvData;
using std::max;
+2 -2
View File
@@ -38,11 +38,11 @@ namespace epics {
SOCKET channel, osiSockAddr& bindAddress,
short remoteTransportRevision);
public:
static BlockingUDPTransport::shared_pointer create(std::auto_ptr<ResponseHandler>& responseHandler,
static shared_pointer create(std::auto_ptr<ResponseHandler>& responseHandler,
SOCKET channel, osiSockAddr& bindAddress,
short remoteTransportRevision)
{
BlockingUDPTransport::shared_pointer thisPointer(
shared_pointer thisPointer(
new BlockingUDPTransport(responseHandler, channel, bindAddress, remoteTransportRevision)
);
return thisPointer;
+22 -5
View File
@@ -182,7 +182,7 @@ namespace epics {
{
for(size_t i = 0; i <_ignoredAddresses->size(); i++)
{
if(_ignoredAddresses->at(i).ia.sin_addr.s_addr==fromAddress.ia.sin_addr.s_addr)
if((*_ignoredAddresses)[i].ia.sin_addr.s_addr==fromAddress.ia.sin_addr.s_addr)
{
ignore = true;
break;
@@ -295,8 +295,17 @@ namespace epics {
bool BlockingUDPTransport::send(ByteBuffer* buffer, const osiSockAddr& address) {
buffer->flip();
int retval = sendto(_channel, buffer->getArray(),
buffer->getLimit(), 0, &(address.sa), sizeof(sockaddr));
int retval = sendto(_channel,
#ifdef __vxworks
(char *)
#endif
buffer->getArray(),
buffer->getLimit(), 0,
#ifdef __vxworks
(sockaddr*)
#endif
&(address.sa), sizeof(sockaddr));
if(unlikely(retval<0))
{
char errStr[64];
@@ -315,8 +324,16 @@ namespace epics {
bool allOK = true;
for(size_t i = 0; i<_sendAddresses->size(); i++) {
int retval = sendto(_channel, buffer->getArray(),
buffer->getLimit(), 0, &(_sendAddresses->at(i).sa),
int retval = sendto(_channel,
#ifdef __vxworks
(char *)
#endif
buffer->getArray(),
buffer->getLimit(), 0,
#ifdef __vxworks
(sockaddr*)
#endif
&(_sendAddresses->at(i).sa),
sizeof(sockaddr));
if(unlikely(retval<0))
{
@@ -10,7 +10,10 @@
#include <pv/remote.h>
#include <osiSock.h>
#ifndef __vxworks
/* why not use pvType.h here? */
#include <stdint.h>
#endif
namespace epics {
namespace pvAccess {
+2 -2
View File
@@ -77,7 +77,7 @@ auto_ptr<TransportRegistry::transportVector_t> TransportRegistry::get(String con
prioritiesIter != priorities->end();
prioritiesIter++, i++)
{
transportArray->at(i) = prioritiesIter->second;
(*transportArray)[i] = prioritiesIter->second;
}
return transportArray;
}
@@ -146,7 +146,7 @@ auto_ptr<TransportRegistry::transportVector_t> TransportRegistry::toArray()
prioritiesIter != priorities->end();
prioritiesIter++, i++)
{
transportArray->at(i) = prioritiesIter->second;
(*transportArray)[i] = prioritiesIter->second;
}
}
@@ -31,7 +31,7 @@
#include <pv/serializationHelper.h>
#include <pv/convert.h>
#include <tr1/unordered_map>
//#include <tr1/unordered_map>
using std::tr1::dynamic_pointer_cast;
using std::tr1::static_pointer_cast;
@@ -48,7 +48,8 @@ namespace epics {
String emptyString;
// TODO consider std::unordered_map
typedef std::tr1::unordered_map<pvAccessID, ResponseRequest::weak_pointer> IOIDResponseRequestMap;
//typedef std::tr1::unordered_map<pvAccessID, ResponseRequest::weak_pointer> IOIDResponseRequestMap;
typedef std::map<pvAccessID, ResponseRequest::weak_pointer> IOIDResponseRequestMap;
#define EXCEPTION_GUARD(code) try { code; } \
@@ -1697,9 +1698,9 @@ namespace epics {
}
public:
static ChannelGetFieldRequestImpl::shared_pointer create(ChannelImpl::shared_pointer const & channel, GetFieldRequester::shared_pointer const & callback, String const & subField)
static shared_pointer create(ChannelImpl::shared_pointer const & channel, GetFieldRequester::shared_pointer const & callback, String const & subField)
{
ChannelGetFieldRequestImpl::shared_pointer thisPointer(new ChannelGetFieldRequestImpl(channel, callback, subField), delayed_destroyable_deleter());
shared_pointer thisPointer(new ChannelGetFieldRequestImpl(channel, callback, subField), delayed_destroyable_deleter());
thisPointer->activate();
return thisPointer;
}
@@ -3957,9 +3958,9 @@ namespace epics {
public:
static InternalClientContextImpl::shared_pointer create()
static shared_pointer create()
{
InternalClientContextImpl::shared_pointer thisPointer(new InternalClientContextImpl(), delayed_destroyable_deleter());
shared_pointer thisPointer(new InternalClientContextImpl(), delayed_destroyable_deleter());
static_cast<InternalClientContextImpl*>(thisPointer.get())->activate();
return thisPointer;
}
@@ -4140,7 +4141,7 @@ TODO
for (size_t i = 0; broadcastAddresses.get() && i < broadcastAddresses->size(); i++)
LOG(logLevelDebug,
"Broadcast address #%d: %s", i, inetAddressToString(broadcastAddresses->at(i)).c_str());
"Broadcast address #%d: %s", i, inetAddressToString((*broadcastAddresses)[i]).c_str());
// where to bind (listen) address
osiSockAddr listenLocalAddress;
+2 -2
View File
@@ -308,11 +308,11 @@ void ServerCreateChannelHandler::handleResponse(osiSockAddr* responseFrom,
}
// TODO !!!
//ServerChannelRequesterImpl::create(_providers.at(0), transport, channelName, cid);
//ServerChannelRequesterImpl::create(_providers[0], transport, channelName, cid);
if (_providers.size() == 1)
ServerChannelRequesterImpl::create(_providers.at(0), transport, channelName, cid);
ServerChannelRequesterImpl::create(_providers[0], transport, channelName, cid);
else
ServerChannelRequesterImpl::create(ServerSearchHandler::s_channelNameToProvider[channelName].lock(), transport, channelName, cid); // TODO !!!!
}
+45 -4
View File
@@ -7,6 +7,11 @@
#include <pv/configuration.h>
#include <pv/epicsException.h>
#if defined(__GNUC__) && __GNUC__ < 3
#define OLDGCC
#define NO_STREAM_EXCEPTIONS
#endif
namespace epics {
namespace pvAccess {
@@ -77,11 +82,17 @@ void Properties::load()
{
_properties.clear();
#ifdef NO_STREAM_EXCEPTIONS
_infile->open(_fileName.c_str(),ifstream::in);
if (_infile->fail())
#else
try
{
_infile->open(_fileName.c_str(),ifstream::in);
}
catch (ifstream::failure& e) {
catch (ifstream::failure& e)
#endif
{
string errMsg = "Error opening file: " + string(_fileName.c_str());
THROW_BASE_EXCEPTION(errMsg.c_str());
}
@@ -89,13 +100,28 @@ void Properties::load()
string line;
string property;
string key;
#ifndef NO_STREAM_EXCEPTIONS
try
{
#endif
while(!_infile->eof())
{
line.clear();
std::getline(*_infile,line);
#ifdef NO_STREAM_EXCEPTIONS
if (_infile->fail())
{
_infile->close();
if(_infile->eof())
{
return; //end of file
}
string errMsg = "Error reading file: " + _fileName;
THROW_BASE_EXCEPTION(errMsg.c_str());
}
#endif
//remove trailing spaces
truncate(line);
@@ -105,7 +131,7 @@ void Properties::load()
continue;
}
// comment
if(line.at(0) == '#')
if(line[0] == '#')
{
continue;
}
@@ -124,6 +150,7 @@ void Properties::load()
truncate(property);
_properties[key] = property;
}
#ifndef NO_STREAM_EXCEPTIONS
}
catch (ifstream::failure& e)
{
@@ -135,6 +162,7 @@ void Properties::load()
string errMsg = "Error reading file: " + _fileName;
THROW_BASE_EXCEPTION(errMsg.c_str());
}
#endif
_infile->close();
}
@@ -146,11 +174,17 @@ void Properties::load(const string &fileName)
void Properties::store()
{
#ifdef NO_STREAM_EXCEPTIONS
_outfile->open(_fileName.c_str(),ifstream::trunc);
if (_outfile->fail())
#else
try
{
_outfile->open(_fileName.c_str(),ifstream::trunc);
}
catch (ofstream::failure& e) {
catch (ofstream::failure& e)
#endif
{
string errMsg = "Error opening file: " + string(_fileName.c_str());
THROW_BASE_EXCEPTION(errMsg.c_str());
}
@@ -160,12 +194,19 @@ void Properties::store()
propertiesIterator != _properties.end();
propertiesIterator++ )
{
#ifndef NO_STREAM_EXCEPTIONS
try
{
#endif
string line = string(propertiesIterator->first) + string("=") + string(propertiesIterator->second) + string("\n");
_outfile->write(line.c_str(),line.length());
#ifdef NO_STREAM_EXCEPTIONS
if(_outfile->fail())
#else
}
catch (ofstream::failure& e) {
catch (ofstream::failure& e)
#endif
{
_outfile->close();
string errMsg = "Error writing to file: " + string(_fileName.c_str());
THROW_BASE_EXCEPTION(errMsg.c_str());
+4
View File
@@ -68,7 +68,11 @@ void hexDump(String const & prologue, String const & name, const int8 *bs,
if(((i-start)%16)==0) {
out += chars;
out += '\n';
#if defined(__GNUC__) && __GNUC__ < 3
chars.erase();
#else
chars.clear();
#endif
}
chars += toAscii(bs[i]);
+2 -1
View File
@@ -11,6 +11,7 @@
#include <osiSock.h>
#include <ellLib.h>
#include <epicsAssert.h>
#include <pv/logger.h>
#include <vector>
#include <cstring>
@@ -134,7 +135,7 @@ InetAddrVector* getSocketAddressList(String list, int defaultPort,
if(appendList!=NULL) {
for(size_t i = 0; i<appendList->size(); i++)
iav->push_back(appendList->at(i));
iav->push_back((*appendList)[i]);
}
return iav;
}
@@ -74,12 +74,20 @@ void IntrospectionRegistry::printKeysAndValues(string name)
cout << "############## print of all key/values of " << name.c_str() << " registry : ###################" << endl;
for(registryMap_t::iterator registryIter = _registry.begin(); registryIter != _registry.end(); registryIter++)
{
#if defined(__GNUC__) && __GNUC__ < 3
buffer.erase();
#else
buffer.clear();
#endif
cout << "\t" << "Key: "<< registryIter->first << endl;
cout << "\t" << "Value: " << registryIter->second << endl;
cout << "\t" << "References: " << buffer.c_str() << endl;
#if defined(__GNUC__) && __GNUC__ < 3
buffer.erase();
#else
buffer.clear();
#endif
registryIter->second->toString(&buffer);
cout << "\t" << "Value toString: " << buffer.c_str() << endl;
}
+1 -1
View File
@@ -7,7 +7,7 @@
#ifndef LIKELY_H_
#define LIKELY_H_
#if defined(__GNUC__)
#if defined(__GNUC__) && __GNUC__ >= 3
#define likely(x) __builtin_expect (x, 1)
#define unlikely(x) __builtin_expect (x, 0)
#else
+1
View File
@@ -17,6 +17,7 @@
#include <iostream>
#include <time.h>
#include <cstring>
#include <stdio.h>
using namespace epics::pvData;
using std::ofstream;
+5 -1
View File
@@ -39,7 +39,11 @@ namespace pvAccess {
void pvAccessLog(pvAccessLogLevel level, const char* format, ...);
void pvAccessSetLogLevel(pvAccessLogLevel level);
#define LOG(level, format, ...) pvAccessLog(level, format, ##__VA_ARGS__)
#if defined (__GNUC__) && __GNUC__ < 3
#define LOG(level, format, ARGS...) pvAccessLog(level, format, ##ARGS)
#else
#define LOG(level, format, ...) pvAccessLog(level, format, ##__VA_ARGS__)
#endif
#define SET_LOG_LEVEL(level) pvAccessSetLogLevel(level)
// EPICS errlog