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


Michael Schonberg <mschonberg@...>
 

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

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

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

#define wGetCurrentThreadId pthread_self

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

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

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

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

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

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


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

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

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

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

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

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

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



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


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

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

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

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

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

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

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

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

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


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

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

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

timeZones = getTimeZones();

list_for_each (timeZones, checkTzIter, NULL);

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

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