Date   

[PATCH 04/50] Added WCACHEExpDLL macro for building NYSE wirecache

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

This is all part of DLL hell for windows: when we build common we need to
indicate that the mehtods from common are export from the DLL, and then we need
to indicate that they are imported when we build other products. This is
further complicated when products mix static and dynamic linking for different
components.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/wConfig.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/common/c_cpp/src/c/linux/wConfig.h b/common/c_cpp/src/c/linux/wConfig.h
index 1d3d906..b817757 100644
--- a/common/c_cpp/src/c/linux/wConfig.h
+++ b/common/c_cpp/src/c/linux/wConfig.h
@@ -30,6 +30,7 @@
#define MAMDAExpDLL
#define MAMDAOPTExpDLL
#define MAMAExpBridgeDLL
+#define WCACHEExpDLL
#define MAMACALLTYPE

#define WCOMMONINLINE inline static
--
1.7.7.6


[PATCH 03/50] Fix timer implementation for Windows

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

Address subtle difference between Linux and Windows networking required by
timers. Since there are no pipes on Windows, the timer implementation use a
loopback socket which requires send and recv rather the read/write.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/network.c | 1 +
common/c_cpp/src/c/linux/port.h | 19 +++++++++++--------
common/c_cpp/src/c/timers.c | 12 ++++--------
common/c_cpp/src/c/timers.h | 12 ++++++------
common/c_cpp/src/c/windows/network.c | 2 +-
common/c_cpp/src/c/windows/port.c | 28 ++++++++++++++++++++++------
common/c_cpp/src/c/windows/port.h | 9 +++++++--
7 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/common/c_cpp/src/c/linux/network.c b/common/c_cpp/src/c/linux/network.c
index 9969ff9..5c32910 100644
--- a/common/c_cpp/src/c/linux/network.c
+++ b/common/c_cpp/src/c/linux/network.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <net/if.h>
#include "wombat/wCommon.h"


diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index c328479..b3a928d 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -28,15 +28,9 @@
#ifndef PORT_LINUX_H__
#define PORT_LINUX_H__

-#if defined (__cplusplus)
-extern "C"
-{
-#endif
-
#include <pthread.h>
#include <sys/types.h>
#include <sys/ioctl.h>
-#include <sys/mman.h>
#include <sys/vfs.h>
#include <sys/param.h>
#include <sys/resource.h>
@@ -44,9 +38,9 @@ extern "C"
#include <sys/times.h>
#include <sys/socket.h>
#include <sys/utsname.h>
+#include <sys/mman.h>
#include <arpa/inet.h>
#include <netinet/in.h>
-#include <net/if.h>
#include <netdb.h>
#include <semaphore.h>
#include <dirent.h>
@@ -57,6 +51,10 @@ extern "C"

#include "wConfig.h"

+#if defined (__cplusplus)
+extern "C"
+{
+#endif
/* PTHREAD static locks are easy */
typedef pthread_mutex_t wthread_static_mutex_t;
#define WSTATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -108,12 +106,17 @@ typedef pthread_key_t wthread_key_t;
int wsem_timedwait (wsem_t* sem, unsigned int ts);

/* Windows does not support AF_UNIX sockets, socketpairs, etc */
+#define wsocketstartup()
+#define wsocketcleanup()
+
#define wsocketpair(dom, type, prot, pair) (socketpair((dom),(type),(prot),(pair)))
#define wsetnonblock(s) (fcntl((s), F_SETFL, fcntl((s), F_GETFL) | O_NONBLOCK))
+#define wread read
+#define wwrite write

#define CPU_AFFINITY_SET cpu_set_t

-/* User pthreads for linux */
+/* Use pthreads for linux */
#define INVALID_THREAD (-1)

#define wthread_mutex_t pthread_mutex_t
diff --git a/common/c_cpp/src/c/timers.c b/common/c_cpp/src/c/timers.c
index cb93ce8..87ae925 100644
--- a/common/c_cpp/src/c/timers.c
+++ b/common/c_cpp/src/c/timers.c
@@ -84,11 +84,7 @@ int createTimerHeap (timerHeap* heap)

wthread_mutex_init (&heapImpl->mEndingLock, NULL);

- if (wthread_cond_init (&heapImpl->mEndingCond, NULL) != 0)
- {
- free (heapImpl);
- return -1;
- }
+ wthread_cond_init (&heapImpl->mEndingCond, NULL);

RB_INIT (&heapImpl->mTimeTree);

@@ -152,7 +148,7 @@ void* dispatchEntry (void *closure)
int numRead = 0;
do
{
- numRead = read(heap->mSockPair[0], &buff, sizeof (buff));
+ numRead = wread(heap->mSockPair[0], &buff, sizeof (buff));
if (numRead < 0)
{
if (errno == EINTR)
@@ -221,7 +217,7 @@ int destroyHeap (timerHeap heap)
timerHeapImpl* heapImpl = (timerHeapImpl*)heap;

writeagain:
- if (write (heapImpl->mSockPair[1], "d", 1) < 0)
+ if (wwrite (heapImpl->mSockPair[1], "d", 1) < 0)
{
if ((errno == EINTR) || (errno == EAGAIN))
goto writeagain;
@@ -277,7 +273,7 @@ int createTimer (timerElement* timer, timerHeap heap, timerFireCb cb, struct tim
if (kickPipe)
{
writeagain:
- if (write (heapImpl->mSockPair[1], "w", 1) < 0)
+ if (wwrite (heapImpl->mSockPair[1], "w", 1) < 0)
{
if ((errno == EINTR) || (errno == EAGAIN))
goto writeagain;
diff --git a/common/c_cpp/src/c/timers.h b/common/c_cpp/src/c/timers.h
index 22989f3..962163b 100644
--- a/common/c_cpp/src/c/timers.h
+++ b/common/c_cpp/src/c/timers.h
@@ -29,12 +29,12 @@ typedef void* timerHeap;

typedef void (*timerFireCb)(timerElement timer, void* mClosure);

-int createTimerHeap (timerHeap* heap);
-int startDispatchTimerHeap (timerHeap heap);
-wthread_t timerHeapGetTid (timerHeap heap);
-int destroyHeap (timerHeap heap);
+COMMONExpDLL int createTimerHeap (timerHeap* heap);
+COMMONExpDLL int startDispatchTimerHeap (timerHeap heap);
+COMMONExpDLL wthread_t timerHeapGetTid (timerHeap heap);
+COMMONExpDLL int destroyHeap (timerHeap heap);

-int createTimer (timerElement* timer, timerHeap heap, timerFireCb cb, struct timeval* timeout, void* closure);
-int destroyTimer (timerHeap heap, timerElement timer);
+COMMONExpDLL int createTimer (timerElement* timer, timerHeap heap, timerFireCb cb, struct timeval* timeout, void* closure);
+COMMONExpDLL int destroyTimer (timerHeap heap, timerElement timer);

#endif
diff --git a/common/c_cpp/src/c/windows/network.c b/common/c_cpp/src/c/windows/network.c
index b80914e..ce467f6 100644
--- a/common/c_cpp/src/c/windows/network.c
+++ b/common/c_cpp/src/c/windows/network.c
@@ -18,7 +18,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"

struct in_addr wresolve_ip (const char * arg)
{
diff --git a/common/c_cpp/src/c/windows/port.c b/common/c_cpp/src/c/windows/port.c
index 12f6431..2b92c90 100644
--- a/common/c_cpp/src/c/windows/port.c
+++ b/common/c_cpp/src/c/windows/port.c
@@ -18,7 +18,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"

int gettimeofday( struct timeval *result, void *dummy )
{
@@ -133,10 +133,10 @@ DWORD wthread_cond_wait( HANDLE *event, LPCRITICAL_SECTION *cs )
{
DWORD rval;

- LeaveCriticalSection( *cs );
+ LeaveCriticalSection( cs );
rval = WaitForSingleObject( *event, INFINITE );
ResetEvent( *event );
- EnterCriticalSection( *cs );
+ EnterCriticalSection( cs );

return rval;
}
@@ -177,6 +177,24 @@ const char *getlogin()
}

int
+wsocketstartup ()
+{
+ WSADATA wsaData;
+ int err =WSAStartup(MAKEWORD(2,2), &wsaData);
+ if (err)
+ {
+ return -1;
+ }
+ return 0;
+}
+
+void
+wsocketcleanup ()
+{
+ WSACleanup( );
+}
+
+int
wsocketpair (int domain, int type, int protocol, int* pair)
{
struct sockaddr_in addr;
@@ -184,7 +202,7 @@ wsocketpair (int domain, int type, int protocol, int* pair)
int l;

l = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (INVALID_SOCKET == pair[0])
+ if (INVALID_SOCKET == l)
return -1;

ZeroMemory (&addr, sizeof(addr));
@@ -233,8 +251,6 @@ wsocketpair (int domain, int type, int protocol, int* pair)
return -1;
}

- _close (l);
-
return 0;
}

diff --git a/common/c_cpp/src/c/windows/port.h b/common/c_cpp/src/c/windows/port.h
index 92080fd..df06b4f 100644
--- a/common/c_cpp/src/c/windows/port.h
+++ b/common/c_cpp/src/c/windows/port.h
@@ -86,6 +86,11 @@ typedef __int64 w_i64_t;
#define PATH_DELIM ';'

#define PATHSEP "\\"
+COMMONExpDLL int
+wsocketstartup (void);
+
+COMMONExpDLL void
+wsocketcleanup (void);

/* Socket Pair and set non blocking */
COMMONExpDLL int
@@ -143,8 +148,8 @@ int wsem_getvalue (wsem_t*, int* items);
#define strdup _strdup
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
-#define read _read
-#define write _write
+#define wread(x,y,z) recv((x),(y),(z),0)
+#define wwrite(x,y,z) send((x),(y),(z),0)
#define close _close
#define sleep(x) Sleep( (x)*1000)

--
1.7.7.6


[PATCH 02/50] c linkage for wlock_xxx() methods

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

These must be declared with extern "C" to link correctly with C++ applications.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/wlock.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/common/c_cpp/src/c/wlock.h b/common/c_cpp/src/c/wlock.h
index 199dad8..f43051f 100644
--- a/common/c_cpp/src/c/wlock.h
+++ b/common/c_cpp/src/c/wlock.h
@@ -22,11 +22,19 @@
#ifndef _WOMBAT_WLOCK_H
#define _WOMBAT_WLOCK_H

+#include <wombat/wConfig.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
typedef void * wLock;

COMMONExpDLL wLock wlock_create( void );
COMMONExpDLL void wlock_destroy( wLock lock );
COMMONExpDLL void wlock_lock( wLock lock );
COMMONExpDLL void wlock_unlock( wLock lock );
+#if defined (__cplusplus)
+}
+#endif

#endif /* _WOMBAT_WLOCK_H */
--
1.7.7.6


[PATCH 01/50] Ownership of message buffers

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

The msg payload bridges now have a msgPayloadSetParent() call which is
used to set the parent mamaMsg object for a payload. This allows the
"ownership" of the mamaMsg to be interrogated from a payload bridge
i.e. if a message can be modified or not. The use of the message owner
term has also been normalised.

Signed-off-by: Glenn McClements <gmcclements@...>
Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/wombat/wConfig.h | 2 +-
mama/c_cpp/src/c/msg.c | 106 +++++++++++++++---------
mama/c_cpp/src/c/msgfield.c | 6 +-
mama/c_cpp/src/c/payload/avismsg/avismsgimpl.h | 1 +
mama/c_cpp/src/c/payload/avismsg/avispayload.c | 12 +++
mama/c_cpp/src/c/payload/avismsg/avispayload.h | 3 +
mama/c_cpp/src/c/payloadbridge.h | 12 ++-
7 files changed, 94 insertions(+), 48 deletions(-)

diff --git a/common/c_cpp/src/c/wombat/wConfig.h b/common/c_cpp/src/c/wombat/wConfig.h
index 3414bff..e7aeede 120000
--- a/common/c_cpp/src/c/wombat/wConfig.h
+++ b/common/c_cpp/src/c/wombat/wConfig.h
@@ -1 +1 @@
-../../.././src/c/linux/wConfig.h
\ No newline at end of file
+../../../src/c/linux/wConfig.h
\ No newline at end of file
diff --git a/mama/c_cpp/src/c/msg.c b/mama/c_cpp/src/c/msg.c
index ca17bf0..af51d25 100644
--- a/mama/c_cpp/src/c/msg.c
+++ b/mama/c_cpp/src/c/msg.c
@@ -92,7 +92,7 @@ typedef struct mamaMsgImpl_
msgBridge mBridgeMessage;
/*If we have detached the middleware message we will own it
and are responsible for destroying it*/
- int mMiddlewareMessageOwner;
+ int mMessageOwner;

/*The context if this is a msg from the dqStrategy cache*/
mamaDqContext* mDqStrategyContext;
@@ -121,7 +121,7 @@ mamaMsg_destroy (mamaMsg msg)
mamaMsgImpl_destroyLastVectorMsg (impl);
}

- if (impl->mPayloadBridge && impl->mMiddlewareMessageOwner)
+ if (impl->mPayloadBridge && impl->mMessageOwner)
{
if (impl->mFieldPayload)
{
@@ -138,9 +138,9 @@ mamaMsg_destroy (mamaMsg msg)

impl->mPayloadBridge = NULL;

- /*set mMiddlewareMessageOwner to zero now the payload has been destroyed to prevent
+ /*set mMessageOwner to zero now the payload has been destroyed to prevent
us destroying the underlying message again in the bridge specific function*/
- impl->mMiddlewareMessageOwner = 0;
+ impl->mMessageOwner = 0;
}

if (impl->mNestedMessages != NULL)
@@ -159,7 +159,7 @@ mamaMsg_destroy (mamaMsg msg)
{
/*Invoke the bridge specific destroy function*/
impl->mBridgeImpl->bridgeMamaMsgDestroy (
- impl->mBridgeMessage, impl->mMiddlewareMessageOwner);
+ impl->mBridgeMessage, impl->mMessageOwner);
}
else
{
@@ -228,8 +228,10 @@ mamaMsg_detach (mamaMsg msg)
{
mamaMsgImpl* impl = (mamaMsgImpl*)msg;
mama_status status = MAMA_STATUS_OK;
- if (!impl) return MAMA_STATUS_NULL_ARG;
- if (!impl->mQueue) return MAMA_STATUS_INVALID_QUEUE;
+ msgPayload payload = NULL;
+
+ if (!impl) return MAMA_STATUS_NULL_ARG;
+ if (!impl->mQueue) return MAMA_STATUS_INVALID_QUEUE;
if (!impl->mBridgeImpl) return MAMA_STATUS_NO_BRIDGE_IMPL;

if (MAMA_STATUS_OK!=(status=mamaQueueImpl_detachMsg (impl->mQueue, msg)))
@@ -237,8 +239,8 @@ mamaMsg_detach (mamaMsg msg)
/*Message already logged in mamaQueueImpl_detachMsg*/
return status;
}
-
- /*We also need to detach the bridge specific message*/
+
+ /*We also need to detach the middleware bridge specific message*/
if (MAMA_STATUS_OK!=(status=impl->mBridgeImpl->bridgeMamaMsgDetach
(impl->mBridgeMessage)))
{
@@ -246,10 +248,24 @@ mamaMsg_detach (mamaMsg msg)
"Could not detach bridge message.");
return status;
}
+ /* Copy the payload */
+ if (MAMA_STATUS_OK != (status =
+ (msg->mPayloadBridge->msgPayloadCopy (impl->mPayload,
+ &payload))))
+ {
+ mama_log(MAMA_LOG_LEVEL_ERROR,
+ "mamaMsg_detach() Failed. "
+ "Could not copy native payload [%d]", status);
+ return status;
+ }

+ msg->mPayload = payload;
+ msg->mPayloadBridge->msgPayloadSetParent (impl->mPayload, msg);
+
/*If this is a dqStrategy cache message*/
if (impl->mDqStrategyContext)
- {
+ {
+
if (MAMA_STATUS_OK!=(status=dqStrategyImpl_detachMsg (impl->mDqStrategyContext, msg)))
{
mama_log (MAMA_LOG_LEVEL_ERROR, "mamaMsg_detach(): "
@@ -259,7 +275,7 @@ mamaMsg_detach (mamaMsg msg)
}

/*We are now responsible for destroying the middleware message*/
- impl->mMiddlewareMessageOwner = 1;
+ impl->mMessageOwner = 1;

return MAMA_STATUS_OK;
}
@@ -383,7 +399,7 @@ mamaMsgImpl_setPayloadBridge (mamaMsg msg, mamaPayloadBridgeImpl* payloadBridge)
}

mama_status
-mamaMsgImpl_setPayload (mamaMsg msg, msgPayload payload, short ownsMsg)
+mamaMsgImpl_setPayload (mamaMsg msg, msgPayload payload, short owner)
{
mamaMsgImpl* impl = (mamaMsgImpl*)msg;
if (!impl) return MAMA_STATUS_NULL_ARG;
@@ -400,8 +416,10 @@ mamaMsgImpl_setPayload (mamaMsg msg, msgPayload payload, short ownsMsg)
/* Do not destroy the list. We can reuse the memory! */
}

- impl->mPayload = payload;
- impl->mMiddlewareMessageOwner = ownsMsg;
+ impl->mPayload = payload;
+ impl->mMessageOwner = owner;
+ impl->mPayloadBridge->msgPayloadSetParent (impl->mPayload, msg);
+
return MAMA_STATUS_OK;
}

@@ -434,7 +452,7 @@ mamaMsg_createForPayloadBridge (mamaMsg* msg, mamaPayloadBridge payloadBridge)
return mamaMsgImpl_createForPayload (msg,
payload,
payloadBridge,
- 0);
+ 1);
}


@@ -469,7 +487,7 @@ mamaMsgImpl_setMsgBuffer(mamaMsg msg,
/*If there is an existing message buffer which we own destroy it*/
if (impl->mBridgeImpl &&
impl->mBridgeMessage &&
- impl->mMiddlewareMessageOwner)
+ impl->mMessageOwner)
{
if (MAMA_STATUS_OK!=
impl->mBridgeImpl->bridgeMamaMsgDestroyMiddlewareMsg (
@@ -481,8 +499,7 @@ mamaMsgImpl_setMsgBuffer(mamaMsg msg,
}
impl->mBridgeMessage = NULL;
}
-
- impl->mMiddlewareMessageOwner = 0;
+ impl->mMessageOwner = 0;

if (id == '\0')
id = (char) ((const char*)data) [0];
@@ -550,6 +567,7 @@ mamaMsgImpl_createNestedForPayload (mamaMsg* result,
impl->mPayloadBridge = parent->mPayloadBridge;
impl->mPayload = payload;
impl->mParent = parent;
+ impl->mPayloadBridge->msgPayloadSetParent (impl->mPayload, impl);

return MAMA_STATUS_OK;
}
@@ -562,20 +580,20 @@ mamaMsgImpl_setMessageOwner (mamaMsg msg,
mama_status status = MAMA_STATUS_OK;

mamaMsgImpl* impl = (mamaMsgImpl*)msg;
- impl->mMiddlewareMessageOwner = owner;
+ impl->mMessageOwner = owner;

return status;
}

mama_status
mamaMsgImpl_getMessageOwner (mamaMsg msg,
- short* owner)
+ short* owner)
{
mama_status status = MAMA_STATUS_OK;

mamaMsgImpl* impl = (mamaMsgImpl*)msg;
- *owner = impl->mMiddlewareMessageOwner;
-
+ *owner = impl->mMessageOwner;
+
return status;
}

@@ -583,7 +601,7 @@ mama_status
mamaMsgImpl_createForPayload (mamaMsg* msg,
msgPayload payload,
mamaPayloadBridgeImpl* payloadBridge,
- short noDeletePayload)
+ short owner)
{
mama_status status = MAMA_STATUS_OK;
mamaMsgImpl* impl = NULL;
@@ -609,14 +627,20 @@ mamaMsgImpl_createForPayload (mamaMsg* msg,
}
*msg = (mamaMsg)impl;

- impl->mPayload = payload;
- impl->mPayloadBridge = payloadBridge;
- impl->mFieldPayload = NULL;
+ impl->mPayload = payload;
+ impl->mPayloadBridge = payloadBridge;
+ impl->mFieldPayload = NULL;
/*These will be set later if necessary*/
- impl->mBridgeImpl = NULL;
- impl->mBridgeMessage = NULL;
- impl->mMiddlewareMessageOwner = noDeletePayload == 1 ? 0 : 1;
- impl->mDqStrategyContext = NULL;
+ impl->mBridgeImpl = NULL;
+ impl->mBridgeMessage = NULL;
+ impl->mMessageOwner = owner;
+ impl->mDqStrategyContext = NULL;
+
+ /* The payloadBridge and payload are optional for this function */
+ if (payloadBridge)
+ {
+ impl->mPayloadBridge->msgPayloadSetParent (impl->mPayload, impl);
+ }

return status;
}
@@ -650,7 +674,7 @@ mamaMsg_copy (mamaMsg src, mamaMsg* copy)
if (*copy == NULL)
{
if (MAMA_STATUS_OK != (status =
- mamaMsgImpl_createForPayload (copy, payload, source->mPayloadBridge, 0)))
+ mamaMsgImpl_createForPayload (copy, payload, source->mPayloadBridge, 1)))
{
mama_log(MAMA_LOG_LEVEL_ERROR,
"mamaMsg_copy Failed. "
@@ -695,7 +719,7 @@ mamaMsg_create (mamaMsg* msg)
return mamaMsgImpl_createForPayload (msg,
payload,
bridge,
- 0);
+ 1);
}

mama_status
@@ -2958,7 +2982,7 @@ mamaMsg_getVectorMsg (
impl->mPayloadBridge);
/*
* We do not detach the middle ware message so we do
- * not own it. NOTE Inverse sense to the create call below
+ * not own it.
*/
mamaMsgImpl_setPayload (impl->mLastVectorPayloadMsg[i],
payloadVector[i],
@@ -2969,12 +2993,12 @@ mamaMsg_getVectorMsg (
{
/*
* We create from payload so payload owns
- * We set noDelete to true to not delete the payload
+ * We set owner to false to not delete the payload
*/
mamaMsgImpl_createForPayload (&(impl->mLastVectorPayloadMsg[i]),
payloadVector[i],
impl->mPayloadBridge,
- 1);
+ 0);
}

/*Store the maxumim vector we have encountered*/
@@ -3052,9 +3076,9 @@ mamaMsgImpl_getPayloadBuffer (
if (impl->mPayloadBridge)
{
return
- impl->mPayloadBridge->msgPayloadGetByteBuffer (impl->mPayload,
- buffer,
- bufferLength);
+ impl->mPayloadBridge->msgPayloadGetByteBuffer (impl->mPayload,
+ buffer,
+ bufferLength);
}
return MAMA_STATUS_NULL_ARG;
}
@@ -3072,9 +3096,9 @@ mamaMsg_setNewBuffer (mamaMsg msg, void* buffer,
if (impl->mPayloadBridge)
{
return
- impl->mPayloadBridge->msgPayloadUnSerialize (impl->mPayload,
- buffer,
- size);
+ impl->mPayloadBridge->msgPayloadUnSerialize (impl->mPayload,
+ buffer,
+ size);
}

return MAMA_STATUS_NULL_ARG;
diff --git a/mama/c_cpp/src/c/msgfield.c b/mama/c_cpp/src/c/msgfield.c
index 747f983..ac5fee3 100644
--- a/mama/c_cpp/src/c/msgfield.c
+++ b/mama/c_cpp/src/c/msgfield.c
@@ -755,7 +755,7 @@ mamaMsgField_getVectorMsg (
impl->myPayloadBridge);
/*
* We do not detach the middleware message so we do
- * not own it. NOTE Inverse sense to the create call below
+ * not own it.
*/
mamaMsgImpl_setPayload (impl->myLastVectorPayloadMsg[i],
payloadVector[i],
@@ -766,12 +766,12 @@ mamaMsgField_getVectorMsg (
{
/*
* We create from payload so payload owns
- * We set noDelete to true to not delete the payload
+ * We set owner to false to not delete the payload
*/
mamaMsgImpl_createForPayload (&(impl->myLastVectorPayloadMsg[i]),
payloadVector[i],
impl->myPayloadBridge,
- 1);
+ 0);
}

/*Store the maxumim vector we have encountered*/
diff --git a/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.h b/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.h
index c68c28e..ade9b0b 100755
--- a/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.h
+++ b/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.h
@@ -33,6 +33,7 @@ typedef struct avisPayload
{
Attributes* mAvisMsg;
struct avisFieldPayload* mAvisField;
+ mamaMsg mParent;

void * mBuffer;
uint16_t mBufferLen;
diff --git a/mama/c_cpp/src/c/payload/avismsg/avispayload.c b/mama/c_cpp/src/c/payload/avismsg/avispayload.c
index e0f9df6..28cca7a 100755
--- a/mama/c_cpp/src/c/payload/avismsg/avispayload.c
+++ b/mama/c_cpp/src/c/payload/avismsg/avispayload.c
@@ -205,6 +205,18 @@ avismsgPayload_destroy (msgPayload msg)
}

mama_status
+avisPayload_setParent (msgPayload msg,
+ const mamaMsg parent)
+{
+ avisPayloadImpl* impl = (avisPayloadImpl*) msg;
+ if (!impl) return MAMA_STATUS_NULL_ARG;
+
+ impl->mParent = parent;
+
+ return MAMA_STATUS_OK;
+}
+
+mama_status
avismsgPayload_getByteSize (const msgPayload msg,
mama_size_t* size)
{
diff --git a/mama/c_cpp/src/c/payload/avismsg/avispayload.h b/mama/c_cpp/src/c/payload/avismsg/avispayload.h
index 4bb7f37..a2c1388 100755
--- a/mama/c_cpp/src/c/payload/avismsg/avispayload.h
+++ b/mama/c_cpp/src/c/payload/avismsg/avispayload.h
@@ -54,6 +54,9 @@ avismsgPayload_clear (msgPayload msg);
extern mama_status
avismsgPayload_destroy (msgPayload msg);
extern mama_status
+avismsgPayload_setParent (msgPayload msg,
+ const mamaMsg parent);
+extern mama_status
avismsgPayload_getByteSize (const msgPayload msg,
mama_size_t* size);

diff --git a/mama/c_cpp/src/c/payloadbridge.h b/mama/c_cpp/src/c/payloadbridge.h
index 97396f9..6d851ae 100644
--- a/mama/c_cpp/src/c/payloadbridge.h
+++ b/mama/c_cpp/src/c/payloadbridge.h
@@ -55,6 +55,8 @@ do \
= identifier ## Payload_clear; \
msgPayloadImpl->msgPayloadDestroy \
= identifier ## Payload_destroy; \
+ msgPayloadImpl->msgPayloadSetParent \
+ = identifier ## Payload_setParent; \
msgPayloadImpl->msgPayloadGetByteSize \
= identifier ## Payload_getByteSize; \
msgPayloadImpl->msgPayloadGetNumFields \
@@ -437,6 +439,9 @@ typedef mama_status
typedef mama_status
(*msgPayload_destroy) (msgPayload msg);
typedef mama_status
+(*msgPayload_setParent) (msgPayload msg,
+ const mamaMsg parent);
+typedef mama_status
(*msgPayload_getByteSize) (msgPayload msg,
mama_size_t* size);
typedef mama_status
@@ -456,14 +461,14 @@ typedef mama_status
void* closure);

typedef mama_status
-(*msgPayload_serialize) (const msgPayload msg,
+(*msgPayload_serialize) (const msgPayload msg,
const void** buffer,
mama_size_t* bufferLength);

typedef mama_status
-(*msgPayload_unSerialize) (const msgPayload msg,
+(*msgPayload_unSerialize) (const msgPayload msg,
const void** buffer,
- mama_size_t bufferLength);
+ mama_size_t bufferLength);

typedef mama_status
(*msgPayload_getByteBuffer) (const msgPayload msg,
@@ -1303,6 +1308,7 @@ typedef struct mamaPayloadBridgeImpl_
msgPayload_copy msgPayloadCopy;
msgPayload_clear msgPayloadClear;
msgPayload_destroy msgPayloadDestroy;
+ msgPayload_setParent msgPayloadSetParent;
msgPayload_getByteSize msgPayloadGetByteSize;
msgPayload_getNumFields msgPayloadGetNumFields;
msgPayload_getSendSubject msgPayloadGetSendSubject;
--
1.7.7.6


[PATCH 00/50] Final Sync from NYSE Technologies

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

This very large patch set consists of minor new features and bug fixes
introduced by NYSE Technologies as part of routine maintenance of the
current
MAMA release. Merging these changes into OpenMAMA is the final major change
required prior to introducing C++, JAVA and MAMDA.

After C++, Java and MAMDA are checked in later this month, the rhythm of
development will settle into something much more typical of open source
projects.


Mike Schonberg (50):
Ownership of message buffers
c linkage for wlock_xxx() methods
Fix timer implementation for Windows
Added WCACHEExpDLL macro for building NYSE wirecache
Make includes paths consistent
Adding new files for C++ and Windows Support
[windows] Macros for MSVC Version
[bridge] Timout for Stopping Internal Queue
[bridge] Added mamaTransport_forceClientDisconnect()
[mama] Free CM Subscription in Destroy Callback
[mama] minor datetime fixes
[mama][dqpublisher] Improved Message Handling
[mama] mamaDQPublisher_sendReplyWithHandle
[mama] Add cache and closure to dqpublisher
[mama] dqpublisher manager bug fixes
[mama] dqpublisher destroy
[mama] Configurable Schemes for data quality
[mama] Subscription: don't put invalid actions on the throttle queue
[mama] Create an Internal Transport for Monitoring
[mama] transport write queue high and low watermarks
[mama] mamaTransport_forceClientDisconnect
[mama] Change static mutexes to be recursive
[mama] Cleaup Statistics Handling in mama_close
[mama] mama.c cleanup
[mama] Add closure to mamaQueue
[mama] Do not modify attached messages
[mama] Log Messages with MAMA_MSG_STATUS_UNKNOWN
[mama] Minor Header Adjustments
[avis] Use Platform Independent UUID from Common
[avis] Fixed Compiler Warnings
[avis] Windows Changes
[avis-payload] Fixed compiler warnings
[examples] Changes for Windows
[examples] Put C examples in .../examples/c
[examples] Remove Properietary Property Entries
[mama] Renamed Methods in ft.c for Consistency
[testtools] Calling Convention for Windows Callbacks
[common] Change uuid to char* from int for Windows
[avis-payload] Correct Calling Convention for Windows
[common] Added Missing LGPL Headers
[common] Windows int MIN and MAX Definititions
[common] C Linkage for Detroy Handle
[mama] GCC 4.6.2 Support
[testtools] Renamed shutdown() method in executables
[mama] Remove msgFieldPayload from mamaMsg
[unit tests] Fixed unit tests build
[common] Moved windows/port.h to windows/wombat/port.h
[common] Removed Unnecessary Symlink to wConfig.h
[common] More Win32 Support
[unittest] Adding C Unit Tests

common/c_cpp/configure.ac | 6 +-
common/c_cpp/src/c/Makefile.am | 7 +-
common/c_cpp/src/c/destroyHandle.h | 6 +
common/c_cpp/src/c/linux/network.c | 1 +
common/c_cpp/src/c/linux/port.h | 25 +-
common/c_cpp/src/c/linux/wConfig.h | 1 +
common/c_cpp/src/c/linux/wMath.h | 32 +
common/c_cpp/src/c/linux/wUuid.h | 34 +
common/c_cpp/src/c/timers.c | 12 +-
common/c_cpp/src/c/timers.h | 12 +-
common/c_cpp/src/c/wMessageStats.c | 1021 ++++++++++++++++++++
common/c_cpp/src/c/windows/machine_win.c | 2 +-
common/c_cpp/src/c/windows/network.c | 2 +-
common/c_cpp/src/c/windows/platform.c | 2 +-
common/c_cpp/src/c/windows/port.c | 28 +-
common/c_cpp/src/c/windows/port.h | 251 -----
common/c_cpp/src/c/windows/strpcasecmp.c | 88 ++
common/c_cpp/src/c/windows/strptime.c | 376 +++++++
common/c_cpp/src/c/windows/wSemaphore.c | 2 +-
common/c_cpp/src/c/windows/wUuid.c | 69 ++
common/c_cpp/src/c/windows/wombat/port.h | 293 ++++++
common/c_cpp/src/c/windows/wombat/targetsxs.h | 29 +
common/c_cpp/src/c/windows/wombat/wConfig.h | 5 +-
common/c_cpp/src/c/windows/wombat/wMath.h | 31 +
common/c_cpp/src/c/windows/wombat/wUuid.h | 34 +
common/c_cpp/src/c/wlock.h | 8 +
common/c_cpp/src/c/wombat/environment.h | 2 +-
common/c_cpp/src/c/wombat/strutils.h | 2 +
common/c_cpp/src/c/wombat/wConfig.h | 1 -
common/c_cpp/src/c/wombat/wMessageStats.h | 210 ++++
mama/c_cpp/src/c/bridge.c | 5 +-
mama/c_cpp/src/c/bridge.h | 11 +-
mama/c_cpp/src/c/bridge/avis/Makefile.am | 2 +-
mama/c_cpp/src/c/bridge/avis/avisbridgefunctions.h | 7 +-
mama/c_cpp/src/c/bridge/avis/bridge.c | 36 +-
mama/c_cpp/src/c/bridge/avis/msg.c | 14 +-
mama/c_cpp/src/c/bridge/avis/publisher.c | 30 +-
mama/c_cpp/src/c/bridge/avis/queue.c | 20 +-
mama/c_cpp/src/c/bridge/avis/sub.c | 10 +-
mama/c_cpp/src/c/bridge/avis/subinitial.c | 26 +-
mama/c_cpp/src/c/bridge/avis/timer.c | 10 +-
mama/c_cpp/src/c/bridge/avis/transportbridge.c | 59 +-
mama/c_cpp/src/c/clientmanageresponder.c | 33 +-
mama/c_cpp/src/c/datetime.c | 155 ++--
mama/c_cpp/src/c/dqpublisher.c | 228 ++++-
mama/c_cpp/src/c/dqpublishermanager.c | 90 ++-
mama/c_cpp/src/c/dqstrategy.c | 46 +-
mama/c_cpp/src/c/dqstrategy.h | 5 +-
mama/c_cpp/src/c/ft.c | 25 +-
mama/c_cpp/src/c/listenermsgcallback.c | 144 ++--
mama/c_cpp/src/c/mama.c | 151 ++--
mama/c_cpp/src/c/mama/dqpublisher.h | 20 +
mama/c_cpp/src/c/mama/mama.h | 53 +-
mama/c_cpp/src/c/mama/queue.h | 7 +
mama/c_cpp/src/c/mama/status.h | 6 +-
mama/c_cpp/src/c/mama/subscription.h | 19 +-
mama/c_cpp/src/c/mama/transport.h | 16 +-
mama/c_cpp/src/c/mama/types.h | 9 +-
mama/c_cpp/src/c/mamainternal.h | 1 +
mama/c_cpp/src/c/middleware.c | 1 +
mama/c_cpp/src/c/msg.c | 269 ++++--
mama/c_cpp/src/c/msgfield.c | 129 ++-
mama/c_cpp/src/c/msgfieldimpl.h | 2 +-
mama/c_cpp/src/c/msgimpl.h | 3 +
mama/c_cpp/src/c/payload/avismsg/avismsgimpl.h | 1 +
mama/c_cpp/src/c/payload/avismsg/avispayload.c | 113 ++-
mama/c_cpp/src/c/payload/avismsg/avispayload.h | 5 +
mama/c_cpp/src/c/payload/avismsg/msgfield.c | 2 +-
mama/c_cpp/src/c/payloadbridge.h | 12 +-
mama/c_cpp/src/c/queue.c | 27 +-
mama/c_cpp/src/c/queueimpl.h | 6 -
mama/c_cpp/src/c/statsgenerator.c | 24 +
mama/c_cpp/src/c/statsgeneratorinternal.h | 14 +-
mama/c_cpp/src/c/status.c | 2 +-
mama/c_cpp/src/c/subscription.c | 19 +-
mama/c_cpp/src/c/transport.c | 348 +++++--
mama/c_cpp/src/c/transportimpl.h | 52 +-
mama/c_cpp/src/examples/c/Makefile.am | 2 +-
mama/c_cpp/src/examples/c/Makefile.sample | 2 +-
mama/c_cpp/src/examples/c/mamaftmemberc.c | 4 +-
mama/c_cpp/src/examples/c/mamainboxc.c | 4 +
mama/c_cpp/src/examples/c/mamalistenc.c | 1 -
mama/c_cpp/src/examples/c/mamamultisubscriberc.c | 14 +-
mama/c_cpp/src/examples/c/mamaproxyc.c | 4 +
mama/c_cpp/src/examples/c/mamapublisherc.c | 2 +-
mama/c_cpp/src/examples/mama.properties | 107 +--
mama/c_cpp/src/gunittest/c/MainUnitTestC.cpp | 20 +
mama/c_cpp/src/gunittest/c/MainUnitTestC.h | 22 +-
mama/c_cpp/src/gunittest/c/Makefile.am | 17 +-
mama/c_cpp/src/gunittest/c/datetimetest.cpp | 133 +++
mama/c_cpp/src/gunittest/c/openclose.c | 51 -
mama/c_cpp/src/gunittest/c/openclosetest.cpp | 152 +++
mama/c_cpp/src/gunittest/c/pricetest.cpp | 295 ++++++
mama/c_cpp/src/gunittest/c/subscriptiontest.cpp | 181 ++++
mama/c_cpp/src/gunittest/c/timertest.cpp | 258 +++++
.../src/testtools/capturereplay/c/Makefile.am | 2 +-
mama/c_cpp/src/testtools/load/c/Makefile.am | 2 +-
mama/c_cpp/src/testtools/load/c/mamachurnc.c | 16 +-
mama/c_cpp/src/testtools/performance/c/Makefile.am | 2 +-
.../src/testtools/performance/c/mamaconsumerc.c | 19 +-
.../src/testtools/performance/c/mamaconsumerc_v2.c | 6 +-
.../src/testtools/performance/c/mamapingpongc.c | 6 +-
.../src/testtools/performance/c/mamaproducerc_v2.c | 6 +-
103 files changed, 4997 insertions(+), 1190 deletions(-)
create mode 100644 common/c_cpp/src/c/linux/wMath.h
create mode 100644 common/c_cpp/src/c/linux/wUuid.h
create mode 100644 common/c_cpp/src/c/wMessageStats.c
delete mode 100644 common/c_cpp/src/c/windows/port.h
create mode 100644 common/c_cpp/src/c/windows/strpcasecmp.c
create mode 100644 common/c_cpp/src/c/windows/strptime.c
create mode 100644 common/c_cpp/src/c/windows/wUuid.c
create mode 100644 common/c_cpp/src/c/windows/wombat/port.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wMath.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wUuid.h
delete mode 120000 common/c_cpp/src/c/wombat/wConfig.h
create mode 100644 common/c_cpp/src/c/wombat/wMessageStats.h
create mode 100644 mama/c_cpp/src/gunittest/c/datetimetest.cpp
delete mode 100644 mama/c_cpp/src/gunittest/c/openclose.c
create mode 100644 mama/c_cpp/src/gunittest/c/openclosetest.cpp
create mode 100644 mama/c_cpp/src/gunittest/c/pricetest.cpp
create mode 100644 mama/c_cpp/src/gunittest/c/subscriptiontest.cpp
create mode 100644 mama/c_cpp/src/gunittest/c/timertest.cpp

--
1.7.7.6


[PATCH 30/30] Renamed resolve_ip to wresolve_ip

Michael Schonberg <mschonberg@...>
 

Renamed resolve_ip() to avoid naming conflicts. Also removed shared object
export prefixes from port.h as they are now in wConfig.h.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/network.c | 2 +-
common/c_cpp/src/c/linux/platform.c | 3 +-
common/c_cpp/src/c/linux/port.h | 14 +------
common/c_cpp/src/c/windows/network.c | 2 +-
common/c_cpp/src/c/windows/port.h | 76 +---------------------------------
common/c_cpp/src/c/wombat/wCommon.h | 2 +-
mama/c_cpp/src/c/ft.c | 4 +-
7 files changed, 9 insertions(+), 94 deletions(-)

diff --git a/common/c_cpp/src/c/linux/network.c b/common/c_cpp/src/c/linux/network.c
index 75e5658..9969ff9 100644
--- a/common/c_cpp/src/c/linux/network.c
+++ b/common/c_cpp/src/c/linux/network.c
@@ -25,7 +25,7 @@
#include "wombat/wCommon.h"


-struct in_addr resolve_ip (const char * arg)
+struct in_addr wresolve_ip (const char * arg)
{

struct in_addr resolved;
diff --git a/common/c_cpp/src/c/linux/platform.c b/common/c_cpp/src/c/linux/platform.c
index 881ecde..dcab90a 100644
--- a/common/c_cpp/src/c/linux/platform.c
+++ b/common/c_cpp/src/c/linux/platform.c
@@ -1,5 +1,4 @@
-/* $Id: platform.c,v 1.8.16.2 2011/08/10 14:53:24 nicholasmarriott Exp $
- *
+/*
* OpenMAMA: The open middleware agnostic messaging API
* Copyright (C) 2011 NYSE Inc.
*
diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 35877a1..c328479 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -55,15 +55,7 @@ extern "C"
#include <inttypes.h>
#include <pwd.h>

-/* Call Types */
-#define COMMONExpDLL
-#define WMWExpDLL
-#define MAMAExpDLL
-#define MAMACPPExpDLL
-#define MAMDAExpDLL
-#define MAMDAOPTExpDLL
-#define MAMAExpBridgeDLL
-#define MAMACALLTYPE
+#include "wConfig.h"

/* PTHREAD static locks are easy */
typedef pthread_mutex_t wthread_static_mutex_t;
@@ -71,10 +63,6 @@ typedef pthread_mutex_t wthread_static_mutex_t;
#define wthread_static_mutex_lock(x) pthread_mutex_lock((x))
#define wthread_static_mutex_unlock(x) pthread_mutex_unlock((x))

-
-#define WCOMMONINLINE inline static
-#define WCOMMONFORCEINLINE inline static
-
/* Type for handle to dynamically loaded library */
typedef void* LIB_HANDLE;

diff --git a/common/c_cpp/src/c/windows/network.c b/common/c_cpp/src/c/windows/network.c
index e7c1ece..b80914e 100644
--- a/common/c_cpp/src/c/windows/network.c
+++ b/common/c_cpp/src/c/windows/network.c
@@ -20,7 +20,7 @@

#include "port.h"

-struct in_addr resolve_ip (const char * arg)
+struct in_addr wresolve_ip (const char * arg)
{
struct in_addr resolved;

diff --git a/common/c_cpp/src/c/windows/port.h b/common/c_cpp/src/c/windows/port.h
index 7df1f55..92080fd 100644
--- a/common/c_cpp/src/c/windows/port.h
+++ b/common/c_cpp/src/c/windows/port.h
@@ -37,6 +37,7 @@
#include <tlhelp32.h>
#include <time.h>

+#include "wConfig.h"
#include "lock.h"
#include "mmap.h"

@@ -47,9 +48,6 @@ extern "C" {
/* So Windows compiler ignores gcc __attribute__(x) */
#define __attribute__(a)

-#define WCOMMONINLINE __inline
-#define WCOMMONFORCEINLINE __forceinline
-
/* Type for handle to dynamically loaded library */
typedef HINSTANCE LIB_HANDLE;

@@ -89,76 +87,6 @@ typedef __int64 w_i64_t;

#define PATHSEP "\\"

-/* Calling conventions */
-#define MAMACALLTYPE __stdcall
-
-#if defined( COMMON_DLL )
- /* We are building common dll */
-# define COMMONExpDLL __declspec( dllexport )
-#elif defined( MAMA_DLL ) && defined( MAMA )
- /* We are building mama as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL __declspec( dllexport )
-#elif defined( MAMA_DLL ) && defined( BRIDGE )
- /* We are building mama bridge as a dll */
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMAExpBridgeDLL __declspec( dllimport )
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL
-# define MAMDAExpDLL
-# define MAMDAOPTExpDLL
-# define WMWExpDLL __declspec( dllimport )
-#elif defined( MAMA_DLL ) && defined( MAMACPP )
- /* We are building mamacpp as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL
-#elif defined( MAMDA_DLL ) && defined( MAMDA )
- /* We are building mamda as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllimport )
-# define MAMDAExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL
-#elif defined( MAMDA_DLL ) && defined( MAMDAOPT )
- /* We are building extra mamda as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllimport )
-# define MAMDAExpDLL __declspec( dllimport )
-# define MAMDAOPTExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL
-#elif !defined ( MAMA_STATIC ) && !defined ( WMW_STATIC ) && !defined (WIRECACHE_STATIC)
- /* We are building mama apps (non static) */
-# define COMMONExpDLL __declspec( dllimport )
-# define WMWExpDLL __declspec( dllexport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllimport )
-# define MAMDAExpDLL __declspec( dllimport )
-# define MAMDAOPTExpDLL __declspec( dllimport )
-# define MAMAExpBridgeDLL
-#elif defined( WIN32 ) && defined( WMW_DLL )
- /* We are building wmw as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define WMWExpDLL __declspec( dllexport )
-#elif defined( WIN32 ) && defined( WMW_APP )
- /* We are building wmw test apps */
-# define COMMONExpDLL __declspec( dllimport )
-# define WMWExpDLL __declspec( dllimport )
-#else
- /* We are building on linux or statically */
-# define COMMONExpDLL
-# define WMWExpDLL
-# define WCACHEExpDLL
-# define MAMAExpDLL
-# define MAMACPPExpDLL
-# define MAMDAExpDLL
-# define MAMDAOPTExpDLL
-# define MAMAExpBridgeDLL
-#endif
-
/* Socket Pair and set non blocking */
COMMONExpDLL int
wsocketpair (int domain, int type, int protocol, int* pair);
@@ -172,7 +100,7 @@ wsetnonblock (int s);
COMMONExpDLL const char* getIpAddress (void);
COMMONExpDLL const char* getHostName (void);
COMMONExpDLL const char* getlogin (void);
-COMMONExpDLL struct in_addr resolve_ip (const char * arg);
+COMMONExpDLL struct in_addr wresolve_ip (const char * arg);

/* Thread local storage */
typedef DWORD wthread_key_t;
diff --git a/common/c_cpp/src/c/wombat/wCommon.h b/common/c_cpp/src/c/wombat/wCommon.h
index 647751b..71085b9 100644
--- a/common/c_cpp/src/c/wombat/wCommon.h
+++ b/common/c_cpp/src/c/wombat/wCommon.h
@@ -25,6 +25,6 @@
/* Moved to _os_/port.h */
#include "wombat/port.h"

-struct in_addr resolve_ip(const char * arg);
+struct in_addr wresolve_ip(const char * arg);

#endif /* _WOMBAT_WCOMMON_H */
diff --git a/mama/c_cpp/src/c/ft.c b/mama/c_cpp/src/c/ft.c
index 1948650..97c9bae 100644
--- a/mama/c_cpp/src/c/ft.c
+++ b/mama/c_cpp/src/c/ft.c
@@ -204,7 +204,7 @@ void checkHeartbeat (mamaFtMemberImpl* impl,
int hbPrimary,
char* hbGroupName);

-struct in_addr resolve_ip (const char * arg);
+struct in_addr wresolve_ip (const char * arg);

/* FT callbacks: */
static void MAMACALLTYPE
@@ -882,7 +882,7 @@ multicastFt_setup (
/* if interface name is set */
if (ftInterface!=NULL && ftInterface[0]!='\0')
{
- cFtIfAddr = resolve_ip (ftInterface);
+ cFtIfAddr = wresolve_ip (ftInterface);

if (cFtIfAddr.s_addr == INADDR_NONE)
{
--
1.7.7.6


[PATCH 29/30] Moved port.h to wombat sub directory

Michael Schonberg <mschonberg@...>
 

Moved port.h to wombat subdirectory since it should be part of the distribution.
wConfig was als split with the windows shared object prefixes into the linux and
windows subdirectories.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/configure.ac | 15 ++--
common/c_cpp/src/c/MRSWLock.c | 2 +-
common/c_cpp/src/c/Makefile.am | 2 +-
common/c_cpp/src/c/destroyHandle.c | 2 +-
common/c_cpp/src/c/linux/machine.c | 2 +-
common/c_cpp/src/c/linux/platform.c | 2 +-
common/c_cpp/src/c/linux/port.h | 2 +-
common/c_cpp/src/c/linux/wConfig.h | 40 ++++++++
common/c_cpp/src/c/linux/wSemaphore.c | 2 +-
common/c_cpp/src/c/list.c | 2 +-
common/c_cpp/src/c/machine.c | 2 +-
common/c_cpp/src/c/properties.l | 2 +-
common/c_cpp/src/c/property.c | 2 +-
common/c_cpp/src/c/queue.c | 2 +-
common/c_cpp/src/c/strutils.c | 2 +-
common/c_cpp/src/c/timers.c | 2 +-
common/c_cpp/src/c/timers.h | 2 +-
common/c_cpp/src/c/windows/wombat/wConfig.h | 101 ++++++++++++++++++++
common/c_cpp/src/c/wlock.c | 2 +-
common/c_cpp/src/c/wombat/wCommon.h | 2 +-
common/c_cpp/src/c/wombat/wConfig.h | 31 +------
common/c_cpp/src/c/wombat/wSemaphore.h | 2 +-
common/c_cpp/src/c/wombat/wincompat.h | 2 +-
mama/c_cpp/src/c/bridge/avis/bridge.c | 2 +-
mama/c_cpp/src/c/bridge/avis/msg.c | 2 +-
mama/c_cpp/src/c/bridge/avis/transportbridge.c | 2 +-
mama/c_cpp/src/c/conflation/connection.c | 2 +-
mama/c_cpp/src/c/conflation/connection_int.h | 2 +-
mama/c_cpp/src/c/conflation/manager.c | 2 +-
mama/c_cpp/src/c/conflation/manager_int.h | 2 +-
mama/c_cpp/src/c/conflation/serverconnection_int.h | 2 +-
mama/c_cpp/src/c/imagerequest.c | 2 +-
mama/c_cpp/src/c/imagerequest.h | 2 +-
mama/c_cpp/src/c/mama.c | 2 +-
mama/c_cpp/src/c/mama/conflation/manager.h | 2 +-
mama/c_cpp/src/c/mama/datetime.h | 2 +-
mama/c_cpp/src/c/mama/fielddesc.h | 2 +-
mama/c_cpp/src/c/mama/msg.h | 2 +-
mama/c_cpp/src/c/mama/msgfield.h | 2 +-
mama/c_cpp/src/c/mama/subscriptiontype.h | 2 +-
mama/c_cpp/src/c/mama/timezone.h | 2 +-
mama/c_cpp/src/c/mama/types.h | 2 +-
mama/c_cpp/src/c/msg.c | 2 +-
mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c | 2 +-
mama/c_cpp/src/c/playback/playbackFileParser.h | 2 +-
mama/c_cpp/src/c/playback/playbackpublisher.h | 2 +-
mama/c_cpp/src/c/queue.c | 2 +-
mama/c_cpp/src/c/senderId.c | 2 +-
mama/c_cpp/src/c/stat.c | 2 +-
mama/c_cpp/src/c/timezone.c | 2 +-
mama/c_cpp/src/examples/c/mamainboxc.c | 2 +-
mama/c_cpp/src/examples/c/mamaio.c | 2 +-
mama/c_cpp/src/examples/c/mamalistenc.c | 2 +-
mama/c_cpp/src/examples/c/mamaproxyc.c | 2 +-
mama/c_cpp/src/examples/c/mamapublisherc.c | 2 +-
55 files changed, 201 insertions(+), 88 deletions(-)
create mode 100644 common/c_cpp/src/c/linux/wConfig.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wConfig.h
mode change 100644 => 120000 common/c_cpp/src/c/wombat/wConfig.h

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index ab991b4..e288769 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -46,13 +46,14 @@ AC_CANONICAL_BUILD()
# Set up symbolic links for os-specific files
AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
case $build_os in
- linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h
- src/c/wombat/wInterlocked.h:src/c/linux/wInterlocked.h
- src/c/machine_port.c:src/c/linux/machine.c
- src/c/platform.c:src/c/linux/platform.c
- src/c/wSemaphore.c:src/c/linux/wSemaphore.c
- src/c/network.c:src/c/linux/network.c
- src/c/environment.c:src/c/linux/environment.c]) ;;
+ linux*-*) AC_CONFIG_LINKS([$srcdir/src/c/wombat/port.h:src/c/linux/port.h
+ $srcdir/src/c/wombat/wConfig.h:src/c/linux/wConfig.h
+ $srcdir/src/c/wombat/wInterlocked.h:src/c/linux/wInterlocked.h
+ $srcdir/src/c/machine_port.c:src/c/linux/machine.c
+ $srcdir/src/c/platform.c:src/c/linux/platform.c
+ $srcdir/src/c/wSemaphore.c:src/c/linux/wSemaphore.c
+ $srcdir/src/c/network.c:src/c/linux/network.c
+ $srcdir/src/c/environment.c:src/c/linux/environment.c]) ;;
esac

# Checks for programs.
diff --git a/common/c_cpp/src/c/MRSWLock.c b/common/c_cpp/src/c/MRSWLock.c
index 8cccb7c..16131ee 100644
--- a/common/c_cpp/src/c/MRSWLock.c
+++ b/common/c_cpp/src/c/MRSWLock.c
@@ -22,7 +22,7 @@
/* ********************************************************** */
/* Includes. */
/* ********************************************************** */
-#include "port.h"
+#include "wombat/port.h"
#include "wombat/MRSWLock.h"
#include <stdlib.h>

diff --git a/common/c_cpp/src/c/Makefile.am b/common/c_cpp/src/c/Makefile.am
index 9258c21..9a42259 100644
--- a/common/c_cpp/src/c/Makefile.am
+++ b/common/c_cpp/src/c/Makefile.am
@@ -38,7 +38,7 @@ nobase_include_HEADERS = \
property.h \
wlock.h \
timers.h \
- port.h \
+ wombat/port.h \
wombat/MRSWLock.h \
wombat/environment.h \
wombat/machine.h \
diff --git a/common/c_cpp/src/c/destroyHandle.c b/common/c_cpp/src/c/destroyHandle.c
index cf63ea8..9a21b10 100644
--- a/common/c_cpp/src/c/destroyHandle.c
+++ b/common/c_cpp/src/c/destroyHandle.c
@@ -22,7 +22,7 @@
/* ************************************************************** */
/* Includes. */
/* ************************************************************** */
-#include "port.h"
+#include "wombat/port.h"
#include "destroyHandle.h"
#include <stdio.h>

diff --git a/common/c_cpp/src/c/linux/machine.c b/common/c_cpp/src/c/linux/machine.c
index 375734c..60fa0a1 100644
--- a/common/c_cpp/src/c/linux/machine.c
+++ b/common/c_cpp/src/c/linux/machine.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <sys/stat.h>

#include <ctype.h>
diff --git a/common/c_cpp/src/c/linux/platform.c b/common/c_cpp/src/c/linux/platform.c
index 8bf7f4e..881ecde 100644
--- a/common/c_cpp/src/c/linux/platform.c
+++ b/common/c_cpp/src/c/linux/platform.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 4e956c8..35877a1 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -179,7 +179,7 @@ struct wtimespec
long tv_nsec;
};

-#define wnanosleep (ts, remain) nanosleep(((struct timespec)(ts)),(remain))
+#define wnanosleep(ts, remain) nanosleep(((struct timespec*)(ts)),(remain))


/* net work utility functions */
diff --git a/common/c_cpp/src/c/linux/wConfig.h b/common/c_cpp/src/c/linux/wConfig.h
new file mode 100644
index 0000000..1d3d906
--- /dev/null
+++ b/common/c_cpp/src/c/linux/wConfig.h
@@ -0,0 +1,40 @@
+/* $Id: wConfig.h,v 1.1.2.1 2012/02/22 01:20:51 mikeschonberg Exp $
+ *
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _WOMBAT_WCONFIG_H
+#define _WOMBAT_WCONFIG_H
+
+/* Call Types */
+#define COMMONExpDLL
+#define WMWExpDLL
+#define MAMAExpDLL
+#define MAMACPPExpDLL
+#define MAMDAExpDLL
+#define MAMDAOPTExpDLL
+#define MAMAExpBridgeDLL
+#define MAMACALLTYPE
+
+#define WCOMMONINLINE inline static
+#define WCOMMONFORCEINLINE inline static
+
+#endif /* _WOMBAT_WCONFIG_H */
+
+
diff --git a/common/c_cpp/src/c/linux/wSemaphore.c b/common/c_cpp/src/c/linux/wSemaphore.c
index 39327fb..7c29b4b 100644
--- a/common/c_cpp/src/c/linux/wSemaphore.c
+++ b/common/c_cpp/src/c/linux/wSemaphore.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"

#include "wombat/wSemaphore.h"

diff --git a/common/c_cpp/src/c/list.c b/common/c_cpp/src/c/list.c
index ef3a00d..42f3072 100644
--- a/common/c_cpp/src/c/list.c
+++ b/common/c_cpp/src/c/list.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"

#include <stdlib.h>
#include <stdio.h>
diff --git a/common/c_cpp/src/c/machine.c b/common/c_cpp/src/c/machine.c
index fc43143..38b602d 100644
--- a/common/c_cpp/src/c/machine.c
+++ b/common/c_cpp/src/c/machine.c
@@ -18,7 +18,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <sys/stat.h>

#include <ctype.h>
diff --git a/common/c_cpp/src/c/properties.l b/common/c_cpp/src/c/properties.l
index 3c327e3..2a6f0a8 100644
--- a/common/c_cpp/src/c/properties.l
+++ b/common/c_cpp/src/c/properties.l
@@ -22,7 +22,7 @@
/** This file should be processed by FLEX or LEX **/

%{
-#include "port.h"
+#include "wombat/port.h"
#include "propertyinternal.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/common/c_cpp/src/c/property.c b/common/c_cpp/src/c/property.c
index a5271ec..77cac8e 100644
--- a/common/c_cpp/src/c/property.c
+++ b/common/c_cpp/src/c/property.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"

#include <stdlib.h>
#include <stdio.h>
diff --git a/common/c_cpp/src/c/queue.c b/common/c_cpp/src/c/queue.c
index 6ae740b..1969d6a 100644
--- a/common/c_cpp/src/c/queue.c
+++ b/common/c_cpp/src/c/queue.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/common/c_cpp/src/c/strutils.c b/common/c_cpp/src/c/strutils.c
index 4874fe6..5410770 100644
--- a/common/c_cpp/src/c/strutils.c
+++ b/common/c_cpp/src/c/strutils.c
@@ -23,7 +23,7 @@
#define __STDC_FORMAT_MACROS
#endif

-#include "port.h"
+#include "wombat/port.h"

#include <stdio.h>
#include <string.h>
diff --git a/common/c_cpp/src/c/timers.c b/common/c_cpp/src/c/timers.c
index b5680c8..cb93ce8 100644
--- a/common/c_cpp/src/c/timers.c
+++ b/common/c_cpp/src/c/timers.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include "timers.h"

#include <sys/types.h>
diff --git a/common/c_cpp/src/c/timers.h b/common/c_cpp/src/c/timers.h
index 4f4fb4d..22989f3 100644
--- a/common/c_cpp/src/c/timers.h
+++ b/common/c_cpp/src/c/timers.h
@@ -22,7 +22,7 @@
#ifndef TIMERS_INTERNAL_
#define TIMERS_INTERNAL_

-#include "port.h"
+#include "wombat/port.h"

typedef void* timerElement;
typedef void* timerHeap;
diff --git a/common/c_cpp/src/c/windows/wombat/wConfig.h b/common/c_cpp/src/c/windows/wombat/wConfig.h
new file mode 100644
index 0000000..2b944be
--- /dev/null
+++ b/common/c_cpp/src/c/windows/wombat/wConfig.h
@@ -0,0 +1,101 @@
+/* $Id: wConfig.h,v 1.1.2.1 2012/02/22 03:02:23 mikeschonberg Exp $
+ *
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _WOMBAT_WCONFIG_H
+#define _WOMBAT_WCONFIG_H
+
+/* Calling conventions */
+#define MAMACALLTYPE __stdcall
+
+#if defined( COMMON_DLL )
+ /* We are building common dll */
+# define COMMONExpDLL __declspec( dllexport )
+#elif defined( MAMA_DLL ) && defined( MAMA )
+ /* We are building mama as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL __declspec( dllexport )
+#elif defined( MAMA_DLL ) && defined( BRIDGE )
+ /* We are building mama bridge as a dll */
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMAExpBridgeDLL __declspec( dllimport )
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL
+# define MAMDAExpDLL
+# define MAMDAOPTExpDLL
+# define WMWExpDLL __declspec( dllimport )
+#elif defined( MAMA_DLL ) && defined( MAMACPP )
+ /* We are building mamacpp as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL
+#elif defined( MAMDA_DLL ) && defined( MAMDA )
+ /* We are building mamda as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllimport )
+# define MAMDAExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL
+#elif defined( MAMDA_DLL ) && defined( MAMDAOPT )
+ /* We are building extra mamda as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllimport )
+# define MAMDAExpDLL __declspec( dllimport )
+# define MAMDAOPTExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL
+#elif !defined ( MAMA_STATIC ) && !defined ( WMW_STATIC ) && !defined (WIRECACHE_STATIC)
+ /* We are building mama apps (non static) */
+# define COMMONExpDLL __declspec( dllimport )
+# define WMWExpDLL __declspec( dllexport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllimport )
+# define MAMDAExpDLL __declspec( dllimport )
+# define MAMDAOPTExpDLL __declspec( dllimport )
+# define MAMAExpBridgeDLL
+#elif defined( WIN32 ) && defined( WMW_DLL )
+ /* We are building wmw as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define WMWExpDLL __declspec( dllexport )
+#elif defined( WIN32 ) && defined( WMW_APP )
+ /* We are building wmw test apps */
+# define COMMONExpDLL __declspec( dllimport )
+# define WMWExpDLL __declspec( dllimport )
+#else
+ /* We are building on linux or statically */
+# define COMMONExpDLL
+# define WMWExpDLL
+# define WCACHEExpDLL
+# define MAMAExpDLL
+# define MAMACPPExpDLL
+# define MAMDAExpDLL
+# define MAMDAOPTExpDLL
+# define MAMAExpBridgeDLL
+#endif
+
+#define WCOMMONINLINE __inline
+#define WCOMMONFORCEINLINE __forceinline
+
+
+#endif /* _WOMBAT_WCONFIG_H */
+
+
diff --git a/common/c_cpp/src/c/wlock.c b/common/c_cpp/src/c/wlock.c
index e23daa6..c57bd5c 100644
--- a/common/c_cpp/src/c/wlock.c
+++ b/common/c_cpp/src/c/wlock.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"

#include <stdlib.h>
#include <stdio.h>
diff --git a/common/c_cpp/src/c/wombat/wCommon.h b/common/c_cpp/src/c/wombat/wCommon.h
index c40112f..647751b 100644
--- a/common/c_cpp/src/c/wombat/wCommon.h
+++ b/common/c_cpp/src/c/wombat/wCommon.h
@@ -23,7 +23,7 @@
#define _WOMBAT_WCOMMON_H

/* Moved to _os_/port.h */
-#include "port.h"
+#include "wombat/port.h"

struct in_addr resolve_ip(const char * arg);

diff --git a/common/c_cpp/src/c/wombat/wConfig.h b/common/c_cpp/src/c/wombat/wConfig.h
deleted file mode 100644
index c7cf7af..0000000
--- a/common/c_cpp/src/c/wombat/wConfig.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $Id: wConfig.h,v 1.6.2.1.12.4 2011/08/10 14:53:24 nicholasmarriott Exp $
- *
- * OpenMAMA: The open middleware agnostic messaging API
- * Copyright (C) 2011 NYSE Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#ifndef _WOMBAT_WCONFIG_H
-#define _WOMBAT_WCONFIG_H
-
-/* Moved to _os_/port/h */
-#include "port.h"
-
-#endif /* _WOMBAT_WCONFIG_H */
-
-
diff --git a/common/c_cpp/src/c/wombat/wConfig.h b/common/c_cpp/src/c/wombat/wConfig.h
new file mode 120000
index 0000000..3414bff
--- /dev/null
+++ b/common/c_cpp/src/c/wombat/wConfig.h
@@ -0,0 +1 @@
+../../.././src/c/linux/wConfig.h
\ No newline at end of file
diff --git a/common/c_cpp/src/c/wombat/wSemaphore.h b/common/c_cpp/src/c/wombat/wSemaphore.h
index 9adb8d2..15e90cf 100644
--- a/common/c_cpp/src/c/wombat/wSemaphore.h
+++ b/common/c_cpp/src/c/wombat/wSemaphore.h
@@ -22,6 +22,6 @@
#ifndef WSEMAPHORE_H__
#define WSEMAPHORE_H__

-#include "port.h"
+#include "wombat/port.h"

#endif /* WSEMAPHORE_H__ */
diff --git a/common/c_cpp/src/c/wombat/wincompat.h b/common/c_cpp/src/c/wombat/wincompat.h
index c80c60b..4e785e8 100644
--- a/common/c_cpp/src/c/wombat/wincompat.h
+++ b/common/c_cpp/src/c/wombat/wincompat.h
@@ -23,6 +23,6 @@
#define _WOMBAT_WINCOMPAT_H

/* Moved to _os_/port.h */
-#include "port.h"
+#include "wombat/port.h"

#endif /* _WOMBAT_WINCOMPAT_H */
diff --git a/mama/c_cpp/src/c/bridge/avis/bridge.c b/mama/c_cpp/src/c/bridge/avis/bridge.c
index 5f2b973..24c369a 100755
--- a/mama/c_cpp/src/c/bridge/avis/bridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/bridge.c
@@ -21,7 +21,7 @@

#include <avis/elvin.h>

-#include "port.h"
+#include "wombat/port.h"

#include <mama/mama.h>
#include <timers.h>
diff --git a/mama/c_cpp/src/c/bridge/avis/msg.c b/mama/c_cpp/src/c/bridge/avis/msg.c
index 82176e9..8cc97eb 100644
--- a/mama/c_cpp/src/c/bridge/avis/msg.c
+++ b/mama/c_cpp/src/c/bridge/avis/msg.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <stdlib.h>
#include <string.h>

diff --git a/mama/c_cpp/src/c/bridge/avis/transportbridge.c b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
index 1d7bc44..c994879 100755
--- a/mama/c_cpp/src/c/bridge/avis/transportbridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
@@ -22,7 +22,7 @@
#include <avis/elvin.h>
#include <avis/avis_client_config.h>

-#include "port.h"
+#include "wombat/port.h"

#include <property.h>
#include <mama/mama.h>
diff --git a/mama/c_cpp/src/c/conflation/connection.c b/mama/c_cpp/src/c/conflation/connection.c
index eddb291..4f0fed9 100644
--- a/mama/c_cpp/src/c/conflation/connection.c
+++ b/mama/c_cpp/src/c/conflation/connection.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/
#include <string.h>
-#include "port.h"
+#include "wombat/port.h"

#include "mama/conflation/connection.h"
#include "conflation/connection_int.h"
diff --git a/mama/c_cpp/src/c/conflation/connection_int.h b/mama/c_cpp/src/c/conflation/connection_int.h
index a478b79..28f8590 100644
--- a/mama/c_cpp/src/c/conflation/connection_int.h
+++ b/mama/c_cpp/src/c/conflation/connection_int.h
@@ -22,7 +22,7 @@
#ifndef MAMA_CONNECTION_INT_H__
#define MAMA_CONNECTION_INT_H__

-#include "port.h"
+#include "wombat/port.h"

#include "mama/conflation/connection.h"

diff --git a/mama/c_cpp/src/c/conflation/manager.c b/mama/c_cpp/src/c/conflation/manager.c
index 90fed15..53fa5ab 100644
--- a/mama/c_cpp/src/c/conflation/manager.c
+++ b/mama/c_cpp/src/c/conflation/manager.c
@@ -20,7 +20,7 @@
*/

#include <string.h>
-#include "port.h"
+#include "wombat/port.h"

#include "mama/mama.h"
#include "mama/conflation/manager.h"
diff --git a/mama/c_cpp/src/c/conflation/manager_int.h b/mama/c_cpp/src/c/conflation/manager_int.h
index 1464579..7d4bc70 100644
--- a/mama/c_cpp/src/c/conflation/manager_int.h
+++ b/mama/c_cpp/src/c/conflation/manager_int.h
@@ -26,7 +26,7 @@

#ifndef MAMA_MANAGER_INT_H__
#define MAMA_MANAGER_INT_H__
-#include "port.h"
+#include "wombat/port.h"

#include "mama/conflation/manager.h"

diff --git a/mama/c_cpp/src/c/conflation/serverconnection_int.h b/mama/c_cpp/src/c/conflation/serverconnection_int.h
index c5bcb51..1c6fa92 100644
--- a/mama/c_cpp/src/c/conflation/serverconnection_int.h
+++ b/mama/c_cpp/src/c/conflation/serverconnection_int.h
@@ -22,7 +22,7 @@
#ifndef MAMA_SERVER_CONNECTION_INT_H__
#define MAMA_SERVER_CONNECTION_INT_H__

-#include "port.h"
+#include "wombat/port.h"

#if defined(__cplusplus)
extern "C" {
diff --git a/mama/c_cpp/src/c/imagerequest.c b/mama/c_cpp/src/c/imagerequest.c
index 7e42ed6..b6d855d 100644
--- a/mama/c_cpp/src/c/imagerequest.c
+++ b/mama/c_cpp/src/c/imagerequest.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <mama/mama.h>
#include <mamainternal.h>
#include <imagerequest.h>
diff --git a/mama/c_cpp/src/c/imagerequest.h b/mama/c_cpp/src/c/imagerequest.h
index 9605916..9c8c6d1 100644
--- a/mama/c_cpp/src/c/imagerequest.h
+++ b/mama/c_cpp/src/c/imagerequest.h
@@ -22,7 +22,7 @@
#ifndef MamaImageRequestH__
#define MamaImageRequestH__

-#include "port.h"
+#include "wombat/port.h"

#include "wombat/wincompat.h"
#include "throttle.h"
diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c
index 3891b39..206892d 100644
--- a/mama/c_cpp/src/c/mama.c
+++ b/mama/c_cpp/src/c/mama.c
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <limits.h>

-#include "port.h"
+#include "wombat/port.h"
#include "wombat/environment.h"
#include "wombat/strutils.h"

diff --git a/mama/c_cpp/src/c/mama/conflation/manager.h b/mama/c_cpp/src/c/mama/conflation/manager.h
index 0bce01a..fc7f32a 100644
--- a/mama/c_cpp/src/c/mama/conflation/manager.h
+++ b/mama/c_cpp/src/c/mama/conflation/manager.h
@@ -25,7 +25,7 @@

#include <string.h>

-#include "port.h"
+#include "wombat/port.h"
#include "mama/mama.h"

#if defined(__cplusplus)
diff --git a/mama/c_cpp/src/c/mama/datetime.h b/mama/c_cpp/src/c/mama/datetime.h
index ecc77d0..c9e862a 100644
--- a/mama/c_cpp/src/c/mama/datetime.h
+++ b/mama/c_cpp/src/c/mama/datetime.h
@@ -26,7 +26,7 @@
#include <mama/status.h>
#include <mama/types.h>
#include <mama/timezone.h>
-#include "port.h"
+#include "wombat/port.h"

#include <time.h>

diff --git a/mama/c_cpp/src/c/mama/fielddesc.h b/mama/c_cpp/src/c/mama/fielddesc.h
index 8d7f907..fbf2d83 100644
--- a/mama/c_cpp/src/c/mama/fielddesc.h
+++ b/mama/c_cpp/src/c/mama/fielddesc.h
@@ -30,7 +30,7 @@
#include <mama/types.h>
#include <stdlib.h>

-#include "port.h"
+#include "wombat/port.h"

#if defined(__cplusplus)
extern "C" {
diff --git a/mama/c_cpp/src/c/mama/msg.h b/mama/c_cpp/src/c/mama/msg.h
index 2d17d22..77fc94f 100644
--- a/mama/c_cpp/src/c/mama/msg.h
+++ b/mama/c_cpp/src/c/mama/msg.h
@@ -26,7 +26,7 @@
#include <mama/status.h>
#include <mama/fielddesc.h>
#include <mama/msgtype.h>
-#include "port.h"
+#include "wombat/port.h"
#include <stdlib.h>

#define ENTITLE_FIELD_NAME "wEntitleCode"
diff --git a/mama/c_cpp/src/c/mama/msgfield.h b/mama/c_cpp/src/c/mama/msgfield.h
index 191b700..f9931ca 100644
--- a/mama/c_cpp/src/c/mama/msgfield.h
+++ b/mama/c_cpp/src/c/mama/msgfield.h
@@ -27,7 +27,7 @@
#include <mama/fielddesc.h>
#include <stdlib.h>

-#include "port.h"
+#include "wombat/port.h"

#if defined(__cplusplus)
extern "C" {
diff --git a/mama/c_cpp/src/c/mama/subscriptiontype.h b/mama/c_cpp/src/c/mama/subscriptiontype.h
index 14e023d..6597fad 100644
--- a/mama/c_cpp/src/c/mama/subscriptiontype.h
+++ b/mama/c_cpp/src/c/mama/subscriptiontype.h
@@ -22,7 +22,7 @@
#ifndef MAMA_SUBSC_TYPE_H__
#define MAMA_SUBSC_TYPE_H__

-#include "port.h"
+#include "wombat/port.h"
/*
* This file provides subscription type information.
*/
diff --git a/mama/c_cpp/src/c/mama/timezone.h b/mama/c_cpp/src/c/mama/timezone.h
index 5991b8c..d3f0c97 100644
--- a/mama/c_cpp/src/c/mama/timezone.h
+++ b/mama/c_cpp/src/c/mama/timezone.h
@@ -25,7 +25,7 @@
#include <mama/config.h>
#include <mama/status.h>
#include <mama/types.h>
-#include "port.h"
+#include "wombat/port.h"

#include <time.h>

diff --git a/mama/c_cpp/src/c/mama/types.h b/mama/c_cpp/src/c/mama/types.h
index 4874fc8..d26c206 100644
--- a/mama/c_cpp/src/c/mama/types.h
+++ b/mama/c_cpp/src/c/mama/types.h
@@ -26,7 +26,7 @@
extern "C" {
#endif

-#include "port.h"
+#include "wombat/port.h"
#include <stdlib.h>
#include <string.h>

diff --git a/mama/c_cpp/src/c/msg.c b/mama/c_cpp/src/c/msg.c
index ca26b6b..ca17bf0 100644
--- a/mama/c_cpp/src/c/msg.c
+++ b/mama/c_cpp/src/c/msg.c
@@ -20,7 +20,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
diff --git a/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c b/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c
index 7d13748..93cecc3 100755
--- a/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c
+++ b/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c
@@ -26,7 +26,7 @@

#include <avis/elvin.h>

-#include "port.h"
+#include "wombat/port.h"

#include <mama/mama.h>
#include "avismsgimpl.h"
diff --git a/mama/c_cpp/src/c/playback/playbackFileParser.h b/mama/c_cpp/src/c/playback/playbackFileParser.h
index 6435033..dea82c6 100644
--- a/mama/c_cpp/src/c/playback/playbackFileParser.h
+++ b/mama/c_cpp/src/c/playback/playbackFileParser.h
@@ -27,7 +27,7 @@
extern "C" {
#endif

-#include "port.h"
+#include "wombat/port.h"

#include <stdlib.h>
#include <fcntl.h>
diff --git a/mama/c_cpp/src/c/playback/playbackpublisher.h b/mama/c_cpp/src/c/playback/playbackpublisher.h
index 1e638d2..f0e4fc2 100644
--- a/mama/c_cpp/src/c/playback/playbackpublisher.h
+++ b/mama/c_cpp/src/c/playback/playbackpublisher.h
@@ -39,7 +39,7 @@ extern "C" {
#include <lookup2.h>
#include <wombat/wtable.h>
#include "playbackFileParser.h"
-#include "port.h"
+#include "wombat/port.h"

#define BUFFER_SIZE 128
typedef struct mamaFilePlayback_
diff --git a/mama/c_cpp/src/c/queue.c b/mama/c_cpp/src/c/queue.c
index 2dcda25..4026a1a 100644
--- a/mama/c_cpp/src/c/queue.c
+++ b/mama/c_cpp/src/c/queue.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <mama/mama.h>
#include <mama/queue.h>
#include "bridge.h"
diff --git a/mama/c_cpp/src/c/senderId.c b/mama/c_cpp/src/c/senderId.c
index f37c94c..8b4c849 100644
--- a/mama/c_cpp/src/c/senderId.c
+++ b/mama/c_cpp/src/c/senderId.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include "wombat/wincompat.h"
#include "mama/senderId.h"

diff --git a/mama/c_cpp/src/c/stat.c b/mama/c_cpp/src/c/stat.c
index 4564edb..89b257c 100644
--- a/mama/c_cpp/src/c/stat.c
+++ b/mama/c_cpp/src/c/stat.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <string.h>
#include <stddef.h>
#include "wombat/wincompat.h"
diff --git a/mama/c_cpp/src/c/timezone.c b/mama/c_cpp/src/c/timezone.c
index a18a7ad..90698b6 100644
--- a/mama/c_cpp/src/c/timezone.c
+++ b/mama/c_cpp/src/c/timezone.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include "wombat/environment.h"
#include <mama/timezone.h>
#include <list.h>
diff --git a/mama/c_cpp/src/examples/c/mamainboxc.c b/mama/c_cpp/src/examples/c/mamainboxc.c
index 9f528b8..4e2b9b7 100644
--- a/mama/c_cpp/src/examples/c/mamainboxc.c
+++ b/mama/c_cpp/src/examples/c/mamainboxc.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include "mama/mama.h"
#include "string.h"

diff --git a/mama/c_cpp/src/examples/c/mamaio.c b/mama/c_cpp/src/examples/c/mamaio.c
index 4066ca9..47df6e3 100644
--- a/mama/c_cpp/src/examples/c/mamaio.c
+++ b/mama/c_cpp/src/examples/c/mamaio.c
@@ -30,7 +30,7 @@
* [-q] Quiet mode. Suppress output.
*---------------------------------------------------------------------------*/

-#include "port.h"
+#include "wombat/port.h"
#include <sys/types.h>
#include <errno.h>
#include <string.h>
diff --git a/mama/c_cpp/src/examples/c/mamalistenc.c b/mama/c_cpp/src/examples/c/mamalistenc.c
index b57ce87..80ca789 100644
--- a/mama/c_cpp/src/examples/c/mamalistenc.c
+++ b/mama/c_cpp/src/examples/c/mamalistenc.c
@@ -58,7 +58,7 @@
*
*/

-#include "port.h"
+#include "wombat/port.h"

#include <stdlib.h>
#include <stdio.h>
diff --git a/mama/c_cpp/src/examples/c/mamaproxyc.c b/mama/c_cpp/src/examples/c/mamaproxyc.c
index 993e140..dfb5aa0 100644
--- a/mama/c_cpp/src/examples/c/mamaproxyc.c
+++ b/mama/c_cpp/src/examples/c/mamaproxyc.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include "mama/mama.h"
#include "mama/log.h"
#include "mama/msgtype.h"
diff --git a/mama/c_cpp/src/examples/c/mamapublisherc.c b/mama/c_cpp/src/examples/c/mamapublisherc.c
index 0ed845c..e00ea9d 100644
--- a/mama/c_cpp/src/examples/c/mamapublisherc.c
+++ b/mama/c_cpp/src/examples/c/mamapublisherc.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"

#include "mama/mama.h"
#include "string.h"
--
1.7.7.6


[PATCH 28/30] Added wdlXXX macos to linux/port.h

Michael Schonberg <mschonberg@...>
 

These are simple macros for manipulating shared objects. Windows
uses the corresponding Win32 Methods.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 83a7a82..4e956c8 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -164,6 +164,12 @@ int wsem_timedwait (wsem_t* sem, unsigned int ts);

#define wGetCurrentThreadId pthread_self

+/* macros for shared libraries */
+#define wdlopen dlopen
+#define wdlsym dlsym
+#define wdlclose dlclose
+#define wdlerror dlerror
+
/* timegm() and nanosleep not available on Windows */
#define wtimegm timegm

--
1.7.7.6


[PATCH 27/30] Changes for Windows

Michael Schonberg <mschonberg@...>
 

This needs to be split into several patches. The changes include correct
calling conventions for dynamic linking, and other minor issues that arose
building for WDF, and NYSE commercial componenets.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 10 +++-
mama/c_cpp/src/c/mama/mama.h | 2 +-
mama/c_cpp/src/c/timezone.c | 4 +-
mama/c_cpp/src/examples/c/mamainboxc.c | 15 +++---
mama/c_cpp/src/examples/c/mamaio.c | 9 +--
mama/c_cpp/src/examples/c/mamalistenc.c | 56 ++++++++++----------
mama/c_cpp/src/examples/c/mamaproxyc.c | 46 ++++++++--------
mama/c_cpp/src/examples/c/mamapublisherc.c | 19 ++++---
mama/c_cpp/src/examples/c/mamasubscriberc.c | 20 ++++----
.../src/examples/c/mamasymbollistsubscriberc.c | 44 ++++++++--------
10 files changed, 115 insertions(+), 110 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 4e69c7c..83a7a82 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -166,7 +166,15 @@ int wsem_timedwait (wsem_t* sem, unsigned int ts);

/* timegm() and nanosleep not available on Windows */
#define wtimegm timegm
-#define wnanosleep nanosleep
+
+struct wtimespec
+{
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#define wnanosleep (ts, remain) nanosleep(((struct timespec)(ts)),(remain))
+

/* net work utility functions */
const char* getIpAddress (void);
diff --git a/mama/c_cpp/src/c/mama/mama.h b/mama/c_cpp/src/c/mama/mama.h
index 0bffcbe..c6cbe1c 100644
--- a/mama/c_cpp/src/c/mama/mama.h
+++ b/mama/c_cpp/src/c/mama/mama.h
@@ -366,7 +366,7 @@ extern "C"
* when mama_startBackground() exits normally in which case status will be
* MAMA_STATUS_OK.
*/
- typedef void (*mamaStartCB) (mama_status status);
+ typedef void (MAMACALLTYPE *mamaStartCB) (mama_status status);

/**
* Start Mama in the background. This method invokes mama_start() in a
diff --git a/mama/c_cpp/src/c/timezone.c b/mama/c_cpp/src/c/timezone.c
index e086758..a18a7ad 100644
--- a/mama/c_cpp/src/c/timezone.c
+++ b/mama/c_cpp/src/c/timezone.c
@@ -401,8 +401,8 @@ checkTzIter (wList list, void* element, void* closure)
static void* updateTimeZones (void* ptr)
{

- struct timespec delay;
- struct timespec initialDelay;
+ struct wtimespec delay;
+ struct wtimespec initialDelay;
wList timeZones;

initialDelay.tv_sec = 10;
diff --git a/mama/c_cpp/src/examples/c/mamainboxc.c b/mama/c_cpp/src/examples/c/mamainboxc.c
index e7da732..9f528b8 100644
--- a/mama/c_cpp/src/examples/c/mamainboxc.c
+++ b/mama/c_cpp/src/examples/c/mamainboxc.c
@@ -19,10 +19,9 @@
* 02110-1301 USA
*/

-
+#include "port.h"
#include "mama/mama.h"
#include "string.h"
-#include <unistd.h>

static mamaTransport gTransport = NULL;
static mamaInbox gInbox = NULL;
@@ -59,14 +58,14 @@ static void createInbox (void);
static void createPublisher (void);
static void sendRequest (void);

-static void
+static void MAMACALLTYPE
msgCB (mamaMsg msg, void* closure);

-static void
+static void MAMACALLTYPE
errorCB (mama_status status, void* closure);


-static void
+static void MAMACALLTYPE
timerCallback (mamaTimer timer, void *closure)
{
sendRequest ();
@@ -156,7 +155,7 @@ void initializeMama (void)
}

/* Used to destroy messages sent on the throttle */
-static void
+static void MAMACALLTYPE
sendCompleteCb (mamaPublisher publisher,
mamaMsg msg,
mama_status status,
@@ -230,13 +229,13 @@ static void createInbox (void)
}
}

-static void
+static void MAMACALLTYPE
msgCB (mamaMsg msg, void *closure)
{
printf ("Received reply: %s\n", mamaMsg_toString (msg));
}

-static void
+static void MAMACALLTYPE
errorCB (mama_status status, void *closure)
{
printf ("Error creating inbox: %s\n",
diff --git a/mama/c_cpp/src/examples/c/mamaio.c b/mama/c_cpp/src/examples/c/mamaio.c
index 4e0a9aa..4066ca9 100644
--- a/mama/c_cpp/src/examples/c/mamaio.c
+++ b/mama/c_cpp/src/examples/c/mamaio.c
@@ -30,11 +30,8 @@
* [-q] Quiet mode. Suppress output.
*---------------------------------------------------------------------------*/

+#include "port.h"
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
#include <errno.h>
#include <string.h>

@@ -55,7 +52,7 @@ static void initializeMama (void);
static void waitForConection (void);
static void createIOHandlers (void);

-static void
+static void MAMACALLTYPE
ioCallback (mamaIo io, mamaIoType ioType, void *closure);

int main (int argc, const char **argv)
@@ -152,7 +149,7 @@ static void waitForConection (void)
strlen ("Type \"quit\" to stop server.\n"), 0 );
}

-static void
+static void MAMACALLTYPE
ioCallback (mamaIo io, mamaIoType ioType, void *closure)
{
char buffer[1024];
diff --git a/mama/c_cpp/src/examples/c/mamalistenc.c b/mama/c_cpp/src/examples/c/mamalistenc.c
index 5c472db..b57ce87 100644
--- a/mama/c_cpp/src/examples/c/mamalistenc.c
+++ b/mama/c_cpp/src/examples/c/mamalistenc.c
@@ -58,13 +58,12 @@
*
*/

+#include "port.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
-#include <pthread.h>
-
-#include <unistd.h>

#include <mama/mama.h>
#include <mama/marketdata.h>
@@ -239,12 +238,12 @@ static void mamashutdown (void);
static void setQueueMonitors (mamaQueue queue, int queueIndex);
static FILE* gLogFile = NULL;

-static void
+static void MAMACALLTYPE
subscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void* closure,
void* itemClosure);
-static void
+static void MAMACALLTYPE
subscriptionOnQuality (mamaSubscription subsc,
mamaQuality quality,
const char* symbol,
@@ -252,13 +251,13 @@ subscriptionOnQuality (mamaSubscription subsc,
const void* platformInfo,
void* closure);

-static void
+static void MAMACALLTYPE
subscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
const char* subject,
void* closure);
-static void
+static void MAMACALLTYPE
subscriptionOnCreate (mamaSubscription subscription,
void* closure);

@@ -273,38 +272,38 @@ static void displayAllFields (mamaMsg msg,
mamaSubscription subscription,
int indentLevel);

-static void
+static void MAMACALLTYPE
rateReporterCallback (mamaTimer timer,
void * closure);

-static void
+static void MAMACALLTYPE
timeoutCb (mamaDictionary dict,
void * closure);
-static void
+static void MAMACALLTYPE
errorCb (mamaDictionary dict,
const char * errMsg,
void * closure);
-static void
+static void MAMACALLTYPE
completeCb (mamaDictionary dict,
void * closure);
-static void
+static void MAMACALLTYPE
displayCb (const mamaMsg msg,
const mamaMsgField field,
void * closure);

/*Callback for event queue high watermark monitoring.*/
-static void
+static void MAMACALLTYPE
highWaterMarkCallback (mamaQueue queue,
size_t size,
void* closure);

/*Callback for event queue low watermark monitoring.*/
-static void
+static void MAMACALLTYPE
lowWaterMarkCallback (mamaQueue queue,
size_t size,
void* closure);

-static void
+static void MAMACALLTYPE
shutdownTimerCallback(mamaTimer timer, void *closure)
{
/* Stop dispatching messages. */
@@ -586,21 +585,21 @@ static void dumpDataDictionary (void)
}
}

-void
+void MAMACALLTYPE
timeoutCb (mamaDictionary dict, void *closure)
{
printf ("Timed out waiting for dictionary\n" );
mama_stop(gMamaBridge);
}

-void
+void MAMACALLTYPE
errorCb (mamaDictionary dict, const char *errMsg, void *closure)
{
fprintf (stderr, "Error getting dictionary: %s\n", errMsg );
mama_stop(gMamaBridge);
}

-void
+void MAMACALLTYPE
completeCb (mamaDictionary dict, void *closure)
{
gDictionaryComplete = 1;
@@ -750,7 +749,7 @@ static void mamashutdown (void)
mama_close ();
}

-static void
+static void MAMACALLTYPE
transportCb (mamaTransport tport,
mamaTransportEvent ev,
short cause,
@@ -763,7 +762,8 @@ transportCb (mamaTransport tport,
/*Steps required for initializing the API*/
void initializeMama (void)
{
- mama_status status = MAMA_STATUS_OK;
+ mama_status status = MAMA_STATUS_OK;
+ mamaPayloadBridge payBridge = NULL;

/*
mama_setApplicationName should be called before mama_open().
@@ -1234,7 +1234,7 @@ static void parseCommandLine (int argc, const char** argv)
where most of the processing within a MAMA based application will occur.
This callback is invoked for each message received by the API.
*/
-void
+void MAMACALLTYPE
subscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void *closure,
@@ -1303,7 +1303,7 @@ subscriptionOnMsg (mamaSubscription subscription,
The onQuality callback is invoked when the quality of a subscription
changes state. E.g. From OK to STALE and vise versa.
*/
-void
+void MAMACALLTYPE
subscriptionOnQuality (mamaSubscription subsc,
mamaQuality quality,
const char* symbol,
@@ -1676,7 +1676,7 @@ void displayField (mamaMsgField field, const mamaMsg msg, int indentLevel)
}/*End switch*/
}

-void
+void MAMACALLTYPE
displayCb (const mamaMsg msg,
const mamaMsgField field,
void* closure)
@@ -1752,7 +1752,7 @@ void displayAllFields (mamaMsg msg, mamaSubscription subscription, int
is invoked whenther the subscription request is sent from the throttle
queue.
*/
-void
+void MAMACALLTYPE
subscriptionOnCreate (mamaSubscription subscription, void* closure)
{
const char* source = NULL;
@@ -1773,7 +1773,7 @@ subscriptionOnCreate (mamaSubscription subscription, void* closure)
}
}

-static void
+static void MAMACALLTYPE
subscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -1786,7 +1786,7 @@ subscriptionOnError (mamaSubscription subscription,
mamaStatus_stringForStatus (status));
}

-static void
+static void MAMACALLTYPE
rateReporterCallback (mamaTimer timer, void* closure)
{
int msgInterval = gNumMsg - gNumMsgLast;
@@ -1811,7 +1811,7 @@ void usage (int exitStatus)
exit (exitStatus);
}

-static void
+static void MAMACALLTYPE
highWaterMarkCallback (mamaQueue queue,
size_t size,
void* closure)
@@ -1837,7 +1837,7 @@ highWaterMarkCallback (mamaQueue queue,
queueName == NULL ? "" : queueName, (unsigned int)size);
}

-static void
+static void MAMACALLTYPE
lowWaterMarkCallback (mamaQueue queue,
size_t size,
void* closure)
diff --git a/mama/c_cpp/src/examples/c/mamaproxyc.c b/mama/c_cpp/src/examples/c/mamaproxyc.c
index 795d1f4..993e140 100644
--- a/mama/c_cpp/src/examples/c/mamaproxyc.c
+++ b/mama/c_cpp/src/examples/c/mamaproxyc.c
@@ -19,6 +19,7 @@
* 02110-1301 USA
*/

+#include "port.h"
#include "mama/mama.h"
#include "mama/log.h"
#include "mama/msgtype.h"
@@ -27,7 +28,6 @@
#include "mama/dqpublisher.h"
#include "mama/dqpublishermanager.h"
#include "string.h"
-#include "unistd.h"

static const char * gUsageString[] =
{
@@ -95,59 +95,59 @@ static MamaLogLevel gSubscLogLevel;
static mamaTimer gSyncTimer;
static void parseCommandLine (int argc, const char** argv);

-static void
+static void MAMACALLTYPE
subscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void* closure,
void* itemClosure);
-static void
+static void MAMACALLTYPE
subscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
const char* subject,
void* closure);
-static void
+static void MAMACALLTYPE
subscriptionOnCreate (mamaSubscription subscription,
void* closure);

-static void
+static void MAMACALLTYPE
syncCallback (mamaTimer timer,
void * closure);

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnCreateCb (mamaDQPublisherManager manager);

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnNewRequestCb(mamaDQPublisherManager manager,
const char* symbol,
short subType,
short msgType,
mamaMsg msg);

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnRequestCb(mamaDQPublisherManager manager,
mamaPublishTopic* info,
short subType,
short msgType,
mamaMsg msg);

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnRefreshCb(mamaDQPublisherManager manager,
mamaPublishTopic* info,
short subType,
short msgType,
mamaMsg msg);

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnErrorCb(mamaDQPublisherManager manager,
mama_status status,
const char* errortxt,
mamaMsg msg);

-static void
+static void MAMACALLTYPE
sendRecap (mamaQueue queue, void* closure);

-static void
+static void MAMACALLTYPE
startCB ( mama_status status );

static void createPublisher (void);
@@ -188,7 +188,7 @@ static void createPublisher ()
}
}

-void startCB ( mama_status status )
+void MAMACALLTYPE startCB ( mama_status status )
{}

static void start ()
@@ -271,7 +271,7 @@ static void initializeMama ()

}

-static void
+static void MAMACALLTYPE
syncCallback (mamaTimer timer, void* closure)
{
mamaTimer_destroy (timer);
@@ -299,13 +299,13 @@ int main (int argc, const char **argv)
return 0;
}

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnCreateCb (mamaDQPublisherManager manager)
{
printf ("Created publisher subscription.\n");
}

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnErrorCb (mamaDQPublisherManager manager,
mama_status status,
const char* errortxt,
@@ -326,7 +326,7 @@ subscriptionHandlerOnErrorCb (mamaDQPublisherManager manager,
}
}

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnNewRequestCb (mamaDQPublisherManager manager,
const char* symbol,
short subType,
@@ -378,7 +378,7 @@ subscriptionHandlerOnNewRequestCb (mamaDQPublisherManager manager,

}

-static void
+static void MAMACALLTYPE
sendRecap (mamaQueue queue, void* closure)
{
recapInfo* info = (recapInfo*) closure;
@@ -399,7 +399,7 @@ sendRecap (mamaQueue queue, void* closure)
free (info);
}

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnRequestCb (mamaDQPublisherManager manager,
mamaPublishTopic* publishTopicInfo,
short subType,
@@ -446,7 +446,7 @@ subscriptionHandlerOnRequestCb (mamaDQPublisherManager manager,
}
}

-static void
+static void MAMACALLTYPE
subscriptionHandlerOnRefreshCb (mamaDQPublisherManager publisherManager,
mamaPublishTopic* publishTopicInfo,
short subType,
@@ -607,13 +607,13 @@ usage (int exitStatus)
}


-void
+void MAMACALLTYPE
subscriptionOnCreate (mamaSubscription subscription, void* closure)
{

}

-static void
+static void MAMACALLTYPE
subscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -626,7 +626,7 @@ subscriptionOnError (mamaSubscription subscription,
mamaStatus_stringForStatus (status));
}

-void
+void MAMACALLTYPE
subscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void *closure,
diff --git a/mama/c_cpp/src/examples/c/mamapublisherc.c b/mama/c_cpp/src/examples/c/mamapublisherc.c
index 964de7c..0ed845c 100644
--- a/mama/c_cpp/src/examples/c/mamapublisherc.c
+++ b/mama/c_cpp/src/examples/c/mamapublisherc.c
@@ -19,7 +19,7 @@
* 02110-1301 USA
*/

-#include <unistd.h>
+#include "port.h"

#include "mama/mama.h"
#include "string.h"
@@ -62,18 +62,19 @@ NULL
static void parseCommandLine (int argc, const char **argv);
static void initializeMama (void);
static void createIntervalTimer (void);
-static void timerCallback (mamaTimer timer, void *closure);
static void createInboundSubscription (void);
-static void inboundCreateCb (mamaSubscription subscription, void *closure);

-static void
+static void MAMACALLTYPE timerCallback (mamaTimer timer, void *closure);
+static void MAMACALLTYPE inboundCreateCb (mamaSubscription subscription, void *closure);
+
+static void MAMACALLTYPE
inboundErrorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
const char *subject,
void *closure);

-static void
+static void MAMACALLTYPE
inboundMsgCb (mamaSubscription subscription,
mamaMsg msg,
void *closure,
@@ -274,7 +275,7 @@ static void createInboundSubscription (void)
}
}

-static void
+static void MAMACALLTYPE
inboundCreateCb (mamaSubscription subscription, void *closure)
{
if (gQuietLevel < 2)
@@ -283,7 +284,7 @@ inboundCreateCb (mamaSubscription subscription, void *closure)
}
}

-static void
+static void MAMACALLTYPE
inboundErrorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -295,7 +296,7 @@ inboundErrorCb (mamaSubscription subscription,
exit (status);
}

-static void
+static void MAMACALLTYPE
inboundMsgCb (mamaSubscription subscription,
mamaMsg msg,
void* closure,
@@ -335,7 +336,7 @@ static void createIntervalTimer (void)
}


-static void
+static void MAMACALLTYPE
timerCallback (mamaTimer timer, void *closure)
{
publishMessage (NULL);
diff --git a/mama/c_cpp/src/examples/c/mamasubscriberc.c b/mama/c_cpp/src/examples/c/mamasubscriberc.c
index f2745a1..635defc 100644
--- a/mama/c_cpp/src/examples/c/mamasubscriberc.c
+++ b/mama/c_cpp/src/examples/c/mamasubscriberc.c
@@ -62,29 +62,29 @@ static void createSubscriber (void);
static void createWildCardSubscriber (void);
static void displayMsg (mamaMsg msg);

-static void
+static void MAMACALLTYPE
displayCb (const mamaMsg msg,
const mamaMsgField field,
void * closure);

-static void
+static void MAMACALLTYPE
createCb (mamaSubscription subscription,
void * closure);

-static void
+static void MAMACALLTYPE
errorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
const char* subject,
void* closure);

-static void
+static void MAMACALLTYPE
msgCb (mamaSubscription subscription,
mamaMsg msg,
void * closure,
void * itemClosure);

-static void
+static void MAMACALLTYPE
wildCardMsgCb (mamaSubscription subscription,
mamaMsg msg,
const char* topic,
@@ -220,7 +220,7 @@ static void createSubscriber (void)
}
}

-static void
+static void MAMACALLTYPE
createCb (mamaSubscription subscription, void *closure)
{
if (gQuietLevel < 2)
@@ -229,7 +229,7 @@ createCb (mamaSubscription subscription, void *closure)
}
}

-static void
+static void MAMACALLTYPE
errorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -241,7 +241,7 @@ errorCb (mamaSubscription subscription,
exit (status);
}

-static void
+static void MAMACALLTYPE
msgCb (mamaSubscription subscription,
mamaMsg msg,
void* closure,
@@ -254,7 +254,7 @@ msgCb (mamaSubscription subscription,
displayMsg (msg);
}

-static void
+static void MAMACALLTYPE
wildCardMsgCb (mamaSubscription subscription,
mamaMsg msg,
const char* topic,
@@ -287,7 +287,7 @@ wildCardMsgCb (mamaSubscription subscription,
displayMsg (msg);
}

-void
+void MAMACALLTYPE
displayCb (const mamaMsg msg,
const mamaMsgField field,
void* closure)
diff --git a/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c b/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
index 0160df7..a0422ca 100644
--- a/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
+++ b/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
@@ -82,13 +82,13 @@ static void parseCommandLine (int argc, const char* argv[]);
static void initializeMama (void);
static void buildDataDictionary (void);

-static void
+static void MAMACALLTYPE
subscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void* closure,
void* itemClosure);

-static void
+static void MAMACALLTYPE
subscriptionOnQuality (mamaSubscription subsc,
mamaQuality quality,
const char* symbol,
@@ -96,23 +96,23 @@ subscriptionOnQuality (mamaSubscription subsc,
const void* platformInfo,
void* closure);

-static void
+static void MAMACALLTYPE
subscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
const char* subject,
void* closure);
-static void
+static void MAMACALLTYPE
subscriptionOnCreate (mamaSubscription subscription,
void* closure);

-static void
+static void MAMACALLTYPE
symbolListSubscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void* closure,
void* itemClosure);

-static void
+static void MAMACALLTYPE
symbolListSubscriptionOnQuality (mamaSubscription subsc,
mamaQuality quality,
const char* symbol,
@@ -120,26 +120,26 @@ symbolListSubscriptionOnQuality (mamaSubscription subsc,
const void* platformInfo,
void* closure);

-static void
+static void MAMACALLTYPE
symbolListSubscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
const char* subject,
void* closure);

-static void
+static void MAMACALLTYPE
symbolListSubscriptionOnCreate (mamaSubscription subscription,
void* closure);

-static void
+static void MAMACALLTYPE
timeoutCb (mamaDictionary dict,
void * closure);
-static void
+static void MAMACALLTYPE
errorCb (mamaDictionary dict,
const char * errMsg,
void * closure);

-static void
+static void MAMACALLTYPE
completeCb (mamaDictionary dict,
void * closure);

@@ -202,21 +202,21 @@ int main (int argc, const char **argv)
return 0;
}

-void
+void MAMACALLTYPE
timeoutCb (mamaDictionary dict, void *closure)
{
printf ("Timed out waiting for dictionary\n" );
mama_stop(gMamaBridge);
}

-void
+void MAMACALLTYPE
errorCb (mamaDictionary dict, const char *errMsg, void *closure)
{
fprintf (stderr, "Error getting dictionary: %s\n", errMsg );
mama_stop(gMamaBridge);
}

-void
+void MAMACALLTYPE
completeCb (mamaDictionary dict, void *closure)
{
gDictionaryComplete = 1;
@@ -537,7 +537,7 @@ static void subscribeToSymbols (void)
}


-void
+void MAMACALLTYPE
symbolListSubscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void *closure,
@@ -570,7 +570,7 @@ symbolListSubscriptionOnMsg (mamaSubscription subscription,
}
}

-void
+void MAMACALLTYPE
symbolListSubscriptionOnCreate (mamaSubscription subscription, void* closure)
{
const char* source = NULL;
@@ -582,7 +582,7 @@ symbolListSubscriptionOnCreate (mamaSubscription subscription, void* closure)
source);
}

-static void
+static void MAMACALLTYPE
symbolListSubscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -594,7 +594,7 @@ symbolListSubscriptionOnError (mamaSubscription subscription,
mamaStatus_stringForStatus (status));
}

-static void
+static void MAMACALLTYPE
symbolListSubscriptionOnQuality (mamaSubscription subsc,
mamaQuality quality,
const char* symbol,
@@ -607,7 +607,7 @@ symbolListSubscriptionOnQuality (mamaSubscription subsc,
platformInfo ? (char*)platformInfo: "");
}

-void
+void MAMACALLTYPE
subscriptionOnMsg (mamaSubscription subscription,
mamaMsg msg,
void *closure,
@@ -625,7 +625,7 @@ subscriptionOnMsg (mamaSubscription subscription,

}

-void
+void MAMACALLTYPE
subscriptionOnCreate (mamaSubscription subscription, void* closure)
{
const char* source = NULL;
@@ -639,7 +639,7 @@ subscriptionOnCreate (mamaSubscription subscription, void* closure)
source, symbol);
}

-static void
+static void MAMACALLTYPE
subscriptionOnError (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -652,7 +652,7 @@ subscriptionOnError (mamaSubscription subscription,
mamaStatus_stringForStatus (status));
}

-static void
+static void MAMACALLTYPE
subscriptionOnQuality (mamaSubscription subsc,
mamaQuality quality,
const char* symbol,
--
1.7.7.6


[PATCH 26/30] Adding new common/../windows/* files

Michael Schonberg <mschonberg@...>
 

These files contain macros and functions required to support Windows
withouth the need for #ifdef WIN scattered through out the code.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/windows/environment.c | 81 ++++++
common/c_cpp/src/c/windows/lock.h | 82 ++++++
common/c_cpp/src/c/windows/machine_win.c | 213 ++++++++++++++
common/c_cpp/src/c/windows/mmap.h | 28 ++
common/c_cpp/src/c/windows/network.c | 87 ++++++
common/c_cpp/src/c/windows/platform.c | 84 ++++++
common/c_cpp/src/c/windows/port.c | 276 ++++++++++++++++++
common/c_cpp/src/c/windows/port.h | 323 ++++++++++++++++++++++
common/c_cpp/src/c/windows/wSemaphore.c | 147 ++++++++++
common/c_cpp/src/c/windows/wombat/targetsxs.h | 38 +++
common/c_cpp/src/c/windows/wombat/wInterlocked.h | 97 +++++++
11 files changed, 1456 insertions(+), 0 deletions(-)
create mode 100644 common/c_cpp/src/c/windows/environment.c
create mode 100644 common/c_cpp/src/c/windows/lock.h
create mode 100644 common/c_cpp/src/c/windows/machine_win.c
create mode 100644 common/c_cpp/src/c/windows/mmap.h
create mode 100644 common/c_cpp/src/c/windows/network.c
create mode 100644 common/c_cpp/src/c/windows/platform.c
create mode 100644 common/c_cpp/src/c/windows/port.c
create mode 100644 common/c_cpp/src/c/windows/port.h
create mode 100644 common/c_cpp/src/c/windows/wSemaphore.c
create mode 100644 common/c_cpp/src/c/windows/wombat/targetsxs.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wInterlocked.h

diff --git a/common/c_cpp/src/c/windows/environment.c b/common/c_cpp/src/c/windows/environment.c
new file mode 100644
index 0000000..d413432
--- /dev/null
+++ b/common/c_cpp/src/c/windows/environment.c
@@ -0,0 +1,81 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "stdlib.h"
+#include "wombat/environment.h"
+
+int environment_deleteVariable(const char *name)
+{
+ /* Returns. */
+ int ret = -1;
+
+ /* Check arguments. */
+ if(name != NULL)
+ {
+ /* Set the value. */
+ errno_t pe = _putenv_s(name, "");
+ if(pe == 0)
+ {
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
+const char *environment_getVariable(const char *name)
+{
+ /* Returns. */
+ const char *ret = NULL;
+
+ /* Check the argument. */
+ if(name != NULL)
+ {
+ ret = getenv(name);
+
+ /* Return NULL for a blank string. */
+ if((ret != NULL) && (ret[0] == '\0'))
+ {
+ ret = NULL;
+ }
+ }
+
+ return ret;
+}
+
+int environment_setVariable(const char *name, const char *value)
+{
+ /* Returns. */
+ int ret = -1;
+
+ /* Check the arguments. */
+ if((name != NULL) && (value != NULL))
+ {
+ /* Set the value. */
+ errno_t pe = _putenv_s(name, value);
+ if(pe == 0)
+ {
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
diff --git a/common/c_cpp/src/c/windows/lock.h b/common/c_cpp/src/c/windows/lock.h
new file mode 100644
index 0000000..50d7c09
--- /dev/null
+++ b/common/c_cpp/src/c/windows/lock.h
@@ -0,0 +1,82 @@
+
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef STATICLOCK_H__
+#define STATICLOCK_H__
+
+/* Make windows synchronization look like pthreads we use 'w' rather than 'p' to
+ * avoid conflicts with other pthreads for windows implementations
+ */
+typedef CRITICAL_SECTION wthread_mutex_t;
+typedef HANDLE wthread_cond_t;
+typedef void * wthread_t;
+
+#define INVALID_THREAD NULL
+
+#define PTHREAD_CREATE_JOINABLE 0
+#define PTHREAD_MUTEX_RECURSIVE_NP 0
+#define PTHREAD_MUTEX_RECURSIVE 0
+
+typedef wthread_mutex_t wthread_spinlock_t;
+
+#define wthread_spin_lock wthread_mutex_lock
+#define wthread_spin_unlock wthread_mutex_unlock
+#define wthread_spin_init wthread_mutex_init
+#define wthread_spin_destroy wthread_mutex_destroy
+
+#define wthread_mutex_init( h, zip ) (InitializeCriticalSection( (h) ))
+#define wthread_mutex_unlock( h ) (LeaveCriticalSection( (h) ) )
+#define wthread_mutex_lock( h ) (EnterCriticalSection( (h) ) )
+#define wthread_mutex_destroy( h ) (DeleteCriticalSection( (h) ) )
+
+/* Windows does not have static lock initializers */
+/* the xxxUseLock variable is needed if 2 threads are started together, the
+ * first thread checks the lexerlockInitialized through atomic action and then
+ * starts to initialize the mutex which isn't atomic. The second thread checks
+ * the variable lexerlockInitialized it has been incremented, this thread would
+ * then try to grab a lock that is not initialized. On windows this causes the
+ * application to hang therefore after the mutex is initialized the variable
+ * xxxUseLock is set to 1. Just before a lock is acquired it will poll until
+ * xxxUseLock is not equal to zero this will stop the race condition. A
+ * condition variable can't be used because you get into the same problem of
+ * waiting for an uninitialized condition variable
+ */
+typedef struct
+{
+ wthread_mutex_t mLock;
+ volatile long mInitialized;
+ volatile long mUseLock;
+} wthread_static_mutex_t;
+
+#define WSTATIC_MUTEX_INITIALIZER {0,0,0}
+
+#define wthread_static_mutex_lock(x) \
+ if( InterlockedIncrement(&((x)->mInitialized)) == 1 ) \
+ { \
+ wthread_mutex_init(&((x)->mLock), NULL); \
+ (x)->mUseLock = 1; \
+ } \
+ while((x)->mUseLock == 0); \
+ wthread_mutex_lock(&((x)->mLock))
+
+#define wthread_static_mutex_unlock(x) wthread_mutex_unlock(&((x)->mLock))
+
+#endif /* STATIClOCK_H__ */
diff --git a/common/c_cpp/src/c/windows/machine_win.c b/common/c_cpp/src/c/windows/machine_win.c
new file mode 100644
index 0000000..f6f3ad5
--- /dev/null
+++ b/common/c_cpp/src/c/windows/machine_win.c
@@ -0,0 +1,213 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "port.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "wombat/machine.h"
+#include "wombat/wtable.h"
+
+#define DMKEY "HARDWARE\\DESCRIPTION" /*where to look*/
+void GetProcessNameById(DWORD Id, const char *buffer[]);
+
+time_t getTimeSinceEpoch(void)
+{
+ time_t rawTime;
+ time(&rawTime);
+ return rawTime;
+}
+
+int getSystemMemory (systemMemVals* mem)
+{
+ return 0;
+}
+
+long getTotalSystemMem(void)
+{
+ return 0;
+}
+
+int getProcessInfo(int pid ,memVals *memV,cpuVals *cpuV,int childFlag)
+{
+ PDH_FMT_COUNTERVALUE pValue={0};
+ HANDLE gProcessHandle;
+ FILETIME lpCreationTime;
+ FILETIME lpExitTime;
+ FILETIME lpKernelTime;
+ FILETIME lpUserTime;
+
+ LONGLONG tUser64;
+ LONGLONG tKernel64;
+ int error=0;
+
+ static const char* buffer[64];
+ static DWORD processId = 0;
+
+ if (processId ==0)
+ {
+ processId = GetCurrentProcessId();
+ GetProcessNameById(processId,buffer);
+ }
+
+ /*PROCESS_MEMORY_COUNTERS pmc;*/
+ if(cpuV)
+ {
+ if((gProcessHandle =
+ OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
+ FALSE, processId))==NULL)
+ {
+ printf("OpenProcess Error code : %ld \n\n\n",GetLastError());
+ }
+ if((GetProcessTimes(gProcessHandle,&lpCreationTime,&lpExitTime,&lpKernelTime,&lpUserTime))==0)
+ {
+ printf("GetProcessTimes Error code : %ld \n\n\n",GetLastError());
+ }
+ else
+ {
+ tUser64 = *(LONGLONG *)&lpUserTime;
+ tKernel64 = *(LONGLONG *)&lpKernelTime;
+ cpuV->userTime =(tUser64 * 0.0000001);
+ cpuV->sysTime =(tKernel64 * 0.0000001);
+ CloseHandle(gProcessHandle);
+ }
+ }
+ if(memV)
+ {
+ TCHAR memCounterPath[64];
+ HCOUNTER memCounter;
+ PDH_STATUS pdhStatus; /* return status of PDH functions */
+ LPCTSTR szDataSource = NULL;/* NULL for dynamic registry entries */
+ HQUERY phQuery; /* query Handle */
+ PDH_FMT_COUNTERVALUE pValue={0};
+
+ snprintf(memCounterPath,64,"\\Process(%s)\\Private Bytes",buffer);
+
+ /* create query */
+ pdhStatus = PdhOpenQuery(NULL,0,&phQuery);
+ if (pdhStatus != ERROR_SUCCESS)
+ {
+ /* Print the error value. */
+ _tprintf (TEXT("PdhOpenQuery failed with %ld\n"), pdhStatus);
+ error=1;
+ }
+ /* add counter for MEM */
+ pdhStatus = PdhAddCounter(phQuery,memCounterPath,0,&memCounter);
+ if (pdhStatus != ERROR_SUCCESS)
+ {
+ /* Print the error value. */
+ _tprintf (TEXT("PdhAddCounter Failed with 0x%x\n"), pdhStatus);
+ error=1;
+ }
+ /* collect Data */
+ pdhStatus = PdhCollectQueryData(phQuery);
+ if (pdhStatus != ERROR_SUCCESS)
+ {
+ /* Print the error value. */
+ _tprintf (TEXT("PdhCollectQueryData Failed with 0x%x\n"), pdhStatus);
+ error=1;
+ }
+ pdhStatus = PdhGetFormattedCounterValue(memCounter,
+ PDH_FMT_DOUBLE,
+ NULL,
+ &pValue);
+ if (pdhStatus == ERROR_SUCCESS)
+ {
+
+ memV->rss = (long)(pValue.doubleValue/1.0e3);
+ }
+ else
+ {
+ /* Print the error value. */
+ _tprintf (TEXT("PdhGetFormattedCounterValue Failed with 0x%x\n"), pdhStatus);
+ error=1;
+ }
+ PdhCloseQuery(phQuery);
+ }
+ return error;
+}
+
+void searchDirs(int procChildren[], int dirNames[],
+ int count,cpuVals *cpv,int tempPid)
+{
+ /*function not needed on windows*/
+}
+
+void getProcAndChildCpu(int pid, cpuVals* cpv)
+{
+ (void)getProcessInfo(pid ,NULL,cpv,0);
+}
+
+int getNumCpu(void)
+{
+ int value;
+
+ SYSTEM_INFO siSysInfo;
+ GetSystemInfo(&siSysInfo);
+ value = siSysInfo.dwNumberOfProcessors;
+
+ return value;
+}
+
+void initProcTable(int pid, int debuginfo)
+{
+ /*function not needed on windows*/
+}
+
+void getSystemTime(double* upTime,double* idleTime)
+{
+ *upTime=0.0;
+ *idleTime=0.0;
+}
+
+void getProcessorTime(long* usageTime,long* idleTime,int processor)
+{
+ *usageTime=0;
+ *idleTime=0;
+}
+
+void GetProcessNameById(DWORD Id, const char* buffer[])
+{
+ PROCESSENTRY32 pEntry = { 0 };
+ HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
+ pEntry.dwSize = sizeof(PROCESSENTRY32);
+
+ if (Process32First(hSnapShot, &pEntry))
+ {
+ do
+ {
+ if (pEntry.th32ProcessID == Id)
+ {
+ *buffer = (const char*)
+ malloc(strlen((const char*)pEntry.szExeFile) - 4);
+
+ pEntry.szExeFile[strlen((const char*)pEntry.szExeFile) -4]='\0';
+ strcpy((char*)buffer,(const char*)pEntry.szExeFile);
+ break;
+ }
+ }while (Process32Next(hSnapShot, &pEntry));
+ }
+ CloseHandle(hSnapShot);
+}
+
diff --git a/common/c_cpp/src/c/windows/mmap.h b/common/c_cpp/src/c/windows/mmap.h
new file mode 100644
index 0000000..76dd2ed
--- /dev/null
+++ b/common/c_cpp/src/c/windows/mmap.h
@@ -0,0 +1,28 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef WINDOWS_MMAP_H__
+#define WINDOWS_MMAP_H__
+
+/**
+ * Open a file that will be mapped to memory. Return
+ */
+
+#endif /* WINDOWS_MMAP_H__ */
diff --git a/common/c_cpp/src/c/windows/network.c b/common/c_cpp/src/c/windows/network.c
new file mode 100644
index 0000000..e7c1ece
--- /dev/null
+++ b/common/c_cpp/src/c/windows/network.c
@@ -0,0 +1,87 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "port.h"
+
+struct in_addr resolve_ip (const char * arg)
+{
+ struct in_addr resolved;
+
+ if (0 == strcmp(arg, ""))
+ resolved.s_addr = INADDR_ANY;
+ else
+ resolved.s_addr = inet_addr (arg);
+ return (resolved);
+}
+
+int
+wsetnonblock (int s)
+{
+ unsigned long arg = 1;
+ if (0 != ioctlsocket (s, FIONBIO, &arg))
+ return -1;
+ return 0;
+}
+
+static char gIPAddress[16];
+static const char* gHostName = NULL;
+
+static void lookupIPAddress (void)
+{
+ struct hostent *host = NULL;
+ char *addrStr = "not determined";
+
+ char hostname[256];
+ if( 0 != gethostname( hostname, 256 ) )
+ {
+ snprintf( hostname, strlen( "localhost" ), "localhost" );
+ }
+ gHostName = strdup (hostname);
+
+ host = gethostbyname( gHostName );
+
+ if( gHostName == NULL ||
+ host == NULL ||
+ host->h_addr_list[0] == NULL )
+ {
+ strncpy( (char *)gIPAddress, "not determined", sizeof( gIPAddress ) );
+/* return MAMA_STATUS_IP_NOT_FOUND;*/
+ }
+ else
+ {
+ addrStr = inet_ntoa( *((struct in_addr *)( host->h_addr_list[0] )));
+ }
+
+ strncpy ((char*)gIPAddress, addrStr, sizeof (gIPAddress));
+}
+
+const char* getIpAddress(void)
+{
+ if (NULL == gHostName)
+ lookupIPAddress();
+ return gIPAddress;
+}
+
+const char* getHostName(void)
+{
+ if (NULL == gHostName)
+ lookupIPAddress();
+ return gHostName;
+}
diff --git a/common/c_cpp/src/c/windows/platform.c b/common/c_cpp/src/c/windows/platform.c
new file mode 100644
index 0000000..f17e1f9
--- /dev/null
+++ b/common/c_cpp/src/c/windows/platform.c
@@ -0,0 +1,84 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "port.h"
+#include "platform.h"
+
+#define PATH_SEPERATOR "\\"
+
+/**
+ * Functions relating to DLLs/shared objects
+ */
+char errorBuf[25];
+LIB_HANDLE openSharedLib (const char* libName, const char* path)
+{
+ size_t nameLength;
+ char* fileName;
+ LIB_HANDLE handle;
+
+ if (path)
+ {
+ nameLength = strlen(path) + strlen(libName) + strlen(LIB_EXTENSION) +
+ strlen(PATH_SEPERATOR) + strlen("lib") + 1;
+ }
+ else
+ {
+ nameLength = strlen(libName) + strlen(LIB_EXTENSION) + strlen("lib") + 1;
+ }
+ fileName = (char*) calloc (nameLength, sizeof (char));
+ if(fileName == NULL)
+ {
+ return 0;
+ }
+
+ if (path)
+ {
+ snprintf (fileName, nameLength, "%s%slib%s%s", path, PATH_SEPERATOR, libName, LIB_EXTENSION);
+ }
+ else
+ {
+ snprintf (fileName, nameLength, "lib%s%s", libName, LIB_EXTENSION);
+ }
+
+ handle = LoadLibrary (fileName);
+ free(fileName);
+ return handle;
+}
+
+
+int closeSharedLib (LIB_HANDLE handle)
+{
+ return FreeLibrary ((HMODULE) handle);
+}
+
+void* loadLibFunc (LIB_HANDLE handle, const char* funcName)
+{
+ return GetProcAddress (handle, funcName);
+
+}
+
+char* getLibError (void)
+{
+ itoa(GetLastError(), errorBuf, 10);
+ return errorBuf;
+}
diff --git a/common/c_cpp/src/c/windows/port.c b/common/c_cpp/src/c/windows/port.c
new file mode 100644
index 0000000..12f6431
--- /dev/null
+++ b/common/c_cpp/src/c/windows/port.c
@@ -0,0 +1,276 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "port.h"
+
+int gettimeofday( struct timeval *result, void *dummy )
+{
+ time_t rawTime;
+ SYSTEMTIME t;
+ GetSystemTime( &t );
+ time(&rawTime);
+ result->tv_sec = (long)rawTime;
+ result->tv_usec = (t.wMilliseconds*1000);
+
+ return 0;
+}
+
+
+typedef struct
+{
+ HANDLE mThread;
+ int mIsStopping; /* Reads and writes to 32 bit vars are atomic in WIN32 */
+} threadContext;
+
+
+
+int wthread_set_affinity_mask( wthread_t h,
+ CPU_AFFINITY_SET* dwThreadAffinityMask)
+{
+ return (int) SetThreadAffinityMask( ((threadContext*) h)->mThread,
+ (DWORD_PTR) dwThreadAffinityMask );
+}
+
+
+int wthread_create( wthread_t *h, void *atts, void *(*startProc)( void * ), void *arg )
+{
+ threadContext *result = (threadContext *)calloc( 1, sizeof( threadContext ) );
+
+ if( result == NULL )
+ {
+ return 1;
+ }
+
+ *h = result;
+
+ result->mIsStopping = 0;
+
+ result->mThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)startProc, arg, 0, NULL );
+ if (result->mThread == 0)
+ {
+ free( result );
+ return 1;
+ }
+
+ return 0;
+}
+
+void wthread_destroy(wthread_t thread)
+{
+ if(NULL != thread)
+ {
+ /* Get the impl. */
+ threadContext *impl = (threadContext *)thread;
+
+ /* Close the thread handle. */
+ CloseHandle(impl->mThread);
+
+ /* Clean the structure. */
+ free(impl);
+ }
+}
+
+int wthread_join (wthread_t t, void **value_ptr)
+{
+ threadContext *ctx = (threadContext*)t;
+ WaitForSingleObject (ctx->mThread, INFINITE);
+ if (value_ptr!=NULL)
+ *value_ptr = NULL;
+ return 0;
+}
+
+void wthread_testcancel( wthread_t h )
+{
+ threadContext *ctx = (threadContext*)h;
+ if( ctx->mIsStopping )
+ {
+ ExitThread(0);
+ }
+}
+
+void wthread_cancel( wthread_t h )
+{
+ threadContext *ctx = (threadContext*)h;
+ ctx->mIsStopping = 1;
+ WaitForSingleObject( ctx->mThread, INFINITE );
+ free( ctx );
+}
+
+void wthread_attr_init (int* attr)
+{
+}
+
+void wthread_attr_setdetachstate (int* attr, int param)
+{
+}
+
+void wthread_mutexattr_init (int* attr)
+{
+}
+
+void wthread_mutexattr_settype (int* attr, int param)
+{
+}
+
+DWORD wthread_cond_wait( HANDLE *event, LPCRITICAL_SECTION *cs )
+{
+ DWORD rval;
+
+ LeaveCriticalSection( *cs );
+ rval = WaitForSingleObject( *event, INFINITE );
+ ResetEvent( *event );
+ EnterCriticalSection( *cs );
+
+ return rval;
+}
+
+const char* index( const char *str, char c )
+{
+ unsigned int i = 0;
+ while( i < strlen( str ) )
+ {
+ if( str[i] == c )
+ {
+ return str + i;
+ }
+ i++;
+ }
+ return NULL;
+}
+
+int getpid()
+{
+ return GetCurrentProcessId();
+}
+
+struct tm* localtime_r (const time_t* t, struct tm* result)
+{
+ localtime_s (result, t);
+ return result;
+}
+
+char user[256];
+
+const char *getlogin()
+{
+ /* NOTE: This will fail if user name is over 256 characters */
+ unsigned long len = 256;
+ GetUserName( user, &len );
+ return user;
+}
+
+int
+wsocketpair (int domain, int type, int protocol, int* pair)
+{
+ struct sockaddr_in addr;
+ int len = sizeof(addr);
+ int l;
+
+ l = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (INVALID_SOCKET == pair[0])
+ return -1;
+
+ ZeroMemory (&addr, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = 0; /* any available */
+ addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
+ if (0 != bind (l, (struct sockaddr*)(&addr), sizeof(addr)))
+ {
+ _close (l);
+ return -1;
+ }
+
+ /* Get the port and address for the other end */
+ if( 0 != getsockname (l, (struct sockaddr*)(&addr), &len))
+ {
+ _close (l);
+ return -1;
+ }
+
+ if (0 != listen (l, 1))
+ {
+ _close (l);
+ return -1;
+ }
+
+ pair[0] = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (INVALID_SOCKET == pair[0])
+ {
+ _close (l);
+ return -1;
+ }
+
+ if (0 != connect (pair[0], (struct sockaddr*)(&addr), sizeof(addr)))
+ {
+ _close (l);
+ _close (pair[0]);
+ return -1;
+ }
+
+ pair[1] = accept (l, NULL, NULL);
+ if (INVALID_SOCKET == pair[1])
+ {
+ _close (l);
+ _close (pair[0]);
+ return -1;
+ }
+
+ _close (l);
+
+ return 0;
+}
+
+int
+wthread_key_create(wthread_key_t* key, void* val)
+{
+ *key = TlsAlloc();
+ if (TLS_OUT_OF_INDEXES == *key)
+ return 1;
+ TlsSetValue(*key, val);
+ return 0;
+}
+
+time_t wtimegm (struct tm *tm)
+{
+ time_t ret;
+ char *tz;
+
+ tz = environment_getVariable("TZ");
+ environment_setVariable("TZ", "");
+ tzset();
+ ret = mktime(tm);
+ if (tz)
+ environment_setVariable("TZ", tz);
+ else
+ environment_deleteVariable("TZ");
+ tzset();
+ return ret;
+}
+
+int wnanosleep (struct wtimespec* ts, struct timnespec* remain)
+{
+ DWORD millis = ts->tv_sec * 1000 + ts->tv_nsec/1000;
+ /* if tv_nsec > 0 add at least 1 milli */
+ if (ts->tv_nsec > 0 && ts->tv_nsec < 1000)
+ millis += 1;
+ Sleep(millis);
+ return 0;
+}
diff --git a/common/c_cpp/src/c/windows/port.h b/common/c_cpp/src/c/windows/port.h
new file mode 100644
index 0000000..7df1f55
--- /dev/null
+++ b/common/c_cpp/src/c/windows/port.h
@@ -0,0 +1,323 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef WINDOWS_H__
+#define WINDOWS_H__
+
+#define WIN32_EXTRA_LEAN
+#define WIN32_LEAN_AND_MEAN
+
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <windows.h>
+#include <stdlib.h>
+#include <io.h>
+#include <malloc.h>
+#include <float.h>
+#include <tchar.h>
+#include <pdh.h>
+#include <pdhmsg.h>
+#include <tlhelp32.h>
+#include <time.h>
+
+#include "lock.h"
+#include "mmap.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* So Windows compiler ignores gcc __attribute__(x) */
+#define __attribute__(a)
+
+#define WCOMMONINLINE __inline
+#define WCOMMONFORCEINLINE __forceinline
+
+/* Type for handle to dynamically loaded library */
+typedef HINSTANCE LIB_HANDLE;
+
+/* Missing typedefs */
+typedef void * caddr_t;
+typedef u_long in_addr_t;
+
+typedef unsigned char uint8_t;
+typedef char int8_t;
+typedef unsigned short uint16_t;
+typedef short int16_t;
+typedef unsigned int uint32_t;
+typedef int int32_t;
+typedef unsigned __int64 uint64_t;
+typedef __int64 int64_t;
+
+
+/* suffix for shared libraries */
+#ifdef _DEBUG
+#define LIB_EXTENSION "mdd.dll"
+#else
+#define LIB_EXTENSION "md.dll"
+#endif
+
+/* 8 byte int typedefs */
+typedef unsigned __int64 w_u64_t;
+typedef __int64 w_i64_t;
+
+/* Network conversion function */
+#define htonll(x) \
+ ((uint64_t)htonl((uint32_t)((x)>>32)) | (uint64_t)htonl((uint32_t)(x))<<32)
+#define ntohll(x) \
+ ((uint64_t)ntohl((uint32_t)((x)>>32)) | (uint64_t)ntohl((uint32_t)(x))<<32)
+
+/* For delimiting multiple paths in env variables properties */
+#define PATH_DELIM ';'
+
+#define PATHSEP "\\"
+
+/* Calling conventions */
+#define MAMACALLTYPE __stdcall
+
+#if defined( COMMON_DLL )
+ /* We are building common dll */
+# define COMMONExpDLL __declspec( dllexport )
+#elif defined( MAMA_DLL ) && defined( MAMA )
+ /* We are building mama as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL __declspec( dllexport )
+#elif defined( MAMA_DLL ) && defined( BRIDGE )
+ /* We are building mama bridge as a dll */
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMAExpBridgeDLL __declspec( dllimport )
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL
+# define MAMDAExpDLL
+# define MAMDAOPTExpDLL
+# define WMWExpDLL __declspec( dllimport )
+#elif defined( MAMA_DLL ) && defined( MAMACPP )
+ /* We are building mamacpp as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL
+#elif defined( MAMDA_DLL ) && defined( MAMDA )
+ /* We are building mamda as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllimport )
+# define MAMDAExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL
+#elif defined( MAMDA_DLL ) && defined( MAMDAOPT )
+ /* We are building extra mamda as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllimport )
+# define MAMDAExpDLL __declspec( dllimport )
+# define MAMDAOPTExpDLL __declspec( dllexport )
+# define MAMAExpBridgeDLL
+#elif !defined ( MAMA_STATIC ) && !defined ( WMW_STATIC ) && !defined (WIRECACHE_STATIC)
+ /* We are building mama apps (non static) */
+# define COMMONExpDLL __declspec( dllimport )
+# define WMWExpDLL __declspec( dllexport )
+# define MAMAExpDLL __declspec( dllimport )
+# define MAMACPPExpDLL __declspec( dllimport )
+# define MAMDAExpDLL __declspec( dllimport )
+# define MAMDAOPTExpDLL __declspec( dllimport )
+# define MAMAExpBridgeDLL
+#elif defined( WIN32 ) && defined( WMW_DLL )
+ /* We are building wmw as a dll */
+# define COMMONExpDLL __declspec( dllimport )
+# define WMWExpDLL __declspec( dllexport )
+#elif defined( WIN32 ) && defined( WMW_APP )
+ /* We are building wmw test apps */
+# define COMMONExpDLL __declspec( dllimport )
+# define WMWExpDLL __declspec( dllimport )
+#else
+ /* We are building on linux or statically */
+# define COMMONExpDLL
+# define WMWExpDLL
+# define WCACHEExpDLL
+# define MAMAExpDLL
+# define MAMACPPExpDLL
+# define MAMDAExpDLL
+# define MAMDAOPTExpDLL
+# define MAMAExpBridgeDLL
+#endif
+
+/* Socket Pair and set non blocking */
+COMMONExpDLL int
+wsocketpair (int domain, int type, int protocol, int* pair);
+
+COMMONExpDLL int
+wsetnonblock (int s);
+
+#define shutdown(x, y) closesocket((x))
+
+/* net work utility functions */
+COMMONExpDLL const char* getIpAddress (void);
+COMMONExpDLL const char* getHostName (void);
+COMMONExpDLL const char* getlogin (void);
+COMMONExpDLL struct in_addr resolve_ip (const char * arg);
+
+/* Thread local storage */
+typedef DWORD wthread_key_t;
+
+COMMONExpDLL int
+wthread_key_create(wthread_key_t* key, void* val);
+
+#define wthread_key_delete(x) TlsFree(x)
+#define wthread_setspecific(x, val) TlsSetValue((x),(void*)((val)))
+#define wthread_getspecific(x) TlsGetValue((x))
+
+/* Posix Semaphores for Windows */
+typedef void* wsem_t;
+
+COMMONExpDLL
+int wsem_init (wsem_t* sem, int dummy, int count);
+
+COMMONExpDLL
+int wsem_destroy (wsem_t* sem);
+
+COMMONExpDLL
+int wsem_post (wsem_t* sem);
+
+COMMONExpDLL
+int wsem_wait (wsem_t* sem);
+
+COMMONExpDLL
+int wsem_timedwait (wsem_t* sem, unsigned int ts);
+
+COMMONExpDLL
+int wsem_trywait (wsem_t* sem);
+
+COMMONExpDLL
+int wsem_getvalue (wsem_t*, int* items);
+
+/* These functions are different on Windows */
+#define bzero( x, y ) ZeroMemory( ((void *)(x)), (y) )
+#define strtok_r(x, y, z) strtok((x),(y))
+#define snprintf _snprintf
+#define strdup _strdup
+#define strncasecmp _strnicmp
+#define strcasecmp _stricmp
+#define read _read
+#define write _write
+#define close _close
+#define sleep(x) Sleep( (x)*1000)
+
+COMMONExpDLL
+int gettimeofday( struct timeval *result, void *dummy );
+
+COMMONExpDLL
+int getpid();
+
+const char *index( const char *str, char c );
+
+#define ctime_r ctime
+
+#define gmtime_r( _clock, _result ) \
+ ( *(_result) = *gmtime( (_clock) ), \
+ (_result) )
+
+/*
+ inttypes.h doesn't exist on windows.
+ emulate some definitions here.
+*/
+#define PRId64 "I64d"
+#define PRIu64 "I64u"
+
+#define wthread_detach( h ) /* noop */
+#define wthread_self GetCurrentThread
+#define wthread_equal( h1, h2 ) ((h1) == (h2))
+
+#define wthread_cond_init( h, zip ) ((*(h)) = CreateEvent( NULL, 1, 0, NULL ))
+#define wthread_cond_signal( h ) (SetEvent( *(h) ))
+#define wthread_cond_destroy( h ) (CloseHandle( *(h) ))
+
+COMMONExpDLL DWORD
+wthread_cond_wait( HANDLE *event, LPCRITICAL_SECTION *cs );
+
+#define wthread_exit ExitThread
+
+#define wthread_cleanup_push( x, y ) /* noop */
+#define wthread_cleanup_pop(x) /* noop */
+
+#define CPU_AFFINITY_SET DWORD
+
+COMMONExpDLL int wthread_create( wthread_t *h, void *atts, void *(*startProc)( void * ), void *arg );
+COMMONExpDLL void wthread_destroy(wthread_t thread);
+COMMONExpDLL int wthread_join (wthread_t t, void **value_ptr);
+COMMONExpDLL void wthread_testcancel( wthread_t h );
+COMMONExpDLL void wthread_cancel( wthread_t h );
+COMMONExpDLL struct tm* localtime_r (const time_t* t, struct tm* result);
+COMMONExpDLL int wthread_set_affinity_mask( wthread_t h, CPU_AFFINITY_SET* dwThreadAffinityMask);
+
+typedef int wthread_attr_t;
+COMMONExpDLL void wthread_attr_init (int* attr);
+COMMONExpDLL void wthread_attr_setdetachstate (int* attr, int);
+
+typedef int wthread_mutexattr_t;
+COMMONExpDLL void wthread_mutexattr_init (int* attr);
+COMMONExpDLL void wthread_mutexattr_settype (int* attr, int);
+
+#define wGetCurrentThreadId GetCurrentThreadId
+
+/* Macros for shared library access */
+#define wdlopen(a,b) LoadLibrary(a)
+#define wdlclose FreeLibrary
+#define wdlerror GetLastError
+#define wdlsym GetProcAddress
+
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+
+#define timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+
+
+/* time gm not available on Windows */
+COMMONExpDLL
+time_t wtimegm (struct tm *tm);
+
+struct wtimespec
+{
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+COMMONExpDLL int wnanosleep (struct wtimespec* ts, struct timnespec* remain);
+
+#if defined(__cplusplus)
+} /* extern "C" */
+#endif
+
+#endif /* WINDOWS_H__ */
diff --git a/common/c_cpp/src/c/windows/wSemaphore.c b/common/c_cpp/src/c/windows/wSemaphore.c
new file mode 100644
index 0000000..6947ac4
--- /dev/null
+++ b/common/c_cpp/src/c/windows/wSemaphore.c
@@ -0,0 +1,147 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "port.h"
+
+#include "wombat/wSemaphore.h"
+
+/**
+ * Waiting on Win32 semaphore involves a system call and is very inefficient. When
+ * we test to determine if the queue is empty with a Win32 semaphore
+ * WaitForSingleObject consumes all the CPU!!!!. We can be much more efficient using
+ * a critical section and not call WaitForSingleObject when there is nothing on the Queue.
+ */
+
+typedef struct
+{
+ unsigned int mCount;
+ HANDLE mEvent;
+ CRITICAL_SECTION mCs;
+} sem_t;
+
+int wsem_init (wsem_t* result, int dummy, int count)
+{
+ sem_t* sem = (sem_t*)malloc (sizeof (sem_t));
+ if (sem == NULL)
+ {
+ return 1;
+ }
+
+ *result = sem;
+ sem->mCount = count;
+ sem->mEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
+ if (sem->mEvent == INVALID_HANDLE_VALUE)
+ {
+ return 1;
+ }
+ InitializeCriticalSection (&sem->mCs);
+
+ return 0;
+}
+
+int wsem_destroy (wsem_t* sem)
+{
+ sem_t* impl = (sem_t*)(*sem);
+ CloseHandle (impl->mEvent);
+ DeleteCriticalSection (&impl->mCs);
+ free (impl);
+ return 0;
+}
+
+int wsem_post (wsem_t* sem)
+{
+ sem_t* impl = (sem_t*)(*sem);
+ EnterCriticalSection (&impl->mCs);
+ impl->mCount++;
+
+ /* MLS: we might be able to optimize here and only call SetEvent when the
+ * count is 1; however, this would require extensive testing as a race
+ * condition would stop dispatching altogether. I don't see any obvious
+ * race conditions but I am a little concerned that there might be undefined
+ * behavior when SetEvent and WaitForSingleObject race. MS does not
+ * indicate this directly but the documentation for PulseEvent() mentions
+ * some potential problems. We don't use pulse event for this reason.
+ */
+ SetEvent (impl->mEvent);
+ LeaveCriticalSection (&impl->mCs);
+ return 0;
+}
+
+int wsem_wait (wsem_t* sem)
+{
+ unsigned int t = INFINITE;
+ return wsem_timedwait (sem, t);
+
+}
+
+int wsem_trywait (wsem_t* sem)
+{
+ sem_t* impl = (sem_t*)(*sem);
+ int wouldWait = 0;
+
+ EnterCriticalSection (&impl->mCs);
+ if (impl->mCount)
+ {
+ impl->mCount--;
+ }
+ else
+ {
+ wouldWait = 1;
+ }
+ LeaveCriticalSection (&impl->mCs);
+
+ return wouldWait;
+}
+
+int wsem_getvalue (wsem_t* sem, int* items)
+{
+ sem_t* impl = (sem_t*)(*sem);
+ EnterCriticalSection (&impl->mCs);
+ *items = impl->mCount;
+ LeaveCriticalSection (&impl->mCs);
+
+ return 0;
+}
+
+
+
+int wsem_timedwait (wsem_t* sem, unsigned int timeoutval)
+{
+ DWORD ts = (DWORD) timeoutval;
+ sem_t* impl = (sem_t*)(*sem);
+ int wait = 0;
+
+ do
+ {
+ EnterCriticalSection (&impl->mCs);
+ if (impl->mCount <= 1) ResetEvent (impl->mEvent);
+ if (impl->mCount)
+ {
+ impl->mCount--;
+ LeaveCriticalSection (&impl->mCs);
+ return 0;
+ }
+ LeaveCriticalSection (&impl->mCs);
+ } while (WAIT_OBJECT_0 == WaitForSingleObject (impl->mEvent, ts));
+
+ /* Time out or worse */
+ return -1;
+}
+
diff --git a/common/c_cpp/src/c/windows/wombat/targetsxs.h b/common/c_cpp/src/c/windows/wombat/targetsxs.h
new file mode 100644
index 0000000..a8d8280
--- /dev/null
+++ b/common/c_cpp/src/c/windows/wombat/targetsxs.h
@@ -0,0 +1,38 @@
+#ifndef _WOMBAT_TARGETSXS_H
+#define _WOMBAT_TARGETSXS_H
+
+#ifndef VC7
+
+#ifdef VC8
+#define _SXS_ASSEMBLY_VERSION "8.0.50727.762"
+#endif
+
+#ifdef VC9
+#define _SXS_ASSEMBLY_VERSION "9.0.21022.8"
+#endif
+
+#ifdef VC10
+#define _SXS_ASSEMBLY_VERSION "10.0.30319.1"
+#endif
+
+#ifndef __midl
+
+#define _CRT_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION
+#define _MFC_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION
+#define _ATL_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+__declspec(selectany) int _forceCRTManifest;
+__declspec(selectany) int _forceMFCManifest;
+__declspec(selectany) int _forceAtlDllManifest;
+__declspec(selectany) int _forceCRTManifestRTM;
+__declspec(selectany) int _forceMFCManifestRTM;
+__declspec(selectany) int _forceAtlDllManifestRTM;
+#ifdef __cplusplus
+}
+#endif
+#endif
+#endif
+#endif
diff --git a/common/c_cpp/src/c/windows/wombat/wInterlocked.h b/common/c_cpp/src/c/windows/wombat/wInterlocked.h
new file mode 100644
index 0000000..ecfb72c
--- /dev/null
+++ b/common/c_cpp/src/c/windows/wombat/wInterlocked.h
@@ -0,0 +1,97 @@
+/*
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef WINTERLOCKED_H
+#define WINTERLOCKED_H
+
+#include "port.h"
+
+/* The base interlocked type on Windows. */
+typedef volatile long wInterlockedInt;
+
+/**
+ * This function will initialise a wInterlockedInt.
+ *
+ * @param[in] value Pointer to the item to be initialized.
+ * @return 0 on success.
+ */
+
+WCOMMONINLINE int wInterlocked_initialize(wInterlockedInt *value)
+{
+ return 0;
+}
+
+/**
+ * This function will destroy a wInterlockedInt.
+ *
+ * @param[in] value Pointer to the item to be destroyed.
+ * @return 0 on success.
+ */
+WCOMMONINLINE int wInterlocked_destroy(wInterlockedInt *value)
+{
+ return 0;
+}
+
+/**
+ * This function will atomically decrement a 32-bit integer value.
+ *
+ * @param[in] value Pointer to the value to be decremented.
+ * @return The decremented integer.
+ */
+WCOMMONINLINE int wInterlocked_decrement(wInterlockedInt *value)
+{
+ return (int)InterlockedDecrement(value);
+}
+
+/**
+ * This function will atomically increment a 32-bit integer value.
+ *
+ * @param[in] value Pointer to the value to be incremented.
+ * @return The incremented integer.
+ */
+WCOMMONINLINE int wInterlocked_increment(wInterlockedInt *value)
+{
+ return (int)InterlockedIncrement(value);
+}
+
+/**
+ * This function will return the value of the interlocked variable.
+ *
+ * @param[in] value Pointer to the value to be read.
+ * @return The value itself.
+ */
+WCOMMONINLINE int wInterlocked_read(wInterlockedInt *value)
+{
+ return *value;
+}
+
+/**
+ * This function will atomically set a 32-bit integer value.
+ *
+ * @param[in] newValue The new value to set.
+ * @param[in] value Pointer to the value to be set.
+ * @return The updated integer.
+ */
+WCOMMONINLINE int wInterlocked_set(int newValue, wInterlockedInt *value)
+{
+ return (int)InterlockedExchange(value, (long)newValue);
+}
+
+#endif
--
1.7.7.6


[PATCH 25/30] Removed #ifdef WIN32 from playbackFileParser #ifdef

Michael Schonberg <mschonberg@...>
 

The windows specific logic for memory mapped files was incorrect and
likely would not work. PAGE_READONLY should be passed to
CreateFileMapping(), not OpenFile(). It is not clear whether this ever
worked on Windows, and it can be added correctly in the future if
required.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 1 +
mama/c_cpp/src/c/playback/playbackFileParser.c | 31 +-----------------------
2 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 27cf055..4e69c7c 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -36,6 +36,7 @@ extern "C"
#include <pthread.h>
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <sys/mman.h>
#include <sys/vfs.h>
#include <sys/param.h>
#include <sys/resource.h>
diff --git a/mama/c_cpp/src/c/playback/playbackFileParser.c b/mama/c_cpp/src/c/playback/playbackFileParser.c
index c05b926..16d38cf 100644
--- a/mama/c_cpp/src/c/playback/playbackFileParser.c
+++ b/mama/c_cpp/src/c/playback/playbackFileParser.c
@@ -152,10 +152,7 @@ mamaPlaybackFileParser_openFile (mamaPlaybackFileParser fileParser,
char* fileName)
{
mama_status status = MAMA_STATUS_OK;
-#ifdef WIN32
- OFSTRUCT of;
- HANDLE hMMFile;
-#endif
+
mamaPlaybackFileParserImpl* impl =
(mamaPlaybackFileParserImpl*)fileParser;
if (impl == NULL) return MAMA_STATUS_NULL_ARG;
@@ -166,22 +163,6 @@ mamaPlaybackFileParser_openFile (mamaPlaybackFileParser fileParser,
"openFile: checking for file: %s", fileName);
mamaPlaybackFileParser_setSize (impl,fileName);

-#ifdef WIN32
-
-
-
- if ((impl->myFileDescriptor = (OpenFile (fileName, &of, PAGE_READONLY))) >= 0)
- {
- hMMFile = CreateFileMapping ((void*)impl->myFileDescriptor, NULL, 0x02, 0, 0, NULL);
-
- impl->myFiledata = (char *)MapViewOfFile (hMMFile,
- FILE_MAP_READ,
- 0,
- 0,
- 0);
-
-
-#else
if ((impl->myFileDescriptor = (open (fileName,
/*O_RDWR*/O_RDONLY | O_NONBLOCK,
0))) >= 0)
@@ -191,14 +172,8 @@ mamaPlaybackFileParser_openFile (mamaPlaybackFileParser fileParser,
MAP_SHARED,
impl->myFileDescriptor,
0);
-
-#endif
if (!impl->myFiledata)
{
-#ifdef WIN32
- int err;
- err=GetLastError();
-#endif
mama_log(MAMA_LOG_LEVEL_NORMAL,
"memory mapping failed?\n");
exit(1);
@@ -225,11 +200,7 @@ mamaPlaybackFileParser_closeFile (mamaPlaybackFileParser fileParser)
{
return MAMA_STATUS_NULL_ARG;
}
-#ifdef WIN32
- CloseHandle((void*)impl->myFileDescriptor);
-#else
munmap(impl->myFiledata, impl->myFileSize);
-#endif
return MAMA_STATUS_OK;
}

--
1.7.7.6


[PATCH 24/30] Replaced numerous #ifdef WIN32 with port.h #ifdef

Michael Schonberg <mschonberg@...>
 

Most were callbacks where __stdcall needed to be replaced with
MAMACALLTYPE or "#include "wincompat.h"" which can be replaced with
"port.h".

Signed-off-by: Mike Schonberg <mschonberg@...>
---
mama/c_cpp/src/c/bridge/avis/bridge.c | 5 +-
mama/c_cpp/src/c/bridge/avis/msg.c | 5 +-
mama/c_cpp/src/c/bridge/avis/transportbridge.c | 5 +-
mama/c_cpp/src/c/conflation/connection.c | 4 +-
mama/c_cpp/src/c/conflation/connection_int.h | 10 +---
mama/c_cpp/src/c/conflation/manager.c | 5 +-
mama/c_cpp/src/c/conflation/manager_int.h | 4 +-
mama/c_cpp/src/c/conflation/serverconnection_int.h | 8 +--
mama/c_cpp/src/c/mama/conflation/manager.h | 2 +-
mama/c_cpp/src/c/mama/datetime.h | 4 +-
mama/c_cpp/src/c/mama/fielddesc.h | 4 +-
mama/c_cpp/src/c/mama/mama.h | 12 +---
mama/c_cpp/src/c/mama/msg.h | 14 +----
mama/c_cpp/src/c/mama/msgfield.h | 4 +-
mama/c_cpp/src/c/mama/timezone.h | 4 +-
mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c | 4 +-
mama/c_cpp/src/c/playback/playbackFileParser.h | 10 +---
mama/c_cpp/src/c/playback/playbackpublisher.h | 5 +-
mama/c_cpp/src/c/priceimpl.c | 19 +-----
mama/c_cpp/src/regression/c/tools/basicinbox.c | 31 ++--------
mama/c_cpp/src/regression/c/tools/basicpub.c | 50 +++-------------
mama/c_cpp/src/regression/c/tools/basicsub.c | 61 ++++----------------
22 files changed, 56 insertions(+), 214 deletions(-)

diff --git a/mama/c_cpp/src/c/bridge/avis/bridge.c b/mama/c_cpp/src/c/bridge/avis/bridge.c
index cfb920c..5f2b973 100755
--- a/mama/c_cpp/src/c/bridge/avis/bridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/bridge.c
@@ -21,10 +21,7 @@

#include <avis/elvin.h>

-#ifdef WIN32
-#include <wombat/wincompat.h>
-#endif /* WIN32 */
-
+#include "port.h"

#include <mama/mama.h>
#include <timers.h>
diff --git a/mama/c_cpp/src/c/bridge/avis/msg.c b/mama/c_cpp/src/c/bridge/avis/msg.c
index 92c1da3..82176e9 100644
--- a/mama/c_cpp/src/c/bridge/avis/msg.c
+++ b/mama/c_cpp/src/c/bridge/avis/msg.c
@@ -19,15 +19,12 @@
* 02110-1301 USA
*/

+#include "port.h"
#include <stdlib.h>
#include <string.h>

#include <avis/elvin.h>

-#ifdef WIN32
-#include <wombat/wincompat.h>
-#endif /* WIN32 */
-
#include <mama/mama.h>
#include <msgimpl.h>
#include "avisdefs.h"
diff --git a/mama/c_cpp/src/c/bridge/avis/transportbridge.c b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
index 7ab3b39..1d7bc44 100755
--- a/mama/c_cpp/src/c/bridge/avis/transportbridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
@@ -22,10 +22,7 @@
#include <avis/elvin.h>
#include <avis/avis_client_config.h>

-#ifdef WIN32
-#include <wombat/wincompat.h>
-#endif /* WIN32 */
-
+#include "port.h"

#include <property.h>
#include <mama/mama.h>
diff --git a/mama/c_cpp/src/c/conflation/connection.c b/mama/c_cpp/src/c/conflation/connection.c
index 1689a3f..eddb291 100644
--- a/mama/c_cpp/src/c/conflation/connection.c
+++ b/mama/c_cpp/src/c/conflation/connection.c
@@ -19,9 +19,7 @@
* 02110-1301 USA
*/
#include <string.h>
-#ifdef WIN32
-#include <wombat/wincompat.h>
-#endif
+#include "port.h"

#include "mama/conflation/connection.h"
#include "conflation/connection_int.h"
diff --git a/mama/c_cpp/src/c/conflation/connection_int.h b/mama/c_cpp/src/c/conflation/connection_int.h
index c883123..a478b79 100644
--- a/mama/c_cpp/src/c/conflation/connection_int.h
+++ b/mama/c_cpp/src/c/conflation/connection_int.h
@@ -22,9 +22,8 @@
#ifndef MAMA_CONNECTION_INT_H__
#define MAMA_CONNECTION_INT_H__

-#ifndef WIN32
-#include <netinet/in.h>
-#endif
+#include "port.h"
+
#include "mama/conflation/connection.h"

#if defined(__cplusplus)
@@ -34,12 +33,7 @@ extern "C" {
#define MAX_STR_LEN 67
#define MAX_USER_STR_LEN 256

-/* This definition contains the length of the IP address string. */
-#ifndef WIN32
#define MAMACONNECTION_MAX_IP_ADDRESS_LEN INET_ADDRSTRLEN
-#else
-#define MAMACONNECTION_MAX_IP_ADDRESS_LEN 16
-#endif

typedef struct mamaConnection_
{
diff --git a/mama/c_cpp/src/c/conflation/manager.c b/mama/c_cpp/src/c/conflation/manager.c
index d596c29..90fed15 100644
--- a/mama/c_cpp/src/c/conflation/manager.c
+++ b/mama/c_cpp/src/c/conflation/manager.c
@@ -20,9 +20,7 @@
*/

#include <string.h>
-#ifdef WIN32
-#include <wombat/wincompat.h>
-#endif
+#include "port.h"

#include "mama/mama.h"
#include "mama/conflation/manager.h"
@@ -343,7 +341,6 @@ mamaConflationManager_publish (mamaConflationManager mgr,

}

-
static void MAMACALLTYPE
flushCallback (wombatQueue queue, void* data, void* itemClosure, void* closure)
{
diff --git a/mama/c_cpp/src/c/conflation/manager_int.h b/mama/c_cpp/src/c/conflation/manager_int.h
index a28721d..1464579 100644
--- a/mama/c_cpp/src/c/conflation/manager_int.h
+++ b/mama/c_cpp/src/c/conflation/manager_int.h
@@ -26,10 +26,8 @@

#ifndef MAMA_MANAGER_INT_H__
#define MAMA_MANAGER_INT_H__
+#include "port.h"

-#ifndef WIN32
-#include <netinet/in.h>
-#endif
#include "mama/conflation/manager.h"

#if defined(__cplusplus)
diff --git a/mama/c_cpp/src/c/conflation/serverconnection_int.h b/mama/c_cpp/src/c/conflation/serverconnection_int.h
index fd5186c..c5bcb51 100644
--- a/mama/c_cpp/src/c/conflation/serverconnection_int.h
+++ b/mama/c_cpp/src/c/conflation/serverconnection_int.h
@@ -22,9 +22,7 @@
#ifndef MAMA_SERVER_CONNECTION_INT_H__
#define MAMA_SERVER_CONNECTION_INT_H__

-#ifndef WIN32
-#include <netinet/in.h>
-#endif
+#include "port.h"

#if defined(__cplusplus)
extern "C" {
@@ -32,11 +30,7 @@ extern "C" {

typedef struct mamaServerConnection_
{
-#ifndef WIN32
char mIpAddress[INET_ADDRSTRLEN];
-#else
- char mIpAddress[16];
-#endif
uint16_t mPort;
int mConnectionStatus;
} mamaServerConnectionImpl;
diff --git a/mama/c_cpp/src/c/mama/conflation/manager.h b/mama/c_cpp/src/c/mama/conflation/manager.h
index f5dcf45..0bce01a 100644
--- a/mama/c_cpp/src/c/mama/conflation/manager.h
+++ b/mama/c_cpp/src/c/mama/conflation/manager.h
@@ -24,8 +24,8 @@
#define CONFLATION_MANAGER_H__

#include <string.h>
-#include "port.h"

+#include "port.h"
#include "mama/mama.h"

#if defined(__cplusplus)
diff --git a/mama/c_cpp/src/c/mama/datetime.h b/mama/c_cpp/src/c/mama/datetime.h
index bbbc724..ecc77d0 100644
--- a/mama/c_cpp/src/c/mama/datetime.h
+++ b/mama/c_cpp/src/c/mama/datetime.h
@@ -26,10 +26,8 @@
#include <mama/status.h>
#include <mama/types.h>
#include <mama/timezone.h>
+#include "port.h"

-#ifndef WIN32
-#include <sys/time.h>
-#endif
#include <time.h>


diff --git a/mama/c_cpp/src/c/mama/fielddesc.h b/mama/c_cpp/src/c/mama/fielddesc.h
index 0249748..8d7f907 100644
--- a/mama/c_cpp/src/c/mama/fielddesc.h
+++ b/mama/c_cpp/src/c/mama/fielddesc.h
@@ -30,9 +30,7 @@
#include <mama/types.h>
#include <stdlib.h>

-#ifndef WIN32
-#include <inttypes.h>
-#endif
+#include "port.h"

#if defined(__cplusplus)
extern "C" {
diff --git a/mama/c_cpp/src/c/mama/mama.h b/mama/c_cpp/src/c/mama/mama.h
index 557ac2c..0bffcbe 100644
--- a/mama/c_cpp/src/c/mama/mama.h
+++ b/mama/c_cpp/src/c/mama/mama.h
@@ -441,9 +441,7 @@ extern "C"
@param appName "site server" or application name of application that userId is using to connect (possibly NULL)
*/
typedef void (
- #ifdef WIN32
- __stdcall
- #endif
+ MAMACALLTYPE
*onSessionDisconnectCB) (const sessionDisconnectReason reason,
const char* userId,
const char* host,
@@ -453,9 +451,7 @@ extern "C"
Callback invoked after dynamic entitlements update has occurred
*/
typedef void (
- #ifdef WIN32
- __stdcall
- #endif
+ MAMACALLTYPE
*onEntitlementUpdateCB) (void);

/**
@@ -465,9 +461,7 @@ extern "C"
otherwise 0.
*/
typedef void (
- #ifdef WIN32
- __stdcall
- #endif
+ MAMACALLTYPE
*onEntitlementCheckingSwitchCB) (const int isEntitlementCheckingDisabled);
/**
Convenience structure for registering entitlement callbacks to MAMA
diff --git a/mama/c_cpp/src/c/mama/msg.h b/mama/c_cpp/src/c/mama/msg.h
index 2b99c85..2d17d22 100644
--- a/mama/c_cpp/src/c/mama/msg.h
+++ b/mama/c_cpp/src/c/mama/msg.h
@@ -26,12 +26,9 @@
#include <mama/status.h>
#include <mama/fielddesc.h>
#include <mama/msgtype.h>
+#include "port.h"
#include <stdlib.h>

-#ifndef WIN32
-#include <inttypes.h>
-#endif
-
#define ENTITLE_FIELD_NAME "wEntitleCode"
#define ENTITLE_FIELD_ID 496

@@ -2115,16 +2112,9 @@ mamaMsg_getFieldAsString (
* @param closure The closure specified in mamaMsg_iterateFields().
*
*/
-#ifndef WIN32
-typedef void(*mamaMsgIteratorCb)(const mamaMsg msg,
+typedef void(MAMACALLTYPE *mamaMsgIteratorCb)(const mamaMsg msg,
const mamaMsgField field,
void* closure);
-#else
-typedef void(__stdcall *mamaMsgIteratorCb)(
- const mamaMsg msg,
- const mamaMsgField field,
- void* closure);
-#endif

/**
* Invoke the specified callback for each field in the message.
diff --git a/mama/c_cpp/src/c/mama/msgfield.h b/mama/c_cpp/src/c/mama/msgfield.h
index b96b3fd..191b700 100644
--- a/mama/c_cpp/src/c/mama/msgfield.h
+++ b/mama/c_cpp/src/c/mama/msgfield.h
@@ -27,9 +27,7 @@
#include <mama/fielddesc.h>
#include <stdlib.h>

-#ifndef WIN32
-#include <inttypes.h>
-#endif
+#include "port.h"

#if defined(__cplusplus)
extern "C" {
diff --git a/mama/c_cpp/src/c/mama/timezone.h b/mama/c_cpp/src/c/mama/timezone.h
index bf31562..5991b8c 100644
--- a/mama/c_cpp/src/c/mama/timezone.h
+++ b/mama/c_cpp/src/c/mama/timezone.h
@@ -25,10 +25,8 @@
#include <mama/config.h>
#include <mama/status.h>
#include <mama/types.h>
+#include "port.h"

-#ifndef WIN32
-#include <sys/time.h>
-#endif
#include <time.h>


diff --git a/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c b/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c
index 70a69f0..7d13748 100755
--- a/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c
+++ b/mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c
@@ -26,9 +26,7 @@

#include <avis/elvin.h>

-#ifdef WIN32
-#include <wombat/wincompat.h>
-#endif /* WIN32 */
+#include "port.h"

#include <mama/mama.h>
#include "avismsgimpl.h"
diff --git a/mama/c_cpp/src/c/playback/playbackFileParser.h b/mama/c_cpp/src/c/playback/playbackFileParser.h
index 70ac5e1..6435033 100644
--- a/mama/c_cpp/src/c/playback/playbackFileParser.h
+++ b/mama/c_cpp/src/c/playback/playbackFileParser.h
@@ -26,14 +26,8 @@
#if defined(__cplusplus)
extern "C" {
#endif
-#ifndef WIN32
-#include <unistd.h>
-#include <sys/mman.h>
-#else
-#include <io.h>
-#include <windows.h>
-#include <winbase.h>
-#endif
+
+#include "port.h"

#include <stdlib.h>
#include <fcntl.h>
diff --git a/mama/c_cpp/src/c/playback/playbackpublisher.h b/mama/c_cpp/src/c/playback/playbackpublisher.h
index 13cb071..1e638d2 100644
--- a/mama/c_cpp/src/c/playback/playbackpublisher.h
+++ b/mama/c_cpp/src/c/playback/playbackpublisher.h
@@ -39,9 +39,8 @@ extern "C" {
#include <lookup2.h>
#include <wombat/wtable.h>
#include "playbackFileParser.h"
-#ifndef WIN32
-#include <unistd.h>
-#endif
+#include "port.h"
+
#define BUFFER_SIZE 128
typedef struct mamaFilePlayback_
{
diff --git a/mama/c_cpp/src/c/priceimpl.c b/mama/c_cpp/src/c/priceimpl.c
index f88249b..1d540a4 100644
--- a/mama/c_cpp/src/c/priceimpl.c
+++ b/mama/c_cpp/src/c/priceimpl.c
@@ -22,17 +22,6 @@
#include <mama/mama.h>
#include "priceimpl.h"

-/* The format specifier for large integers is different on window and gcc. The standard
- * specifier isn't supported on windows from compiler versions previous to VC7.
- */
-#ifdef WIN32
-#define MAMA_PRICE_IMPL_LARGE_INT32_FORMAT_SPECIFIER "%I32d"
-#define MAMA_PRICE_IMPL_LARGE_INT64_FORMAT_SPECIFIER "%I64d"
-#else
-#define MAMA_PRICE_IMPL_LARGE_INT32_FORMAT_SPECIFIER "%ld"
-#define MAMA_PRICE_IMPL_LARGE_INT64_FORMAT_SPECIFIER "%lld"
-#endif
-
static void mamaPriceImpl_getAsStringDecimal (double value,
mama_size_t decimals,
char* buf,
@@ -114,7 +103,7 @@ void mamaPriceImpl_getAsStringInteger (double value,
mama_size_t bufMaxLen)
{
int64_t integer = (int64_t)value;
- snprintf (buf, bufMaxLen, MAMA_PRICE_IMPL_LARGE_INT64_FORMAT_SPECIFIER, integer);
+ snprintf (buf, bufMaxLen, "%lld", integer);
}


@@ -128,18 +117,18 @@ void mamaPriceImpl_getAsStringFraction (double value,
int64_t numer = (int64_t)((double)denom * fraction);
if (numer == 0)
{
- snprintf (buf, bufMaxLen, MAMA_PRICE_IMPL_LARGE_INT64_FORMAT_SPECIFIER, integer);
+ snprintf (buf, bufMaxLen, "%lld", integer);
}
else if (integer == 0)
{
char formatSpecifier[20] = "";
- sprintf(formatSpecifier, "%s/%s", MAMA_PRICE_IMPL_LARGE_INT64_FORMAT_SPECIFIER, MAMA_PRICE_IMPL_LARGE_INT32_FORMAT_SPECIFIER);
+ sprintf(formatSpecifier, "%s/%s", "%lld", "%ld");
snprintf (buf, bufMaxLen, formatSpecifier, numer, denom);
}
else
{
char formatSpecifier[20] = "";
- sprintf(formatSpecifier, "%s %s/%s", MAMA_PRICE_IMPL_LARGE_INT64_FORMAT_SPECIFIER, MAMA_PRICE_IMPL_LARGE_INT64_FORMAT_SPECIFIER, MAMA_PRICE_IMPL_LARGE_INT32_FORMAT_SPECIFIER);
+ sprintf(formatSpecifier, "%s %s/%s", "%lld", "%lld", "%ld");
if (integer < 0)
{
numer = -numer;
diff --git a/mama/c_cpp/src/regression/c/tools/basicinbox.c b/mama/c_cpp/src/regression/c/tools/basicinbox.c
index 0f2f290..cba88ff 100755
--- a/mama/c_cpp/src/regression/c/tools/basicinbox.c
+++ b/mama/c_cpp/src/regression/c/tools/basicinbox.c
@@ -57,17 +57,11 @@ static void initializeMama (void);
static void createInbox (void);
static void createPublisher (void);
static void sendRequest (void);
-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+
+static void MAMACALLTYPE
msgCB (mamaMsg msg, void* closure);
-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+
+static void MAMACALLTYPE
errorCB (mama_status status, void* closure);


@@ -165,10 +159,7 @@ void initializeMama (void)
}

/* Used to destroy messages sent on the throttle */
-static void
-#ifdef WIN32
-__stdcall
-#endif
+static void MAMACALLTYPE
sendCompleteCb (mamaPublisher publisher,
mamaMsg msg,
mama_status status,
@@ -251,11 +242,7 @@ static void createInbox (void)
}
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
msgCB (mamaMsg msg, void *closure)
{
printf ("Received reply: %s\n", mamaMsg_toString (msg));
@@ -263,11 +250,7 @@ msgCB (mamaMsg msg, void *closure)
exit(0);
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
errorCB (mama_status status, void *closure)
{
printf ("Error creating inbox: %s\n",
diff --git a/mama/c_cpp/src/regression/c/tools/basicpub.c b/mama/c_cpp/src/regression/c/tools/basicpub.c
index 7568989..ab1c8e7 100644
--- a/mama/c_cpp/src/regression/c/tools/basicpub.c
+++ b/mama/c_cpp/src/regression/c/tools/basicpub.c
@@ -78,37 +78,23 @@ NULL
static void parseCommandLine (int argc, const char **argv);
static void initializeMama (void);
static void createIntervalTimer (void);
-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+
+static void MAMACALLTYPE
timerCallback (mamaTimer timer, void *closure);
+
static void createInboundSubscription (void);

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
inboundCreateCb (mamaSubscription subscription, void *closure);

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
inboundErrorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
const char *subject,
void *closure);

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
inboundMsgCb (mamaSubscription subscription,
mamaMsg msg,
void *closure,
@@ -362,11 +348,7 @@ static void createInboundSubscription (void)
}
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
inboundCreateCb (mamaSubscription subscription, void *closure)
{
if (gQuietLevel < 2)
@@ -375,11 +357,7 @@ inboundCreateCb (mamaSubscription subscription, void *closure)
}
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
inboundErrorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -391,11 +369,7 @@ inboundErrorCb (mamaSubscription subscription,
exit (status);
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
inboundMsgCb (mamaSubscription subscription,
mamaMsg msg,
void* closure,
@@ -437,11 +411,7 @@ static void createIntervalTimer (void)
}


-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
timerCallback (mamaTimer timer, void *closure)
{
publishMessage (NULL);
diff --git a/mama/c_cpp/src/regression/c/tools/basicsub.c b/mama/c_cpp/src/regression/c/tools/basicsub.c
index 17c1009..b096814 100755
--- a/mama/c_cpp/src/regression/c/tools/basicsub.c
+++ b/mama/c_cpp/src/regression/c/tools/basicsub.c
@@ -74,49 +74,30 @@ static void initializeMama (void);
static void createSubscriber (void);
static void createWildCardSubscriber (void);
static void displayMsg (mamaMsg msg);
-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+
+static void MAMACALLTYPE
displayCb (const mamaMsg msg,
const mamaMsgField field,
void * closure);

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
createCb (mamaSubscription subscription,
void * closure);

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
errorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
const char* subject,
void* closure);

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
msgCb (mamaSubscription subscription,
mamaMsg msg,
void * closure,
void * itemClosure);

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
wildCardMsgCb (mamaSubscription subscription,
mamaMsg msg,
const char* topic,
@@ -252,11 +233,7 @@ static void createSubscriber (void)
}
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
createCb (mamaSubscription subscription, void *closure)
{
if (gQuietLevel < 2)
@@ -265,11 +242,7 @@ createCb (mamaSubscription subscription, void *closure)
}
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
errorCb (mamaSubscription subscription,
mama_status status,
void* platformError,
@@ -281,11 +254,7 @@ errorCb (mamaSubscription subscription,
exit (status);
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
msgCb (mamaSubscription subscription,
mamaMsg msg,
void* closure,
@@ -298,11 +267,7 @@ msgCb (mamaSubscription subscription,
displayMsg (msg);
}

-#ifdef WIN32
-static void __stdcall
-#else
-static void
-#endif
+static void MAMACALLTYPE
wildCardMsgCb (mamaSubscription subscription,
mamaMsg msg,
const char* topic,
@@ -335,11 +300,7 @@ wildCardMsgCb (mamaSubscription subscription,
displayMsg (msg);
}

-#ifdef WIN32
-void __stdcall
-#else
-void
-#endif
+void MAMACALLTYPE
displayCb (const mamaMsg msg,
const mamaMsgField field,
void* closure)
--
1.7.7.6


[PATCH 23/30] Conflation manager fixes for windows

Michael Schonberg <mschonberg@...>
 

The callbacks need to be MAMACALLTYPE (__stdcall) and include port.h
rather than using #ifdef WIN32

Signed-off-by: Mike Schonberg <mschonberg@...>
---
mama/c_cpp/src/c/conflation/manager.c | 7 ++-----
mama/c_cpp/src/c/mama/conflation/manager.h | 16 ++++------------
2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/mama/c_cpp/src/c/conflation/manager.c b/mama/c_cpp/src/c/conflation/manager.c
index e3cf42f..d596c29 100644
--- a/mama/c_cpp/src/c/conflation/manager.c
+++ b/mama/c_cpp/src/c/conflation/manager.c
@@ -343,11 +343,8 @@ mamaConflationManager_publish (mamaConflationManager mgr,

}

-#ifndef WIN32
-static void
-#else
-static void __stdcall
-#endif
+
+static void MAMACALLTYPE
flushCallback (wombatQueue queue, void* data, void* itemClosure, void* closure)
{
mamaConflationManager mgr = (mamaConflationManager)closure;
diff --git a/mama/c_cpp/src/c/mama/conflation/manager.h b/mama/c_cpp/src/c/mama/conflation/manager.h
index def3e1d..f5dcf45 100644
--- a/mama/c_cpp/src/c/mama/conflation/manager.h
+++ b/mama/c_cpp/src/c/mama/conflation/manager.h
@@ -24,9 +24,7 @@
#define CONFLATION_MANAGER_H__

#include <string.h>
-#ifdef WIN32
-#include <wombat/wincompat.h>
-#endif
+#include "port.h"

#include "mama/mama.h"

@@ -34,15 +32,9 @@
extern "C" {
#endif

-#ifndef WIN32
-typedef void (*mamaConflationEnqueueCallback)(mamaMsg msg,
- const char* topic,
- void* closure);
-#else
-typedef void (__stdcall *mamaConflationEnqueueCallback)(mamaMsg msg,
- const char* topic,
- void* closure);
-#endif
+typedef void (MAMACALLTYPE *mamaConflationEnqueueCallback)(mamaMsg msg,
+ const char* topic,
+ void* closure);

mama_status
mamaConflationManager_allocate (mamaConflationManager* mgr);
--
1.7.7.6


[PATCH 22/30] Correct windows calling convention for queue

Michael Schonberg <mschonberg@...>
 

The calling convention for the methods must be COMMONExpDLL and callbacks
need MAMACALLTYPE to workproperly for windows.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/wombat/queue.h | 52 ++++++++++++++++++------------------
1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/common/c_cpp/src/c/wombat/queue.h b/common/c_cpp/src/c/wombat/queue.h
index e9e2093..e5d9da0 100644
--- a/common/c_cpp/src/c/wombat/queue.h
+++ b/common/c_cpp/src/c/wombat/queue.h
@@ -39,7 +39,7 @@ extern "C"


/* Callback for dispatching events from a queue. */
-typedef void (*wombatQueueCb)(void* data, void* closure);
+typedef void (MAMACALLTYPE *wombatQueueCb)(void* data, void* closure);

typedef void* wombatQueue;

@@ -62,7 +62,7 @@ typedef enum
*
* Size and other parameters may be set prior to calling wombatQueue_create().
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_allocate (wombatQueue *result);

/**
@@ -73,14 +73,14 @@ wombatQueue_allocate (wombatQueue *result);
* unbounded up to WOMBAT_QUEUE_MAX_SIZE.
*
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_create (wombatQueue queue, uint32_t maxSize, uint32_t initialSize,
uint32_t growBySize);

/**
* Destroy the Queue.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_destroy (wombatQueue queue);

/**
@@ -91,26 +91,26 @@ wombatQueue_destroy (wombatQueue queue);
* If it is not the actual max size will be rounded up to a multiple of the
* chunk size.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_setMaxSize (wombatQueue queue, unsigned int value);

/**
* Get the maximum size of the queue. WOMBAT_QUEUE_MAX_SIZE is the maximum
* queue size permitted and the default value.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_getMaxSize (wombatQueue queue, unsigned int *value);

/**
* Get the number of items currently in the queue.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_getSize (wombatQueue queue, int* size);

/**
* Enqueue an event.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_enqueue (wombatQueue queue,
wombatQueueCb cb,
void* data,
@@ -125,7 +125,7 @@ wombatQueue_enqueue (wombatQueue queue,
* This call blocks until an item is enqueued if the queue is empty.
*
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_dispatch (wombatQueue queue, void** data, void** closure);

/**
@@ -137,7 +137,7 @@ wombatQueue_dispatch (wombatQueue queue, void** data, void** closure);
* returning WOMBAT_QUEUE_TIMEOUT
*
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_timedDispatch (wombatQueue queue, void** data, void** closure,
uint64_t timeout);

@@ -145,7 +145,7 @@ wombatQueue_timedDispatch (wombatQueue queue, void** data, void** closure,
* Poll. This function deques and item if the queue is not empty otherwise it
* returns immediately with WOMBAT__WOULD_BLOCK.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_poll (wombatQueue queue, void** data, void** closure);


@@ -153,7 +153,7 @@ wombatQueue_poll (wombatQueue queue, void** data, void** closure);
* Cause a waiting thread to unblock without dequing an item. This is useful
* when cleaning up.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_unblock (wombatQueue queue);

/**
@@ -164,12 +164,12 @@ wombatQueue_unblock (wombatQueue queue);
* enqueued. The "closure" is the closure passed to wombatQueue_flush().
*
*/
-typedef void (*wombatQueueFlushCb)(wombatQueue queue,
- void* data,
- void* itemClosure,
- void* closure);
+typedef void (MAMACALLTYPE *wombatQueueFlushCb)(wombatQueue queue,
+ void* data,
+ void* itemClosure,
+ void* closure);

-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_flush (wombatQueue queue, wombatQueueFlushCb cb, void* closure);

/**
@@ -179,7 +179,7 @@ wombatQueue_flush (wombatQueue queue, wombatQueueFlushCb cb, void* closure);
* iterator is at the end of the queue. In this case the iterator does not
* move.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_next (wombatQueue queue, void** data, void** closure);

/**
@@ -188,7 +188,7 @@ wombatQueue_next (wombatQueue queue, void** data, void** closure);
* It returns WOMBAT_QUEUE_END and sets the data and closure to NULL if the
* iterator is at the beginning of the queue.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_prev (wombatQueue queue, void** data, void** closure);

/**
@@ -196,14 +196,14 @@ wombatQueue_prev (wombatQueue queue, void** data, void** closure);
* the queue is empty or the iterator is not initialized (next() not called),
* it returns WOMBAT_QUEUE_END, and does sets the data and closure to NULL.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_cur (wombatQueue queue, void** data, void** closure);

/**
* Remove the current item. If the queue is empty this method returns
* WOMBAT_QUEUE_END.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_remove (wombatQueue queue, void** data, void** closure);

/**
@@ -211,7 +211,7 @@ wombatQueue_remove (wombatQueue queue, void** data, void** closure);
* queue is empty the iterator is positioned so that next() returns the newly
* inserted item.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_insertAfter (wombatQueue queue,
wombatQueueCb cb,
void* data,
@@ -222,7 +222,7 @@ wombatQueue_insertAfter (wombatQueue queue,
* queue is empty the iterator is positioned so that prev() returns the newly
* inserted item.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_insertBefore (wombatQueue queue,
wombatQueueCb cb,
void* data,
@@ -233,7 +233,7 @@ wombatQueue_insertBefore (wombatQueue queue,
* positioned because the queue is empty or next() has not been called,
* it will return WOMBAT_QUEUE_END.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_replace (wombatQueue queue,
wombatQueueCb cb,
void* data,
@@ -242,13 +242,13 @@ wombatQueue_replace (wombatQueue queue,
/**
* Position the iterator so next() will return the first element.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_begin (wombatQueue queue);

/**
* Position the iterator so prev() will return the last element.
*/
-wombatQueueStatus
+COMMONExpDLL wombatQueueStatus
wombatQueue_end (wombatQueue queue);


--
1.7.7.6


[PATCH 21/30] Correct Method Signatures for Linking On Windows

Michael Schonberg <mschonberg@...>
 

Added wnanaosleep() and timegm() since Windows does not support these
calls. Also fixed up method signatures for linking on windows.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 3 ++-
mama/c_cpp/src/c/mama/subscriptiontype.h | 3 ++-
mama/c_cpp/src/c/statsgenerator.c | 2 +-
mama/c_cpp/src/c/statslogger.c | 4 ++--
mama/c_cpp/src/c/syncresponder.c | 4 ++--
mama/c_cpp/src/c/timezone.c | 28 ++++++++++++++--------------
6 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index fc80ed9..27cf055 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -163,8 +163,9 @@ int wsem_timedwait (wsem_t* sem, unsigned int ts);

#define wGetCurrentThreadId pthread_self

-/* time gm not available on Windows */
+/* timegm() and nanosleep not available on Windows */
#define wtimegm timegm
+#define wnanosleep nanosleep

/* net work utility functions */
const char* getIpAddress (void);
diff --git a/mama/c_cpp/src/c/mama/subscriptiontype.h b/mama/c_cpp/src/c/mama/subscriptiontype.h
index 8aa6a40..14e023d 100644
--- a/mama/c_cpp/src/c/mama/subscriptiontype.h
+++ b/mama/c_cpp/src/c/mama/subscriptiontype.h
@@ -22,6 +22,7 @@
#ifndef MAMA_SUBSC_TYPE_H__
#define MAMA_SUBSC_TYPE_H__

+#include "port.h"
/*
* This file provides subscription type information.
*/
@@ -43,7 +44,7 @@ typedef enum mamaSubscriptionType
MAMA_SUBSC_TYPE_SYMBOL_LIST_BOOK = 8
} mamaSubscriptionType;

-extern const char* MamaSubscTypeStr (mamaSubscriptionType subtype);
+MAMAExpDLL extern const char* MamaSubscTypeStr (mamaSubscriptionType subtype);

#if defined(__cplusplus)
}
diff --git a/mama/c_cpp/src/c/statsgenerator.c b/mama/c_cpp/src/c/statsgenerator.c
index 33ed10b..8e47268 100644
--- a/mama/c_cpp/src/c/statsgenerator.c
+++ b/mama/c_cpp/src/c/statsgenerator.c
@@ -222,7 +222,7 @@ mamaStatsGenerator_setLogStats (mamaStatsGenerator statsGenerator, int logStats)
return MAMA_STATUS_OK;
}

-static void
+static void MAMACALLTYPE
mamaStatsGenerator_onReportTimer (mamaTimer timer, void* closure)
{
mamaStatsGenerator statsgenerator = (mamaStatsGenerator)closure;
diff --git a/mama/c_cpp/src/c/statslogger.c b/mama/c_cpp/src/c/statslogger.c
index 82d3b19..9100f0b 100644
--- a/mama/c_cpp/src/c/statslogger.c
+++ b/mama/c_cpp/src/c/statslogger.c
@@ -123,7 +123,7 @@ void mamaStatsLoggerImpl_clearEventArray (
mamaStatsLoggerImpl* impl);


-static void
+static void MAMACALLTYPE
mamaStatsLoggerImpl_onReportTimer (
mamaTimer timer,
void* closure);
@@ -982,7 +982,7 @@ mama_status mamaStatsLoggerImpl_addEvent (
return MAMA_STATUS_OK;
}

-static void
+static void MAMACALLTYPE
mamaStatsLoggerImpl_onReportTimer (mamaTimer timer, void* closure)
{
mamaStatsLoggerImpl* impl = (mamaStatsLoggerImpl*) closure;
diff --git a/mama/c_cpp/src/c/syncresponder.c b/mama/c_cpp/src/c/syncresponder.c
index 850b136..b479611 100644
--- a/mama/c_cpp/src/c/syncresponder.c
+++ b/mama/c_cpp/src/c/syncresponder.c
@@ -37,7 +37,7 @@
*/
static void syncCommand_dtor (void *handle);

-static void
+static void MAMACALLTYPE
timerCB (mamaTimer timer, void *closure);

typedef struct
@@ -175,7 +175,7 @@ void syncCommand_dtor(void *handle)
impl->mTimer = NULL;
}

- free (impl->mTopics);
+ free ((void*)impl->mTopics);
free (impl->mTypes);

free (impl);
diff --git a/mama/c_cpp/src/c/timezone.c b/mama/c_cpp/src/c/timezone.c
index 932a48b..e086758 100644
--- a/mama/c_cpp/src/c/timezone.c
+++ b/mama/c_cpp/src/c/timezone.c
@@ -80,12 +80,12 @@ static long getNextId(void) { return ++sInstanceId; }
static int sThreadStarted = 0;

/* Mutex used in the check() method. */
-static wthread_mutex_t sCheck_mutex = PTHREAD_MUTEX_INITIALIZER;
+static wthread_static_mutex_t sCheck_mutex = WSTATIC_MUTEX_INITIALIZER;



/* Mutex used when accessing the vector. */
-static wthread_mutex_t sVector_mutex = PTHREAD_MUTEX_INITIALIZER;
+static wthread_static_mutex_t sVector_mutex = WSTATIC_MUTEX_INITIALIZER;


/*
@@ -121,13 +121,13 @@ mamaTimeZone_create (mamaTimeZone* timeZone)
mamaTimeZoneImpl* impl;
wList tzList;

- wthread_mutex_lock (&sVector_mutex);
+ wthread_static_mutex_lock (&sVector_mutex);

tzList = getTimeZones();
impl = list_allocate_element (tzList);
if (!impl)
{
- wthread_mutex_unlock (&sVector_mutex);
+ wthread_static_mutex_unlock (&sVector_mutex);
return MAMA_STATUS_NOMEM;
}
else
@@ -137,7 +137,7 @@ mamaTimeZone_create (mamaTimeZone* timeZone)
if (!sThreadStarted)
startThread();

- wthread_mutex_unlock (&sVector_mutex);
+ wthread_static_mutex_unlock (&sVector_mutex);

*timeZone = (mamaTimeZone)impl;
return MAMA_STATUS_OK;
@@ -187,11 +187,11 @@ mamaTimeZone_destroy (mamaTimeZone timeZone)
/* Remove from the list and free the memory. */
mamaTimeZoneImpl* impl = (mamaTimeZoneImpl*)timeZone;
wList tzList;
- wthread_mutex_lock (&sVector_mutex);
+ wthread_static_mutex_lock (&sVector_mutex);
tzList = getTimeZones();
list_remove_element (tzList, impl);
list_free_element (tzList, impl);
- wthread_mutex_unlock (&sVector_mutex);
+ wthread_static_mutex_unlock (&sVector_mutex);
return MAMA_STATUS_OK;
}
}
@@ -305,7 +305,7 @@ mamaTimeZone_check (mamaTimeZone timeZone)
/* get the mutex for the accessing thread stops other threads
* from calling this method at the same time as the TZ update
* thread. */
- wthread_mutex_lock (&sCheck_mutex);
+ wthread_static_mutex_lock (&sCheck_mutex);

/* Save the current value of TZ: */
tzSaved = environment_getVariable("TZ");
@@ -353,7 +353,7 @@ mamaTimeZone_check (mamaTimeZone timeZone)
impl->mOffset = difftime (gmClock, tzClock);

/* release the mutex on this method */
- wthread_mutex_unlock (&sCheck_mutex);
+ wthread_static_mutex_unlock (&sCheck_mutex);

return MAMA_STATUS_OK;
}
@@ -407,7 +407,7 @@ static void* updateTimeZones (void* ptr)

initialDelay.tv_sec = 10;
initialDelay.tv_nsec = 0;
- nanosleep (&initialDelay, NULL);
+ wnanosleep (&initialDelay, NULL);


/* It makes sense for this thread to continue running for the life
@@ -424,20 +424,20 @@ static void* updateTimeZones (void* ptr)
{
delay.tv_sec = 60;
delay.tv_nsec = 100;
- nanosleep(&delay,NULL);
+ wnanosleep(&delay,NULL);

continue;
}
- nanosleep(&delay,NULL);
+ wnanosleep(&delay,NULL);

/* Lock access to the list of timezones while we recheck. */
- wthread_mutex_lock (&sVector_mutex);
+ wthread_static_mutex_lock (&sVector_mutex);

timeZones = getTimeZones();

list_for_each (timeZones, checkTzIter, NULL);

- wthread_mutex_unlock (&sVector_mutex);
+ wthread_static_mutex_unlock (&sVector_mutex);
}

/* The return value is not applicable. */
--
1.7.7.6


[PATCH 20/30] Add wtimegm macro for poritning timegm

Michael Schonberg <mschonberg@...>
 

timegm() is not avaliable on windows so we need a macro to abstract the
method. The windows implementation is simple using mktime() and
temporarily setting the timezone to GMT.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 3 +++
mama/c_cpp/src/c/datetime.c | 2 +-
2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 86d6d2b..fc80ed9 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -163,6 +163,9 @@ int wsem_timedwait (wsem_t* sem, unsigned int ts);

#define wGetCurrentThreadId pthread_self

+/* time gm not available on Windows */
+#define wtimegm timegm
+
/* net work utility functions */
const char* getIpAddress (void);
const char* getHostName (void);
diff --git a/mama/c_cpp/src/c/datetime.c b/mama/c_cpp/src/c/datetime.c
index 3639fa6..1cb8cde 100644
--- a/mama/c_cpp/src/c/datetime.c
+++ b/mama/c_cpp/src/c/datetime.c
@@ -1653,7 +1653,7 @@ unsigned long makeTime (
timeInfo.tm_sec = sec;
timeInfo.tm_isdst = 0;

- return timegm (&timeInfo);
+ return wtimegm (&timeInfo);
}

void utcTm (
--
1.7.7.6


[PATCH 19/30] Moved wombat/wInterlocked.h to Linux directory

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

These inline asm functions are os depenent.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/configure.ac | 1 +
common/c_cpp/src/c/linux/wInterlocked.h | 142 ++++++++++++++++++++++++++++++
common/c_cpp/src/c/wombat/wInterlocked.h | 142 ------------------------------
3 files changed, 143 insertions(+), 142 deletions(-)
create mode 100644 common/c_cpp/src/c/linux/wInterlocked.h
delete mode 100644 common/c_cpp/src/c/wombat/wInterlocked.h

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index 115602e..ab991b4 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -47,6 +47,7 @@ AC_CANONICAL_BUILD()
AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
case $build_os in
linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h
+ src/c/wombat/wInterlocked.h:src/c/linux/wInterlocked.h
src/c/machine_port.c:src/c/linux/machine.c
src/c/platform.c:src/c/linux/platform.c
src/c/wSemaphore.c:src/c/linux/wSemaphore.c
diff --git a/common/c_cpp/src/c/linux/wInterlocked.h b/common/c_cpp/src/c/linux/wInterlocked.h
new file mode 100644
index 0000000..c128804
--- /dev/null
+++ b/common/c_cpp/src/c/linux/wInterlocked.h
@@ -0,0 +1,142 @@
+/* $Id: wInterlocked.h,v 1.1.2.6.8.3 2011/08/10 14:53:24 nicholasmarriott Exp $
+ *
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _WOMBAT_WINTERLOCKED_H
+#define _WOMBAT_WINTERLOCKED_H
+
+/*
+ * This file contains a set of interlock functions for atomic access on scalar
+ * variables.
+ */
+
+#include "wCommon.h"
+
+/* *************************************************** */
+/* Linux implementation. */
+/* *************************************************** */
+
+/* 32-bit atomic exchange. Returns previous value. */
+static __inline__ uint32_t
+axchg32 (uint32_t* ptr, uint32_t newVal)
+{
+ __asm__ volatile ("xchgl %k0, %1"
+ : "=r" (newVal)
+ : "m" (*ptr), "0" (newVal)
+ : "memory");
+ return newVal;
+}
+
+/* 32-bit atomic increment. */
+static __inline__ void
+ainc32 (uint32_t* ptr)
+{
+ __asm__ volatile ("lock; incl %0"
+ : "=m" (*ptr)
+ : "m" (*ptr));
+}
+
+/* 32-bit atomic decrement. */
+static __inline__ void
+adec32 (uint32_t* ptr)
+{
+ __asm__ volatile ("lock; decl %0"
+ : "=m" (*ptr)
+ : "m" (*ptr));
+}
+
+/* *************************************************** */
+/* Type Defines. */
+/* *************************************************** */
+/* The structure on linux. */
+typedef uint32_t wInterlockedInt;
+
+/**
+ * This function will initialise a wInterlockedInt.
+ *
+ * @param[in] value Pointer to the item to be initialized.
+ * @return 0 on success.
+ */
+
+WCOMMONINLINE int wInterlocked_initialize(wInterlockedInt *value)
+{
+ return 0;
+}
+
+/**
+ * This function will destroy a wInterlockedInt.
+ *
+ * @param[in] value Pointer to the item to be destroyed.
+ * @return 0 on success.
+ */
+WCOMMONINLINE int wInterlocked_destroy(wInterlockedInt *value)
+{
+ return 0;
+}
+
+/**
+ * This function will atomically decrement a 32-bit integer value.
+ *
+ * @param[in] value Pointer to the value to be decremented.
+ * @return The decremented integer.
+ */
+WCOMMONINLINE int wInterlocked_decrement(wInterlockedInt *value)
+{
+ adec32(value);
+ return (int)*value;
+}
+
+/**
+ * This function will atomically increment a 32-bit integer value.
+ *
+ * @param[in] value Pointer to the value to be incremented.
+ * @return The incremented integer.
+ */
+WCOMMONINLINE int wInterlocked_increment(wInterlockedInt *value)
+{
+ ainc32(value);
+ return (int)*value;
+}
+
+/**
+ * This function will return the value of the interlocked variable.
+ *
+ * @param[in] value Pointer to the value to be read.
+ * @return The value itself.
+ */
+WCOMMONINLINE int wInterlocked_read(wInterlockedInt *value)
+{
+ return (int)*value;
+}
+
+/**
+ * This function will atomically set a 32-bit integer value.
+ *
+ * @param[in] newValue The new value to set.
+ * @param[in] value Pointer to the value to be set.
+ * @return The updated integer.
+ */
+WCOMMONINLINE int wInterlocked_set(int newValue, wInterlockedInt *value)
+{
+ axchg32(value, (uint32_t)newValue);
+ return (int)*value;
+}
+
+#endif /* _WOMBAT_WINTERLOCKED_H */
diff --git a/common/c_cpp/src/c/wombat/wInterlocked.h b/common/c_cpp/src/c/wombat/wInterlocked.h
deleted file mode 100644
index c128804..0000000
--- a/common/c_cpp/src/c/wombat/wInterlocked.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* $Id: wInterlocked.h,v 1.1.2.6.8.3 2011/08/10 14:53:24 nicholasmarriott Exp $
- *
- * OpenMAMA: The open middleware agnostic messaging API
- * Copyright (C) 2011 NYSE Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#ifndef _WOMBAT_WINTERLOCKED_H
-#define _WOMBAT_WINTERLOCKED_H
-
-/*
- * This file contains a set of interlock functions for atomic access on scalar
- * variables.
- */
-
-#include "wCommon.h"
-
-/* *************************************************** */
-/* Linux implementation. */
-/* *************************************************** */
-
-/* 32-bit atomic exchange. Returns previous value. */
-static __inline__ uint32_t
-axchg32 (uint32_t* ptr, uint32_t newVal)
-{
- __asm__ volatile ("xchgl %k0, %1"
- : "=r" (newVal)
- : "m" (*ptr), "0" (newVal)
- : "memory");
- return newVal;
-}
-
-/* 32-bit atomic increment. */
-static __inline__ void
-ainc32 (uint32_t* ptr)
-{
- __asm__ volatile ("lock; incl %0"
- : "=m" (*ptr)
- : "m" (*ptr));
-}
-
-/* 32-bit atomic decrement. */
-static __inline__ void
-adec32 (uint32_t* ptr)
-{
- __asm__ volatile ("lock; decl %0"
- : "=m" (*ptr)
- : "m" (*ptr));
-}
-
-/* *************************************************** */
-/* Type Defines. */
-/* *************************************************** */
-/* The structure on linux. */
-typedef uint32_t wInterlockedInt;
-
-/**
- * This function will initialise a wInterlockedInt.
- *
- * @param[in] value Pointer to the item to be initialized.
- * @return 0 on success.
- */
-
-WCOMMONINLINE int wInterlocked_initialize(wInterlockedInt *value)
-{
- return 0;
-}
-
-/**
- * This function will destroy a wInterlockedInt.
- *
- * @param[in] value Pointer to the item to be destroyed.
- * @return 0 on success.
- */
-WCOMMONINLINE int wInterlocked_destroy(wInterlockedInt *value)
-{
- return 0;
-}
-
-/**
- * This function will atomically decrement a 32-bit integer value.
- *
- * @param[in] value Pointer to the value to be decremented.
- * @return The decremented integer.
- */
-WCOMMONINLINE int wInterlocked_decrement(wInterlockedInt *value)
-{
- adec32(value);
- return (int)*value;
-}
-
-/**
- * This function will atomically increment a 32-bit integer value.
- *
- * @param[in] value Pointer to the value to be incremented.
- * @return The incremented integer.
- */
-WCOMMONINLINE int wInterlocked_increment(wInterlockedInt *value)
-{
- ainc32(value);
- return (int)*value;
-}
-
-/**
- * This function will return the value of the interlocked variable.
- *
- * @param[in] value Pointer to the value to be read.
- * @return The value itself.
- */
-WCOMMONINLINE int wInterlocked_read(wInterlockedInt *value)
-{
- return (int)*value;
-}
-
-/**
- * This function will atomically set a 32-bit integer value.
- *
- * @param[in] newValue The new value to set.
- * @param[in] value Pointer to the value to be set.
- * @return The updated integer.
- */
-WCOMMONINLINE int wInterlocked_set(int newValue, wInterlockedInt *value)
-{
- axchg32(value, (uint32_t)newValue);
- return (int)*value;
-}
-
-#endif /* _WOMBAT_WINTERLOCKED_H */
--
1.7.7.6


[PATCH 18/30] mama.c changes for windows support

Michael Schonberg <mschonberg@...>
 

Converted pthread_xxx calls to wthread_xxx. Use getLogin(),
getIpAddress(), and getHostName() from common for os dependent
implemnatons of these functions.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
mama/c_cpp/src/c/mama.c | 148 +++++++++++++++++------------------------------
1 files changed, 53 insertions(+), 95 deletions(-)

diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c
index 9ac45b4..3891b39 100644
--- a/mama/c_cpp/src/c/mama.c
+++ b/mama/c_cpp/src/c/mama.c
@@ -109,13 +109,8 @@ int gPublishGlobalStats = 0;
int gPublishLbmStats = 0;
int gCatchCallbackExceptions = 0;

-static char gIPAddress[16];
-static const char* gUserName = NULL;
-static const char* gHostName = NULL;
-
static void lookupIPAddress (void);

-
wproperty_t gProperties = 0;
static mamaStatsLogger gStatsPublisher = NULL;

@@ -136,7 +131,7 @@ mamaStat gRvMsgsStat;

static mamaPayloadBridge gDefaultPayload = NULL;

-static pthread_key_t last_err_key;
+static wthread_key_t last_err_key;

/**
* struct mamaApplicationGroup
@@ -157,18 +152,18 @@ typedef struct mamaAppContext_
*/
typedef struct mamaImpl_
{
- mamaBridge myBridges[MAMA_MIDDLEWARE_MAX];
- mamaPayloadBridge myPayloads[MAMA_PAYLOAD_MAX];
- LIB_HANDLE myBridgeLibraries[MAMA_MIDDLEWARE_MAX];
- LIB_HANDLE myPayloadLibraries[MAMA_PAYLOAD_MAX];
- unsigned int myRefCount;
- pthread_mutex_t myLock;
+ mamaBridge myBridges[MAMA_MIDDLEWARE_MAX];
+ mamaPayloadBridge myPayloads[MAMA_PAYLOAD_MAX];
+ LIB_HANDLE myBridgeLibraries[MAMA_MIDDLEWARE_MAX];
+ LIB_HANDLE myPayloadLibraries[MAMA_PAYLOAD_MAX];
+ unsigned int myRefCount;
+ wthread_static_mutex_t myLock;
} mamaImpl;

static mamaApplicationContext appContext;
static char mama_ver_string[256];

-static mamaImpl gImpl = {{0}, {0}, {0}, {0}, 0, PTHREAD_MUTEX_INITIALIZER};
+static mamaImpl gImpl = {{0}, {0}, {0}, {0}, 0, WSTATIC_MUTEX_INITIALIZER};

/* ************************************************************************* */
/* Private Function Prototypes. */
@@ -378,11 +373,10 @@ mamaInternal_createStatsPublisher ()
return result;

mama_getUserName (&userName);
- lookupIPAddress();
mamaStatsLogger_setReportSize (gStatsPublisher, 100);
mamaStatsLogger_setUserName (gStatsPublisher, userName);
- mamaStatsLogger_setIpAddress (gStatsPublisher, gIPAddress);
- mamaStatsLogger_setHostName (gStatsPublisher, gHostName);
+ mamaStatsLogger_setIpAddress (gStatsPublisher, getIpAddress());
+ mamaStatsLogger_setHostName (gStatsPublisher, getHostName());
mamaStatsLogger_setApplicationName (gStatsPublisher,
appContext.myApplicationName);
mamaStatsLogger_setApplicationClass (gStatsPublisher,
@@ -651,9 +645,9 @@ mama_openWithPropertiesCount (const char* path,
const char* statsLogging = "false";
const char* catchCallbackExceptions = NULL;

- pthread_mutex_lock (&gImpl.myLock);
+ wthread_static_mutex_lock (&gImpl.myLock);

- if (pthread_key_create(&last_err_key, NULL) != 0)
+ if (wthread_key_create(&last_err_key, NULL) != 0)
{
mama_log (MAMA_LOG_LEVEL_NORMAL, "WARNING!!! - CANNOT ALLOCATE KEY FOR ERRORS");
}
@@ -696,7 +690,7 @@ mama_openWithPropertiesCount (const char* path,
if (count)
*count = gImpl.myRefCount;

- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}
/* Code after this point is one-time initialization */
@@ -721,7 +715,6 @@ mama_openWithPropertiesCount (const char* path,

mamaInternal_loadProperties (path, filename);

- lookupIPAddress();
initReservedFields();
mama_loginit();

@@ -761,7 +754,7 @@ mama_openWithPropertiesCount (const char* path,
if (count)
*count = gImpl.myRefCount;

- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}

@@ -881,7 +874,7 @@ mama_openWithPropertiesCount (const char* path,
if (count)
*count = gImpl.myRefCount;

- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -893,7 +886,7 @@ mama_openWithPropertiesCount (const char* path,
if (count)
*count = gImpl.myRefCount;

- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -910,7 +903,7 @@ mama_openWithPropertiesCount (const char* path,
mama_log (MAMA_LOG_LEVEL_SEVERE,
"mama_openWithProperties(): "
"Error connecting to Entitlements Server");
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
mama_close();

if (count)
@@ -954,7 +947,7 @@ mama_openWithPropertiesCount (const char* path,
{
if (count)
*count = gImpl.myRefCount;
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}
}
@@ -966,7 +959,7 @@ mama_openWithPropertiesCount (const char* path,
"Could not set queue for stats generator.");
if (count)
*count = gImpl.myRefCount;
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}

@@ -977,7 +970,7 @@ mama_openWithPropertiesCount (const char* path,
"Failed to enable stats logging");
if (count)
*count = gImpl.myRefCount;
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}
}
@@ -985,7 +978,7 @@ mama_openWithPropertiesCount (const char* path,
gImpl.myRefCount++;
if (count)
*count = gImpl.myRefCount;
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}

@@ -1114,12 +1107,12 @@ mama_closeCount (unsigned int* count)
mamaMiddleware middleware = 0;
int payload = 0;

- pthread_mutex_lock (&gImpl.myLock);
+ wthread_static_mutex_lock (&gImpl.myLock);
if (gImpl.myRefCount == 0)
{
if (count)
*count = gImpl.myRefCount;
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_OK;
}

@@ -1133,7 +1126,7 @@ mama_closeCount (unsigned int* count)
}
#endif /* WITH_ENTITLEMENTS */

- pthread_key_delete(last_err_key);
+ wthread_key_delete(last_err_key);

for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)
{
@@ -1234,9 +1227,6 @@ mama_closeCount (unsigned int* count)

cleanupReservedFields();

- if (gHostName)
- free ((void*)gHostName);
-
/* Look for a bridge for each of the middlewares and close them */
for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)
{
@@ -1281,7 +1271,7 @@ mama_closeCount (unsigned int* count)
}
if (count)
*count = gImpl.myRefCount;
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}

@@ -1315,9 +1305,9 @@ mama_start (mamaBridge bridgeImpl)
return MAMA_STATUS_INVALID_QUEUE;
}

- pthread_mutex_lock(&gImpl.myLock);
+ wthread_static_mutex_lock(&gImpl.myLock);
prevRefCnt = impl->mRefCount++;
- pthread_mutex_unlock(&gImpl.myLock);
+ wthread_static_mutex_unlock(&gImpl.myLock);

if (prevRefCnt > 0)
return MAMA_STATUS_OK;
@@ -1328,9 +1318,9 @@ mama_start (mamaBridge bridgeImpl)

if (rval != MAMA_STATUS_OK)
{
- pthread_mutex_lock(&gImpl.myLock);
+ wthread_static_mutex_lock(&gImpl.myLock);
impl->mRefCount--;
- pthread_mutex_unlock(&gImpl.myLock);
+ wthread_static_mutex_unlock(&gImpl.myLock);
}

return rval;
@@ -1425,7 +1415,7 @@ mama_stop (mamaBridge bridgeImpl)
}

/*Delegate to the bridge specific implementation*/
- pthread_mutex_lock(&gImpl.myLock);
+ wthread_static_mutex_lock(&gImpl.myLock);
if (impl->mRefCount > 0)
{
impl->mRefCount--;
@@ -1436,7 +1426,7 @@ mama_stop (mamaBridge bridgeImpl)
impl->mRefCount++;
}
}
- pthread_mutex_unlock(&gImpl.myLock);
+ wthread_static_mutex_unlock(&gImpl.myLock);
return rval;
}

@@ -1499,12 +1489,7 @@ mama_getUserName (const char** userName)
if (userName == NULL)
return MAMA_STATUS_NULL_ARG;

- if (!gUserName)
- {
- gUserName = strdup (getpwuid(getuid())->pw_name);
- }
-
- *userName = gUserName;
+ *userName = getlogin();
return MAMA_STATUS_OK;
}

@@ -1512,7 +1497,7 @@ mama_status
mama_getHostName (const char** hostName)
{
if (hostName == NULL) return MAMA_STATUS_NULL_ARG;
- *hostName = gHostName;
+ *hostName = getHostName();
return MAMA_STATUS_OK;
}

@@ -1520,37 +1505,10 @@ mama_status
mama_getIpAddress (const char** ipAddress)
{
if (ipAddress == NULL) return MAMA_STATUS_NULL_ARG;
- *ipAddress = gIPAddress;
+ *ipAddress = getIpAddress();
return MAMA_STATUS_OK;
}

-static void
-lookupIPAddress (void)
-{
- struct hostent *host = NULL;
- char *addrStr = "not determined";
-
- struct utsname uts;
- memset( gIPAddress, 0, 16 );
- uname (&uts);
- gHostName = strdup (uts.nodename);
-
- host = gethostbyname( gHostName );
-
- if( gHostName == NULL ||
- host == NULL ||
- host->h_addr_list[0] == NULL )
- {
- strncpy( (char *)gIPAddress, "not determined", sizeof( gIPAddress ) );
- }
- else
- {
- addrStr = inet_ntoa( *((struct in_addr *)( host->h_addr_list[0] )));
- }
-
- strncpy ((char*)gIPAddress, addrStr, sizeof (gIPAddress));
-}
-
#ifdef WITH_ENTITLEMENTS

mama_status
@@ -1800,10 +1758,10 @@ mamaInternal_registerBridge (mamaBridge bridge,
return;
}

- pthread_mutex_lock (&gImpl.myLock);
+ wthread_static_mutex_lock (&gImpl.myLock);
gImpl.myBridges[middleware] = bridge;
((mamaBridgeImpl*)(bridge))->mRefCount = 0;
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
}

mama_status
@@ -1836,7 +1794,7 @@ mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
payloadName);

if (lock)
- pthread_mutex_lock (&gImpl.myLock);
+ wthread_static_mutex_lock (&gImpl.myLock);

bridgeLib = openSharedLib (bridgeImplName, NULL);

@@ -1849,7 +1807,7 @@ mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
bridgeImplName ? bridgeImplName : "",
getLibError());
if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -1868,7 +1826,7 @@ mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
closeSharedLib (bridgeLib);

if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);

return MAMA_STATUS_NO_BRIDGE_IMPL;
}
@@ -1876,7 +1834,7 @@ mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
if (MAMA_STATUS_OK != (status = initFunc (impl, &payloadChar)))
{
if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);

return status;
}
@@ -1887,7 +1845,7 @@ mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
"mama_loadPayloadBridge(): Error in [%s] ", initFuncName);

if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);

return MAMA_STATUS_NO_BRIDGE_IMPL;
}
@@ -1900,7 +1858,7 @@ mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
payloadName);

if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);

return MAMA_STATUS_OK;
}
@@ -1919,7 +1877,7 @@ mama_loadPayloadBridgeInternal (mamaPayloadBridge* impl,
payloadName, bridgeImplName);

if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);

return MAMA_STATUS_OK;
}
@@ -1973,14 +1931,14 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,
}

if (lock)
- pthread_mutex_lock (&gImpl.myLock);
+ wthread_static_mutex_lock (&gImpl.myLock);

/* Check if a bridge has already been initialized for the middleware */
if (gImpl.myBridges [middleware])
{
*impl = gImpl.myBridges [middleware];
if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_OK;
}

@@ -2009,7 +1967,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,
getLibError());
}
if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -2027,7 +1985,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,
bridgeImplName ? bridgeImplName : "");
closeSharedLib (bridgeLib);
if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -2038,7 +1996,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,
mama_log (MAMA_LOG_LEVEL_ERROR,
"mama_loadBridge(): Error in [%s] ", initFuncName);
if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

@@ -2053,7 +2011,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,
if (MAMA_STATUS_OK != result)
{
if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return result;
}

@@ -2070,7 +2028,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,
gImpl.myBridgeLibraries [middleware] = bridgeLib;

if (lock)
- pthread_mutex_unlock (&gImpl.myLock);
+ wthread_static_mutex_unlock (&gImpl.myLock);
return MAMA_STATUS_OK;
}

@@ -2121,19 +2079,19 @@ mama_wrapperGetVersion(mamaBridge bridge)
void
mama_setLastError (mamaError error)
{
- pthread_setspecific(last_err_key, (void*)error);
+ wthread_setspecific(last_err_key, (void*)error);
}

mamaError
mama_getLastErrorCode (void)
{
- return (mamaError)pthread_getspecific(last_err_key);
+ return (mamaError)wthread_getspecific(last_err_key);
}

const char*
mama_getLastErrorText (void)
{
- return mamaError_convertToString((mamaError)pthread_getspecific(last_err_key));
+ return mamaError_convertToString((mamaError)wthread_getspecific(last_err_key));
}


--
1.7.7.6


[PATCH 17/30] Added getHostName and getIpAddress.

Michael Schonberg <mschonberg@...>
 

Added to linux/port.h and linux/network.c for windows support. The API
calls to determine the hostname and ip address are os specific.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/network.c | 46 ++++++++++++++++++++++++++++++++++++
common/c_cpp/src/c/linux/port.h | 4 +++
2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/common/c_cpp/src/c/linux/network.c b/common/c_cpp/src/c/linux/network.c
index f5923d9..75e5658 100644
--- a/common/c_cpp/src/c/linux/network.c
+++ b/common/c_cpp/src/c/linux/network.c
@@ -19,6 +19,9 @@
* 02110-1301 USA
*/

+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
#include "wombat/wCommon.h"


@@ -147,3 +150,46 @@ struct in_addr resolve_ip (const char * arg)
}
return (resolved);
}
+
+static const char gIPAddress[16];
+static const char* gHostName = NULL;
+
+static void lookupIPAddress (void)
+{
+ struct hostent *host = NULL;
+ char *addrStr = "not determined";
+
+ struct utsname uts;
+ memset( gIPAddress, 0, 16 );
+ uname (&uts);
+ gHostName = strdup (uts.nodename);
+
+ host = gethostbyname( gHostName );
+
+ if( gHostName == NULL ||
+ host == NULL ||
+ host->h_addr_list[0] == NULL )
+ {
+ strncpy( (char *)gIPAddress, "not determined", sizeof( gIPAddress ) );
+ }
+ else
+ {
+ addrStr = inet_ntoa( *((struct in_addr *)( host->h_addr_list[0] )));
+ }
+
+ strncpy ((char*)gIPAddress, addrStr, sizeof (gIPAddress));
+}
+
+const char* getIpAddress(void)
+{
+ if (NULL == gHostName)
+ lookupIPAddress();
+ return gIPAddress;
+}
+
+const char* getHostName(void)
+{
+ if (NULL == gHostName)
+ lookupIPAddress();
+ return gHostName;
+}
diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index e289006..86d6d2b 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -163,6 +163,10 @@ int wsem_timedwait (wsem_t* sem, unsigned int ts);

#define wGetCurrentThreadId pthread_self

+/* net work utility functions */
+const char* getIpAddress (void);
+const char* getHostName (void);
+
#if defined (__cplusplus)
} /* extern "c" */
#endif
--
1.7.7.6


[PATCH 16/30] Added Thread Local Storage

Michael Schonberg <mschonberg@...>
 

In preparation for windows support macros for pthread style thread local
storage added to linux/port.h

wthread_key_create
wthread_key_delete
wthread_getspecific
wthread_setspecific
These map directly to the same pthread_xxx methods for linux, but they
are implemented with TlsAlloc(), etc for windows.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 86d2e50..e289006 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -100,6 +100,13 @@ typedef long long int w_i64_t;

#define PATHSEP "/"

+/* Thread local storage */
+typedef pthread_key_t wthread_key_t;
+#define wthread_key_create(x, val) pthread_key_create((x), (val))
+#define wthread_key_delete(x) pthread_key_delete((x))
+#define wthread_setspecific(x, val) pthread_setspecific((x),(void*)((val)))
+#define wthread_getspecific(x) pthread_getspecific((x))
+
/* Use Posix semaphores for Linux */
#define wsem_t sem_t
#define wsem_init sem_init
--
1.7.7.6