[PATCH 30/50] [avis] Fixed Compiler Warnings
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Moved variable declarations to the beginning of blocks as intermingling decarations and code is not allowed pre-C99. Also fixed a few other minor warnings. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/c/bridge/avis/msg.c | 11 +++++------ mama/c_cpp/src/c/bridge/avis/publisher.c | 30 ++++++++++++++++++------------ mama/c_cpp/src/c/bridge/avis/queue.c | 18 ++++++++++-------- mama/c_cpp/src/c/bridge/avis/sub.c | 6 +++--- mama/c_cpp/src/c/bridge/avis/timer.c | 6 +++--- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/mama/c_cpp/src/c/bridge/avis/msg.c b/mama/c_cpp/src/c/bridge/avis/msg.c index 8cc97eb..b422543 100644 --- a/mama/c_cpp/src/c/bridge/avis/msg.c +++ b/mama/c_cpp/src/c/bridge/avis/msg.c @@ -53,10 +53,11 @@ typedef struct avisMsgImpl mama_status avisBridgeMamaMsg_create (msgBridge* msg, mamaMsg parent) { + avisMsgImpl* impl; if (avisMsg(msg) == NULL) return MAMA_STATUS_NULL_ARG; *msg = NULL; - avisMsgImpl* impl = (avisMsgImpl*) calloc(1, sizeof(avisMsgImpl)); + impl = (avisMsgImpl*) calloc(1, sizeof(avisMsgImpl)); if (!impl) return MAMA_STATUS_NOMEM; mamaMsg_getNativeMsg(parent, (void**)&impl->mAvisMsg); @@ -109,8 +110,8 @@ avisBridgeMamaMsg_getPlatformError (msgBridge msg, void** error) mama_status avisBridgeMamaMsgImpl_setReplyHandle (msgBridge msg, void* result) { - CHECK_MSG(msg); mama_status status = MAMA_STATUS_OK; + CHECK_MSG(msg); if (MAMA_STATUS_OK != (status = mamaMsg_updateString(avisMsg(msg)->mParent, INBOX_FIELD_NAME, 0, (const char*) result))) { return status; } @@ -137,10 +138,9 @@ avisBridgeMamaMsg_setSendSubject (msgBridge msg, const char* symbol, const char* subject) { + mama_status status = MAMA_STATUS_OK; CHECK_MSG(msg); - // TODO -- symbol? - mama_status status = MAMA_STATUS_OK; if (MAMA_STATUS_OK != (status = mamaMsg_updateString(avisMsg(msg)->mParent, SUBJECT_FIELD_NAME, 0, subject))) { return status; } @@ -164,10 +164,9 @@ avisBridgeMamaMsg_getNativeHandle (msgBridge msg, void** result) mama_status avisBridgeMamaMsg_duplicateReplyHandle (msgBridge msg, void** result) { - CHECK_MSG(msg); - const char* replyAddr; mama_status status = MAMA_STATUS_OK; + CHECK_MSG(msg); if (MAMA_STATUS_OK != (status = mamaMsg_getString(avisMsg(msg)->mParent, INBOX_FIELD_NAME, 0, &replyAddr))) { return status; } diff --git a/mama/c_cpp/src/c/bridge/avis/publisher.c b/mama/c_cpp/src/c/bridge/avis/publisher.c index bc416fa..faaceb7 100644 --- a/mama/c_cpp/src/c/bridge/avis/publisher.c +++ b/mama/c_cpp/src/c/bridge/avis/publisher.c @@ -67,12 +67,14 @@ avisBridgeMamaPublisher_createByIndex (publisherBridge* result, void* nativeQueueHandle, mamaPublisher parent) { - if (!result || !tport) return MAMA_STATUS_NULL_ARG; Elvin* avis = getAvis(tport); + avisPublisherBridge* publisher = NULL; + + if (!result || !tport) return MAMA_STATUS_NULL_ARG; CHECK_AVIS(avis); *result = NULL; - avisPublisherBridge* publisher = (avisPublisherBridge*) calloc (1, sizeof(avisPublisherBridge)); + publisher = (avisPublisherBridge*) calloc (1, sizeof(avisPublisherBridge)); if (publisher == NULL) return MAMA_STATUS_NOMEM; publisher->mTransport = tport; @@ -145,10 +147,11 @@ avisBridgeMamaPublisherImpl_buildSendSubject (avisPublisherBridge* impl) mama_status avisBridgeMamaPublisher_send (publisherBridge publisher, mamaMsg msg) { - CHECK_PUBLISHER(publisher); mama_size_t dataLen; mama_status status; - Attributes* attributes; + Attributes* attributes = NULL; + + CHECK_PUBLISHER(publisher); status = mamaMsgImpl_getPayloadBuffer (msg, (const void**)&attributes, &dataLen); if (attributes == NULL) @@ -173,18 +176,20 @@ avisBridgeMamaPublisher_sendReplyToInbox (publisherBridge publisher, mamaMsg request, mamaMsg reply) { - CHECK_PUBLISHER(publisher); Attributes* requestMsg = NULL; Attributes* replyMsg = NULL; + const char* replyAddr = NULL; mama_size_t dataLen; + mama_status status; + + CHECK_PUBLISHER(publisher); mamaMsg_getNativeHandle(request, (void**) &requestMsg); mamaMsgImpl_getPayloadBuffer (reply, (const void**)&replyMsg, &dataLen); if (!requestMsg || !replyMsg) return MAMA_STATUS_NULL_ARG; - const char* replyAddr = NULL; - mama_status status = mamaMsg_getString(request, INBOX_FIELD_NAME, 0, &replyAddr); + status = mamaMsg_getString(request, INBOX_FIELD_NAME, 0, &replyAddr); if ((status != MAMA_STATUS_OK) || (replyAddr == NULL) || (strlen(replyAddr) == 0)) { mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridgeMamaPublisher_sendReplyToInbox(): " "No reply address in message."); @@ -223,6 +228,8 @@ avisBridgeMamaPublisher_sendFromInboxByIndex (publisherBridge publisher, mamaInbox inbox, mamaMsg msg) { + const char* replyAddr = NULL; + mama_status status; // CHECK_PUBLISHER(publisher); if (avisPublisher(publisher) == 0) return MAMA_STATUS_NULL_ARG; @@ -231,13 +238,11 @@ avisBridgeMamaPublisher_sendFromInboxByIndex (publisherBridge publisher, if (!elvin_is_open(avisPublisher(publisher)->mAvis)) return MAMA_STATUS_INVALID_ARG; - - // get reply address from inbox - const char* replyAddr = avisInboxImpl_getReplySubject(mamaInboxImpl_getInboxBridge(inbox)); + replyAddr = avisInboxImpl_getReplySubject(mamaInboxImpl_getInboxBridge(inbox)); // set reply address in msg - mama_status status = mamaMsg_updateString(msg, INBOX_FIELD_NAME, 0, replyAddr); + status = mamaMsg_updateString(msg, INBOX_FIELD_NAME, 0, replyAddr); if (status != MAMA_STATUS_OK) return status; @@ -258,9 +263,10 @@ avisBridgeMamaPublisher_sendReplyToInboxHandle (publisherBridge publisher, void * inbox, mamaMsg reply) { + mama_status status; CHECK_PUBLISHER(publisher); - mama_status status = mamaMsg_updateString(reply, SUBJECT_FIELD_NAME, 0, (const char*) inbox); + status = mamaMsg_updateString(reply, SUBJECT_FIELD_NAME, 0, (const char*) inbox); if (status != MAMA_STATUS_OK) return status; diff --git a/mama/c_cpp/src/c/bridge/avis/queue.c b/mama/c_cpp/src/c/bridge/avis/queue.c index 24ee8d1..fd8c629 100644 --- a/mama/c_cpp/src/c/bridge/avis/queue.c +++ b/mama/c_cpp/src/c/bridge/avis/queue.c @@ -51,11 +51,12 @@ mama_status avisBridgeMamaQueue_create (queueBridge* queue, mamaQueue parent) { + avisQueueBridge* avisQueue = NULL; if (queue == NULL) return MAMA_STATUS_NULL_ARG; *queue = NULL; - avisQueueBridge* avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge)); + avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge)); if (avisQueue == NULL) return MAMA_STATUS_NOMEM; @@ -74,11 +75,12 @@ avisBridgeMamaQueue_create_usingNative (queueBridge* queue, mamaQueue parent, void* nativeQueue) { + avisQueueBridge* avisQueue = NULL; if (queue == NULL) return MAMA_STATUS_NULL_ARG; *queue = NULL; - avisQueueBridge* avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge)); + avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge)); if (avisQueue == NULL) return MAMA_STATUS_NOMEM; @@ -104,9 +106,9 @@ avisBridgeMamaQueue_destroy (queueBridge queue) mama_status avisBridgeMamaQueue_dispatch (queueBridge queue) { - CHECK_QUEUE(queue); wombatQueueStatus status; + CHECK_QUEUE(queue); do { /* 500 is .5 seconds */ @@ -132,8 +134,8 @@ avisBridgeMamaQueue_dispatch (queueBridge queue) mama_status avisBridgeMamaQueue_timedDispatch (queueBridge queue, uint64_t timeout) { - CHECK_QUEUE(queue); wombatQueueStatus status; + CHECK_QUEUE(queue); status = wombatQueue_timedDispatch (avisQueue(queue)->mQueue, NULL, NULL, timeout); @@ -154,8 +156,8 @@ avisBridgeMamaQueue_timedDispatch (queueBridge queue, uint64_t timeout) mama_status avisBridgeMamaQueue_dispatchEvent (queueBridge queue) { - CHECK_QUEUE(queue); wombatQueueStatus status; + CHECK_QUEUE(queue); status = wombatQueue_dispatch (avisQueue(queue)->mQueue, NULL, NULL); @@ -186,10 +188,10 @@ avisBridgeMamaQueue_enqueueEvent (queueBridge queue, void* closure) { wombatQueueStatus status; + avisQueueClosure* cl = NULL; CHECK_QUEUE(queue); - avisQueueClosure* cl = - (avisQueueClosure*)calloc(1, sizeof(avisQueueClosure)); + cl = (avisQueueClosure*)calloc(1, sizeof(avisQueueClosure)); if (NULL == cl) return MAMA_STATUS_NOMEM; cl->mImpl = avisQueue(queue); @@ -208,8 +210,8 @@ avisBridgeMamaQueue_enqueueEvent (queueBridge queue, mama_status avisBridgeMamaQueue_stopDispatch (queueBridge queue) { - CHECK_QUEUE(queue); wombatQueueStatus status; + CHECK_QUEUE(queue); if (queue == NULL) return MAMA_STATUS_NULL_ARG; diff --git a/mama/c_cpp/src/c/bridge/avis/sub.c b/mama/c_cpp/src/c/bridge/avis/sub.c index edc026b..08fc697 100644 --- a/mama/c_cpp/src/c/bridge/avis/sub.c +++ b/mama/c_cpp/src/c/bridge/avis/sub.c @@ -153,7 +153,6 @@ avis_queue_callback (void* data, void* closure) attributes_free ((Attributes*)data); free ((Attributes*)data); - } static void @@ -199,10 +198,11 @@ avisBridgeMamaSubscription_create (subscriptionBridge* subscriber, mamaSubscription subscription, void* closure) { + avisSubscription* impl = NULL; if (!subscriber || !subscription || !transport ) return MAMA_STATUS_NULL_ARG; - avisSubscription* impl = (avisSubscription*)calloc (1, sizeof(avisSubscription)); + impl = (avisSubscription*)calloc (1, sizeof(avisSubscription)); if (impl == NULL) return MAMA_STATUS_NOMEM; @@ -269,9 +269,9 @@ avisBridgeMamaSubscription_createWildCard ( mama_status avisBridgeMamaSubscription_destroy (subscriptionBridge subscriber) { - CHECK_SUBSCRIBER(subscriber); mama_status status = MAMA_STATUS_OK; wombatQueue queue = NULL; + CHECK_SUBSCRIBER(subscriber); elvin_subscription_remove_listener(avisSub(subscriber)->mAvisSubscription, avis_callback); diff --git a/mama/c_cpp/src/c/bridge/avis/timer.c b/mama/c_cpp/src/c/bridge/avis/timer.c index 7a69051..18aad31 100755 --- a/mama/c_cpp/src/c/bridge/avis/timer.c +++ b/mama/c_cpp/src/c/bridge/avis/timer.c @@ -72,7 +72,7 @@ timerCb (timerElement timer, /* Mama timers are repeating */ timeout.tv_sec = (time_t)impl->mInterval; - timeout.tv_usec = (suseconds_t)((impl->mInterval- timeout.tv_sec) * 1000000.0); + timeout.tv_usec = ((impl->mInterval- timeout.tv_sec) * 1000000.0); if (0 != createTimer (&impl->mTimerElement, gTimerHeap, timerCb, @@ -122,7 +122,7 @@ avisBridgeMamaTimer_create (timerBridge* result, *result = (timerBridge)impl; timeout.tv_sec = (time_t)interval; - timeout.tv_usec = (suseconds_t)((interval-timeout.tv_sec) * 1000000.0); + timeout.tv_usec = ((interval-timeout.tv_sec) * 1000000.0); if (0 != createTimer (&impl->mTimerElement, gTimerHeap, timerCb, @@ -180,7 +180,7 @@ avisBridgeMamaTimer_reset (timerBridge timer) impl = (avisTimerImpl*)timer; timeout.tv_sec = (time_t)impl->mInterval; - timeout.tv_usec = (suseconds_t)((impl->mInterval-timeout.tv_sec) * 1000000.0); + timeout.tv_usec = ((impl->mInterval-timeout.tv_sec) * 1000000.0); if (timer == NULL) return MAMA_STATUS_NULL_ARG; -- 1.7.7.6
|
|
[PATCH 31/50] [avis] Windows Changes
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Callbacks must be declared with the correct calling convention for Windows. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/c/bridge/avis/msg.c | 3 +-- mama/c_cpp/src/c/bridge/avis/queue.c | 2 +- mama/c_cpp/src/c/bridge/avis/sub.c | 4 ++-- mama/c_cpp/src/c/bridge/avis/subinitial.c | 8 ++++---- mama/c_cpp/src/c/bridge/avis/timer.c | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/mama/c_cpp/src/c/bridge/avis/msg.c b/mama/c_cpp/src/c/bridge/avis/msg.c index b422543..c0553af 100644 --- a/mama/c_cpp/src/c/bridge/avis/msg.c +++ b/mama/c_cpp/src/c/bridge/avis/msg.c @@ -84,8 +84,7 @@ mama_status avisBridgeMamaMsg_destroyMiddlewareMsg (msgBridge msg) { CHECK_MSG(msg); - attributes_free(avisMsg(msg)->mAvisMsg); - free(avisMsg(msg)->mAvisMsg); + attributes_destroy(avisMsg(msg)->mAvisMsg); avisMsg(msg)->mAvisMsg = NULL; return MAMA_STATUS_OK; diff --git a/mama/c_cpp/src/c/bridge/avis/queue.c b/mama/c_cpp/src/c/bridge/avis/queue.c index fd8c629..1e7263c 100644 --- a/mama/c_cpp/src/c/bridge/avis/queue.c +++ b/mama/c_cpp/src/c/bridge/avis/queue.c @@ -174,7 +174,7 @@ avisBridgeMamaQueue_dispatchEvent (queueBridge queue) return MAMA_STATUS_OK; } -static void queueCb (void *ignored, void* closure) +static void MAMACALLTYPE queueCb (void *ignored, void* closure) { avisQueueClosure* cl = (avisQueueClosure*)closure; if (NULL ==cl) return; diff --git a/mama/c_cpp/src/c/bridge/avis/sub.c b/mama/c_cpp/src/c/bridge/avis/sub.c index 08fc697..5d0752d 100644 --- a/mama/c_cpp/src/c/bridge/avis/sub.c +++ b/mama/c_cpp/src/c/bridge/avis/sub.c @@ -72,7 +72,7 @@ const char* makeAvisSubject(const char* subject) } -static void +static void MAMACALLTYPE destroy_callback(void* subscriber, void* closure) { // cant do anything without a subscriber @@ -92,7 +92,7 @@ destroy_callback(void* subscriber, void* closure) * @param data The Avis Attributes* clone (must be freed) * @param closure The subscriber */ -static void +static void MAMACALLTYPE avis_queue_callback (void* data, void* closure) { mama_status status; diff --git a/mama/c_cpp/src/c/bridge/avis/subinitial.c b/mama/c_cpp/src/c/bridge/avis/subinitial.c index 95c8ff3..7f58441 100644 --- a/mama/c_cpp/src/c/bridge/avis/subinitial.c +++ b/mama/c_cpp/src/c/bridge/avis/subinitial.c @@ -50,7 +50,7 @@ typedef struct avisInboxImpl } while(0) -static void +static void MAMACALLTYPE avisInbox_onMsg( mamaSubscription subscription, mamaMsg msg, @@ -63,14 +63,14 @@ avisInbox_onMsg( (avisInbox(closure)->mMsgCB)(msg, avisInbox(closure)->mClosure); } -static void +static void MAMACALLTYPE avisInbox_onCreate( mamaSubscription subscription, void* closure) { } -static void +static void MAMACALLTYPE avisInbox_onDestroy( mamaSubscription subscription, void* closure) @@ -81,7 +81,7 @@ avisInbox_onDestroy( (avisInbox(closure)->mOnInboxDestroyed)(avisInbox(closure)->mParent, avisInbox(closure)->mClosure); } -static void +static void MAMACALLTYPE avisInbox_onError( mamaSubscription subscription, mama_status status, diff --git a/mama/c_cpp/src/c/bridge/avis/timer.c b/mama/c_cpp/src/c/bridge/avis/timer.c index 18aad31..4489ac6 100755 --- a/mama/c_cpp/src/c/bridge/avis/timer.c +++ b/mama/c_cpp/src/c/bridge/avis/timer.c @@ -42,7 +42,7 @@ typedef struct avisTimerImpl_ /* TODO: add queue */ } avisTimerImpl; -static void +static void MAMACALLTYPE destroy_callback(void* timer, void* closure) { avisTimerImpl* impl = (avisTimerImpl*)timer; @@ -51,7 +51,7 @@ destroy_callback(void* timer, void* closure) free (impl); } -static void +static void MAMACALLTYPE timerQueueCb (void* data, void* closure) { avisTimerImpl* impl = (avisTimerImpl*)data; -- 1.7.7.6
|
|
[PATCH 32/50] [avis-payload] Fixed compiler warnings
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Primarily moved declarations to beginning of scope for non-C99 compliant compilers Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/c/payload/avismsg/avispayload.c | 103 +++++++++++++---------- mama/c_cpp/src/c/payload/avismsg/avispayload.h | 2 + mama/c_cpp/src/c/payload/avismsg/msgfield.c | 2 +- 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/mama/c_cpp/src/c/payload/avismsg/avispayload.c b/mama/c_cpp/src/c/payload/avismsg/avispayload.c index 28cca7a..f3c044a 100755 --- a/mama/c_cpp/src/c/payload/avismsg/avispayload.c +++ b/mama/c_cpp/src/c/payload/avismsg/avispayload.c @@ -131,15 +131,17 @@ avismsgPayload_getType () mama_status avismsgPayload_create (msgPayload* msg) { - if (!msg) return MAMA_STATUS_NULL_ARG; Attributes* avisMsg = attributes_create(); + avisPayloadImpl* newPayload = NULL; + + if (!msg) return MAMA_STATUS_NULL_ARG; if (!avisMsg) { mama_log (MAMA_LOG_LEVEL_ERROR, "attributes_create() failed. Could not create Avis msg"); return MAMA_STATUS_PLATFORM; } - avisPayloadImpl* newPayload = (avisPayloadImpl*)calloc (1, sizeof(avisPayloadImpl)); + newPayload = (avisPayloadImpl*)calloc (1, sizeof(avisPayloadImpl)); newPayload->mAvisMsg=avisMsg; *msg = newPayload; @@ -194,8 +196,7 @@ mama_status avismsgPayload_destroy (msgPayload msg) { CHECK_PAYLOAD(msg); - attributes_free(avisPayload(msg)); - free(avisPayload(msg)); + attributes_destroy(avisPayload(msg)); avismsgPayloadIter_destroy(avisPayloadImpl(msg)->mIterator); free(avisPayloadImpl(msg)->mAvisField); @@ -205,7 +206,7 @@ avismsgPayload_destroy (msgPayload msg) } mama_status -avisPayload_setParent (msgPayload msg, +avismsgPayload_setParent (msgPayload msg, const mamaMsg parent) { avisPayloadImpl* impl = (avisPayloadImpl*) msg; @@ -236,15 +237,15 @@ avismsgPayload_unSerialize (const msgPayload msg, int64_t tempint64; real64_t tempreal64; + uint32_t currLen = 1; + uint16_t len =0; + uint8_t * buffPos = (void*)buffer; if (!impl->mAvisMsg) impl->mAvisMsg = attributes_create(); else attributes_clear(impl->mAvisMsg); - uint32_t currLen = 1; - uint16_t len =0; - void * buffPos = (void*)buffer; buffPos+=1; // Skip payload identifier while (currLen < bufferLength) { @@ -307,7 +308,12 @@ avismsgPayload_serialize (const msgPayload msg, mama_size_t* bufferLength) { avisPayloadImpl* impl = (avisPayloadImpl*) msg; - mama_status status = MAMA_STATUS_OK; + uint8_t * buffPos = NULL; + mama_status status = MAMA_STATUS_OK; + uint16_t len = 0; + uint32_t currLen = 0; + avisFieldPayload* currField = NULL; + if (!impl->mIterator) { status = avismsgPayloadIter_create((msgPayloadIter*) &impl->mIterator, msg); @@ -333,10 +339,8 @@ avismsgPayload_serialize (const msgPayload msg, impl->mBufferLen = 200; } - void * buffPos = impl->mBuffer; - uint16_t len =0; - uint32_t currLen = 0; - avisFieldPayload* currField = avismsgPayloadIter_begin(impl->mIterator, (msgFieldPayload) impl->mAvisField, msg); + buffPos = impl->mBuffer; + currField = avismsgPayloadIter_begin(impl->mIterator, (msgFieldPayload) impl->mAvisField, msg); *(int8_t *)(buffPos) = MAMA_PAYLOAD_AVIS; buffPos+=1; currLen+=1; @@ -346,12 +350,13 @@ avismsgPayload_serialize (const msgPayload msg, switch (currField->mValue->type) { case TYPE_INT32: - len=strlen(currField->mName); + len=(uint16_t)strlen(currField->mName); if (impl->mBufferLen < currLen+3+len+sizeof(int32_t)) { void*vp=realloc (impl->mBuffer, impl->mBufferLen+200); impl->mBuffer = vp; - buffPos=&impl->mBuffer[currLen]; + buffPos=(uint8_t *)impl->mBuffer; + buffPos+=currLen; impl->mBufferLen+=200; } *(int8_t *)(buffPos) = 1; buffPos+=1; currLen+=1; @@ -365,7 +370,8 @@ avismsgPayload_serialize (const msgPayload msg, { void*vp=realloc (impl->mBuffer, impl->mBufferLen+200); impl->mBuffer = vp; - buffPos=&impl->mBuffer[currLen]; + buffPos=&impl->mBuffer; + buffPos+=currLen; impl->mBufferLen+=200; } *(int8_t *)(buffPos) = 2; buffPos+=1; currLen+=1; @@ -379,7 +385,8 @@ avismsgPayload_serialize (const msgPayload msg, { void*vp=realloc (impl->mBuffer, impl->mBufferLen+200); impl->mBuffer = vp; - buffPos=&impl->mBuffer[currLen]; + buffPos=&impl->mBuffer; + buffPos+=currLen; impl->mBufferLen+=200; } *(int8_t *)(buffPos) = 3; buffPos+=1; currLen+=1; @@ -393,7 +400,8 @@ avismsgPayload_serialize (const msgPayload msg, { void*vp=realloc (impl->mBuffer, impl->mBufferLen+200); impl->mBuffer = vp; - buffPos=&impl->mBuffer[currLen]; + buffPos=&impl->mBuffer; + buffPos+=currLen; impl->mBufferLen+=200; } *(int8_t *)(buffPos) = 4; buffPos+=1; currLen+=1; @@ -420,8 +428,8 @@ avismsgPayload_getByteBuffer (const msgPayload msg, const void** buffer, mama_size_t* bufferLength) { - CHECK_PAYLOAD(msg); avisPayloadImpl* impl = (avisPayloadImpl*)msg; + CHECK_PAYLOAD(msg); *buffer = impl->mAvisMsg; @@ -435,8 +443,8 @@ avismsgPayload_setByteBuffer (const msgPayload msg, const void* buffer, mama_size_t bufferLength) { - CHECK_PAYLOAD(msg); avisPayloadImpl* impl = (avisPayloadImpl*)msg; + CHECK_PAYLOAD(msg); impl->mAvisMsg=(Attributes*) buffer; @@ -467,6 +475,10 @@ avismsgPayload_toString (const msgPayload msg) { avisPayloadImpl* impl = (avisPayloadImpl*)msg; mama_status status = MAMA_STATUS_OK; + char *strpos = NULL; + bool comma = false; + uint16_t curlen = 1; + avisFieldPayload* currField = NULL; if (!impl->mIterator) { status = avismsgPayloadIter_create((msgPayloadIter*) &impl->mIterator, msg); @@ -491,12 +503,12 @@ avismsgPayload_toString (const msgPayload msg) impl->mStringBufferLen = 200; } - char *strpos =impl->mStringBuffer; + strpos =impl->mStringBuffer; sprintf (strpos, "%s", "{");strpos++; - bool comma = false; - uint16_t curlen = 1; + comma = false; + curlen = 1; - avisFieldPayload* currField = avismsgPayloadIter_begin(impl->mIterator, (msgFieldPayload) impl->mAvisField, msg); + currField = avismsgPayloadIter_begin(impl->mIterator, (msgFieldPayload) impl->mAvisField, msg); while (currField != NULL) { char valueString[512]; avisValue_getFieldAsString(currField->mValue, NULL, 0, valueString, sizeof(valueString)); @@ -533,6 +545,7 @@ avismsgPayload_iterateFields (const msgPayload msg, { avisPayloadImpl* impl = (avisPayloadImpl*)msg; mama_status status = MAMA_STATUS_OK; + avisFieldPayload* currField = NULL; if (!impl->mIterator) { @@ -552,7 +565,7 @@ avismsgPayload_iterateFields (const msgPayload msg, return status; } - avisFieldPayload* currField = avismsgPayloadIter_begin(impl->mIterator, (msgFieldPayload) impl->mAvisField, msg); + currField = avismsgPayloadIter_begin(impl->mIterator, (msgFieldPayload) impl->mAvisField, msg); while (currField != NULL) { mamaMsgFieldImpl_setPayload (field, currField); (cb)(msg, field, closure); @@ -578,13 +591,12 @@ mama_status avismsgPayload_apply (msgPayload dest, const msgPayload src) { + avisPayloadImpl* implSrc = (avisPayloadImpl*)src; + mama_status status = MAMA_STATUS_OK; + avisFieldPayload* currField = NULL; CHECK_PAYLOAD(dest); CHECK_PAYLOAD(src); - avisPayloadImpl* implSrc = (avisPayloadImpl*)src; - - - mama_status status = MAMA_STATUS_OK; if (!implSrc->mIterator) { @@ -604,7 +616,7 @@ avismsgPayload_apply (msgPayload dest, return status; } - avisFieldPayload* currField = avismsgPayloadIter_begin(implSrc->mIterator, (msgFieldPayload) implSrc->mAvisField, src); + currField = avismsgPayloadIter_begin(implSrc->mIterator, (msgFieldPayload) implSrc->mAvisField, src); while (currField != NULL) { switch (currField->mValue->type) { @@ -1544,23 +1556,23 @@ avismsgPayload_getField (const msgPayload msg, mama_fid_t fid, msgFieldPayload* result) { + avisPayloadImpl* impl = (avisPayloadImpl*)msg; + char tempName[64]; + char* id = (char*) name; + Value* pValue = NULL; CHECK_PAYLOAD(msg); CHECK_NAME(name, fid); - avisPayloadImpl* impl = (avisPayloadImpl*)msg; - if ( (!impl->mAvisField) && (avismsgFieldPayload_create((msgFieldPayload*) &impl->mAvisField) != MAMA_STATUS_OK) ) { return MAMA_STATUS_PLATFORM; } - char tempName[64]; - char* id = (char*) name; if (fid!=0) { snprintf (tempName, 63, "%d", fid); id=tempName; } - Value* pValue = attributes_get(avisPayload(msg), id); + pValue = attributes_get(avisPayload(msg), id); if ((!pValue) &&(name)) { pValue = attributes_get(avisPayload(msg), name); @@ -1816,9 +1828,10 @@ avismsgPayloadIter_create (msgPayloadIter* iter, msgPayload msg) { mama_status status = MAMA_STATUS_OK; + avisIterator* impl = NULL; CHECK_PAYLOAD(msg); - avisIterator* impl = calloc (1, sizeof (avisIterator)); + impl = calloc (1, sizeof (avisIterator)); if (!impl) return (MAMA_STATUS_NOMEM); impl->mMsgIterator = (AttributesIter*) avis_emalloc(sizeof(AttributesIter)); @@ -1843,16 +1856,15 @@ avismsgPayloadIter_get (msgPayloadIter iter, msgFieldPayload field, msgPayload msg) { + avisIterator* impl = (avisIterator*) iter; if (!iter || !msg || !field) return NULL; - avisIterator* impl = (avisIterator*) iter; - - avisField(field)->mName = attributes_iter_name(impl->mMsgIterator); - avisField(field)->mValue = attributes_iter_value(impl->mMsgIterator); + avisField(field)->mName = attributes_iter_name(impl->mMsgIterator); + avisField(field)->mValue = attributes_iter_value(impl->mMsgIterator); - if ((strcmp(SUBJECT_FIELD_NAME, avisField(field)->mName) == 0) || - (strcmp(INBOX_FIELD_NAME, avisField(field)->mName)== 0)) - return (avismsgPayloadIter_next(iter,field,msg)); + if ((strcmp(SUBJECT_FIELD_NAME, avisField(field)->mName) == 0) || + (strcmp(INBOX_FIELD_NAME, avisField(field)->mName)== 0)) + return (avismsgPayloadIter_next(iter,field,msg)); return field; } @@ -1862,9 +1874,9 @@ avismsgPayloadIter_next (msgPayloadIter iter, msgFieldPayload field, msgPayload msg) { + avisIterator* impl = (avisIterator*) iter; if (!iter || !msg || !field) return NULL; - avisIterator* impl = (avisIterator*) iter; if (!attributes_iter_next(impl->mMsgIterator)) return NULL; @@ -1904,8 +1916,9 @@ mama_status avismsgPayloadIter_associate (msgPayloadIter iter, msgPayload msg) { - CHECK_PAYLOAD(msg); avisIterator* impl = (avisIterator*) iter; + CHECK_PAYLOAD(msg); + if (!impl) return MAMA_STATUS_NULL_ARG; attributes_iter_init(impl->mMsgIterator, avisPayload(msg)); diff --git a/mama/c_cpp/src/c/payload/avismsg/avispayload.h b/mama/c_cpp/src/c/payload/avismsg/avispayload.h index a2c1388..2e87888 100755 --- a/mama/c_cpp/src/c/payload/avismsg/avispayload.h +++ b/mama/c_cpp/src/c/payload/avismsg/avispayload.h @@ -30,9 +30,11 @@ extern "C" { #endif +MAMAExpDLL extern mama_status avismsgPayload_destroyImpl (mamaPayloadBridge mamaPayloadBridge); +MAMAExpDLL extern mama_status avismsgPayload_createImpl (mamaPayloadBridge* result, char* identifier); diff --git a/mama/c_cpp/src/c/payload/avismsg/msgfield.c b/mama/c_cpp/src/c/payload/avismsg/msgfield.c index eb0c081..474055b 100755 --- a/mama/c_cpp/src/c/payload/avismsg/msgfield.c +++ b/mama/c_cpp/src/c/payload/avismsg/msgfield.c @@ -86,9 +86,9 @@ mamaMsgField_getDescriptor( const mamaMsgField msgField, mamaFieldDescriptor* result) { + mama_status status = MAMA_STATUS_OK; CHECK_FIELD(msgField); - mama_status status = MAMA_STATUS_OK; /* The FD may have already been obtained for this field from * getName, getFid etc.*/ if (avisField->mFieldDesc) -- 1.7.7.6
|
|
[PATCH 33/50] [examples] Changes for Windows
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Use correct calling convention for callbacks and a few other minor changes. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- 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 +- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/mama/c_cpp/src/examples/c/mamaftmemberc.c b/mama/c_cpp/src/examples/c/mamaftmemberc.c index 8ba53c2..e2e3aa9 100644 --- a/mama/c_cpp/src/examples/c/mamaftmemberc.c +++ b/mama/c_cpp/src/examples/c/mamaftmemberc.c @@ -51,14 +51,14 @@ static void parseCommandLine (int argc, const char **argv); static void initializeMama (void); static void createFtMember (void); -static void onFtStateChangeCb (mamaFtMember ftMember, +static void MAMACALLTYPE onFtStateChangeCb (mamaFtMember ftMember, const char* groupName, mamaFtState state, void* closure); static void usage (int exitStatus); -static void onFtStateChangeCb (mamaFtMember ftMember, +static void MAMACALLTYPE onFtStateChangeCb (mamaFtMember ftMember, const char* groupName, mamaFtState state, void* closure) diff --git a/mama/c_cpp/src/examples/c/mamainboxc.c b/mama/c_cpp/src/examples/c/mamainboxc.c index 4e2b9b7..48d50a7 100644 --- a/mama/c_cpp/src/examples/c/mamainboxc.c +++ b/mama/c_cpp/src/examples/c/mamainboxc.c @@ -198,6 +198,10 @@ static void sendRequest (void) exit (status); } + mama_log (MAMA_LOG_LEVEL_ERROR, + "mamaPublisher_sendFromInboxWithThrottle(): " + " %s", + mamaMsg_toString(msg)); /*The message can be destroyed once the sendCompleteCb has been invoked.*/ status = mamaPublisher_sendFromInboxWithThrottle (gPublisher, gInbox, msg, sendCompleteCb, NULL); diff --git a/mama/c_cpp/src/examples/c/mamalistenc.c b/mama/c_cpp/src/examples/c/mamalistenc.c index 80ca789..be270d1 100644 --- a/mama/c_cpp/src/examples/c/mamalistenc.c +++ b/mama/c_cpp/src/examples/c/mamalistenc.c @@ -763,7 +763,6 @@ transportCb (mamaTransport tport, void initializeMama (void) { mama_status status = MAMA_STATUS_OK; - mamaPayloadBridge payBridge = NULL; /* mama_setApplicationName should be called before mama_open(). diff --git a/mama/c_cpp/src/examples/c/mamamultisubscriberc.c b/mama/c_cpp/src/examples/c/mamamultisubscriberc.c index 2364ffb..c017dc9 100644 --- a/mama/c_cpp/src/examples/c/mamamultisubscriberc.c +++ b/mama/c_cpp/src/examples/c/mamamultisubscriberc.c @@ -21,7 +21,6 @@ #include "mama/mama.h" #include "string.h" -#include <unistd.h> #define MAX_BRIDGES 10 static const char * gTopic = "MAMA_TOPIC"; @@ -52,21 +51,24 @@ NULL static void parseCommandLine (int argc, const char **argv); static void initialize (void); static void createSubscriber (mamaBridge bridge, mamaTransport transport); -static void startCB ( mama_status status ); +static void MAMACALLTYPE startCB ( mama_status status ); static void start (void); static void displayMsg (mamaMsg msg); static void usage (int exitStatus); static void +MAMACALLTYPE displayCb (const mamaMsg msg, const mamaMsgField field, void * closure); static void +MAMACALLTYPE createCb (mamaSubscription subscription, void * closure); static void +MAMACALLTYPE errorCb (mamaSubscription subscription, mama_status status, void* platformError, @@ -74,6 +76,7 @@ errorCb (mamaSubscription subscription, void* closure); static void +MAMACALLTYPE msgCb (mamaSubscription subscription, mamaMsg msg, void * closure, @@ -189,7 +192,8 @@ static void createSubscriber (mamaBridge bridge, mamaTransport transport) } } -void startCB ( mama_status status ) +void MAMACALLTYPE +startCB ( mama_status status ) {} void start () @@ -206,6 +210,7 @@ void start () } static void +MAMACALLTYPE createCb (mamaSubscription subscription, void *closure) { if (gQuietLevel < 2) @@ -215,6 +220,7 @@ createCb (mamaSubscription subscription, void *closure) } static void +MAMACALLTYPE errorCb (mamaSubscription subscription, mama_status status, void* platformError, @@ -227,6 +233,7 @@ errorCb (mamaSubscription subscription, } static void +MAMACALLTYPE msgCb (mamaSubscription subscription, mamaMsg msg, void* closure, @@ -240,6 +247,7 @@ msgCb (mamaSubscription subscription, } void +MAMACALLTYPE displayCb (const mamaMsg msg, const mamaMsgField field, void* closure) diff --git a/mama/c_cpp/src/examples/c/mamaproxyc.c b/mama/c_cpp/src/examples/c/mamaproxyc.c index dfb5aa0..e50fb84 100644 --- a/mama/c_cpp/src/examples/c/mamaproxyc.c +++ b/mama/c_cpp/src/examples/c/mamaproxyc.c @@ -182,6 +182,10 @@ static void createPublisher () "_MD", NULL); + // Turn off updateing of the messages as incoming messages + // from FH already have seqnum and senderid + mamaDQPublisherManager_setSeqNum(gDQPubManager, 0); + mamaDQPublisherManager_setSenderId(gDQPubManager, 0); if (gSendSync) { mamaTimer_create (&gSyncTimer, gPubDefaultQueue, syncCallback, 15, gDQPubManager); diff --git a/mama/c_cpp/src/examples/c/mamapublisherc.c b/mama/c_cpp/src/examples/c/mamapublisherc.c index e00ea9d..a5fce51 100644 --- a/mama/c_cpp/src/examples/c/mamapublisherc.c +++ b/mama/c_cpp/src/examples/c/mamapublisherc.c @@ -305,7 +305,7 @@ inboundMsgCb (mamaSubscription subscription, if (gQuietLevel < 2) { - printf ("Recieved inbound msg. Sending response\n"); + printf ("Recieved inbound msg. (%s) Sending response\n", mamaMsg_toString (msg)); } if (!mamaMsg_isFromInbox (msg)) -- 1.7.7.6
|
|
[PATCH 34/50] [examples] Put C examples in .../examples/c
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
For consistency with the source tree and to keep the examples for different languages separate. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/examples/c/Makefile.am | 2 +- mama/c_cpp/src/examples/c/Makefile.sample | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mama/c_cpp/src/examples/c/Makefile.am b/mama/c_cpp/src/examples/c/Makefile.am index 9a71db8..ff9eb1c 100644 --- a/mama/c_cpp/src/examples/c/Makefile.am +++ b/mama/c_cpp/src/examples/c/Makefile.am @@ -62,7 +62,7 @@ dist_mamamultisubscriberc_SOURCES = mamamultisubscriberc.c dist_mamaftmemberc_SOURCES = mamaftmemberc.c # Additional installation directory for sample source code -exampledir = ${prefix}/examples/mama +exampledir = ${prefix}/examples/mama/c # Rule to install the example programs: example_DATA = \ diff --git a/mama/c_cpp/src/examples/c/Makefile.sample b/mama/c_cpp/src/examples/c/Makefile.sample index 718195e..513fcb0 100644 --- a/mama/c_cpp/src/examples/c/Makefile.sample +++ b/mama/c_cpp/src/examples/c/Makefile.sample @@ -13,7 +13,7 @@ # SOLARIS/Forte: The makefile will need modified to use the Solaris compiler. # See example below. #============================================================================= -API_HOME=../../ +API_HOME=../../../ ## Solaris/Forte compiler: #CXX = CC -- 1.7.7.6
|
|
[PATCH 35/50] [examples] Remove Properietary Property Entries
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/examples/mama.properties | 107 ++++++++++++------------------- 1 files changed, 41 insertions(+), 66 deletions(-) diff --git a/mama/c_cpp/src/examples/mama.properties b/mama/c_cpp/src/examples/mama.properties index b1663e3..59ff173 100644 --- a/mama/c_cpp/src/examples/mama.properties +++ b/mama/c_cpp/src/examples/mama.properties @@ -1,66 +1,41 @@ -################################################################################ -# Global MAMA properties for all middle ware -################################################################################ - -# The path and filename of the V5 Wirecache templates. If no path is given -# then the WOMBAT_PATH environment varible will be used for the path. -mama.wirecache.templates = wcache_templates.xml - -################################################################################ -# Example MAMA properties for Wombat messaging middle ware -################################################################################ - -# Disable WMW signal handlers for application which do not require default SHM -# cleanup and correctly shutdown their application -mama.wmw.disable_signal_handlers=1 - -# The transport name is wmw_tport - -# The transport name is wmw_tport -mama.wmw.transport.pub.is_naming=0 -mama.wmw.transport.pub.publish_port=1456 - -mama.wmw.transport.sub.is_naming=0 -mama.wmw.transport.sub.subscribe_address_0=127.0.0.1 -mama.wmw.transport.sub.subscribe_port_0=1456 - -################################################################################ -# Example MAMA properties for Data Fabric middle ware -# These properties require Data Fabric 6.0 or later -################################################################################ - -# See the NYSE Technologies Data Fabric Configuration Reference Guide for -# detailed explanations of all configuration options on Data Fabric - -# Data Fabric subscriber transport. The subscriber only requires the details of -# the Naming Service Daemon (NSD) which connects publisher to subscribers based -# on topics and groups. This transport can be used to subscribe to any publisher -# type. -mama.wmw.transport.wmw_sub.nsd_0=127.0.0.1:5151 - -# Data Fabric TCP publisher transport. The type defaults to TCP and is therefore -# not required. -mama.wmw.transport.tcp_pub.nsd_0=127.0.0.1:5151 - -# Data Fabric Remote Direct Memory Access (RDMA) publisher transport. -mama.wmw.transport.vms_pub.nsd_0=127.0.0.1:5151 -mama.wmw.transport.vms_pub.type=vms -mama.wmw.transport.vms_pub.publish_address=ib0 - -# Data Fabric Multicast Verbs (MultiVerb) publisher transport. -mama.wmw.transport.ibv_pub.nsd_0=127.0.0.1:5151 -mama.wmw.transport.ibv_pub.type=ibv -mama.wmw.transport.ibv_pub.publish_address=ib0 - -# Data Fabric transports for communicating via a Data Fabric Daemon (DFD) -# The DFD allows bridging between transports and can also be used to segregate -# environments. DFD communication is based on groups to control which -# subscribers connect to the DFD publishing transport and which publishers the -# DFD subscribing transport connects to. -mama.wmw.transport.tcp_dfd_pub.nsd_0=127.0.0.1:5151 -mama.wmw.transport.tcp_dfd_pub.pub_group=feed -mama.wmw.transport.tcp_dfd_pub.sub_groups=rr - -mama.wmw.transport.wmw_dfd_sub.nsd_0=127.0.0.1:5151 -mama.wmw.transport.wmw_dfd_sub.pub_group=dfd_rr -mama.wmw.transport.wmw_dfd_sub.sub_groups=dfd +# $Id: mama.properties.opensource,v 1.1.2.1.4.1 2012/04/17 10:52:12 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 +# +################################################################################ +# Global MAMA properties for all middle ware +################################################################################ + +# A comma delimited list of entitlements servers. Each server is specified as +# host[:port] +entitlement.servers=host1:8095,host2:8096,host3 + +# The lowest and highest TCP/IP port number +# on which a client will listen for requests +# from an entitlements server. +# Required for Concurrent Access Control +# and Dynamic Entitlement Updates functionality. +mama.entitlement.portlow=9500 +mama.entitlement.porthigh=9550 + +################################################################################ +# Example MAMA properties for AVIS messaging middle ware +################################################################################ +# URL for the avis router - default value is elvin://localhost +#mama.avis.transport.url=elvin://host1:5555 -- 1.7.7.6
|
|
[PATCH 36/50] [mama] Renamed Methods in ft.c for Consistency
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/c/ft.c | 25 ++++++++++--------------- 1 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mama/c_cpp/src/c/ft.c b/mama/c_cpp/src/c/ft.c index 97c9bae..a6b886c 100644 --- a/mama/c_cpp/src/c/ft.c +++ b/mama/c_cpp/src/c/ft.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <mama/ft.h> #include <mama/io.h> +#include <wombat/wCommon.h> #include <sys/types.h> @@ -97,9 +98,7 @@ static void bridgeFt_sendHeartbeat (mamaFtMember member); static int multicastFt_receiveHeartbeat(void* member); static int bridgeFt_receiveHeartbeat(void* member); -static const char* -multicastFt_getProperty(char *buffer, const char *propertyName, const char - *transportName); +const char *multicastFt_getProperty(char *buffer, const char *propertyName, const char *transportName); static int foundheartbeat=0; @@ -196,7 +195,7 @@ static mamaIo gReadHandler = NULL; /* General implementation functions. */ int receiveHeartbeat (mamaFtMemberImpl* impl); -void checkHeartbeat (mamaFtMemberImpl* impl, +void mamaCheckHeartbeat (mamaFtMemberImpl* impl, unsigned int hbWeight, unsigned int hbIncarnation, int hbPid, @@ -204,8 +203,6 @@ void checkHeartbeat (mamaFtMemberImpl* impl, int hbPrimary, char* hbGroupName); -struct in_addr wresolve_ip (const char * arg); - /* FT callbacks: */ static void MAMACALLTYPE ftSubCreateCb (mamaSubscription subscription, void* closure); @@ -665,7 +662,7 @@ mama_status resetTimeoutTimer (mamaFtMemberImpl* impl) return mamaTimer_reset (impl->myTimeoutTimer); } -int betterCredentials(mamaFtMemberImpl* impl, unsigned int weight, +int mamaBetterCredentials (mamaFtMemberImpl* impl, unsigned int weight, unsigned int incarnation, in_addr_t ipAddr, int pid) { if (weight > impl->myWeight) @@ -698,7 +695,7 @@ int betterCredentials(mamaFtMemberImpl* impl, unsigned int weight, } -void checkHeartbeat (mamaFtMemberImpl* impl, +void mamaCheckHeartbeat (mamaFtMemberImpl* impl, unsigned int hbWeight, unsigned int hbIncarnation, int hbPid, @@ -722,7 +719,7 @@ void checkHeartbeat (mamaFtMemberImpl* impl, } - if (betterCredentials(impl, hbWeight,hbIncarnation,hbIpAddr,hbPid) == 0) + if (mamaBetterCredentials(impl, hbWeight,hbIncarnation,hbIpAddr,hbPid) == 0) { mama_log (MAMA_LOG_LEVEL_FINER, "MAMA NATIVE FT: received heartbeat"); @@ -818,11 +815,9 @@ multicastFt_setup ( if(transport) { status = mamaTransport_getName(transport, &transportName); - if((MAMA_STATUS_OK != status) || (NULL == transportName) || ('\0' == - transportName[0])) + if((MAMA_STATUS_OK != status) || (NULL == transportName) || ('\0' == transportName[0])) { - mama_log (MAMA_LOG_LEVEL_ERROR, "MAMA multicast FT: the transport name " - "is invalid"); + mama_log (MAMA_LOG_LEVEL_ERROR, "MAMA multicast FT: the transport name is invalid"); return MAMA_STATUS_INVALID_ARG; } } @@ -1148,7 +1143,7 @@ int multicastFt_receiveHeartbeat(void* member) hbIpAddr = ntohl (hbIpAddr); - checkHeartbeat (impl, hbWeight, hbIncarnation, hbPid, hbIpAddr, + mamaCheckHeartbeat (impl, hbWeight, hbIncarnation, hbPid, hbIpAddr, hbPrimary, hbGroupName); return 0; @@ -1372,7 +1367,7 @@ ftSubMsgCb (mamaSubscription subscription, return; } - checkHeartbeat (impl, + mamaCheckHeartbeat (impl, hbWeight, hbIncarnation, hbPid, -- 1.7.7.6
|
|
[PATCH 37/50] [testtools] Calling Convention for Windows Callbacks
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Use MAMACALLTYPE for callbacks in mamachurn and mamaconsumer in the test tools directory. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/testtools/load/c/mamachurnc.c | 16 ++++++++-------- .../src/testtools/performance/c/mamaconsumerc.c | 19 ++++++++----------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/mama/c_cpp/src/testtools/load/c/mamachurnc.c b/mama/c_cpp/src/testtools/load/c/mamachurnc.c index 37a89dd..0f3d037 100644 --- a/mama/c_cpp/src/testtools/load/c/mamachurnc.c +++ b/mama/c_cpp/src/testtools/load/c/mamachurnc.c @@ -110,7 +110,7 @@ static void ClearCounters(void) #define STATS_FIELD_WIDTH -5 /* negative = left alignment */ -static void statsCallback(mamaTimer timer, void *closure) +static void MAMACALLTYPE statsCallback(mamaTimer timer, void *closure) { time_t t; struct tm tmResult; @@ -166,7 +166,7 @@ static void checkStatus(char *err, mama_status status) } } -static void subscriptionOnCreate(mamaSubscription subscription, void* closure) +static void MAMACALLTYPE subscriptionOnCreate(mamaSubscription subscription, void* closure) { const char* symbol = NULL; @@ -178,7 +178,7 @@ static void subscriptionOnCreate(mamaSubscription subscription, void* closure) } } -static void subscriptionOnError(mamaSubscription subscription, +static void MAMACALLTYPE subscriptionOnError(mamaSubscription subscription, mama_status status, void* platformError, const char* subject, @@ -193,7 +193,7 @@ static void subscriptionOnError(mamaSubscription subscription, mamaSubscription_activate(subscription); } -static void subscriptionOnMsg(mamaSubscription subscription, +static void MAMACALLTYPE subscriptionOnMsg(mamaSubscription subscription, mamaMsg msg, void *closure, void *itemClosure) @@ -286,13 +286,13 @@ static void createSubscription(int index) checkStatus("mamaSubscription_create()",status); } -static void lifetimeCallback(mamaTimer timer, void *closure) +static void MAMACALLTYPE lifetimeCallback(mamaTimer timer, void *closure) { mama_stop(gBridge); printf("Lifetime expired\n"); } -static void recreateCallback(mamaTimer timer, void *closure) +static void MAMACALLTYPE recreateCallback(mamaTimer timer, void *closure) { /* try to destroy existing subscription */ destroySubscription((int)closure); @@ -300,7 +300,7 @@ static void recreateCallback(mamaTimer timer, void *closure) mamaTimer_destroy(timer); } -static void churnCallback(mamaTimer timer, void *closure) +static void MAMACALLTYPE churnCallback(mamaTimer timer, void *closure) { int churnCount = 0; int churnIndex = 0; @@ -324,7 +324,7 @@ static void churnCallback(mamaTimer timer, void *closure) gChurned+=churnCount; } -static void transportCb(mamaTransport tport,mamaTransportEvent ev, +static void MAMACALLTYPE transportCb(mamaTransport tport,mamaTransportEvent ev, short cause,const void *opaque,void *closure) { mamaQuality quality = MAMA_QUALITY_UNKNOWN; diff --git a/mama/c_cpp/src/testtools/performance/c/mamaconsumerc.c b/mama/c_cpp/src/testtools/performance/c/mamaconsumerc.c index 106a0ef..2df8881 100644 --- a/mama/c_cpp/src/testtools/performance/c/mamaconsumerc.c +++ b/mama/c_cpp/src/testtools/performance/c/mamaconsumerc.c @@ -24,9 +24,6 @@ #include "string.h" #include <stdlib.h> -#include "pthread.h" -#include <unistd.h> - /* MAMA function checking macro */ #define MAMA_CHECK(status) \ { \ @@ -107,13 +104,13 @@ static void mc_createSubscriber mamaQueue queue ); -static void mc_createCb +static void MAMACALLTYPE mc_createCb ( mamaSubscription subscription, void * closure ); -static void mc_errorCb +static void MAMACALLTYPE mc_errorCb ( mamaSubscription subscription, mama_status status, @@ -122,7 +119,7 @@ static void mc_errorCb void* closure ); -static void mc_msgCb +static void MAMACALLTYPE mc_msgCb ( mamaSubscription subscription, mamaMsg msg, @@ -130,7 +127,7 @@ static void mc_msgCb void * itemClosure ); -static void mc_msgCb2 +static void MAMACALLTYPE mc_msgCb2 ( mamaSubscription subscription, mamaMsg msg, @@ -296,7 +293,7 @@ static void mc_createSubscriber /********************************************************** * mc_createCb * **********************************************************/ -static void mc_createCb +static void MAMACALLTYPE mc_createCb ( mamaSubscription subscription, void * closure @@ -308,7 +305,7 @@ static void mc_createCb /********************************************************** * mc_errorCb * **********************************************************/ -static void mc_errorCb +static void MAMACALLTYPE mc_errorCb ( mamaSubscription subscription, mama_status status, @@ -327,7 +324,7 @@ static void mc_errorCb /********************************************************** * mc_msgCb * **********************************************************/ -static void mc_msgCb +static void MAMACALLTYPE mc_msgCb ( mamaSubscription subscription, mamaMsg msg, @@ -400,7 +397,7 @@ static void mc_msgCb /********************************************************** * mc_msgCb2 * **********************************************************/ -static void mc_msgCb2 +static void MAMACALLTYPE mc_msgCb2 ( mamaSubscription subscription, mamaMsg msg, -- 1.7.7.6
|
|
[PATCH 38/50] [common] Change uuid to char* from int for Windows
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/windows/wombat/wUuid.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/common/c_cpp/src/c/windows/wombat/wUuid.h b/common/c_cpp/src/c/windows/wombat/wUuid.h index 43f4b2c..442e39a 100644 --- a/common/c_cpp/src/c/windows/wombat/wUuid.h +++ b/common/c_cpp/src/c/windows/wombat/wUuid.h @@ -23,7 +23,7 @@ #include "wombat/port.h" -typedef int wUuid; +typedef char* wUuid; COMMONExpDLL void wUuid_generate_time (wUuid myUuid); -- 1.7.7.6
|
|
[PATCH 39/50] [avis-payload] Correct Calling Convention for Windows
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
The avis payload headers need the correct calling convention to export functions from the dynamic libraries. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/windows/wombat/wConfig.h | 5 +---- mama/c_cpp/src/c/payload/avismsg/avispayload.h | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/common/c_cpp/src/c/windows/wombat/wConfig.h b/common/c_cpp/src/c/windows/wombat/wConfig.h index 2b944be..1c9f788 100644 --- a/common/c_cpp/src/c/windows/wombat/wConfig.h +++ b/common/c_cpp/src/c/windows/wombat/wConfig.h @@ -36,11 +36,8 @@ #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 MAMAExpBridgeDLL __declspec( dllexport ) # define WMWExpDLL __declspec( dllimport ) #elif defined( MAMA_DLL ) && defined( MAMACPP ) /* We are building mamacpp as a dll */ diff --git a/mama/c_cpp/src/c/payload/avismsg/avispayload.h b/mama/c_cpp/src/c/payload/avismsg/avispayload.h index 2e87888..69135e2 100755 --- a/mama/c_cpp/src/c/payload/avismsg/avispayload.h +++ b/mama/c_cpp/src/c/payload/avismsg/avispayload.h @@ -30,11 +30,11 @@ extern "C" { #endif -MAMAExpDLL +MAMAExpBridgeDLL extern mama_status avismsgPayload_destroyImpl (mamaPayloadBridge mamaPayloadBridge); -MAMAExpDLL +MAMAExpBridgeDLL extern mama_status avismsgPayload_createImpl (mamaPayloadBridge* result, char* identifier); -- 1.7.7.6
|
|
[PATCH 40/50] [common] Added Missing LGPL Headers
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Also shortened the "#define VCx 1" macros shortened to "#define VC_X". Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/linux/wUuid.h | 20 +++++++++++++++++ common/c_cpp/src/c/wMessageStats.c | 20 +++++++++++++++++ common/c_cpp/src/c/windows/wombat/targetsxs.h | 28 +++++++++++++++++++++--- common/c_cpp/src/c/wombat/wMessageStats.h | 20 +++++++++++++++++ mama/c_cpp/src/gunittest/c/MainUnitTestC.cpp | 20 +++++++++++++++++ mama/c_cpp/src/gunittest/c/MainUnitTestC.h | 22 ++++++++++++++++--- 6 files changed, 122 insertions(+), 8 deletions(-) diff --git a/common/c_cpp/src/c/linux/wUuid.h b/common/c_cpp/src/c/linux/wUuid.h index 608eee7..92090ec 100644 --- a/common/c_cpp/src/c/linux/wUuid.h +++ b/common/c_cpp/src/c/linux/wUuid.h @@ -1,3 +1,23 @@ +/* $Id: wUuid.h,v 1.1.2.4.2.1 2012/04/17 10:52:12 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__ diff --git a/common/c_cpp/src/c/wMessageStats.c b/common/c_cpp/src/c/wMessageStats.c index 5ae85ce..7fa479c 100644 --- a/common/c_cpp/src/c/wMessageStats.c +++ b/common/c_cpp/src/c/wMessageStats.c @@ -1,3 +1,23 @@ +/* $Id: wMessageStats.c,v 1.76.18.3.8.1 2012/04/17 10:52:12 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 + */ #include "wombat/machine.h" #include "wombat/wMessageStats.h" diff --git a/common/c_cpp/src/c/windows/wombat/targetsxs.h b/common/c_cpp/src/c/windows/wombat/targetsxs.h index 2341000..babeaa3 100644 --- a/common/c_cpp/src/c/windows/wombat/targetsxs.h +++ b/common/c_cpp/src/c/windows/wombat/targetsxs.h @@ -1,14 +1,34 @@ +/* $Id: targetsxs.h,v 1.1.4.3.2.2 2012/04/17 10:52:12 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 _WOMBAT_TARGETSXS_H #define _WOMBAT_TARGETSXS_H #if (_MSC_VER >= 1600 && _MSC_VER < 1700) -#define VC10 1 +#define VC10 #elif (_MSC_VER >= 1600 && _MSC_VER < 1500) -#define VC9 1 +#define VC9 #elif (_MSC_VER >= 1400 && _MSC_VER < 1500) -#define VC8 1 +#define VC8 #elif (_MSC_VER >= 1400 && _MSC_VER < 1400) -#define VC7 1 +#define VC7 #endif #ifndef VC7 diff --git a/common/c_cpp/src/c/wombat/wMessageStats.h b/common/c_cpp/src/c/wombat/wMessageStats.h index 4a8916d..a4c3546 100644 --- a/common/c_cpp/src/c/wombat/wMessageStats.h +++ b/common/c_cpp/src/c/wombat/wMessageStats.h @@ -1,3 +1,23 @@ +/* $Id: wMessageStats.h,v 1.7.16.3.8.1 2012/04/17 10:52:12 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 _PERF_DATA_H__ #define _PERF_DATA_H__ diff --git a/mama/c_cpp/src/gunittest/c/MainUnitTestC.cpp b/mama/c_cpp/src/gunittest/c/MainUnitTestC.cpp index 95a1e9f..9b0ea7d 100644 --- a/mama/c_cpp/src/gunittest/c/MainUnitTestC.cpp +++ b/mama/c_cpp/src/gunittest/c/MainUnitTestC.cpp @@ -1,3 +1,23 @@ +/* $Id: MainUnitTestC.cpp,v 1.2.22.2.16.1 2012/04/17 10:52:12 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 + */ #include <cstdlib> #include <iostream> #include <gtest/gtest.h> diff --git a/mama/c_cpp/src/gunittest/c/MainUnitTestC.h b/mama/c_cpp/src/gunittest/c/MainUnitTestC.h index 866df1b..595521b 100644 --- a/mama/c_cpp/src/gunittest/c/MainUnitTestC.h +++ b/mama/c_cpp/src/gunittest/c/MainUnitTestC.h @@ -1,8 +1,22 @@ -/* - * MainUnitTestC.h +/* $Id: MainUnitTestC.h,v 1.1.2.1.16.1 2012/04/17 10:52:12 emmapollock Exp $ * - * Created on: 13 Sep 2011 - * Author: ianb + * 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 MAINUNITTESTC_H_ -- 1.7.7.6
|
|
[PATCH 41/50] [common] Windows int MIN and MAX Definititions
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Also moved 8 byte integer typedefs to wombat/strutils with the other similiar typedefs. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/linux/port.h | 4 --- common/c_cpp/src/c/windows/port.h | 36 ++++++++++++++++++++++++++++++++++ common/c_cpp/src/c/wombat/strutils.h | 2 + 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h index 67ae0c9..b40b4fa 100644 --- a/common/c_cpp/src/c/linux/port.h +++ b/common/c_cpp/src/c/linux/port.h @@ -67,10 +67,6 @@ typedef void* LIB_HANDLE; /* suffix for shared libraries */ #define LIB_EXTENSION ".so" -/* 8 byte int typedefs */ -typedef unsigned long long int w_u64_t; -typedef long long int w_i64_t; - /* Network conversion function */ #if __BYTE_ORDER == __LITTLE_ENDIAN #define htonll(x) \ diff --git a/common/c_cpp/src/c/windows/port.h b/common/c_cpp/src/c/windows/port.h index ded944a..ac35348 100644 --- a/common/c_cpp/src/c/windows/port.h +++ b/common/c_cpp/src/c/windows/port.h @@ -174,6 +174,42 @@ const char *index( const char *str, char c ); */ #define PRId64 "I64d" #define PRIu64 "I64u" +#ifndef INT8_MIN +#define INT8_MIN SCHAR_MIN +#endif +#ifndef INT8_MAX +#define INT8_MAX SCHAR_MAX +#endif +#ifndef INT16_MIN +#define INT16_MIN SHRT_MIN +#endif +#ifndef INT16_MAX +#define INT16_MAX SHRT_MAX +#endif +#ifndef INT32_MIN +#define INT32_MIN INT_MIN +#endif +#ifndef INT32_MAX +#define INT32_MAX INT_MAX +#endif +#ifndef INT64_MIN +#define INT64_MIN LLONG_MIN +#endif +#ifndef INT64_MAX +#define INT64_MAX LLONG_MAX +#endif +#ifndef UINT8_MAX +#define UINT8_MAX UCHAR_MAX +#endif +#ifndef UINT16_MAX +#define UINT16_MAX USHRT_MAX +#endif +#ifndef UINT32_MAX +#define UINT32_MAX UINT_MAX +#endif +#ifndef UINT64_MAX +#define UINT64_MAX ULLONG_MAX +#endif #define wthread_detach( h ) /* noop */ #define wthread_self GetCurrentThread diff --git a/common/c_cpp/src/c/wombat/strutils.h b/common/c_cpp/src/c/wombat/strutils.h index d5d1fb8..be7da86 100644 --- a/common/c_cpp/src/c/wombat/strutils.h +++ b/common/c_cpp/src/c/wombat/strutils.h @@ -33,6 +33,8 @@ typedef unsigned long int w_u32_t; typedef long int w_i32_t; typedef float w_f32_t; typedef double w_f64_t; +typedef unsigned long long int w_u64_t; +typedef long long int w_i64_t; COMMONExpDLL int wmFastCopyAndShiftStr ( -- 1.7.7.6
|
|
[PATCH 42/50] [common] C Linkage for Detroy Handle
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/destroyHandle.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/common/c_cpp/src/c/destroyHandle.h b/common/c_cpp/src/c/destroyHandle.h index 08d2067..80c008d 100644 --- a/common/c_cpp/src/c/destroyHandle.h +++ b/common/c_cpp/src/c/destroyHandle.h @@ -33,6 +33,9 @@ * although the object may be gone the thread will have valid memory to access. */ +#if defined(__cplusplus) +extern "C" { +#endif /* ************************************************************** */ /* Includes. */ /* ************************************************************** */ @@ -121,5 +124,8 @@ extern void * destroyHandle_removeReference( pDestroyHandle handle); +#if defined(__cplusplus) +} +#endif #endif -- 1.7.7.6
|
|
[PATCH 43/50] [mama] GCC 4.6.2 Support
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
GCC 4.6.2 requires -ldl and -lrt. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- .../src/testtools/capturereplay/c/Makefile.am | 2 +- mama/c_cpp/src/testtools/load/c/Makefile.am | 2 +- mama/c_cpp/src/testtools/performance/c/Makefile.am | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mama/c_cpp/src/testtools/capturereplay/c/Makefile.am b/mama/c_cpp/src/testtools/capturereplay/c/Makefile.am index 9614251..fc398ed 100644 --- a/mama/c_cpp/src/testtools/capturereplay/c/Makefile.am +++ b/mama/c_cpp/src/testtools/capturereplay/c/Makefile.am @@ -37,7 +37,7 @@ CFLAGS += -Wmissing-prototypes -Wstrict-prototypes CPPFLAGS += -pedantic -Wall -Wimplicit -Wno-long-long -D_GNU_SOURCE endif -LDADD = -lmama -lpthread -lm -lwombatcommon +LDADD = -lmama -lpthread -lm -lwombatcommon -ldl bin_PROGRAMS = capturereplayc capturec captureconvert diff --git a/mama/c_cpp/src/testtools/load/c/Makefile.am b/mama/c_cpp/src/testtools/load/c/Makefile.am index fbf016f..75fc832 100755 --- a/mama/c_cpp/src/testtools/load/c/Makefile.am +++ b/mama/c_cpp/src/testtools/load/c/Makefile.am @@ -36,7 +36,7 @@ CFLAGS += -Wmissing-prototypes -Wstrict-prototypes CPPFLAGS += -pedantic -Wall -Wimplicit -Wno-long-long -D_GNU_SOURCE endif -LDADD = -lmama -lpthread -lm -lwombatcommon +LDADD = -lmama -lpthread -lm -lwombatcommon -ldl bin_PROGRAMS = mamachurnc diff --git a/mama/c_cpp/src/testtools/performance/c/Makefile.am b/mama/c_cpp/src/testtools/performance/c/Makefile.am index eb19b6e..26f9673 100644 --- a/mama/c_cpp/src/testtools/performance/c/Makefile.am +++ b/mama/c_cpp/src/testtools/performance/c/Makefile.am @@ -36,7 +36,7 @@ CFLAGS += -Wmissing-prototypes -Wstrict-prototypes CPPFLAGS += -pedantic -Wall -Wimplicit -Wno-long-long -D_GNU_SOURCE endif -LDADD = -lmama -lpthread -lm -lwombatcommon +LDADD = -lmama -lpthread -lm -lwombatcommon -ldl -lrt bin_PROGRAMS = mamaproducerc \ -- 1.7.7.6
|
|
[PATCH 44/50] [testtools] Renamed shutdown() method in executables
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Renamed shutdown() to xxxShutdown() to avoid namespace conflicts with Windows system libraries. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- .../src/testtools/performance/c/mamaconsumerc_v2.c | 6 +++--- .../src/testtools/performance/c/mamapingpongc.c | 6 +++--- .../src/testtools/performance/c/mamaproducerc_v2.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mama/c_cpp/src/testtools/performance/c/mamaconsumerc_v2.c b/mama/c_cpp/src/testtools/performance/c/mamaconsumerc_v2.c index 13b52c6..2dd8153 100644 --- a/mama/c_cpp/src/testtools/performance/c/mamaconsumerc_v2.c +++ b/mama/c_cpp/src/testtools/performance/c/mamaconsumerc_v2.c @@ -457,7 +457,7 @@ static void signalCatcher int sig ); -static void shutdown(void); +static void consumerShutdown (void); static void printHeader ( @@ -1126,7 +1126,7 @@ int main (int argc, const char** argv) displayStatsGroupBuckets(&gStatsGroup); } - shutdown(); + consumerShutdown(); for(i=0; i<NUM_STATS_GROUPS; ++i) destroyStatsGroup(&(gStatsGroups[i])); @@ -1195,7 +1195,7 @@ static void printHeader } -static void shutdown(void) +static void consumerShutdown (void) { int i; unsigned nsecSleep = gThrottle != -1 ? 1000000000 / gThrottle : 0; diff --git a/mama/c_cpp/src/testtools/performance/c/mamapingpongc.c b/mama/c_cpp/src/testtools/performance/c/mamapingpongc.c index 8069892..775db81 100644 --- a/mama/c_cpp/src/testtools/performance/c/mamapingpongc.c +++ b/mama/c_cpp/src/testtools/performance/c/mamapingpongc.c @@ -243,7 +243,7 @@ static void signalCatcher int sig ); -static void shutdown(pingPongCtx* ppCtx, pingPongEventCtx* eventCtx); +static void pingpongShutdown (pingPongCtx* ppCtx, pingPongEventCtx* eventCtx); static void initMessages(message* pMsgs, @@ -375,7 +375,7 @@ int main (int argc, const char** argv) /* start the mama bridge, blocks here */ mama_start (gPingPongCtx.mBridge); - shutdown(&gPingPongCtx, &eventCtx); + pingpongShutdown (&gPingPongCtx, &eventCtx); mama_close (); if(!eventCtx.mServer) @@ -491,7 +491,7 @@ static void publishMessage seqNum++; } -static void shutdown(pingPongCtx* ppCtx, pingPongEventCtx* eventCtx) +static void pingpongShutdown (pingPongCtx* ppCtx, pingPongEventCtx* eventCtx) { pthread_mutexattr_t attr; diff --git a/mama/c_cpp/src/testtools/performance/c/mamaproducerc_v2.c b/mama/c_cpp/src/testtools/performance/c/mamaproducerc_v2.c index b8884df..bb64e53 100644 --- a/mama/c_cpp/src/testtools/performance/c/mamaproducerc_v2.c +++ b/mama/c_cpp/src/testtools/performance/c/mamaproducerc_v2.c @@ -309,7 +309,7 @@ static void displayCallback void* closure ); -static void shutdown +static void producerShutdown ( uint32_t msgVar ); @@ -943,7 +943,7 @@ int main (int argc, const char **argv) } pthread_mutex_unlock (&pendingShutdownLock); - shutdown(msgVar); + producerShutdown (msgVar); MAMA_CHECK (mamaDateTime_destroy (gLastDisplayTime)); MAMA_CHECK (mamaDateTime_destroy (gNowTime)); @@ -953,7 +953,7 @@ int main (int argc, const char **argv) return 0; } -static void shutdown +static void producerShutdown ( uint32_t msgVar ) -- 1.7.7.6
|
|
[PATCH 45/50] [mama] Remove msgFieldPayload from mamaMsg
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/c/msg.c | 26 +------------------------- 1 files changed, 1 insertions(+), 25 deletions(-) diff --git a/mama/c_cpp/src/c/msg.c b/mama/c_cpp/src/c/msg.c index d3c0e80..c0530a6 100644 --- a/mama/c_cpp/src/c/msg.c +++ b/mama/c_cpp/src/c/msg.c @@ -85,8 +85,6 @@ typedef struct mamaMsgImpl_ mamaMsgField mCurrentField; mamaDateTime mCurrentDateTime; - - msgFieldPayload mFieldPayload; /*Hold onto the bridge impl for later use*/ mamaBridgeImpl* mBridgeImpl; /*The bridge specific message*/ @@ -124,13 +122,6 @@ mamaMsg_destroy (mamaMsg msg) if (impl->mPayloadBridge && impl->mMessageOwner) { - if (impl->mFieldPayload) - { - impl->mPayloadBridge->msgFieldPayloadDestroy ( - impl->mFieldPayload); - impl->mFieldPayload = NULL; - } - if (MAMA_STATUS_OK != impl->mPayloadBridge->msgPayloadDestroy (impl->mPayload)) { mama_log (MAMA_LOG_LEVEL_ERROR, "mamaMsg_destroy(): " @@ -197,12 +188,6 @@ mamaMsg_clear (mamaMsg msg) if (impl->mPayloadBridge) { - if (impl->mFieldPayload) - { - impl->mPayloadBridge->msgFieldPayloadDestroy ( - impl->mFieldPayload); - } - if (MAMA_STATUS_OK != impl->mPayloadBridge->msgPayloadClear (impl->mPayload)) { mama_log (MAMA_LOG_LEVEL_ERROR, "mamaMsg_clear(): " @@ -579,7 +564,6 @@ mamaMsgImpl_createNestedForPayload (mamaMsg* result, mamaMsgField_create (&impl->mCurrentField); impl->mCurrentField->myPayloadBridge = parent->mPayloadBridge; - impl->mFieldPayload = NULL; impl->mPayloadBridge = parent->mPayloadBridge; impl->mPayload = payload; impl->mParent = parent; @@ -645,7 +629,6 @@ mamaMsgImpl_createForPayload (mamaMsg* msg, impl->mPayload = payload; impl->mPayloadBridge = payloadBridge; - impl->mFieldPayload = NULL; /*These will be set later if necessary*/ impl->mBridgeImpl = NULL; impl->mBridgeMessage = NULL; @@ -1740,22 +1723,15 @@ mamaMsg_getField( mamaField = (mamaMsgFieldImpl*)impl->mCurrentField; - if (!impl->mFieldPayload) - { - impl->mPayloadBridge->msgFieldPayloadCreate ( - &impl->mFieldPayload); - } - if (MAMA_STATUS_OK!=(status = impl->mPayloadBridge->msgPayloadGetField ( impl->mPayload, name, fid, - &impl->mFieldPayload))) + &impl->mCurrentField->myPayload))) { return status; } impl->mCurrentField->myPayloadBridge = impl->mPayloadBridge; - impl->mCurrentField->myPayload = impl->mFieldPayload; impl->mCurrentField->myMsg = impl; mamaField = (mamaMsgFieldImpl*)impl->mCurrentField; -- 1.7.7.6
|
|
[PATCH 46/50] [unit tests] Fixed unit tests build
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- mama/c_cpp/src/gunittest/c/Makefile.am | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mama/c_cpp/src/gunittest/c/Makefile.am b/mama/c_cpp/src/gunittest/c/Makefile.am index abbfee9..13b5915 100644 --- a/mama/c_cpp/src/gunittest/c/Makefile.am +++ b/mama/c_cpp/src/gunittest/c/Makefile.am @@ -29,13 +29,16 @@ CFLAGS += -pedantic -Wno-long-long -O2 -pthread -fPIC CPPFLAGS += -pedantic -Wno-long-long -O2 -pthread -fPIC endif -INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../.. -I$(srcdir)/../../../examples +INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../.. -I$(srcdir)/../../../examples -I$(srcdir)/../../../../../common/c_cpp/src/c CFLAGS += -I@builddir@/../../c CPPFLAGS += -I@builddir@/../../c -LIBS = -lmama -lwombatcommon -lgtest +LDFLAGS += -L${srcdir}/../../c \ + -L${srcdir}/../../../../../common/c_cpp/src/c + +LIBS = -lmama -lwombatcommon -lgtest bin_PROGRAMS = MainUnitTestC -- 1.7.7.6
|
|
[PATCH 47/50] [common] Moved windows/port.h to windows/wombat/port.h
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
This addresses some build issues. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/windows/port.h | 293 ------------------------------ common/c_cpp/src/c/windows/wombat/port.h | 293 ++++++++++++++++++++++++++++++ 2 files changed, 293 insertions(+), 293 deletions(-) delete mode 100644 common/c_cpp/src/c/windows/port.h create mode 100644 common/c_cpp/src/c/windows/wombat/port.h diff --git a/common/c_cpp/src/c/windows/port.h b/common/c_cpp/src/c/windows/port.h deleted file mode 100644 index ac35348..0000000 --- a/common/c_cpp/src/c/windows/port.h +++ /dev/null @@ -1,293 +0,0 @@ -/* - * 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 "wombat/targetsxs.h" -#include "wombat/wConfig.h" -#include "windows/lock.h" -#include "windows/mmap.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -/* So Windows compiler ignores gcc __attribute__(x) */ -#define __attribute__(a) - -/* 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 "\\" -COMMONExpDLL int -wsocketstartup (void); - -COMMONExpDLL void -wsocketcleanup (void); - -/* 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 wresolve_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 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) - -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" -#ifndef INT8_MIN -#define INT8_MIN SCHAR_MIN -#endif -#ifndef INT8_MAX -#define INT8_MAX SCHAR_MAX -#endif -#ifndef INT16_MIN -#define INT16_MIN SHRT_MIN -#endif -#ifndef INT16_MAX -#define INT16_MAX SHRT_MAX -#endif -#ifndef INT32_MIN -#define INT32_MIN INT_MIN -#endif -#ifndef INT32_MAX -#define INT32_MAX INT_MAX -#endif -#ifndef INT64_MIN -#define INT64_MIN LLONG_MIN -#endif -#ifndef INT64_MAX -#define INT64_MAX LLONG_MAX -#endif -#ifndef UINT8_MAX -#define UINT8_MAX UCHAR_MAX -#endif -#ifndef UINT16_MAX -#define UINT16_MAX USHRT_MAX -#endif -#ifndef UINT32_MAX -#define UINT32_MAX UINT_MAX -#endif -#ifndef UINT64_MAX -#define UINT64_MAX ULLONG_MAX -#endif - -#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/wombat/port.h b/common/c_cpp/src/c/windows/wombat/port.h new file mode 100644 index 0000000..ac35348 --- /dev/null +++ b/common/c_cpp/src/c/windows/wombat/port.h @@ -0,0 +1,293 @@ +/* + * 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 "wombat/targetsxs.h" +#include "wombat/wConfig.h" +#include "windows/lock.h" +#include "windows/mmap.h" + +#if defined(__cplusplus) +extern "C" { +#endif + +/* So Windows compiler ignores gcc __attribute__(x) */ +#define __attribute__(a) + +/* 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 "\\" +COMMONExpDLL int +wsocketstartup (void); + +COMMONExpDLL void +wsocketcleanup (void); + +/* 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 wresolve_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 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) + +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" +#ifndef INT8_MIN +#define INT8_MIN SCHAR_MIN +#endif +#ifndef INT8_MAX +#define INT8_MAX SCHAR_MAX +#endif +#ifndef INT16_MIN +#define INT16_MIN SHRT_MIN +#endif +#ifndef INT16_MAX +#define INT16_MAX SHRT_MAX +#endif +#ifndef INT32_MIN +#define INT32_MIN INT_MIN +#endif +#ifndef INT32_MAX +#define INT32_MAX INT_MAX +#endif +#ifndef INT64_MIN +#define INT64_MIN LLONG_MIN +#endif +#ifndef INT64_MAX +#define INT64_MAX LLONG_MAX +#endif +#ifndef UINT8_MAX +#define UINT8_MAX UCHAR_MAX +#endif +#ifndef UINT16_MAX +#define UINT16_MAX USHRT_MAX +#endif +#ifndef UINT32_MAX +#define UINT32_MAX UINT_MAX +#endif +#ifndef UINT64_MAX +#define UINT64_MAX ULLONG_MAX +#endif + +#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__ */ -- 1.7.7.6
|
|
[PATCH 48/50] [common] Removed Unnecessary Symlink to wConfig.h
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/wombat/wConfig.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) delete mode 120000 common/c_cpp/src/c/wombat/wConfig.h diff --git a/common/c_cpp/src/c/wombat/wConfig.h b/common/c_cpp/src/c/wombat/wConfig.h deleted file mode 120000 index e7aeede..0000000 --- a/common/c_cpp/src/c/wombat/wConfig.h +++ /dev/null @@ -1 +0,0 @@ -../../../src/c/linux/wConfig.h \ No newline at end of file -- 1.7.7.6
|
|
[PATCH 49/50] [common] More Win32 Support
Michael Schonberg <mschonberg@...>
From: Mike Schonberg <mschonberg@nyx.com>
wUuid.c for uuid support and strpcasecmp and strptime implementations. Signed-off-by: Mike Schonberg <mschonberg@nyx.com> --- common/c_cpp/src/c/windows/strpcasecmp.c | 88 +++++++ common/c_cpp/src/c/windows/strptime.c | 376 ++++++++++++++++++++++++++++++ common/c_cpp/src/c/windows/wUuid.c | 69 ++++++ 3 files changed, 533 insertions(+), 0 deletions(-) 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 diff --git a/common/c_cpp/src/c/windows/strpcasecmp.c b/common/c_cpp/src/c/windows/strpcasecmp.c new file mode 100644 index 0000000..5483fa8 --- /dev/null +++ b/common/c_cpp/src/c/windows/strpcasecmp.c @@ -0,0 +1,88 @@ +// +// strcasecmp.cc +// +// strcasecmp: replacement of the strcasecmp functions for architectures that do +// not have it. +// +// Part of the ht://Dig package <http://www.htdig.org/> +// Copyright (c) 1999-2004 The ht://Dig Group +// For copyright details, see the file COPYING in your distribution +// or the GNU Library General Public License (LGPL) version 2 or later +// <http://www.gnu.org/copyleft/lgpl.html> +// +// $Id: strpcasecmp.c,v 1.1.2.1 2012/03/15 11:02:57 evinkeating Exp $ +// + +//#ifdef HAVE_CONFIG_H +//#include "htconfig.h" +//#endif /* HAVE_CONFIG_H */ + +//#include "lib.h" +#include <ctype.h> + +//***************************************************************************** +// +int strcasecmp(const char *str1, const char *str2) +{ + if (!str1 && !str2) + return 0; + if (!str1) + return 1; + if (!str2) + return -1; + while (*str1 && + *str2 && + tolower((unsigned char)*str1) == tolower((unsigned char)*str2)) + { + str1++; + str2++; + } + + return tolower((unsigned char)*str1) - tolower((unsigned char)*str2); +} + + +//#define tolower(ch) (isupper(ch) ? (ch) + 'a' - 'A' : (ch)) +//***************************************************************************** +// +int strncasecmp(const char *str1, const char *str2, int n) +{ + if (!str1 && !str2) + return 0; + if (!str1) + return 1; + if (!str2) + return -1; + if (n < 0) + return 0; + while (n && + *str1 && + *str2 && + tolower((unsigned char)*str1) == tolower((unsigned char)*str2)) + { + str1++; + str2++; + n--; + } + + return n == 0 ? 0 : + tolower((unsigned char)*str1) - tolower((unsigned char)*str2); +} + + +//***************************************************************************** +// char *mystrcasestr(const char *s, const char *pattern) +// +const char * +mystrcasestr(const char *s, const char *pattern) +{ + int length = strlen(pattern); + + while (*s) + { + if (strncasecmp(s, pattern, length) == 0) + return s; + s++; + } + return 0; +} \ No newline at end of file diff --git a/common/c_cpp/src/c/windows/strptime.c b/common/c_cpp/src/c/windows/strptime.c new file mode 100644 index 0000000..88035e0 --- /dev/null +++ b/common/c_cpp/src/c/windows/strptime.c @@ -0,0 +1,376 @@ +// Part of the ht://Dig package <http://www.htdig.org/> +// Copyright (c) 1999-2004 The ht://Dig Group +// For copyright details, see the file COPYING in your distribution +// or the GNU Library General Public License (LGPL) version 2 or later +// <http://www.gnu.org/copyleft/lgpl.html> +// + +/* + * Copyright (c) 1994 Powerdog Industries. All rights reserved. + * + * Redistribution and use in source and binary forms, without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgement: + * This product includes software developed by Powerdog Industries. + * 4. The name of Powerdog Industries may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY POWERDOG INDUSTRIES ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE POWERDOG INDUSTRIES BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +/* +static char copyright[] = +"@(#) Copyright (c) 1994 Powerdog Industries. All rights reserved."; +static char sccsid[] = "@(#)strptime.c 1.0 (Powerdog) 94/03/27"; +*/ +#endif /* not lint */ + +//#include <lib.h> + +#include <time.h> +#include <ctype.h> +#include <locale.h> +#include <string.h> + +#define asizeof(a) ((int)(sizeof (a) / sizeof ((a)[0]))) + +struct mydtconv { + char *abbrev_month_names[12]; + char *month_names[12]; + char *abbrev_weekday_names[7]; + char *weekday_names[7]; + char *time_format; + char *sdate_format; + char *dtime_format; + char *am_string; + char *pm_string; + char *ldate_format; +}; + +static struct mydtconv En_US = { + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }, + { "January", "February", "March", "April", + "May", "June", "July", "August", + "September", "October", "November", "December" }, + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }, + { "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" }, + "%H:%M:%S", + "%m/%d/%y", + "%a %b %e %T %Z %Y", + "AM", + "PM", + "%A, %B, %e, %Y" +}; + +char * +strptime(const char *buf, const char *fmt, struct tm *tm) +{ + char c; + const char *ptr; + int i, len = 0; + + ptr = fmt; + while (*ptr != 0) + { + if (*buf == 0) + break; + + c = *ptr++; + + if (c != '%') + { + if (isspace(c)) + while (*buf != 0 && isspace(*buf)) + buf++; + else if (c != *buf++) + return 0; + continue; + } + + c = *ptr++; + switch (c) + { + case 0: + case '%': + if (*buf++ != '%') + return 0; + break; + + case 'C': + buf = strptime(buf, En_US.ldate_format, tm); + if (buf == 0) + return 0; + break; + + case 'c': + buf = strptime(buf, "%x %X", tm); + if (buf == 0) + return 0; + break; + + case 'D': + buf = strptime(buf, "%m/%d/%y", tm); + if (buf == 0) + return 0; + break; + + case 'R': + buf = strptime(buf, "%H:%M", tm); + if (buf == 0) + return 0; + break; + + case 'r': + buf = strptime(buf, "%I:%M:%S %p", tm); + if (buf == 0) + return 0; + break; + + case 'T': + buf = strptime(buf, "%H:%M:%S", tm); + if (buf == 0) + return 0; + break; + + case 'X': + buf = strptime(buf, En_US.time_format, tm); + if (buf == 0) + return 0; + break; + + case 'x': + buf = strptime(buf, En_US.sdate_format, tm); + if (buf == 0) + return 0; + break; + + case 'j': + if (!isdigit(*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit(*buf); buf++) + { + i *= 10; + i += *buf - '0'; + } + if (i > 365) + return 0; + + tm->tm_yday = i; + break; + + case 'M': + case 'S': + if (*buf == 0 || isspace(*buf)) + break; + + if (!isdigit(*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit(*buf); buf++) + { + i *= 10; + i += *buf - '0'; + } + if (i > 59) + return 0; + + if (c == 'M') + tm->tm_min = i; + else + tm->tm_sec = i; + + if (*buf != 0 && isspace(*buf)) + while (*ptr != 0 && !isspace(*ptr)) + ptr++; + break; + + case 'H': + case 'I': + case 'k': + case 'l': + if (!isdigit(*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit(*buf); buf++) + { + i *= 10; + i += *buf - '0'; + } + if (c == 'H' || c == 'k') { + if (i > 23) + return 0; + } else if (i > 11) + return 0; + + tm->tm_hour = i; + + if (*buf != 0 && isspace(*buf)) + while (*ptr != 0 && !isspace(*ptr)) + ptr++; + break; + + case 'p': + len = strlen(En_US.am_string); + if (strncasecmp(buf, En_US.am_string, len) == 0) + { + if (tm->tm_hour > 12) + return 0; + if (tm->tm_hour == 12) + tm->tm_hour = 0; + buf += len; + break; + } + + len = strlen(En_US.pm_string); + if (strncasecmp(buf, En_US.pm_string, len) == 0) + { + if (tm->tm_hour > 12) + return 0; + if (tm->tm_hour != 12) + tm->tm_hour += 12; + buf += len; + break; + } + + return 0; + + case 'A': + case 'a': + for (i = 0; i < asizeof(En_US.weekday_names); i++) + { + len = strlen(En_US.weekday_names[i]); + if (strncasecmp(buf, + En_US.weekday_names[i], + len) == 0) + break; + + len = strlen(En_US.abbrev_weekday_names[i]); + if (strncasecmp(buf, + En_US.abbrev_weekday_names[i], + len) == 0) + break; + } + if (i == asizeof(En_US.weekday_names)) + return 0; + + tm->tm_wday = i; + buf += len; + break; + + case 'd': + case 'e': + if (!isdigit(*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit(*buf); buf++) + { + i *= 10; + i += *buf - '0'; + } + if (i > 31) + return 0; + + tm->tm_mday = i; + + if (*buf != 0 && isspace(*buf)) + while (*ptr != 0 && !isspace(*ptr)) + ptr++; + break; + + case 'B': + case 'b': + case 'h': + for (i = 0; i < asizeof(En_US.month_names); i++) + { + len = strlen(En_US.month_names[i]); + if (strncasecmp(buf, + En_US.month_names[i], + len) == 0) + break; + + len = strlen(En_US.abbrev_month_names[i]); + if (strncasecmp(buf, + En_US.abbrev_month_names[i], + len) == 0) + break; + } + if (i == asizeof(En_US.month_names)) + return 0; + + tm->tm_mon = i; + buf += len; + break; + + case 'm': + if (!isdigit(*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit(*buf); buf++) + { + i *= 10; + i += *buf - '0'; + } + if (i < 1 || i > 12) + return 0; + + tm->tm_mon = i - 1; + + if (*buf != 0 && isspace(*buf)) + while (*ptr != 0 && !isspace(*ptr)) + ptr++; + break; + + case 'Y': + case 'y': + if (*buf == 0 || isspace(*buf)) + break; + + if (!isdigit(*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit(*buf); buf++) + { + i *= 10; + i += *buf - '0'; + } + if (c == 'y' && i < 69) /* Unix Epoch pivot year */ + i += 100; + if (c == 'Y') + i -= 1900; + if (i < 0) + return 0; + + tm->tm_year = i; + + if (*buf != 0 && isspace(*buf)) + while (*ptr != 0 && !isspace(*ptr)) + ptr++; + break; + } + } + + return (char *) buf; +} \ No newline at end of file diff --git a/common/c_cpp/src/c/windows/wUuid.c b/common/c_cpp/src/c/windows/wUuid.c new file mode 100644 index 0000000..54124ec --- /dev/null +++ b/common/c_cpp/src/c/windows/wUuid.c @@ -0,0 +1,69 @@ +/* $Id: wUuid.c,v 1.1.2.3 2012/04/05 09:33:15 evinkeating 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 + */ + + +#include <time.h> +#include <stdio.h> +#include <stdlib.h> +#include "wombat/wUuid.h" + +static uint64_t gRoot = 0; +static uint16_t gGotroot = 0; + +#ifndef HOST_NAME_MAX +# define HOST_NAME_MAX 255 +#endif + +void wUuid_generate_time (wUuid myUuid) +{ +} + +void wUuid_unparse (wUuid myUuid, char* out) +{ + if (!gGotroot) + { + char hostname[HOST_NAME_MAX+1]; + if (gethostname (hostname, HOST_NAME_MAX) == 0) + { + struct in_addr addr; + struct hostent* host = gethostbyname (hostname); + if ((host != NULL) && (host->h_addrtype == AF_INET)) + { + /* Found host by name - we just look at the first entry. + * Maybe we should look at all of the entries (these are not + * aliases though). */ + addr = *(struct in_addr*)(host->h_addr_list[0]); + } + else + addr.s_addr=INADDR_NONE; + + gRoot = (((uint64_t)addr.s_addr) << 32) + getpid(); + } + else + { + gRoot = getpid(); + } + gGotroot = 1; + } + + srand (time (NULL)); + snprintf (out, 49, "%d%d", gRoot, rand() % 10000); +} -- 1.7.7.6
|
|