minimize preprocessor branching for vxWorks

This commit is contained in:
Unknown
2012-09-06 17:13:19 +02:00
parent d19508256f
commit d8ff75900e
6 changed files with 20 additions and 46 deletions
@@ -30,10 +30,6 @@
typedef SSIZE_T ssize_t;
#endif
#ifdef __vxworks
#define INT64_MAX (0x7fffffffffffffffLL)
#endif
using namespace epics::pvData;
using std::max;
+11 -21
View File
@@ -26,6 +26,13 @@ using namespace std;
namespace epics {
namespace pvAccess {
#ifdef __vxworks
inline int sendto(int s, const char *buf, size_t len, int flags, const struct sockaddr *to, int tolen)
{
return ::sendto(s, const_cast<char*>(buf), len, flags, const_cast<struct sockaddr *>(to), tolen);
}
#endif
PVACCESS_REFCOUNT_MONITOR_DEFINE(blockingUDPTransport);
BlockingUDPTransport::BlockingUDPTransport(
@@ -295,17 +302,8 @@ namespace epics {
bool BlockingUDPTransport::send(ByteBuffer* buffer, const osiSockAddr& address) {
buffer->flip();
int retval = sendto(_channel,
#ifdef __vxworks
(char *)
#endif
buffer->getArray(),
buffer->getLimit(), 0,
#ifdef __vxworks
(sockaddr*)
#endif
&(address.sa), sizeof(sockaddr));
int retval = sendto(_channel, buffer->getArray(),
buffer->getLimit(), 0, &(address.sa), sizeof(sockaddr));
if(unlikely(retval<0))
{
char errStr[64];
@@ -324,16 +322,8 @@ namespace epics {
bool allOK = true;
for(size_t i = 0; i<_sendAddresses->size(); i++) {
int retval = sendto(_channel,
#ifdef __vxworks
(char *)
#endif
buffer->getArray(),
buffer->getLimit(), 0,
#ifdef __vxworks
(sockaddr*)
#endif
&((*_sendAddresses)[i].sa),
int retval = sendto(_channel, buffer->getArray(),
buffer->getLimit(), 0, &((*_sendAddresses)[i].sa),
sizeof(sockaddr));
if(unlikely(retval<0))
{
@@ -10,11 +10,6 @@
#include <pv/remote.h>
#include <osiSock.h>
#ifndef __vxworks
/* why not use pvType.h here? */
#include <stdint.h>
#endif
namespace epics {
namespace pvAccess {
+9 -4
View File
@@ -6,8 +6,17 @@
#include <stdexcept>
#include <rpcServer.h>
#ifdef __vxworks
#include <envLib.h>
using std::string;
inline int setenv(const char *name, const char *value, int overwrite)
{
string e(name);
e += "=";
e += value;
return putenv(const_cast<char*>(e.c_str()));
}
#endif
using namespace epics::pvData;
@@ -403,11 +412,7 @@ RPCServer::RPCServer()
m_channelProviderImpl.reset(new RPCChannelProvider());
registerChannelProvider(m_channelProviderImpl);
#ifdef __vxworks
putenv(const_cast<char*>(("EPICS4_CAS_PROVIDER_NAMES=" + m_channelProviderImpl->getProviderName()).c_str()));
#else
setenv("EPICS4_CAS_PROVIDER_NAMES", m_channelProviderImpl->getProviderName().c_str(), 1);
#endif
m_serverContext = ServerContextImpl::create();
m_serverContext->initialize(getChannelAccess());
-4
View File
@@ -68,11 +68,7 @@ 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]);
@@ -74,20 +74,12 @@ 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;
}