Date   

[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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 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@nyx.com>
---
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 00/50] Final Sync from NYSE Technologies

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

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 01/50] Ownership of message buffers

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

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@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
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 02/50] c linkage for wlock_xxx() methods

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

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

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
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 03/50] Fix timer implementation for Windows

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

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@nyx.com>
---
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 04/50] Added WCACHEExpDLL macro for building NYSE wirecache

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

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@nyx.com>
---
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 05/50] Make includes paths consistent

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

wConfig.h and port.h should be included as wombat/xxx.h. This simplifies the
builds and makes the consistent across Windows and Linux.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
common/c_cpp/src/c/windows/machine_win.c | 2 +-
common/c_cpp/src/c/windows/platform.c | 2 +-
common/c_cpp/src/c/windows/port.h | 7 ++++---
common/c_cpp/src/c/windows/wSemaphore.c | 2 +-
common/c_cpp/src/c/wombat/environment.h | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/common/c_cpp/src/c/windows/machine_win.c b/common/c_cpp/src/c/windows/machine_win.c
index f6f3ad5..3fce1cd 100644
--- a/common/c_cpp/src/c/windows/machine_win.c
+++ b/common/c_cpp/src/c/windows/machine_win.c
@@ -18,7 +18,7 @@
* 02110-1301 USA
*/

-#include "port.h"
+#include "wombat/port.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/common/c_cpp/src/c/windows/platform.c b/common/c_cpp/src/c/windows/platform.c
index f17e1f9..8b89525 100644
--- a/common/c_cpp/src/c/windows/platform.c
+++ b/common/c_cpp/src/c/windows/platform.c
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include "port.h"
+#include "wombat/port.h"
#include "platform.h"

#define PATH_SEPERATOR "\\"
diff --git a/common/c_cpp/src/c/windows/port.h b/common/c_cpp/src/c/windows/port.h
index df06b4f..ded944a 100644
--- a/common/c_cpp/src/c/windows/port.h
+++ b/common/c_cpp/src/c/windows/port.h
@@ -37,9 +37,10 @@
#include <tlhelp32.h>
#include <time.h>

-#include "wConfig.h"
-#include "lock.h"
-#include "mmap.h"
+#include "wombat/targetsxs.h"
+#include "wombat/wConfig.h"
+#include "windows/lock.h"
+#include "windows/mmap.h"

#if defined(__cplusplus)
extern "C" {
diff --git a/common/c_cpp/src/c/windows/wSemaphore.c b/common/c_cpp/src/c/windows/wSemaphore.c
index 6947ac4..f3dd8a6 100644
--- a/common/c_cpp/src/c/windows/wSemaphore.c
+++ b/common/c_cpp/src/c/windows/wSemaphore.c
@@ -18,7 +18,7 @@
* 02110-1301 USA
*/

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

#include "wombat/wSemaphore.h"

diff --git a/common/c_cpp/src/c/wombat/environment.h b/common/c_cpp/src/c/wombat/environment.h
index 8acafe5..98c8974 100644
--- a/common/c_cpp/src/c/wombat/environment.h
+++ b/common/c_cpp/src/c/wombat/environment.h
@@ -22,7 +22,7 @@
#ifndef _WOMBAT_ENVIRONMENT_H
#define _WOMBAT_ENVIRONMENT_H

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

/**
* This function will delete an environment varible.
--
1.7.7.6


[PATCH 06/50] Adding new files for C++ and Windows Support

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

These files include support for uuid's required by avis for request reply. Also
adding wMessageStats for C++ and MAMDA.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
common/c_cpp/configure.ac | 6 +-
common/c_cpp/src/c/Makefile.am | 7 +-
common/c_cpp/src/c/linux/wMath.h | 32 +
common/c_cpp/src/c/linux/wUuid.h | 14 +
common/c_cpp/src/c/wMessageStats.c | 1001 +++++++++++++++++++++++++++++
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/wombat/wMessageStats.h | 190 ++++++
8 files changed, 1311 insertions(+), 4 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
create mode 100644 common/c_cpp/src/c/windows/wombat/wMath.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wUuid.h
create mode 100644 common/c_cpp/src/c/wombat/wMessageStats.h

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index e288769..aed5043 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -25,9 +25,9 @@
# VERSION INFO
#
#################################################
-m4_define([product_version_major], [4])
+m4_define([product_version_major], [6])
m4_define([product_version_minor], [0])
-m4_define([product_version_release], [4a])
+m4_define([product_version_release], [0rc15])
m4_define([product_full_version],[product_version_major.product_version_minor.product_version_release])


@@ -47,6 +47,8 @@ AC_CANONICAL_BUILD()
AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
case $build_os in
linux*-*) AC_CONFIG_LINKS([$srcdir/src/c/wombat/port.h:src/c/linux/port.h
+ $srcdir/src/c/wombat/wMath.h:src/c/linux/wMath.h
+ $srcdir/src/c/wombat/wUuid.h:src/c/linux/wUuid.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
diff --git a/common/c_cpp/src/c/Makefile.am b/common/c_cpp/src/c/Makefile.am
index 9a42259..ee0c640 100644
--- a/common/c_cpp/src/c/Makefile.am
+++ b/common/c_cpp/src/c/Makefile.am
@@ -49,13 +49,15 @@ nobase_include_HEADERS = \
wombat/wInterlocked.h \
wombat/wSemaphore.h \
wombat/wincompat.h \
- wombat/wtable.h
+ wombat/wMessageStats.h \
+ wombat/wtable.h \
+ wombat/wUuid.h

if USE_GCC_FLAGS
CPPFLAGS += -pedantic -Wno-long-long -D_GNU_SOURCE -fPIC
endif

-LIBS += -ldl
+LIBS += -ldl -luuid

libwombatcommon_la_SOURCES = \
MRSWLock.c \
@@ -75,4 +77,5 @@ libwombatcommon_la_SOURCES = \
strutils.c \
wSemaphore.c \
wlock.c \
+ wMessageStats.c \
wtable.c
diff --git a/common/c_cpp/src/c/linux/wMath.h b/common/c_cpp/src/c/linux/wMath.h
new file mode 100644
index 0000000..bf2bdcf
--- /dev/null
+++ b/common/c_cpp/src/c/linux/wMath.h
@@ -0,0 +1,32 @@
+/* $Id: wMath.h,v 1.1.2.2 2012/03/20 11:15:17 emmapollock 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 WMATH_H__
+#define WMATH_H__
+
+#include <math.h>
+
+const int wIsnan (double n)
+{
+ return isnan(n);
+}
+
+#endif /* WMATH_H__ */
diff --git a/common/c_cpp/src/c/linux/wUuid.h b/common/c_cpp/src/c/linux/wUuid.h
new file mode 100644
index 0000000..608eee7
--- /dev/null
+++ b/common/c_cpp/src/c/linux/wUuid.h
@@ -0,0 +1,14 @@
+
+
+#ifndef WUUID_H__
+#define WUUID_H__
+
+#include <uuid/uuid.h>
+
+typedef uuid_t wUuid;
+
+#define wUuid_generate_time uuid_generate_time
+
+#define wUuid_unparse uuid_unparse
+
+#endif /* WUUID_H__ */
diff --git a/common/c_cpp/src/c/wMessageStats.c b/common/c_cpp/src/c/wMessageStats.c
new file mode 100644
index 0000000..5ae85ce
--- /dev/null
+++ b/common/c_cpp/src/c/wMessageStats.c
@@ -0,0 +1,1001 @@
+
+#include "wombat/machine.h"
+#include "wombat/wMessageStats.h"
+#include "wombat/wtable.h"
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/stat.h>
+#include <time.h>
+
+#ifndef WIN32
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+#ifndef VMS
+#ifndef __APPLE__
+#include <sys/vfs.h>
+#endif
+#endif
+#include <sys/times.h>
+#endif
+
+#ifdef WIN32
+/*#include "wombat/strptime.h"*/
+typedef struct tms {
+ long tms_utime;
+ long tms_stime;
+ long tms_cutime;
+ long tms_cstime;
+}tms;
+
+#endif
+
+
+#define MAX_SYMBOL_LENGTH 256
+#define MILLISECONDS_IN_HOUR (60*60*1000)
+#define SECONDSINHOUR 60
+
+const char* opHeaderPeriod = \
+ " Symbol Name ," \
+ "Elapsed Time ," \
+ "Msg Count," \
+ "Msg / sec," \
+ "KiloBytes," \
+ "KB / sec," \
+ "Min Lat ms," \
+ "Max Lat ms," \
+ "Ave Lat ms," \
+ "Std Deviation,\n";
+
+const char* opHeaderAcrossAll = \
+ "Msg Count," \
+ "Min Msg/sec," \
+ "Max Msg/sec," \
+ "Ave Msg/sec," \
+ "KiloBytes," \
+ "KB / sec," \
+ "Min Lat ms," \
+ "Max Lat ms," \
+ "Ave Lat ms, " \
+ "Std Dev,\n";
+
+const char* gStatsLevel1Header=\
+ " Global Count,Total Time,Interval,CPU utime,CPU stime, CPU% , Ave CPU% ," \
+ " Memory , Memory% ,\n";
+
+typedef struct statsCache_t
+{
+ perfData* mPData;
+ wtable_t mSymbolTable;
+ int mNumMsg;
+ int mHeader;
+ FILE* mOutfile;
+ long mNumMessages;
+ long mNumBytes;
+ double mLastUpdateTime;/* time in seconds of last update*/
+}statsCache_t;
+
+typedef struct perfData_t
+{
+ double mMinLatencyP; /* min latency for this capture PERIOD*/
+ double mMaxLatencyP; /* max latency for this capture PERIOD */
+ double mAveLatencyP; /* average latency for this capture PERIOD*/
+ double mMinLatencyA; /* min latency across ALL capture periods*/
+ double mMaxLatencyA; /* max latency across ALL capture periods*/
+ double mAveLatencyA; /* average latency across ALL capture periods*/
+
+ /* Separate message counter for latency in case
+ some message don't have latency timestamps
+ or cannto be parsed */
+
+ double mLatAccumP; /* latency accumlation for PERIOD*/
+ long mLatMsgCountP; /* latency message count for PERIOD*/
+ double mLatAccumA; /* latency accumlation ALL capture periods*/
+ long mLatMsgCountA; /* latency message across ALL capture periods*/
+
+ long mMsgCountP; /* rolling message count for this capture PERIOD*/
+ double mMsgPerSecP; /* average message rate for this capture PERIOD*/
+ long mMsgCountA; /* total message count ALL capture periods*/
+ double mMaxMsgPerSecA; /* max average message rate ALL capture periods*/
+ double mMinMsgPerSecA; /* min average message rate ALL capture periods*/
+ double mAveMsgPerSecA; /* average message rate ALL capture periods*/
+
+ double mByteCountP; /* rolling byte count for this capture PERIOD*/
+ double mBytePerSecP; /* average byte rate for this capture PERIOD*/
+ double mByteCountA; /* total byte count across ALL capture periods*/
+ double mMaxBytePerSecA; /* max ave message byte rate ALL capture periods*/
+ double mAveBytePerSecA; /* average message byte rate ALL capture periods*/
+
+ double mLastTime; /* this capture period*/
+ double mTotalTime; /* period since creation*/
+
+ /* Counters are used to collect stats to calculate standard deviation */
+ double mLatSquareP; /* latency squared PERIOD */
+ double mLatSquareA; /* latency squared ALL */
+ double mStdDeviationP; /* standard deviation values for capture PERIOD*/
+ double mStdDeviationA; /* standard deviation values for ALL periods */
+
+ FILE* mOutfile;
+ char mSymbol[MAX_SYMBOL_LENGTH];
+
+}perfData_t;
+
+/*Variables for testing latency stats*/
+long gCount = 0;
+double gMilliSecAdded = 0;
+double gStartTime = 0;
+double gLastTime = 0;
+double gTotalTime = 0;
+double gTotalTimeCalc = 0;
+double gTotalLatency = 0;
+double gLatencyPerThousand = 0;
+/*Variables for measuring cpu time*/
+double gCpuClockTicksPerSecond;
+
+struct cpuVals gLastCpuV={0.0,0.0,0.0,0.0};
+double gStartRealTime = 0;
+struct tms gStartProcTime;
+/*struct tms gCpuStartTime;
+struct tms gCpuEndTime;
+double gCpuStartTimeSeconds = 0;
+double gCpuEndTimeSeconds = 0;
+clock_t gProcStartTime= 0;
+struct timeval gProcessStart={0,0};*/
+
+static int gNumCpu=1;
+
+/*struct tms myAppStartClock;
+struct tms myAppEndClock;
+clock_t myGlobalStartClock;
+clock_t myGlobalEndClock;*/
+double gTotalPercent=0;
+double gRealTime = 0.0;
+
+/*internal function prototypes */
+
+/* Routines for calculating and printing performance data for each period */
+static void processWTableData (wtable_t table, void* data, const char* key, void* closure);
+static int printPerfData(perfData* pData,int headerFlag);
+static void calcPerfData(perfData* mPData,double interval,
+ performanceData* myPerformanceData);
+static void perfDataReportHeader(FILE* outfile);
+extern void getMemVals(int pid, memVals *memV);
+
+/*
+** mode "all" will calculate std deviation across all capture periods
+** mode "period" will calculate it across that period
+*/
+static double calcStdDeviation(perfData* mPData,const char* mode);
+/*static long getTotalSystemMem(void);*/
+/*reset period counters at end of time interval*/
+static void resetPeriodCounters(perfData* mPData);
+
+/* convert timeval structures to strings */
+/*void timeval2string(struct timeval *ts, char buffer[], int len);*/
+/*void ctime_r(long*, const char[],int);*/
+
+/* Routines for printing global/average stats on exiting application */
+static void wtableIteration(
+ wtable_t table, void* data,const char* key, void* closure);
+static void printPerfDataReport(perfData* pData,FILE* outfile);
+static void initPerfData(perfData* pData, FILE* outfile, const char* symbol);
+
+
+
+void startCpuTimer(void)
+{
+#ifndef WIN32
+ gCpuClockTicksPerSecond = (double)sysconf(_SC_CLK_TCK);
+ gStartRealTime = (double)times(&gStartProcTime)/(double)gCpuClockTicksPerSecond;
+ /*printf("initProcTable(getpid(),0)\n");*/
+ initProcTable(getpid(),0);
+ /*printf("getNumCpu()=%d\n",gNumCpu);*/
+#endif
+#ifdef WIN32
+ gCpuClockTicksPerSecond = CLOCKS_PER_SEC;
+ gStartRealTime = (double)clock()/(double)gCpuClockTicksPerSecond;
+#endif
+/* gProcStartTime = times(&gCpuStartTime);*/
+ gNumCpu=getNumCpu();
+}
+
+
+int createStatisticsCache(statsCache** sCache,int numMsgCategories,
+ FILE* outfile,int header)
+{
+ int mysCacheStatus;
+ struct timeval sTime;
+ /*create statsCache struct*/
+ statsCache* mysCache = (statsCache*)calloc(1,sizeof(statsCache));
+ if(!mysCache)
+ {
+ mysCacheStatus = STATS_NO_MEMORY;
+ }
+ mysCache->mNumMsg = numMsgCategories;
+ mysCache->mHeader = header;
+ mysCache->mOutfile = outfile;
+ mysCache->mNumMessages = 0;
+ mysCache->mNumBytes = 0;
+
+ (void)gettimeofday(&sTime,NULL);
+ mysCache->mLastUpdateTime = ( (double) sTime.tv_sec ) +
+ ( (double)sTime.tv_usec / 1000000 );
+
+ /* mysCache->mNumMsg flags wether calculating stats on per symbol
+ * basis or general stats on all symbols, if > 0 then a table is needed
+ * to store data on all symbols
+ */
+
+ if(mysCache->mNumMsg>0)
+ {
+ /*Per symbol/category*/
+ mysCache->mSymbolTable =
+ wtable_create("mSymbolTable",mysCache->mNumMsg);
+
+ if (!mysCache->mSymbolTable)
+ {
+ printf ("Error: wtable_create() failed.\n");
+ }
+ else
+ {
+
+ if(mysCache->mHeader == 1 && mysCache->mOutfile == stdout)
+ {
+ fprintf(mysCache->mOutfile,opHeaderPeriod);
+ mysCache->mHeader=0;
+ }
+
+ *sCache = mysCache;
+ }
+ }
+ else
+ {
+ /* Global statistics */
+ const char* dummySymbol = "Global";
+ mysCache->mPData =(perfData*)calloc(1,sizeof(perfData));
+ if(!mysCache)
+ {
+ return STATS_NO_MEMORY;
+ }
+ initPerfData(mysCache->mPData, outfile, dummySymbol);
+
+ if(mysCache->mPData)
+ {
+ if(mysCache->mHeader == 1 && mysCache->mOutfile == stdout)
+ {
+ fprintf(mysCache->mOutfile,opHeaderPeriod);
+ mysCache->mHeader=0;
+ }
+
+ *sCache = mysCache;
+ }
+ }
+ return STATS_OK;
+}
+
+
+void initPerfData(perfData* pData, FILE* outfile, const char* symbol)
+{
+ /*Initialise Perf Data Structure*/
+ pData->mMinLatencyP=999999999;
+ pData->mMaxLatencyP=0;
+ pData->mAveLatencyP=0.00;
+ pData->mMinLatencyA=999999999;
+ pData->mMaxLatencyA=0;
+ pData->mAveLatencyA=0.00;
+
+ pData->mLatAccumP=0;
+ pData->mLatMsgCountP=0;
+ pData->mLatAccumA=0;
+ pData->mLatMsgCountA=0;
+
+ pData->mMsgCountP=0;
+ pData->mMsgPerSecP=0.00;
+ pData->mMsgCountA=0;
+ pData->mMaxMsgPerSecA=0.00;
+ pData->mMinMsgPerSecA=999999999;
+ pData->mAveMsgPerSecA=0.00;
+
+ pData->mByteCountP=0;
+ pData->mBytePerSecP=0.00;
+ pData->mByteCountA=0;
+ pData->mMaxBytePerSecA=0.00; /* not used at present*/
+ pData->mAveBytePerSecA=0.00; /* not used at present*/
+
+ pData->mLastTime = 0;
+ pData->mTotalTime = 0;
+ pData->mOutfile=outfile;
+ snprintf(pData->mSymbol,MAX_SYMBOL_LENGTH,"%s",symbol);
+}
+
+void resetPeriodCounters(perfData* mPData)
+{
+ mPData->mMsgCountP = 0;
+ mPData->mByteCountP = 0;
+ mPData->mLatMsgCountP = 0;
+ mPData->mLatAccumP = 0;
+ mPData->mMinLatencyP = 999999999;
+ mPData->mMaxLatencyP = 0;
+ mPData->mAveLatencyP = 0;
+ mPData->mStdDeviationP = 0;
+ mPData->mLatSquareP = 0;
+}
+
+
+void statisticsCacheToFile(statsCache* sCache,
+ performanceData* myPerformanceData)
+{
+ double timeIntervalInSeconds;
+ struct timeval sTime;
+ double timeNow;
+ (void)gettimeofday(&sTime,NULL);
+ timeNow= ( (double) sTime.tv_sec ) +
+ ( (double)sTime.tv_usec/1000000 );
+ if(sCache)
+ {
+ timeIntervalInSeconds = timeNow - sCache->mLastUpdateTime;
+
+#ifdef WIN32
+ if(timeIntervalInSeconds<0)
+ timeIntervalInSeconds+=60;
+#endif
+ sCache->mLastUpdateTime = timeNow;
+ if(sCache->mNumMsg>0)
+ {
+ double paramArray[2];
+ paramArray[0]= timeIntervalInSeconds;
+ paramArray[1]= (double) sCache->mHeader;
+
+ /*iterate round wTable and update stats for each symbol*/
+ wtable_for_each (sCache->mSymbolTable,
+ processWTableData, paramArray);
+ }
+ else
+ {
+ /*calculate overall stats for subsCacheriptions*/
+ if(sCache->mPData)
+ {
+ calcPerfData(sCache->mPData,timeIntervalInSeconds,myPerformanceData);
+ if(!myPerformanceData)
+ {
+ /* Print out stats */
+ printPerfData (sCache->mPData,sCache->mHeader);
+ }
+ resetPeriodCounters(sCache->mPData);
+ }
+ }
+ sCache->mNumMessages=0;
+ sCache->mNumBytes=0;
+ }
+}
+
+double calcStdDeviation(perfData* mPData,const char* mode)
+{
+ /*
+ if the POPULATION formula is needed change the final denominator
+ from ( mPData->mLatMsgCountP -1 ) to ( mPData->mLatMsgCountP )
+ and ( mPData->mLatMsgCountA -1 ) to ( mPData->mLatMsgCountA )
+ */
+
+ double stdDeviation=0;
+ if(strcmp(mode,"period")==0)
+ {
+ if( mPData->mLatMsgCountP > 1 )
+ {
+ stdDeviation = sqrt ((mPData->mLatSquareP-
+ (mPData->mLatAccumP*mPData->mLatAccumP)/
+ mPData->mLatMsgCountP) /
+ (mPData->mLatMsgCountP - 1));
+
+ }
+ }
+ else if (strcmp(mode,"all")==0)
+ {
+ if( mPData->mLatMsgCountA > 1 )
+ {
+ stdDeviation =sqrt ((mPData->mLatSquareA-
+ (mPData->mLatAccumA*mPData->mLatAccumA)/
+ mPData->mLatMsgCountA) /
+ (mPData->mLatMsgCountA - 1));
+ }
+ }
+ return stdDeviation;
+}
+
+/*
+** this function is called each time
+** a new data item is retrieved from wtable
+*/
+void processWTableData (
+ wtable_t table, void* data, const char* key, void* closure)
+{
+ double* cpyParamArray = (double*) closure;
+ double interval = cpyParamArray[0];
+ double header = cpyParamArray[1];
+
+ perfData* mPData = NULL;
+ mPData = (perfData*) data;
+
+ if (mPData)
+ {
+ /*calculate overall stats for subscriptions*/
+ calcPerfData(mPData,interval,NULL);
+ /* Print out stats */
+ printPerfData (mPData,(int)header);
+ resetPeriodCounters(mPData);
+ }
+}
+
+
+int updateStatisticsCache(statsCache* sCache ,
+ const char* msgCategoryName ,
+ long numBytesRecieved,
+ long timeSecs,
+ long timeMicroSecs,
+ double cLatency,
+ struct timeval tv)
+{
+ int ret;
+ perfData *mPData = NULL;
+ double latency = 0;
+
+ if(timeSecs != 0 || timeMicroSecs != 0)
+ calcLatency(timeSecs,timeMicroSecs,&latency,tv);
+ else
+ latency=cLatency;
+
+ if(sCache->mNumMsg>0 && sCache->mSymbolTable)
+ {
+ /* More than one category*/
+ mPData =
+ (perfData*) wtable_lookup (sCache->mSymbolTable,msgCategoryName);
+ /* If category doesn't already exist*/
+ if (!mPData)
+ {
+ /* Then create & init*/
+ mPData = (perfData*)calloc(1,sizeof(perfData));
+ initPerfData(mPData,sCache->mOutfile,msgCategoryName);
+ }
+ }
+ else
+ {
+ /* No categories */
+ mPData = sCache->mPData;
+ }
+
+ /* Update statistics for period */
+ mPData->mMsgCountP++;
+ mPData->mByteCountP += (double)numBytesRecieved;
+
+ /* change to get rid of spurious results*/
+ /* if (latency > 0) */
+ if (/*latency >0 &&*/ latency<999999999)
+ {
+ mPData->mLatMsgCountP++;
+ mPData->mLatAccumP += latency;
+ if (latency < mPData->mMinLatencyP)
+ {
+ mPData->mMinLatencyP = latency;
+ }
+ if (latency > mPData->mMaxLatencyP)
+ {
+ mPData->mMaxLatencyP = latency;
+ }
+ mPData->mLatSquareP += (latency*latency);
+ }
+
+ /* Update table in structure if more than one category*/
+ if(sCache->mNumMsg>0)
+ {
+ ret=
+ wtable_insert(sCache->mSymbolTable,msgCategoryName, (void*) mPData);
+ if(ret>0)
+ {
+ /*error in insert*/
+ }
+
+ }
+
+ sCache->mNumMessages++;
+ sCache->mNumBytes+=numBytesRecieved;
+ return STATS_OK;
+}
+
+
+void destroyStatsCache(statsCache* sCache)
+{
+ if (sCache)
+ {
+ if (sCache->mPData)
+ {
+ free (sCache->mPData);
+ }
+ if (sCache->mSymbolTable)
+ {
+ wtable_destroy (sCache->mSymbolTable);
+ }
+ free (sCache);
+ }
+}
+
+latencyVals calcLatency(long timeSecs,
+ long timeMicroSecs,
+ double* latency,
+ struct timeval tv)
+{
+ static long cachedMaxLatencySecs = (LONG_MAX/1000000);
+ static latencyVals noLatVals = {0.0,0.0,0.0};
+ double latencySecs = 0;
+ double latencyUSecs = 0;
+ struct latencyVals latVals = {0.0,0.0,0.0};
+
+ /* Calculate now time */
+ latencySecs = ((double)tv.tv_sec - (double)timeSecs);
+
+ if(cachedMaxLatencySecs > latencySecs)
+ {
+ latencyUSecs =((double)tv.tv_usec - (double)timeMicroSecs);
+ *latency = ((latencySecs *1000000) + latencyUSecs)/1000.0;
+
+ latVals.pubTimeMilliSecs = latencySecs*1000.0;
+ latVals.recieveTimeMilliSecs = latencyUSecs/1000.0;
+ latVals.latencyMilliSecs = *latency;
+ return latVals;
+ }
+ return noLatVals;
+}
+
+latencyVals calcLatency1TimeStamp(const char* timeStamp,
+ const char* timeFormat,
+ double* latency,
+ struct timeval tv)
+{
+ static latencyVals noLatVals = {0.0,0.0,0.0};
+ time_t rawTime;
+ struct tm* currentTime;
+ struct tm myTm;
+ struct latencyVals latVals={0.0,0.0,0.0};
+ long millis = 0;
+ const char* pos1=NULL;
+ int lenTimeFormat = 0;
+ int lenTimeStamp = 0;
+ double latencySecs=0;
+ double latencyUSec=0;
+ int nextNumCharBack=3;
+#ifdef WIN32
+ int secs=0;
+ int mins=0;
+#endif
+
+ lenTimeFormat = strlen(timeFormat);
+ lenTimeStamp = strlen(timeStamp);
+ if ((timeStamp == NULL) || (timeFormat== NULL)
+ || (lenTimeFormat == 0) || (lenTimeStamp == 0))
+ {
+ fprintf(stderr,"Error - calcLatency\n");
+ return noLatVals;
+ }
+ /*printf("TimeStampStr[%s]",timeStamp);*/
+ /* Calculate now time */
+ time ( &rawTime );
+ currentTime = localtime(&rawTime);
+
+/*#ifndef WIN32*/
+
+ pos1 = timeStamp+(lenTimeStamp-nextNumCharBack);
+ millis = strtol(pos1,NULL,10);
+ strptime(timeStamp,timeFormat,&myTm);
+ latencySecs = (((currentTime->tm_hour*60.0+currentTime->tm_min)*60.0)+currentTime->tm_sec) -
+ (((myTm.tm_hour*60.0+myTm.tm_min)*60.0)+myTm.tm_sec);
+ /*printf("%d:%d:%d-%d:%d:%d=%f\n",currentTime->tm_hour,currentTime->tm_min,currentTime->tm_sec,myTm.tm_hour,myTm.tm_min,myTm.tm_sec,latencySecs);*/
+
+/*#else
+
+
+ if(lenTimeStamp>10)
+ {
+ millis=0;
+ pos1 = timeStamp+(lenTimeStamp-nextNumCharBack);
+ if(pos1[0]=='.' || pos1[0] ==':')
+ {
+ nextNumCharBack-=1;
+ pos1 = timeStamp+(lenTimeStamp-nextNumCharBack);
+ nextNumCharBack+=3;
+ }
+ else
+ nextNumCharBack+=3;
+
+ millis = strtol(pos1,NULL,10);
+ }
+ else
+ {
+ nextNumCharBack=2;
+ }
+ pos1 = timeStamp+(lenTimeStamp-nextNumCharBack);
+ nextNumCharBack+=3;
+ secs = (int)strtol(pos1,NULL,10);
+ pos1 = timeStamp+(lenTimeStamp-nextNumCharBack);
+ mins = (int)strtol(pos1,NULL,10);
+ latencySecs = ((currentTime->tm_min*60) + currentTime->tm_sec) -
+ ((mins*60) + secs);
+#endif*/
+
+ latencyUSec = ((double)tv.tv_usec-(millis*1000.0));
+ /*printf("-------%f - %f=%f\n",(double)tv.tv_usec,millis*1000.0,latencyUSec);*/
+
+ /*if(latencySecs<0)
+ {
+ latencySecs+= SECONDSINHOUR;
+ }*/
+
+ *latency = ((latencySecs *1000000) + latencyUSec)/1000.0;
+ latVals.pubTimeMilliSecs = latencySecs*1000.0;
+ latVals.recieveTimeMilliSecs = latencyUSec/1000.0;
+ latVals.latencyMilliSecs = *latency;
+
+ return latVals;
+}
+
+void printStatsLevel1(int numMsg,FILE* graphData)
+{
+ struct cpuVals cpuV={0.0,0.0,0.0,0.0};
+ struct memVals memV={0,0,0.0};
+ gCount+=1;
+
+ if(gCount==1 && graphData == stdout)
+ printf("\n\n%s",gStatsLevel1Header);
+
+ if( (gCount % numMsg) ==0)
+ {
+ if(gCount%(numMsg*30)==0 && graphData == stdout)
+ {
+ printf("\n\n%s",gStatsLevel1Header);
+ }
+ getCpuTimeVals(&cpuV,1);
+ gRealTime+=cpuV.realTime;
+ gTotalPercent+=cpuV.pCpu;
+ getMemVals(getpid(),&memV);
+ if(graphData == stdout)
+ {
+ fprintf(graphData,
+ ",%-12.0ld,%-10.4f,%-9.3f,%-9.4f,%-9.4f,%-7.2f%%,%-9.2f%%,%-8ld,%-8.2f%%,\n",
+ gCount,gRealTime,cpuV.realTime,cpuV.userTime,cpuV.sysTime,
+ cpuV.pCpu,(gTotalPercent/(gCount/numMsg)),
+ memV.rss,memV.memPercent);
+ }
+ else if(graphData != NULL)
+ {
+ /* this file version does not include ave cpu percentage */
+ fprintf(graphData,
+ "%-12.0ld,%-10.4f,%-9.3f,%-9.4f,%-9.4f,%-7.2f,%-8ld,%-8.2f\n",
+ gCount,gRealTime,cpuV.realTime,cpuV.userTime,
+ cpuV.sysTime,cpuV.pCpu,memV.rss,memV.memPercent);
+ }
+ }
+}
+
+/*clock_t utime=0;
+double total=0;
+struct cpuVals lastCpuV;*/
+void getCpuTimeVals(cpuVals* cpuV, int isUpdate)
+{
+ /**
+ * Same value as running top with Interactive command "I"(<shift> i)
+ *
+ * Extract from top man page for INTERACTIVE COMMAND "I":
+ * Toggle between Solaris (CPU percentage divided by total number of
+ * CPUs) and Irix (CPU percentage calculated solely by amount of
+ * time) views. This is a toggle switch that affects only SMP sys-
+ * tems.
+ */
+ double diffRealTime=0.0;
+ double diff = 1234.0;
+ struct tms CurrentProcTime;
+ double CurrentRealTime = 0.0;
+
+#ifndef WIN32
+ CurrentRealTime = (double)times(&CurrentProcTime)/gCpuClockTicksPerSecond;
+#endif
+#ifdef WIN32
+ CurrentRealTime = clock()/(double)gCpuClockTicksPerSecond;
+#endif
+ diffRealTime=CurrentRealTime-gStartRealTime;
+ getProcAndChildCpu((int)getpid(),cpuV);
+ cpuV->realTime =diffRealTime;
+
+/*
+ although solaris cpu% is calculated(moving decaying?) by kernel,
+ it is not accurate in our scheme.
+*/
+
+ diff = (cpuV->userTime+cpuV->sysTime)-
+ (gLastCpuV.userTime+gLastCpuV.sysTime);
+ if(cpuV->realTime > 1e-6)
+ {
+ cpuV->pCpu = diff/diffRealTime*100.0/gNumCpu;
+ /*printf("New : (utime + stime ) (%9f + %9f) = %9f |rtime = %9f\n",cpuV->userTime,
+ cpuV->sysTime,
+ cpuV->userTime+cpuV->sysTime,
+ CurrentRealTime);
+ printf("Last: (utime + stime ) (%9f + %9f) = %9f |rtime = %9f\n",gLastCpuV.userTime,
+ gLastCpuV.sysTime,
+ gLastCpuV.userTime+gLastCpuV.sysTime,
+ gStartRealTime);
+ printf("Diff: (utime + stime ) (%9f + %9f) = %9f |rtime = %9f\n",cpuV->userTime - gLastCpuV.userTime,
+ cpuV->sysTime - gLastCpuV.sysTime,
+ diff,
+ diffRealTime);
+ printf("getCpuTimeval : CPU %9f = %9f / (%9f * %d) \n", cpuV->pCpu, diff, diffRealTime, gNumCpu);*/
+ }
+ else
+ {
+ cpuV->pCpu = -1;
+ }
+
+ if(isUpdate)
+ {
+ gStartRealTime=CurrentRealTime;
+ gStartProcTime=CurrentProcTime;
+ gLastCpuV=*(cpuV);
+ }
+}
+
+
+void getCpuTimeValDiff(cpuVals cpuV1, cpuVals cpuV2, cpuVals* cpuV)
+{
+
+ cpuV->userTime =cpuV2.userTime - cpuV1.userTime;
+
+ cpuV->sysTime =cpuV2.sysTime - cpuV1.sysTime;
+
+ cpuV->realTime =cpuV2.realTime - cpuV1.realTime;
+/*#ifdef __linux__*/
+ /*if (cpuV->realTime != 0)
+ cpuV->pCpu =(((cpuV->userTime + cpuV->sysTime)*100.0)/(cpuV->realTime*gNumCpu));*/
+ if (cpuV->realTime > 1e-6)
+ {
+ cpuV->pCpu =(((cpuV->userTime + cpuV->sysTime)*100.0)/(cpuV->realTime*gNumCpu));
+ /*printf("getCpuTimeValdiff: CPU %9f = %9f / (%9f * %d) \n", cpuV->pCpu,
+ cpuV->userTime + cpuV->sysTime,
+ cpuV->realTime,
+ gNumCpu);*/
+ }
+ else
+ {
+ cpuV->pCpu = -1;
+ }
+ /*printf("getCpuDiff:cpu-num%d-%f\n",gNumCpu,cpuV->pCpu);*/
+/*#endif*/
+
+}
+
+void calcPerfData(perfData* mPData, double interval,
+ performanceData* myPerformanceData)
+{
+ /*Calculate averages for the period*/
+ if (mPData->mMsgCountP > 0)
+ {
+ mPData->mMsgPerSecP = ( (double) mPData->mMsgCountP/
+ (double) interval);
+ }
+ else
+ {
+ mPData->mMsgPerSecP = 0.00;
+ }
+ if (mPData->mByteCountP > 0)
+ {
+ mPData->mBytePerSecP = ( (double) mPData->mByteCountP /
+ (double) interval);
+ }
+ else
+ {
+ mPData->mBytePerSecP = 0.00;
+ }
+ if ( (mPData->mLatAccumP > 0) && (mPData->mLatMsgCountP > 0) )
+ {
+ mPData->mAveLatencyP = ( (double) mPData->mLatAccumP /
+ (double)mPData->mLatMsgCountP );
+ }
+ /*Update global counters*/
+ mPData->mMsgCountA += mPData->mMsgCountP;
+ mPData->mByteCountA += mPData->mByteCountP;
+ mPData->mLatAccumA += mPData->mLatAccumP;
+ mPData->mLatSquareA += mPData->mLatSquareP;
+ mPData->mLatMsgCountA += mPData->mLatMsgCountP;
+ mPData->mTotalTime += interval;
+
+/* sCache->numMessages += mPData->mMsgCountP;
+ sCache->mNumBytes += mPData->mByteCountP;
+*/
+
+ /*Update global Max & Mins*/
+ if (mPData->mMaxMsgPerSecA < mPData->mMsgPerSecP)
+ {
+ mPData->mMaxMsgPerSecA = mPData->mMsgPerSecP;
+ }
+ if (mPData->mMinMsgPerSecA > mPData->mMsgPerSecP)
+ {
+ mPData->mMinMsgPerSecA = mPData->mMsgPerSecP;
+ }
+ if (mPData->mMinLatencyP < mPData->mMinLatencyA)
+ {
+ mPData->mMinLatencyA = mPData->mMinLatencyP;
+ }
+ if (mPData->mMaxLatencyP > mPData->mMaxLatencyA)
+ {
+ mPData->mMaxLatencyA = mPData->mMaxLatencyP;
+ }
+ /* Update global averages*/
+ if (mPData->mMsgCountA > 0)
+ {
+ mPData->mAveMsgPerSecA = ( (double) mPData->mMsgCountA /
+ (double) mPData->mTotalTime);
+ }
+ else
+ {
+ mPData->mAveMsgPerSecA = 0.00;
+ }
+ if (mPData->mByteCountA > 0)
+ {
+ mPData->mAveBytePerSecA = ( (double) mPData->mByteCountA /
+ (double) mPData->mTotalTime);
+ }
+ else
+ {
+ mPData->mAveBytePerSecA = 0.00;
+ }
+ if ( (mPData->mLatAccumA > 0) && (mPData->mLatMsgCountA > 0) )
+ {
+ mPData->mAveLatencyA = ( (double) mPData->mLatAccumA /
+ (double) mPData->mLatMsgCountA);
+ }
+ else
+ {
+ mPData->mAveLatencyA = 0.00;
+ }
+
+ /* call to get standard deviation for this period*/
+ mPData->mStdDeviationP= calcStdDeviation(mPData,"period");
+ if(myPerformanceData)
+ {
+ myPerformanceData->mSymbol = mPData->mSymbol;
+ myPerformanceData->mTotalTime = mPData->mTotalTime;
+ myPerformanceData->mMsgCountP = mPData->mMsgCountP;
+ myPerformanceData->mMsgPerSecP = mPData->mMsgPerSecP;
+ myPerformanceData->mByteCountP = mPData->mByteCountP/1000;
+ myPerformanceData->mBytePerSecP = mPData->mBytePerSecP/1000;
+ myPerformanceData->mMinLatencyP = mPData->mMinLatencyP;
+ myPerformanceData->mMaxLatencyP = mPData->mMaxLatencyP;
+ myPerformanceData->mAveLatencyP = mPData->mAveLatencyP;
+ myPerformanceData->mStdDeviationP = mPData->mStdDeviationP;
+ }
+}
+
+
+
+
+
+int printPerfData(perfData* pData,int headerFlag)
+{
+ if(pData->mOutfile != NULL)
+ {
+ /*only print out symbol details if they have changed*/
+ if( pData->mMsgCountP>0 )
+ {
+
+ if(headerFlag==1)
+ {
+ /* print stats header every time for all symbols */
+ fprintf(pData->mOutfile,opHeaderPeriod);
+ }
+ fprintf(pData->mOutfile," %-13s,",pData->mSymbol);
+ fprintf(pData->mOutfile,"%-13.2f,",pData->mTotalTime);
+ fprintf(pData->mOutfile,"%-9.0ld,",pData->mMsgCountP);
+ fprintf(pData->mOutfile,"%-9.2f,",pData->mMsgPerSecP);
+ fprintf(pData->mOutfile,"%-9.2f,",(pData->mByteCountP/1000));
+ fprintf(pData->mOutfile,"%-8.2f,",(pData->mBytePerSecP/1000));
+ fprintf(pData->mOutfile,"%-10.3f,",pData->mMinLatencyP);
+ fprintf(pData->mOutfile,"%-10.3f,",pData->mMaxLatencyP);
+ fprintf(pData->mOutfile,"%-10.3f,",pData->mAveLatencyP);
+ fprintf(pData->mOutfile,"%-13.4f,\n",pData->mStdDeviationP);
+ }
+ return STATS_OK;
+ }
+ else
+ {
+ return STATS_NULL_PARAM;
+ }
+}
+
+
+int printPerfReport (statsCache* sCache,FILE* outfile)
+{
+ /* update stats using final interval */
+ statisticsCacheToFile(sCache,NULL);
+
+ if(sCache && outfile != NULL)
+ {
+ if(sCache->mNumMsg>0)
+ {
+ /* call to iterate around wTable*/
+ if(outfile==stdout)
+ {
+ perfDataReportHeader(outfile);
+ }
+ wtable_for_each (sCache->mSymbolTable,wtableIteration,outfile );
+ }
+ else
+ {
+ /* just print current perfData*/
+ if(outfile==stdout)
+ {
+ perfDataReportHeader(outfile);
+ }
+ sCache->mPData->mStdDeviationA =
+ calcStdDeviation(sCache->mPData,"all");
+ printPerfDataReport(sCache->mPData,outfile);
+ }
+ return STATS_OK;
+ }
+ else
+ {
+ return STATS_NULL_PARAM;
+ }
+}
+
+void wtableIteration (
+ wtable_t table, void* data, const char* key, void* closure)
+{
+ /*
+ call back function from wtable_for_each() in printPerfReport ()
+ iterates around wtable returning new data item each time.
+ */
+
+ FILE* outfile = (FILE*) closure;
+ perfData* mPData = NULL;
+ mPData = (perfData*) data;
+ if (outfile != NULL)
+ {
+ mPData->mStdDeviationA = calcStdDeviation(mPData,"all");
+ printPerfDataReport(mPData,outfile);
+ }
+}
+void perfDataReportHeader(FILE* outfile)
+{
+ if(outfile!=NULL)
+ {
+ /* prints end of test report header*/
+ fprintf(outfile,
+ "\n\n\n\t\t\t\t\t *** Statistics Summary For Execution ***\n");
+ fprintf(outfile, " Symbol Name ,");
+ fprintf(outfile,opHeaderAcrossAll);
+ }
+}
+void printPerfDataReport(perfData* pData,FILE* outfile)
+{
+ if(outfile!=NULL)
+ {
+ fprintf(outfile," %-13s,",pData->mSymbol);
+ fprintf(outfile,"%-9.0ld,",pData->mMsgCountA);
+ fprintf(outfile,"%-11.2f,",pData->mMinMsgPerSecA);
+ fprintf(outfile,"%-11.2f,",pData->mMaxMsgPerSecA);
+ fprintf(outfile,"%-11.2f,",pData->mAveMsgPerSecA);
+ fprintf(outfile,"%-9.2f,",(pData->mByteCountA/1000));
+ fprintf(outfile,"%-8.2f,",(pData->mAveBytePerSecA/1000));
+ fprintf(outfile,"%-10.3f,",pData->mMinLatencyA);
+ fprintf(outfile,"%-10.3f,",pData->mMaxLatencyA);
+ fprintf(outfile,"%-10.3f,",pData->mAveLatencyA);
+ fprintf(outfile,"%-8.2f,\n",pData->mStdDeviationA);
+ }
+}
diff --git a/common/c_cpp/src/c/windows/wombat/wMath.h b/common/c_cpp/src/c/windows/wombat/wMath.h
new file mode 100644
index 0000000..406b5b5
--- /dev/null
+++ b/common/c_cpp/src/c/windows/wombat/wMath.h
@@ -0,0 +1,31 @@
+/* $Id: wMath.h,v 1.1.2.2 2012/03/20 11:15:17 emmapollock 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 WMATH_H__
+#define WMATH_H__
+
+#include <math.h>
+
+const int wIsnan (double n)
+{
+ return _isnan(n);
+}
+
+#endif /* WMATH_H__ */
diff --git a/common/c_cpp/src/c/windows/wombat/wUuid.h b/common/c_cpp/src/c/windows/wombat/wUuid.h
new file mode 100644
index 0000000..43f4b2c
--- /dev/null
+++ b/common/c_cpp/src/c/windows/wombat/wUuid.h
@@ -0,0 +1,34 @@
+/* $Id: wUuid.h,v 1.1.2.2 2012/03/20 11:15:17 emmapollock 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 WUUID_H__
+#define WUUID_H__
+
+#include "wombat/port.h"
+
+typedef int wUuid;
+
+COMMONExpDLL
+void wUuid_generate_time (wUuid myUuid);
+
+COMMONExpDLL
+void wUuid_unparse (wUuid myUuid, char* out);
+
+#endif /* WUUID_H__ */
diff --git a/common/c_cpp/src/c/wombat/wMessageStats.h b/common/c_cpp/src/c/wombat/wMessageStats.h
new file mode 100644
index 0000000..4a8916d
--- /dev/null
+++ b/common/c_cpp/src/c/wombat/wMessageStats.h
@@ -0,0 +1,190 @@
+
+#ifndef _PERF_DATA_H__
+#define _PERF_DATA_H__
+
+#if defined(__cplusplus)
+ extern "C" {
+#endif /* __cplusplus */
+
+#include "machine.h"
+#include <stdio.h>
+#ifndef WIN32
+#include <sys/time.h>
+#endif
+
+#ifdef WIN32
+
+#include <winsock2.h>
+
+#endif
+
+/*******************************************************************************
+*******************************************************************************/
+
+
+struct perfData_t;
+typedef struct perfData_t perfData;
+
+struct statsCache_t;
+typedef struct statsCache_t statsCache;
+
+struct processInfo_t;
+typedef struct processInfo_t processInfo;
+
+typedef struct latencyVals
+{
+ double pubTimeMilliSecs; /*time msg was published in milliseconds*/
+ double recieveTimeMilliSecs; /*time msg was recieved in milliseconds*/
+ double latencyMilliSecs; /*latency between two previous vals*/
+}latencyVals;
+
+typedef struct performanceData
+{
+ const char* mSymbol;
+ double mTotalTime;
+ long mMsgCountP;
+ double mMsgPerSecP;
+ long mByteCountP;
+ double mBytePerSecP;
+ double mMinLatencyP;
+ double mMaxLatencyP;
+ double mAveLatencyP;
+ double mStdDeviationP;
+}performanceData;
+
+enum
+{
+ STATS_OK = 0,
+ STATS_FAILURE_GENERAL = -1,
+ STATS_NULL_PARAM = 1,
+ STATS_NO_MEMORY = 2
+};
+
+/* used to create instance of struct to hold stats data
+** @param statsCache -- caches relevant statistics data
+**
+** @param numMsgCategories -- 0 if stats for all symbols needed or number of
+** symbols if stats are needed on per symbol basis
+**
+** @param outfile -- where stats are to be displayed
+**
+** @param header -- 1 to display header 0 for never
+**
+** returns STATS_NO_MEMORY or STATS_OK
+*/
+COMMONExpDLL
+int createStatisticsCache(statsCache** sCache,
+ int numMsgCategories,
+ FILE* outfile,
+ int header);
+
+
+
+/* used to gather stats at user specified intervals */
+/*@param myPerformanceData -- if user wants results in performanceData
+** structure pass in pointer to it, pass in null if
+** not, wMessageStats.c will then print results to
+** FILE* outfile that was passed in on creation of
+** statsCache.
+*/
+COMMONExpDLL
+void statisticsCacheToFile(statsCache* sCache,
+ performanceData* myPerformanceData);
+
+
+
+/* stores stats for individual symbols and counts
+** messages and bytes between intervals
+** @param msgCategoryName -- name by which message or symbol
+** is to be identified
+** @param numBytesRecieved -- size of message in Bytes
+** @param timeSecs -- time in secs from epoch until now
+** @param timeMicroSecs -- time in micro seconds from last second
+** @param cLatency -- if latency is already known pass it in,
+** set timeSecs + timeMicroSecs = 0
+** @param tv -- time on which latency will be calculated
+** i.e time message was recieved.
+*/
+COMMONExpDLL
+int updateStatisticsCache(statsCache* sCache,
+ const char* msgCategoryName,
+ long numBytesRecieved,
+ long timeSecs,
+ long timeMicroSecs,
+ double cLatency,
+ struct timeval tv);
+
+COMMONExpDLL
+void destroyStatsCache(statsCache*);
+
+/* prints end of test report to file */
+COMMONExpDLL
+int printPerfReport(statsCache* sCache, FILE*);
+
+
+
+/* function calculates latency between timeSecs,timeMicroSecs
+** and time of calling function. returns latencyVals structure.
+** @param timeSecs -- time in seconds since the epoch
+** @param timeMicroSecs -- time past the last second in micro seconds
+** @param latency -- puts latency value in double* latencyi
+** @param tv -- time on which latency will be calculated
+** i.e time message was recieved.
+*/
+COMMONExpDLL
+latencyVals calcLatency(long timeSecs,
+ long timeMicroSecs,
+ double* latency,
+ struct timeval tv);
+
+
+/* function calculates latency on timestamp and puts result in double* latency
+** @param timeStamp -- timestamp string
+** @param timeFormat -- format of timeStamp string ie "%d:%m:%Y:%H:%M:%S"
+** @param latency -- poiner to double where latency value
+** is to be stored
+** @param tv -- time on which latency will be calculated
+** i.e time message was recieved.
+*/
+COMMONExpDLL
+latencyVals calcLatency1TimeStamp(const char* timeStamp,
+ const char* timeFormat,
+ double* latency,
+ struct timeval tv);
+
+/* Function to print statsLevel 1 values
+** @param timeSecs -- time in seconds since the epoch
+** @param timeMicroSecs -- time past the last second in micro seconds
+** @param numMsg -- when using statsLevel 1, numMsg defines how often to
+** calculate results.
+** @graphData -- where you want data to be displayed ie
+** stdout or specify a directory /home/username/
+*/
+
+
+COMMONExpDLL
+void printStatsLevel1(int numMsg, FILE* graphData);
+/* function prints out to graphData:
+** if out to screen
+** |Global Count|Total Time|CPU utime|CPU stime|CPU%|Ave CPU%|Memory|Memory%|
+**
+** if out to file Ave CPU% is left out
+*/
+
+/* function starts timer for cpu ticks which is used by getCpuTimeVals
+** startCpuTime should be started before using getCpuTimeVals()
+**
+*/
+COMMONExpDLL
+void startCpuTimer(void);
+COMMONExpDLL
+void getCpuTimeVals(cpuVals *cpuV, int isUpdate);
+COMMONExpDLL
+void getCpuTimeValDiff(cpuVals cpuV1,cpuVals cpuV2,cpuVals* cpuV);
+/* function returns memory statistics */
+/*void getMemVals( int pid,memVals *memV);*/
+
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus */
+#endif /*_PERF_DATA_H__*/
--
1.7.7.6


[PATCH 07/50] [windows] Macros for MSVC Version

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

These are necessary to accomodate different version of Visual Studio.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
common/c_cpp/src/c/windows/wombat/targetsxs.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/common/c_cpp/src/c/windows/wombat/targetsxs.h b/common/c_cpp/src/c/windows/wombat/targetsxs.h
index a8d8280..2341000 100644
--- a/common/c_cpp/src/c/windows/wombat/targetsxs.h
+++ b/common/c_cpp/src/c/windows/wombat/targetsxs.h
@@ -1,6 +1,15 @@
#ifndef _WOMBAT_TARGETSXS_H
#define _WOMBAT_TARGETSXS_H

+#if (_MSC_VER >= 1600 && _MSC_VER < 1700)
+#define VC10 1
+#elif (_MSC_VER >= 1600 && _MSC_VER < 1500)
+#define VC9 1
+#elif (_MSC_VER >= 1400 && _MSC_VER < 1500)
+#define VC8 1
+#elif (_MSC_VER >= 1400 && _MSC_VER < 1400)
+#define VC7 1
+#endif
#ifndef VC7

#ifdef VC8
--
1.7.7.6


[PATCH 08/50] [bridge] Timout for Stopping Internal Queue

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

When shutting down, don't wait forever for the internal queue to stop. If the
queue does not stop within the default queue timeout
(mama.defaultqueue.timeout property), continue to shutdown. The default value
is 2000 milliseconds. This prevents hanging at shutdown if the distpach thread
is blocked.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/bridge.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mama/c_cpp/src/c/bridge.c b/mama/c_cpp/src/c/bridge.c
index 6970c8c..94c5caa 100644
--- a/mama/c_cpp/src/c/bridge.c
+++ b/mama/c_cpp/src/c/bridge.c
@@ -121,6 +121,8 @@ mamaBridgeImpl_stopInternalEventQueue (mamaBridge bridgeImpl)
if (impl->mInternalEventQueue)
{

+ /* Get the queue timeout value. */
+ int defaultQueueTimeout = mamaBridgeImpl_getDefaultQueueTimeout();
if (MAMA_STATUS_OK != mamaDispatcher_destroy (impl->mInternalDispatcher))
{
mama_log (MAMA_LOG_LEVEL_WARN, "mamaBridgeImpl_stopInternalEventQueue(): "
@@ -128,7 +130,8 @@ mamaBridgeImpl_stopInternalEventQueue (mamaBridge bridgeImpl)
return MAMA_STATUS_NO_BRIDGE_IMPL;
}

- if (MAMA_STATUS_OK != mamaQueue_destroy (impl->mInternalEventQueue ))
+ /* Destroy the queue waiting for the appropriate time value. */
+ if (MAMA_STATUS_OK != mamaQueue_destroyTimedWait (impl->mInternalEventQueue, defaultQueueTimeout))
{
mama_log (MAMA_LOG_LEVEL_WARN, "mamaBridgeImpl_stopInternalEventQueue(): "
"Could not destroy internal queue");
--
1.7.7.6


[PATCH 09/50] [bridge] Added mamaTransport_forceClientDisconnect()

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

For TCP socket based middleware, allow transports to disconnect individual
clients. This is usefull for eliminating slow consumers or other applications
that may impact the entier system.

Also fixed compiler warnings in Avis bridge files.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/bridge.h | 11 +++-
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/transportbridge.c | 59 ++++++++++++-------
4 files changed, 73 insertions(+), 40 deletions(-)

diff --git a/mama/c_cpp/src/c/bridge.h b/mama/c_cpp/src/c/bridge.h
index 5ab7707..9ead2bd 100644
--- a/mama/c_cpp/src/c/bridge.h
+++ b/mama/c_cpp/src/c/bridge.h
@@ -116,6 +116,8 @@ do \
implIdentifier ## BridgeMamaTransport_destroy; \
bridgeImpl->bridgeMamaTransportCreate = \
implIdentifier ## BridgeMamaTransport_create; \
+ bridgeImpl->bridgeMamaTransportForceClientDisconnect = \
+ implIdentifier ## BridgeMamaTransport_forceClientDisconnect;\
bridgeImpl->bridgeMamaTransportFindConnection = \
implIdentifier ## BridgeMamaTransport_findConnection; \
bridgeImpl->bridgeMamaTransportGetAllConnections = \
@@ -269,7 +271,7 @@ typedef mama_status (*bridge_stop)(mamaQueue defaultEventQueue);
/*Called by mama_getVersion()*/
typedef const char* (*bridge_getVersion)(void);
typedef const char* (*bridge_getName)(void);
-typedef mama_status (*bridge_getDefaultPayloadId)(char**name, char* id);
+typedef mama_status (*bridge_getDefaultPayloadId)(char***name, char** id);

/*===================================================================
= mamaQueue bridge function pointers =
@@ -330,6 +332,11 @@ typedef mama_status (*bridgeMamaTransport_destroy)(transportBridge transport);
typedef mama_status (*bridgeMamaTransport_create)(transportBridge *result,
const char* name,
mamaTransport parent);
+typedef mama_status (*bridgeMamaTransport_forceClientDisconnect)
+ (transportBridge* transports,
+ int numTransports,
+ const char* ipAddress,
+ uint16_t port);
/* Find a connection with specified IP Address and Port. If the port is 0, the
* call returns the first connection with the specified IP Address. If a
* connection is not found the method returns MAMA_STATUS_NOT_FOUND and
@@ -735,6 +742,8 @@ typedef struct mamaBridgeImpl
bridgeMamaTransport_isValid bridgeMamaTransportIsValid;
bridgeMamaTransport_destroy bridgeMamaTransportDestroy;
bridgeMamaTransport_create bridgeMamaTransportCreate;
+ bridgeMamaTransport_forceClientDisconnect
+ bridgeMamaTransportForceClientDisconnect;
bridgeMamaTransport_findConnection bridgeMamaTransportFindConnection;
bridgeMamaTransport_getAllConnections
bridgeMamaTransportGetAllConnections;
diff --git a/mama/c_cpp/src/c/bridge/avis/avisbridgefunctions.h b/mama/c_cpp/src/c/bridge/avis/avisbridgefunctions.h
index 94c4a42..0dd6f8e 100644
--- a/mama/c_cpp/src/c/bridge/avis/avisbridgefunctions.h
+++ b/mama/c_cpp/src/c/bridge/avis/avisbridgefunctions.h
@@ -43,7 +43,7 @@ extern const char*
avisBridge_getVersion (void);

mama_status
-avisBridge_getDefaultPayloadId (char**name, char* id);
+avisBridge_getDefaultPayloadId (char***name, char** id);

extern mama_status
avisBridge_open (mamaBridge bridgeImpl);
@@ -125,6 +125,11 @@ avisBridgeMamaTransport_create (transportBridge* result,
const char* name,
mamaTransport parent);
extern mama_status
+avisBridgeMamaTransport_forceClientDisconnect (transportBridge* transports,
+ int numTransports,
+ const char* ipAddress,
+ uint16_t port);
+extern mama_status
avisBridgeMamaTransport_findConnection (transportBridge* transports,
int numTransports,
mamaConnection* result,
diff --git a/mama/c_cpp/src/c/bridge/avis/bridge.c b/mama/c_cpp/src/c/bridge/avis/bridge.c
index 24c369a..4b5343a 100755
--- a/mama/c_cpp/src/c/bridge/avis/bridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/bridge.c
@@ -35,10 +35,12 @@ timerHeap gTimerHeap;
/*Responsible for creating the bridge impl structure*/
void avisBridge_createImpl (mamaBridge* result)
{
+ avisBridgeImpl* avisBridge = NULL;
+ mamaBridgeImpl* impl = NULL;
if (!result) return;
*result = NULL;

- mamaBridgeImpl* impl = (mamaBridgeImpl*)calloc (1, sizeof (mamaBridgeImpl));
+ impl = (mamaBridgeImpl*)calloc (1, sizeof (mamaBridgeImpl));
if (!impl)
{
mama_log (MAMA_LOG_LEVEL_SEVERE, "avisBridge_createImpl(): "
@@ -46,7 +48,7 @@ void avisBridge_createImpl (mamaBridge* result)
return;
}

- avisBridgeImpl* avisBridge = (avisBridgeImpl*) calloc(1, sizeof(avisBridgeImpl));
+ avisBridge = (avisBridgeImpl*) calloc(1, sizeof(avisBridgeImpl));

/*Populate the bridge impl structure with the function pointers*/
INITIALIZE_BRIDGE (impl, avis);
@@ -59,7 +61,7 @@ void avisBridge_createImpl (mamaBridge* result)
const char*
avisBridge_getVersion (void)
{
- return (const char*) VERSION;
+ return (const char*) "Unable to get version number";
}

const char*
@@ -68,14 +70,14 @@ avisBridge_getName (void)
return "avis";
}

-#define DEFAULT_PAYLOAD_NAME "avismsg"
-#define DEFAULT_PAYLOAD_ID MAMA_PAYLOAD_AVIS
+static const char* PAYLOAD_NAMES[] = {"avismsg",NULL};
+static const char PAYLOAD_IDS[] = {MAMA_PAYLOAD_AVIS,NULL};

mama_status
-avisBridge_getDefaultPayloadId (char**name, char* id)
+avisBridge_getDefaultPayloadId (char***name, char** id)
{
- *name=DEFAULT_PAYLOAD_NAME;
- *id=DEFAULT_PAYLOAD_ID;
+ *name = PAYLOAD_NAMES;
+ *id = PAYLOAD_IDS;

return MAMA_STATUS_OK;
}
@@ -87,6 +89,7 @@ avisBridge_open (mamaBridge bridgeImpl)
mama_status status = MAMA_STATUS_OK;
mamaBridgeImpl* impl = (mamaBridgeImpl*)bridgeImpl;

+ wsocketstartup();
mama_log (MAMA_LOG_LEVEL_FINEST, "avisBridge_open(): Entering.");

if (MAMA_STATUS_OK !=
@@ -123,10 +126,11 @@ avisBridge_open (mamaBridge bridgeImpl)
mama_status
avisBridge_close (mamaBridge bridgeImpl)
{
+ mama_status status = MAMA_STATUS_OK;
+ mamaBridgeImpl* impl = NULL;
mama_log (MAMA_LOG_LEVEL_FINEST, "avisBridge_close(): Entering.");

- mama_status status = MAMA_STATUS_OK;
- mamaBridgeImpl* impl = (mamaBridgeImpl*)bridgeImpl;
+ impl = (mamaBridgeImpl*)bridgeImpl;


if (0 != destroyHeap (gTimerHeap))
@@ -139,6 +143,7 @@ avisBridge_close (mamaBridge bridgeImpl)
mamaQueue_destroyWait(impl->mDefaultEventQueue);

free (impl);
+ wsocketcleanup();
return status;
}

@@ -146,12 +151,12 @@ avisBridge_close (mamaBridge bridgeImpl)
mama_status
avisBridge_start(mamaQueue defaultEventQueue)
{
- mama_log (MAMA_LOG_LEVEL_FINER, "avisBridge_start(): Start dispatching on default event queue.");
-
mama_status status = MAMA_STATUS_OK;
+ avisBridgeImpl* avisBridge = NULL;
+
+ mama_log (MAMA_LOG_LEVEL_FINER, "avisBridge_start(): Start dispatching on default event queue.");

// start Avis event loop(s)
- avisBridgeImpl* avisBridge;
if (MAMA_STATUS_OK != (status = mamaBridgeImpl_getClosure((mamaBridge) mamaQueueImpl_getBridgeImpl(defaultEventQueue), (void**) &avisBridge))) {
mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridge_start(): Could not get Elvin object");
return status;
@@ -168,11 +173,10 @@ avisBridge_start(mamaQueue defaultEventQueue)
mama_status
avisBridge_stop(mamaQueue defaultEventQueue)
{
- mama_log (MAMA_LOG_LEVEL_FINER, "avisBridge_stop(): Stopping bridge.");
-
mama_status status = MAMA_STATUS_OK;
+ avisBridgeImpl* avisBridge = NULL;

- avisBridgeImpl* avisBridge;
+ mama_log (MAMA_LOG_LEVEL_FINER, "avisBridge_stop(): Stopping bridge.");
if (MAMA_STATUS_OK != (status = mamaBridgeImpl_getClosure((mamaBridge) mamaQueueImpl_getBridgeImpl(defaultEventQueue), (void**) &avisBridge))) {
mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridge_stop(): Could not get Elvin object");
return status;
diff --git a/mama/c_cpp/src/c/bridge/avis/transportbridge.c b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
index c994879..de10b61 100755
--- a/mama/c_cpp/src/c/bridge/avis/transportbridge.c
+++ b/mama/c_cpp/src/c/bridge/avis/transportbridge.c
@@ -29,6 +29,7 @@
#include <mama/types.h>
#include <transportimpl.h>
#include <timers.h>
+#include <errno.h>
#include "transportbridge.h"
#include "avisbridgefunctions.h"
#include "avisdefs.h"
@@ -59,14 +60,12 @@ void log_avis_error(MamaLogLevel logLevel, Elvin* avis)

void closeListener(Elvin* avis, CloseReason reason, const char* message, void* closure)
{
+ const char* errMsg;
if (avisBridge(closure) == NULL) {
mama_log (MAMA_LOG_LEVEL_FINE, "Avis closeListener: could not get Avis bridge");
return;
}

- // TODO -- serialize access across multiple threads
-
- const char* errMsg;
switch( reason )
{
case REASON_CLIENT_SHUTDOWN: errMsg = "Avis client shutdown"; break;
@@ -82,16 +81,19 @@ void closeListener(Elvin* avis, CloseReason reason, const char* message, void* c
static const char*
getURL( const char *name )
{
+ int len = 0;
+ char* buff = NULL;
+ const char* property = NULL;
if (name == NULL)
return NULL;

mama_log (MAMA_LOG_LEVEL_FINE, "initializing Avis transport: %s", name);
- int len = strlen(name) + strlen( TPORT_PREFIX ) + strlen(TPORT_PARAM) + 4;
- char* buff = (char *)alloca( len );
+ len = strlen(name) + strlen( TPORT_PREFIX ) + strlen(TPORT_PARAM) + 4;
+ buff = (char *)alloca( len );
memset(buff, '\0', len);
snprintf( buff, len, "%s.%s.%s", TPORT_PREFIX, name, TPORT_PARAM );

- const char* property = properties_Get( mamaInternal_getProperties(), buff );
+ property = properties_Get( mamaInternal_getProperties(), buff );
if ( property == NULL )
return DEFAULT_URL;

@@ -123,13 +125,13 @@ void* avisDispatchThread(void* closure)

mama_status avisTransportBridge_start(avisTransportBridge* transportBridge)
{
- CHECK_TRANSPORT(transportBridge);
-
// stop Avis event loop
- pthread_t tid;
+ wthread_t tid;
int rc;
- if (0 != (rc = pthread_create(&tid, NULL, avisDispatchThread, transportBridge))) {
- mama_log (MAMA_LOG_LEVEL_ERROR, "pthread_create returned %d", rc);
+ CHECK_TRANSPORT(transportBridge);
+
+ if (0 != (rc = wthread_create(&tid, NULL, avisDispatchThread, transportBridge))) {
+ mama_log (MAMA_LOG_LEVEL_ERROR, "wthread_create returned %d", rc);
return MAMA_STATUS_SYSTEM_ERROR;
}

@@ -193,22 +195,24 @@ avisBridgeMamaTransport_create (transportBridge* result,
const char* name,
mamaTransport mamaTport )
{
- avisTransportBridge* transport =
- (avisTransportBridge*)calloc( 1, sizeof( avisTransportBridge ) );
+ mama_status status;
+ avisBridgeImpl* avisBridge = NULL;
+ avisTransportBridge* transport = NULL;
+ mamaBridgeImpl* bridgeImpl = NULL;
+ const char* url = NULL;
+
+ transport = (avisTransportBridge*)calloc( 1, sizeof( avisTransportBridge ) );
if (transport == NULL)
return MAMA_STATUS_NOMEM;

transport->mTransport = (mamaTransport) mamaTport;

- // TODO -- serialize access across multiple threads
- mamaBridgeImpl* bridgeImpl = mamaTransportImpl_getBridgeImpl(mamaTport);
+ bridgeImpl = mamaTransportImpl_getBridgeImpl(mamaTport);
if (!bridgeImpl) {
mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridgeMamaTransport_create(): Could not get bridge");
free(transport);
return MAMA_STATUS_PLATFORM;
}
- mama_status status;
- avisBridgeImpl* avisBridge;
if (MAMA_STATUS_OK != (status = mamaBridgeImpl_getClosure((mamaBridge) bridgeImpl, (void**) &avisBridge))) {
mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridgeMamaTransport_create(): Could not get Avis bridge object");
free(transport);
@@ -229,7 +233,7 @@ avisBridgeMamaTransport_create (transportBridge* result,
}

// open the server connection
- const char* url = getURL(name);
+ url = getURL(name);
if (url == NULL) {
mama_log (MAMA_LOG_LEVEL_NORMAL, "No %s property defined for transport : %s", TPORT_PARAM, name);
return MAMA_STATUS_INVALID_ARG;
@@ -253,15 +257,17 @@ avisBridgeMamaTransport_create (transportBridge* result,
mama_status
avisBridgeMamaTransport_destroy (transportBridge transport)
{
- // TODO -- serialize access across multiple threads
- mamaBridgeImpl* bridgeImpl = mamaTransportImpl_getBridgeImpl(avisTransport(transport)->mTransport);
+ mama_status status;
+ avisBridgeImpl* avisBridge = NULL;
+ mamaBridgeImpl* bridgeImpl = NULL;
+
+
+ bridgeImpl = mamaTransportImpl_getBridgeImpl(avisTransport(transport)->mTransport);
if (!bridgeImpl) {
mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridgeMamaTransport_create(): Could not get bridge");
free(transport);
return MAMA_STATUS_PLATFORM;
}
- mama_status status;
- avisBridgeImpl* avisBridge;
if (MAMA_STATUS_OK != (status = mamaBridgeImpl_getClosure((mamaBridge) bridgeImpl, (void**) &avisBridge))) {
mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridgeMamaTransport_create(): Could not get Avis bridge object");
free(transport);
@@ -286,6 +292,15 @@ avisBridgeMamaTransport_isValid (transportBridge transport)
}

mama_status
+avisBridgeMamaTransport_forceClientDisconnect (transportBridge* transports,
+ int numTransports,
+ const char* ipAddress,
+ uint16_t port)
+{
+ return MAMA_STATUS_NOT_IMPLEMENTED;
+}
+
+mama_status
avisBridgeMamaTransport_findConnection (transportBridge* transports,
int numTransports,
mamaConnection* result,
--
1.7.7.6

101 - 120 of 2305