Date   

[PATCH 12/30] Added wthread_global_mutex macros

Michael Schonberg <mschonberg@...>
 

In preparation for windows support, replace global phread_mutex_t and
wthread_mutex_t inititialized with PTHREAD_MUTEX_INITIALIZER with
wthread_gobal_mtuex() macros. This is required because Windows critical
sections and mutexes do not have static initializers. They need to be
protected with atomic access to a global state variable.

The macros are simple for Linux:
WTHREAD_GLOBAL_MUTEX(NAME) initializes the mutex
wthread_mutex_(un)lock(name) locks and unlocks.

For Windows, the lock macro increments a global reference count to ensure
that the mutex only gets initialized once, and spins on a another variable
to wait until initialization complets. See windows/port.h (future check
in) for details.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 7 +++++++
common/c_cpp/src/c/properties.l | 16 ++++++----------
2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 00a1405..8b4b873 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -58,6 +58,13 @@ extern "C"
#define MAMAExpBridgeDLL
#define MAMACALLTYPE

+/* PTHREAD static locks are easy */
+typedef pthread_mutex_t wthread_static_mutex_t;
+#define WSTATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+#define wthread_static_mutex_lock(x) pthread_mutex_lock((x))
+#define wthread_static_mutex_unlock(x) pthread_mutex_unlock((x))
+
+
#define WCOMMONINLINE inline static
#define WCOMMONFORCEINLINE inline static

diff --git a/common/c_cpp/src/c/properties.l b/common/c_cpp/src/c/properties.l
index 555483b..3c327e3 100644
--- a/common/c_cpp/src/c/properties.l
+++ b/common/c_cpp/src/c/properties.l
@@ -22,19 +22,15 @@
/** This file should be processed by FLEX or LEX **/

%{
+#include "port.h"
#include "propertyinternal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wombat/wincompat.h"

-#ifndef WIN32
-#include <pthread.h>
-#endif
-
extern int gPropertyDebug;
-
-wthread_mutex_t lexerLock = PTHREAD_MUTEX_INITIALIZER;
+wthread_static_mutex_t lexerLock = WSTATIC_MUTEX_INITIALIZER;

%}

@@ -200,12 +196,12 @@ propertiesImpl_ImportPropertiesFromFile( propertiesImpl this,
return 0;
}

- wthread_mutex_lock (&lexerLock);
+ wthread_static_mutex_lock (&lexerLock);
yyrestart(f);
properties = this;
yylex();
properties = NULL;
- wthread_mutex_unlock (&lexerLock);
+ wthread_static_mutex_unlock (&lexerLock);

free( fullPath );
fclose( f );
@@ -220,7 +216,7 @@ propertiesImpl_AddString( propertiesImpl this,

if( gPropertyDebug ) fprintf( stderr, "Scanning property string %s\n", string );

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

properties = this;
/* yy_scan_string changes the global lex stack buffer there lock until this
@@ -229,7 +225,7 @@ propertiesImpl_AddString( propertiesImpl this,
yylex();
yy_delete_buffer(buf);
properties = NULL;
- wthread_mutex_unlock (&lexerLock);
+ wthread_static_mutex_unlock (&lexerLock);

return 1;
}
--
1.7.7.6


[PATCH 11/30] Moved macros for inline functions to _os_/port.h

Michael Schonberg <mschonberg@...>
 

These are compiler/os specific.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 3 +++
common/c_cpp/src/c/wombat/wCommon.h | 27 ++-------------------------
2 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index f8b711c..00a1405 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -58,6 +58,9 @@ extern "C"
#define MAMAExpBridgeDLL
#define MAMACALLTYPE

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

diff --git a/common/c_cpp/src/c/wombat/wCommon.h b/common/c_cpp/src/c/wombat/wCommon.h
index 6b0752b..93c99d1 100644
--- a/common/c_cpp/src/c/wombat/wCommon.h
+++ b/common/c_cpp/src/c/wombat/wCommon.h
@@ -22,30 +22,7 @@
#ifndef _WOMBAT_WCOMMON_H
#define _WOMBAT_WCOMMON_H

-/* Inline function declarations are different on each platform, this define
- * provides the correct keyword.
- */
-#ifndef WCOMMONINLINE
-
-/* Windows */
-#ifdef WIN32
-
-#define WCOMMONINLINE __inline
-#define WCOMMONFORCEINLINE __forceinline
-
-/* Solaris */
-#elif __SUNPRO_C
-
-#define WCOMMONINLINE inline static
-#define WCOMMONFORCEINLINE inline static
-
-/* All other OS, assuming that GCC is supported. */
-#else
-#define WCOMMONINLINE inline static
-#define WCOMMONFORCEINLINE inline static
-
-#endif
-
-#endif
+/* Moved to _os_/port.h */
+#include "port.h"

#endif /* _WOMBAT_WCOMMON_H */
--
1.7.7.6


[PATCH 10/30] Move wSemaphore.c to linx/wSemaphroe.c

Michael Schonberg <mschonberg@...>
 

In preparation for windows support.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/configure.ac | 1 +
common/c_cpp/src/c/linux/wSemaphore.c | 57 ++++++++++
common/c_cpp/src/c/wSemaphore.c | 188 ---------------------------------
3 files changed, 58 insertions(+), 188 deletions(-)
create mode 100644 common/c_cpp/src/c/linux/wSemaphore.c
delete mode 100644 common/c_cpp/src/c/wSemaphore.c

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index dfd450b..39b145f 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -49,6 +49,7 @@ case $build_os in
linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h
src/c/machine_port.c:src/c/linux/machine.c
src/c/platform.c:src/c/linux/platform.c
+ src/c/wSemaphore.c:src/c/linux/wSemaphore.c
src/c/environment.c:src/c/linux/environment.c]) ;;
esac

diff --git a/common/c_cpp/src/c/linux/wSemaphore.c b/common/c_cpp/src/c/linux/wSemaphore.c
new file mode 100644
index 0000000..39327fb
--- /dev/null
+++ b/common/c_cpp/src/c/linux/wSemaphore.c
@@ -0,0 +1,57 @@
+/* $Id: wSemaphore.c,v 1.3.16.4 2011/09/07 09:45:08 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 "port.h"
+
+#include "wombat/wSemaphore.h"
+
+int wsem_timedwait (wsem_t* sem, unsigned int timeoutval)
+{
+ struct timespec ts;
+ struct timeval tv;
+
+ /*NB! - sem_timedwait() uses an absolute timeout on Linux!!*/
+ if (0!=gettimeofday (&tv, NULL))
+ {
+ return 0;
+ }
+
+ /*Convert the timeval to timespec*/
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec * 1000;
+
+ /* Now add our relative timeout to the current time
+ Integer division truncation will give us the seconds.
+ The timeout passed in is in milliseconds*/
+ ts.tv_sec += (timeoutval/1000);
+ /* Now calculate the relative nsec component*/
+ ts.tv_nsec += ((timeoutval%1000) * 1000000);
+
+ /* The nsec component may now be greater than the maximum possible value.
+ If so adjust the members accordingly. */
+ if (ts.tv_nsec>=1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ts.tv_sec += 1;
+ }
+
+ return sem_timedwait (sem, &ts);
+}
diff --git a/common/c_cpp/src/c/wSemaphore.c b/common/c_cpp/src/c/wSemaphore.c
deleted file mode 100644
index df2bae1..0000000
--- a/common/c_cpp/src/c/wSemaphore.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* $Id: wSemaphore.c,v 1.3.16.4 2011/09/07 09:45:08 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 "port.h"
-
-#include "wombat/wSemaphore.h"
-
-#ifndef WIN32
-
-int wsem_timedwait (wsem_t* sem, unsigned int timeoutval)
-{
- struct timespec ts;
- struct timeval tv;
-
- /*NB! - sem_timedwait() uses an absolute timeout on Linux!!*/
- if (0!=gettimeofday (&tv, NULL))
- {
- return 0;
- }
-
- /*Convert the timeval to timespec*/
- ts.tv_sec = tv.tv_sec;
- ts.tv_nsec = tv.tv_usec * 1000;
-
- /* Now add our relative timeout to the current time
- Integer division truncation will give us the seconds.
- The timeout passed in is in milliseconds*/
- ts.tv_sec += (timeoutval/1000);
- /* Now calculate the relative nsec component*/
- ts.tv_nsec += ((timeoutval%1000) * 1000000);
-
- /* The nsec component may now be greater than the maximum possible value.
- If so adjust the members accordingly. */
- if (ts.tv_nsec>=1000000000)
- {
- ts.tv_nsec -= 1000000000;
- ts.tv_sec += 1;
- }
-
- return sem_timedwait (sem, &ts);
-}
-
-
-#else
-
-
-/**
- * Waiting on Win32 semaphore involves a system call and is very inefficient. When
- * we test to determine if the queue is empty with a Win32 semaphore
- * WaitForSingleObject consumes all the CPU!!!!. We can be much more efficient using
- * a critical section and not call WaitForSingleObject when there is nothing on the Queue.
- */
-
-typedef struct
-{
- unsigned int mCount;
- HANDLE mEvent;
- CRITICAL_SECTION mCs;
-} sem_t;
-
-int wsem_init (wsem_t* result, int dummy, int count)
-{
- sem_t* sem = (sem_t*)malloc (sizeof (sem_t));
- if (sem == NULL)
- {
- return 1;
- }
-
- *result = sem;
- sem->mCount = count;
- sem->mEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
- if (sem->mEvent == INVALID_HANDLE_VALUE)
- {
- return 1;
- }
- InitializeCriticalSection (&sem->mCs);
-
- return 0;
-}
-
-int wsem_destroy (wsem_t* sem)
-{
- sem_t* impl = (sem_t*)(*sem);
- CloseHandle (impl->mEvent);
- DeleteCriticalSection (&impl->mCs);
- free (impl);
- return 0;
-}
-
-int wsem_post (wsem_t* sem)
-{
- sem_t* impl = (sem_t*)(*sem);
- EnterCriticalSection (&impl->mCs);
- impl->mCount++;
-
- /* MLS: we might be able to optimize here and only call SetEvent when the
- * count is 1; however, this would require extensive testing as a race
- * condition would stop dispatching altogether. I don't see any obvious
- * race conditions but I am a little concerned that there might be undefined
- * behavior when SetEvent and WaitForSingleObject race. MS does not
- * indicate this directly but the documentation for PulseEvent() mentions
- * some potential problems. We don't use pulse event for this reason.
- */
- SetEvent (impl->mEvent);
- LeaveCriticalSection (&impl->mCs);
- return 0;
-}
-
-int wsem_wait (wsem_t* sem)
-{
- unsigned int t = INFINITE;
- return wsem_timedwait (sem, t);
-
-}
-
-int wsem_trywait (wsem_t* sem)
-{
- sem_t* impl = (sem_t*)(*sem);
- int wouldWait = 0;
-
- EnterCriticalSection (&impl->mCs);
- if (impl->mCount)
- {
- impl->mCount--;
- }
- else
- {
- wouldWait = 1;
- }
- LeaveCriticalSection (&impl->mCs);
-
- return wouldWait;
-}
-
-int wsem_getvalue (wsem_t* sem, int* items)
-{
- sem_t* impl = (sem_t*)(*sem);
- EnterCriticalSection (&impl->mCs);
- *items = impl->mCount;
- LeaveCriticalSection (&impl->mCs);
-
- return 0;
-}
-
-
-
-int wsem_timedwait (wsem_t* sem, unsigned int timeoutval)
-{
- DWORD ts = (DWORD) timeoutval;
- sem_t* impl = (sem_t*)(*sem);
- int wait = 0;
-
- do
- {
- EnterCriticalSection (&impl->mCs);
- if (impl->mCount <= 1) ResetEvent (impl->mEvent);
- if (impl->mCount)
- {
- impl->mCount--;
- LeaveCriticalSection (&impl->mCs);
- return 0;
- }
- LeaveCriticalSection (&impl->mCs);
- } while (WAIT_OBJECT_0 == WaitForSingleObject (impl->mEvent, ts));
-
- /* Time out or worse */
- return -1;
-}
-
-#endif
--
1.7.7.6


[PATCH 09/30] Preparing timer.c and timer.c for windows support

Michael Schonberg <mschonberg@...>
 

These files are required by the Avis bridge as Avis does not provide
native timer support. The changes include changing pthread_xxx calls to
wthread_xxx calls, and implementing macros for socketpair and setting
nonblocking because windows does not support socketpair() and uses a
slightly differfent call for setting non-blocking on a socket.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 7 ++
common/c_cpp/src/c/timers.c | 176 +++++++++++++++++++--------------------
common/c_cpp/src/c/timers.h | 2 +-
3 files changed, 92 insertions(+), 93 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 1a00b25..f8b711c 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -40,6 +40,7 @@ extern "C"
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/times.h>
+#include <sys/socket.h>
#include <netinet/in.h>
#include <semaphore.h>
#include <dirent.h>
@@ -94,9 +95,15 @@ typedef long long int w_i64_t;

int wsem_timedwait (wsem_t* sem, unsigned int ts);

+/* Windows does not support AF_UNIX sockets, socketpairs, etc */
+#define wsocketpair(dom, type, prot, pair) (socketpair((dom),(type),(prot),(pair)))
+#define wsetnonblock(s) (fcntl((s), F_SETFL, O_NONBLOCK))
+
#define CPU_AFFINITY_SET cpu_set_t

/* User pthreads for linux */
+#define INVALID_THREAD (-1)
+
#define wthread_mutex_t pthread_mutex_t
#define wthread_mutex_init pthread_mutex_init
#define wthread_mutex_unlock pthread_mutex_unlock
diff --git a/common/c_cpp/src/c/timers.c b/common/c_cpp/src/c/timers.c
index 5901643..b5680c8 100644
--- a/common/c_cpp/src/c/timers.c
+++ b/common/c_cpp/src/c/timers.c
@@ -19,11 +19,10 @@
* 02110-1301 USA
*/

+#include "port.h"
#include "timers.h"

-#include <sys/socket.h>
#include <sys/types.h>
-#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
@@ -59,41 +58,33 @@ RB_GENERATE_STATIC(orderedTimeRBTree_, timerImpl_, mTreeEntry, orderedTimeRBTree

typedef struct timerHeapImpl_
{
- pthread_mutex_t mLock;
- pthread_t mDispatchThread;
+ wthread_mutex_t mLock;
+ wthread_t mDispatchThread;
orderedTimeRBTree mTimeTree;
int mSockPair[2];
- pthread_mutex_t mEndingLock;
- pthread_cond_t mEndingCond;
+ wthread_mutex_t mEndingLock;
+ wthread_cond_t mEndingCond;
int mEnding;
} timerHeapImpl;


int createTimerHeap (timerHeap* heap)
{
- pthread_mutexattr_t attr;
+ wthread_mutexattr_t attr;
timerHeapImpl* heapImpl = (timerHeapImpl*)calloc (1, sizeof (timerHeapImpl));
if (heapImpl == NULL)
return -1;

- pthread_mutexattr_init (&attr);
- pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+ wthread_mutexattr_init (&attr);
+ wthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);

/* Need to make the lock recursive as it should be possible to remove timers
in the call back */
- if (pthread_mutex_init (&heapImpl->mLock, &attr) != 0)
- {
- free (heapImpl);
- return -1;
- }
+ wthread_mutex_init (&heapImpl->mLock, &attr);

- if (pthread_mutex_init (&heapImpl->mEndingLock, NULL) != 0)
- {
- free (heapImpl);
- return -1;
- }
+ wthread_mutex_init (&heapImpl->mEndingLock, NULL);

- if (pthread_cond_init (&heapImpl->mEndingCond, NULL) != 0)
+ if (wthread_cond_init (&heapImpl->mEndingCond, NULL) != 0)
{
free (heapImpl);
return -1;
@@ -101,14 +92,14 @@ int createTimerHeap (timerHeap* heap)

RB_INIT (&heapImpl->mTimeTree);

- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, heapImpl->mSockPair) == -1)
+ if (wsocketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, heapImpl->mSockPair) == -1)
{
free (heapImpl);
return -1;
}

- fcntl (heapImpl->mSockPair[0], F_SETFL, O_NONBLOCK);
- fcntl (heapImpl->mSockPair[1], F_SETFL, O_NONBLOCK);
+ wsetnonblock(heapImpl->mSockPair[0]);
+ wsetnonblock(heapImpl->mSockPair[1]);

*heap = heapImpl;
return 0;
@@ -126,42 +117,42 @@ void* dispatchEntry (void *closure)
timerImpl* ele = NULL;
struct timeval timeout, now, *timeptr;

- pthread_mutex_lock (&heap->mLock);
+ wthread_mutex_lock (&heap->mLock);
ele = RB_MIN (orderedTimeRBTree_, &heap->mTimeTree);

while (1)
{
if (ele==NULL)
timeptr = NULL;
- else
- {
- timeptr = &timeout;
- gettimeofday (&now, NULL);
- if (!timercmp(&ele->mTimeout, &now, >))
- timerclear (&timeout);
- else
- timersub(&ele->mTimeout, &now, &timeout);
- }
- pthread_mutex_unlock (&heap->mLock);
-
- /* Sit on Select as it has the best resolution */
- FD_ZERO(&wakeUpDes);
- FD_SET(heap->mSockPair[0], &wakeUpDes);
+ else
+ {
+ timeptr = &timeout;
+ gettimeofday (&now, NULL);
+ if (!timercmp(&ele->mTimeout, &now, >))
+ timerclear (&timeout);
+ else
+ timersub(&ele->mTimeout, &now, &timeout);
+ }
+ wthread_mutex_unlock (&heap->mLock);
+
+ /* Sit on Select as it has the best resolution */
+ FD_ZERO(&wakeUpDes);
+ FD_SET(heap->mSockPair[0], &wakeUpDes);

- selectReturn = select(heap->mSockPair[0] + 1, &wakeUpDes, NULL, NULL, timeptr);
+ selectReturn = select(heap->mSockPair[0] + 1, &wakeUpDes, NULL, NULL, timeptr);

- pthread_mutex_lock (&heap->mLock);
- if (selectReturn == -1)
- {
+ wthread_mutex_lock (&heap->mLock);
+ if (selectReturn == -1)
+ {
if (errno != EINTR)
- perror("select()");
- }
- else if (selectReturn)
- {
- int numRead = 0;
- do
- {
- numRead = read(heap->mSockPair[0], &buff, sizeof (buff));
+ perror("select()");
+ }
+ else if (selectReturn)
+ {
+ int numRead = 0;
+ do
+ {
+ numRead = read(heap->mSockPair[0], &buff, sizeof (buff));
if (numRead < 0)
{
if (errno == EINTR)
@@ -169,33 +160,33 @@ void* dispatchEntry (void *closure)
}
if (buff == 'd')
goto endLoop;
- }
- while (numRead > 0);
- }
-
- /* Dispatch all expired timers */
- ele = RB_MIN (orderedTimeRBTree_, &heap->mTimeTree);
- /* It is possible that this could be empty if the timer was removed before timeout */
- if (ele != NULL)
- {
+ }
+ while (numRead > 0);
+ }
+
+ /* Dispatch all expired timers */
+ ele = RB_MIN (orderedTimeRBTree_, &heap->mTimeTree);
+ /* It is possible that this could be empty if the timer was removed before timeout */
+ if (ele != NULL)
+ {
gettimeofday (&now, NULL);
- while (!timercmp(&ele->mTimeout, &now, >))
- {
- RB_REMOVE (orderedTimeRBTree_, &heap->mTimeTree, ele);
- ele->mCb (ele, ele->mClosure);
- ele = RB_MIN (orderedTimeRBTree_, &heap->mTimeTree);
- /* No timers left so break */
- if (ele == NULL)
- break;
+ while (!timercmp(&ele->mTimeout, &now, >))
+ {
+ RB_REMOVE (orderedTimeRBTree_, &heap->mTimeTree, ele);
+ ele->mCb (ele, ele->mClosure);
+ ele = RB_MIN (orderedTimeRBTree_, &heap->mTimeTree);
+ /* No timers left so break */
+ if (ele == NULL)
+ break;
}
- }
+ }
}
endLoop:
- pthread_mutex_unlock (&heap->mLock);
- pthread_mutex_lock (&heap->mEndingLock);
+ wthread_mutex_unlock (&heap->mLock);
+ wthread_mutex_lock (&heap->mEndingLock);
heap->mEnding = 1;
- pthread_cond_signal (&heap->mEndingCond);
- pthread_mutex_unlock (&heap->mEndingLock);
+ wthread_cond_signal (&heap->mEndingCond);
+ wthread_mutex_unlock (&heap->mEndingLock);
}
return NULL;
}
@@ -206,14 +197,15 @@ int startDispatchTimerHeap (timerHeap heap)
return -1;
{
timerHeapImpl* heapImpl = (timerHeapImpl*)heap;
- return pthread_create(&heapImpl->mDispatchThread, NULL, dispatchEntry, (void*)heapImpl);
+ return wthread_create(&heapImpl->mDispatchThread, NULL, dispatchEntry, (void*)heapImpl);
}
}

-pthread_t timerHeapGetTid (timerHeap heap)
+wthread_t timerHeapGetTid (timerHeap heap)
{
if (heap == NULL)
- return -1;
+ return INVALID_THREAD;
+
{
timerHeapImpl* heapImpl = (timerHeapImpl*)heap;
return heapImpl->mDispatchThread;
@@ -240,13 +232,13 @@ writeagain:
}
}

- pthread_mutex_lock (&heapImpl->mEndingLock);
+ wthread_mutex_lock (&heapImpl->mEndingLock);
while (heapImpl->mEnding == 0)
{
- pthread_cond_wait (&heapImpl->mEndingCond,
+ wthread_cond_wait (&heapImpl->mEndingCond,
&heapImpl->mEndingLock);
}
- pthread_mutex_unlock (&heapImpl->mEndingLock);
+ wthread_mutex_unlock (&heapImpl->mEndingLock);
free (heapImpl);
}
return 0;
@@ -273,7 +265,7 @@ int createTimer (timerElement* timer, timerHeap heap, timerFireCb cb, struct tim
ele->mCb = cb;
ele->mClosure = closure;

- pthread_mutex_lock (&heapImpl->mLock);
+ wthread_mutex_lock (&heapImpl->mLock);
nextTimeOut = RB_MIN (orderedTimeRBTree_, &heapImpl->mTimeTree);
if (nextTimeOut == NULL)
kickPipe = 1;
@@ -286,18 +278,18 @@ int createTimer (timerElement* timer, timerHeap heap, timerFireCb cb, struct tim
{
writeagain:
if (write (heapImpl->mSockPair[1], "w", 1) < 0)
- {
- if ((errno == EINTR) || (errno == EAGAIN))
- goto writeagain;
- else
- {
- perror ("write()");
- pthread_mutex_unlock (&heapImpl->mLock);
- return -1;
- }
- }
+ {
+ if ((errno == EINTR) || (errno == EAGAIN))
+ goto writeagain;
+ else
+ {
+ perror ("write()");
+ wthread_mutex_unlock (&heapImpl->mLock);
+ return -1;
+ }
+ }
}
- pthread_mutex_unlock (&heapImpl->mLock);
+ wthread_mutex_unlock (&heapImpl->mLock);

*timer = ele;
}
@@ -313,10 +305,10 @@ int destroyTimer (timerHeap heap, timerElement timer)
timerImpl* ele = (timerImpl*)timer;
timerHeapImpl* heapImpl = (timerHeapImpl*)heap;

- pthread_mutex_lock (&heapImpl->mLock);
+ wthread_mutex_lock (&heapImpl->mLock);
if (RB_FIND (orderedTimeRBTree_, &heapImpl->mTimeTree, ele))
RB_REMOVE (orderedTimeRBTree_, &heapImpl->mTimeTree, ele);
- pthread_mutex_unlock (&heapImpl->mLock);
+ wthread_mutex_unlock (&heapImpl->mLock);
free (ele);
}
return 0;
diff --git a/common/c_cpp/src/c/timers.h b/common/c_cpp/src/c/timers.h
index 38a3732..4f4fb4d 100644
--- a/common/c_cpp/src/c/timers.h
+++ b/common/c_cpp/src/c/timers.h
@@ -31,7 +31,7 @@ typedef void (*timerFireCb)(timerElement timer, void* mClosure);

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

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


[PATCH 08/30] wlock.c changes for windows support

Michael Schonberg <mschonberg@...>
 

The pthread_xxx references changed to wthread_xxx

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

diff --git a/common/c_cpp/src/c/wlock.c b/common/c_cpp/src/c/wlock.c
index 9cd7d21..e23daa6 100644
--- a/common/c_cpp/src/c/wlock.c
+++ b/common/c_cpp/src/c/wlock.c
@@ -39,10 +39,10 @@ wlock_create( void )
{
wLockImpl* rval = calloc(1, sizeof( wLockImpl ) );

- pthread_mutexattr_t attr;
- pthread_mutexattr_init (&attr);
- pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);
- pthread_mutex_init (&rval->mMutex, &attr);
+ wthread_mutexattr_t attr;
+ wthread_mutexattr_init (&attr);
+ wthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+ wthread_mutex_init (&rval->mMutex, &attr);

return( rval );
}
--
1.7.7.6


[PATCH 07/30] Changes for queue.c to build on windows

Michael Schonberg <mschonberg@...>
 

We need to call the wthread_xxx macros rather than pthread_xxx. A few
compiler warnings and bugs fixed as well.

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

diff --git a/common/c_cpp/src/c/queue.c b/common/c_cpp/src/c/queue.c
index 03cf678..6ae740b 100644
--- a/common/c_cpp/src/c/queue.c
+++ b/common/c_cpp/src/c/queue.c
@@ -19,15 +19,12 @@
* 02110-1301 USA
*/

-
#include "port.h"
-
-#include "wombat/wSemaphore.h"
-
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include "wombat/queue.h"
+#include "wombat/wSemaphore.h"

#define WQ_REMOVE(impl, ele) \
(ele)->mPrev->mNext = (ele)->mNext; \
@@ -52,7 +49,7 @@ typedef struct wombatQueueItem_
typedef struct
{
wsem_t mSem;
- pthread_mutex_t mLock; /* for multiple readers */
+ wthread_mutex_t mLock; /* for multiple readers */

uint8_t mUnblocking;

@@ -113,10 +110,7 @@ wombatQueue_create (wombatQueue queue, uint32_t maxSize, uint32_t initialSize,
return WOMBAT_QUEUE_SEM_ERR;
}

- if (pthread_mutex_init( &impl->mLock, NULL) != 0)
- {
- return WOMBAT_QUEUE_MTX_ERR;
- }
+ wthread_mutex_init( &impl->mLock, NULL);

initialSize = initialSize == 0 ? WOMBAT_QUEUE_CHUNK_SIZE : initialSize;
wombatQueueImpl_allocChunk (impl, initialSize);
@@ -134,7 +128,7 @@ wombatQueue_destroy (wombatQueue queue)
wombatQueueStatus result = WOMBAT_QUEUE_OK;
wombatQueueItem *curItem;

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);
/* Free the datas */
curItem = impl->mChunks;
while (curItem)
@@ -144,9 +138,9 @@ wombatQueue_destroy (wombatQueue queue)
curItem = tmp;
}

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

- /* Thee wsem_destroy and pthread_mutex_destroy methods simply makes
+ /* Thee wsem_destroy and wthread_mutex_destroy methods simply makes
* sure that no threads are waiting since the synchronization objects can
* not be destroyed if threads are waiting. We could devise a mechanism
* to ensure that dispatchers are not waiting or dispatching. We can
@@ -162,11 +156,7 @@ wombatQueue_destroy (wombatQueue queue)
result = WOMBAT_QUEUE_SEM_ERR;
}

- if (pthread_mutex_destroy( &impl->mLock) != 0)
- {
- result = WOMBAT_QUEUE_MTX_ERR;
- }
-
+ wthread_mutex_destroy( &impl->mLock);
free (impl);
return WOMBAT_QUEUE_OK;
}
@@ -201,7 +191,7 @@ wombatQueue_enqueue (wombatQueue queue,
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
wombatQueueItem* item = NULL;

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

/* If there are no items in the free list, allocate some. It will set the
* next free node to NULL if the queue is too big or there is no memory.
@@ -227,7 +217,7 @@ wombatQueue_enqueue (wombatQueue queue,

/* Notify next available thread that an item is ready */
wsem_post (&impl->mSem);
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

return WOMBAT_QUEUE_OK;
}
@@ -254,7 +244,7 @@ wombatQueue_dispatchInt (wombatQueue queue, void** data, void** closure,

if (isTimed)
{
- if (wsem_timedwait (&impl->mSem, timout) !=0)
+ if (wsem_timedwait (&impl->mSem, (unsigned int)timout) !=0)
return WOMBAT_QUEUE_TIMEOUT;
}
else
@@ -271,7 +261,7 @@ wombatQueue_dispatchInt (wombatQueue queue, void** data, void** closure,
}
}

- pthread_mutex_lock (&impl->mLock); /* May be multiple readers */
+ wthread_mutex_lock (&impl->mLock); /* May be multiple readers */

/* remove the item */
head = impl->mHead.mNext;
@@ -288,7 +278,7 @@ wombatQueue_dispatchInt (wombatQueue queue, void** data, void** closure,
closure_ = head->mClosure;
data_ = head->mData;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

if (cb)
{
@@ -326,7 +316,7 @@ wombatQueue_poll (wombatQueue queue, void** data, void** closure)
return WOMBAT_QUEUE_WOULD_BLOCK;
}

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

head = impl->mHead.mNext;
WQ_REMOVE (impl, head);
@@ -342,7 +332,7 @@ wombatQueue_poll (wombatQueue queue, void** data, void** closure)
closure_ = head->mClosure;
data_ = head->mData;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

if (cb)
{
@@ -375,7 +365,7 @@ wombatQueueImpl_allocChunk ( wombatQueueImpl* impl, unsigned int items)

/* Create the links */
{
- int i;
+ unsigned int i;
for (i = 0; i < items - 1; i++) /* -1 so last is NULL */
{
result[i].mNext = &result[i+1];
@@ -408,14 +398,14 @@ wombatQueue_flush (wombatQueue queue, wombatQueueFlushCb cb, void* closure)
return WOMBAT_QUEUE_OK;
}

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

head = impl->mHead.mNext;
WQ_REMOVE (impl, head);

cb (queue, head->mData, head->mClosure, closure);

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

return WOMBAT_QUEUE_OK;
}
@@ -425,7 +415,7 @@ wombatQueueStatus
wombatQueue_next (wombatQueue queue, void** data, void** closure)
{
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);
impl->mIterator = impl->mIterator->mNext;

if (impl->mIterator == &impl->mTail) /* at end */
@@ -439,7 +429,7 @@ wombatQueue_next (wombatQueue queue, void** data, void** closure)
* expected.
*/
impl->mIterator = impl->mIterator->mPrev;
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_END;
}

@@ -448,7 +438,7 @@ wombatQueue_next (wombatQueue queue, void** data, void** closure)
if (closure)
*closure = impl->mIterator->mClosure;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_OK;
}

@@ -456,7 +446,7 @@ wombatQueueStatus
wombatQueue_prev (wombatQueue queue, void** data, void** closure)
{
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);
impl->mIterator = impl->mIterator->mPrev;

if (impl->mIterator == &impl->mHead) /* at beginning */
@@ -470,7 +460,7 @@ wombatQueue_prev (wombatQueue queue, void** data, void** closure)
* expected.
*/
impl->mIterator = impl->mIterator->mNext;
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_END;
}

@@ -479,7 +469,7 @@ wombatQueue_prev (wombatQueue queue, void** data, void** closure)
if (closure)
*closure = impl->mIterator->mClosure;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_OK;
}

@@ -487,7 +477,7 @@ wombatQueueStatus
wombatQueue_cur (wombatQueue queue, void** data, void** closure)
{
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

if (impl->mIterator == &impl->mHead || impl->mIterator == &impl->mTail)
{
@@ -496,7 +486,7 @@ wombatQueue_cur (wombatQueue queue, void** data, void** closure)
if (closure)
*closure = NULL;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_END;
}

@@ -505,7 +495,7 @@ wombatQueue_cur (wombatQueue queue, void** data, void** closure)
if (closure)
*closure = impl->mIterator->mClosure;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_OK;
}

@@ -514,11 +504,11 @@ wombatQueue_remove (wombatQueue queue, void** data, void** closure)
{
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
wombatQueueItem* tmp;
- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

if (impl->mIterator == &impl->mHead || impl->mIterator == &impl->mTail)
{
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_END;
}

@@ -537,7 +527,7 @@ wombatQueue_remove (wombatQueue queue, void** data, void** closure)
tmp->mNext = impl->mFirstFree.mNext;
impl->mFirstFree.mNext = tmp;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_OK;
}

@@ -550,11 +540,11 @@ wombatQueue_insertAfter (wombatQueue queue,
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
wombatQueueItem* item = NULL;

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

/* If we are empty and positioned on the tail move to the head. */
if (impl->mIterator == &impl->mTail)
- impl->mIterator == &impl->mHead;
+ impl->mIterator = &impl->mHead;

/* If there are no items in the free list, allocate some. It will set the
* Next free node to NULL if the queue is too big or there is no memeory.
@@ -580,7 +570,7 @@ wombatQueue_insertAfter (wombatQueue queue,

/* Notify next available thread that an item is ready */
wsem_post (&impl->mSem);
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

return WOMBAT_QUEUE_OK;
}
@@ -594,11 +584,11 @@ wombatQueue_insertBefore (wombatQueue queue,
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
wombatQueueItem* item = NULL;

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

/* If we are empty and positioned on the head move to the tail. */
if (impl->mIterator == &impl->mHead)
- impl->mIterator == &impl->mTail;
+ impl->mIterator = &impl->mTail;

/* If there are no items in the free list, allocate some. It will set the
* Next free node to NULL if the queue is too big or there is no memeory.
@@ -624,7 +614,7 @@ wombatQueue_insertBefore (wombatQueue queue,

/* Notify next available thread that an item is ready */
wsem_post (&impl->mSem);
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

return WOMBAT_QUEUE_OK;
}
@@ -636,18 +626,18 @@ wombatQueue_replace (wombatQueue queue,
void* closure)
{
wombatQueueImpl* impl = (wombatQueueImpl*)queue;
- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);

if (impl->mIterator == &impl->mHead || impl->mIterator == &impl->mTail)
{
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_END;
}

impl->mIterator->mData = data;
impl->mIterator->mClosure = closure;

- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);
return WOMBAT_QUEUE_OK;
}

@@ -656,9 +646,9 @@ wombatQueue_begin (wombatQueue queue)
{
wombatQueueImpl* impl = (wombatQueueImpl*)queue;

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);
impl->mIterator = &impl->mHead;
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

return WOMBAT_QUEUE_OK;
}
@@ -668,9 +658,9 @@ wombatQueue_end (wombatQueue queue)
{
wombatQueueImpl* impl = (wombatQueueImpl*)queue;

- pthread_mutex_lock (&impl->mLock);
+ wthread_mutex_lock (&impl->mLock);
impl->mIterator = &impl->mTail;
- pthread_mutex_unlock (&impl->mLock);
+ wthread_mutex_unlock (&impl->mLock);

return WOMBAT_QUEUE_OK;
}
--
1.7.7.6


[PATCH 06/30] Moved wincompat.h contents to _os_/port.h

Michael Schonberg <mschonberg@...>
 

In preparation for windows support, wincompat.h now simply includes the
appropriate port.h file. The file remains in the tree as other products
include it.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 4 +++
common/c_cpp/src/c/wombat/wincompat.h | 48 +--------------------------------
2 files changed, 5 insertions(+), 47 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index a1de75d..1a00b25 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -81,6 +81,8 @@ typedef long long int w_i64_t;
/* For delimiting multiple paths in env variables properties */
#define PATH_DELIM ':'

+#define PATHSEP "/"
+
/* Use Posix semaphores for Linux */
#define wsem_t sem_t
#define wsem_init sem_init
@@ -92,6 +94,8 @@ typedef long long int w_i64_t;

int wsem_timedwait (wsem_t* sem, unsigned int ts);

+#define CPU_AFFINITY_SET cpu_set_t
+
/* User pthreads for linux */
#define wthread_mutex_t pthread_mutex_t
#define wthread_mutex_init pthread_mutex_init
diff --git a/common/c_cpp/src/c/wombat/wincompat.h b/common/c_cpp/src/c/wombat/wincompat.h
index 756ecea..c80c60b 100644
--- a/common/c_cpp/src/c/wombat/wincompat.h
+++ b/common/c_cpp/src/c/wombat/wincompat.h
@@ -22,53 +22,7 @@
#ifndef _WOMBAT_WINCOMPAT_H
#define _WOMBAT_WINCOMPAT_H

+/* Moved to _os_/port.h */
#include "port.h"
-#include "wConfig.h"
-
-#define PATHSEP "/"
-#define CPU_AFFINITY_SET cpu_set_t
-
-#define wthread_mutex_t pthread_mutex_t
-#define wthread_mutex_init pthread_mutex_init
-#define wthread_mutex_unlock pthread_mutex_unlock
-#define wthread_mutex_lock pthread_mutex_lock
-#define wthread_mutex_destroy pthread_mutex_destroy
-
-#define wthread_t pthread_t
-#define wthread_detach pthread_detach
-#define wthread_self pthread_self
-#define wthread_equal pthread_equal
-#define wthread_cleanup_push pthread_cleanup_push
-#define wthread_cleanup_pop pthread_cleanup_pop
-#define wthread_join pthread_join
-#define wthread_create pthread_create
-#define wthread_exit pthread_exit
-
-#define wthread_cond_t pthread_cond_t
-#define wthread_cond_init pthread_cond_init
-#define wthread_cond_signal pthread_cond_signal
-#define wthread_cond_destroy pthread_cond_destroy
-#define wthread_cond_wait pthread_cond_wait
-
-#define wthread_spinlock_t pthread_spinlock_t
-#define wthread_spin_init pthread_spin_init
-#define wthread_spin_unlock pthread_spin_unlock
-#define wthread_spin_lock pthread_spin_lock
-#define wthread_spin_destroy pthread_spin_destroy
-
-#define wdlopen dlopen
-#define wdlsym dlsym
-#define wdlclose dlclose
-#define wdlerror dlerror
-
-#define wthread_attr_t pthread_attr_t
-#define wthread_attr_init pthread_attr_init
-#define wthread_attr_setdetachstate pthread_attr_setdetachstate
-
-#define wthread_mutexattr_t pthread_mutexattr_t
-#define wthread_mutexattr_init pthread_mutexattr_init
-#define wthread_mutexattr_settype pthread_mutexattr_settype
-
-#define wGetCurrentThreadId pthread_self

#endif /* _WOMBAT_WINCOMPAT_H */
--
1.7.7.6


[PATCH 05/30] Moved platform.c to linux/platform.c

Michael Schonberg <mschonberg@...>
 

The funcitons for accessing shared libraries in platform.c are os
dependent. This is in prepration for windows support.

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

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index 31e78fc..dfd450b 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -48,6 +48,7 @@ AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
case $build_os in
linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h
src/c/machine_port.c:src/c/linux/machine.c
+ src/c/platform.c:src/c/linux/platform.c
src/c/environment.c:src/c/linux/environment.c]) ;;
esac

diff --git a/common/c_cpp/src/c/linux/platform.c b/common/c_cpp/src/c/linux/platform.c
new file mode 100644
index 0000000..8bf7f4e
--- /dev/null
+++ b/common/c_cpp/src/c/linux/platform.c
@@ -0,0 +1,85 @@
+/* $Id: platform.c,v 1.8.16.2 2011/08/10 14:53:24 nicholasmarriott Exp $
+ *
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "port.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+#include "platform.h"
+#include "wombat/wincompat.h"
+
+/**
+ * Functions relating to DLLs/shared objects
+ */
+char errorBuf[25];
+LIB_HANDLE openSharedLib (const char* libName, const char* path)
+{
+ size_t nameLength;
+ char* fileName;
+ LIB_HANDLE handle;
+
+ if (path)
+ {
+ nameLength = strlen(path) + strlen(libName) + strlen(LIB_EXTENSION) +
+ strlen(PATHSEP) + strlen("lib") + 1;
+ }
+ else
+ {
+ nameLength = strlen(libName) + strlen(LIB_EXTENSION) + strlen("lib") + 1;
+ }
+ fileName = (char*) calloc (nameLength, sizeof (char));
+ if(fileName == NULL)
+ {
+ return 0;
+ }
+
+ if (path)
+ {
+ snprintf (fileName, nameLength, "%s%slib%s%s", path, PATHSEP, libName, LIB_EXTENSION);
+ }
+ else
+ {
+ snprintf (fileName, nameLength, "lib%s%s", libName, LIB_EXTENSION);
+ }
+
+ handle = dlopen (fileName, RTLD_NOW | RTLD_GLOBAL);
+
+ free(fileName);
+ return handle;
+}
+
+
+int closeSharedLib (LIB_HANDLE handle)
+{
+ return dlclose (handle);
+}
+
+void* loadLibFunc (LIB_HANDLE handle, const char* funcName)
+{
+ return dlsym (handle, funcName);
+}
+
+char* getLibError (void)
+{
+ return dlerror();
+}
diff --git a/common/c_cpp/src/c/platform.c b/common/c_cpp/src/c/platform.c
deleted file mode 100644
index 8bf7f4e..0000000
--- a/common/c_cpp/src/c/platform.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* $Id: platform.c,v 1.8.16.2 2011/08/10 14:53:24 nicholasmarriott Exp $
- *
- * OpenMAMA: The open middleware agnostic messaging API
- * Copyright (C) 2011 NYSE Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#include "port.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stddef.h>
-
-#include "platform.h"
-#include "wombat/wincompat.h"
-
-/**
- * Functions relating to DLLs/shared objects
- */
-char errorBuf[25];
-LIB_HANDLE openSharedLib (const char* libName, const char* path)
-{
- size_t nameLength;
- char* fileName;
- LIB_HANDLE handle;
-
- if (path)
- {
- nameLength = strlen(path) + strlen(libName) + strlen(LIB_EXTENSION) +
- strlen(PATHSEP) + strlen("lib") + 1;
- }
- else
- {
- nameLength = strlen(libName) + strlen(LIB_EXTENSION) + strlen("lib") + 1;
- }
- fileName = (char*) calloc (nameLength, sizeof (char));
- if(fileName == NULL)
- {
- return 0;
- }
-
- if (path)
- {
- snprintf (fileName, nameLength, "%s%slib%s%s", path, PATHSEP, libName, LIB_EXTENSION);
- }
- else
- {
- snprintf (fileName, nameLength, "lib%s%s", libName, LIB_EXTENSION);
- }
-
- handle = dlopen (fileName, RTLD_NOW | RTLD_GLOBAL);
-
- free(fileName);
- return handle;
-}
-
-
-int closeSharedLib (LIB_HANDLE handle)
-{
- return dlclose (handle);
-}
-
-void* loadLibFunc (LIB_HANDLE handle, const char* funcName)
-{
- return dlsym (handle, funcName);
-}
-
-char* getLibError (void)
-{
- return dlerror();
-}
--
1.7.7.6


[PATCH 04/30] Moved linux code from machine.c to linux/machine.c

Michael Schonberg <mschonberg@...>
 

In preparation for windows support, machine.c contains generic code while
Linux specific code is now in linux/machine.c

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/configure.ac | 1 +
common/c_cpp/src/c/Makefile.am | 1 +
common/c_cpp/src/c/linux/machine.c | 599 ++++++++++++++++++++++++++++++++++++
common/c_cpp/src/c/machine.c | 566 +---------------------------------
4 files changed, 603 insertions(+), 564 deletions(-)
create mode 100644 common/c_cpp/src/c/linux/machine.c

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index b6f537a..31e78fc 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -47,6 +47,7 @@ AC_CANONICAL_BUILD()
AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
case $build_os in
linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h
+ src/c/machine_port.c:src/c/linux/machine.c
src/c/environment.c:src/c/linux/environment.c]) ;;
esac

diff --git a/common/c_cpp/src/c/Makefile.am b/common/c_cpp/src/c/Makefile.am
index facce7c..362d457 100644
--- a/common/c_cpp/src/c/Makefile.am
+++ b/common/c_cpp/src/c/Makefile.am
@@ -66,6 +66,7 @@ libwombatcommon_la_SOURCES = \
list.c \
lookup2.c \
machine.c \
+ machine_port.c \
platform.c \
properties.l \
property.c \
diff --git a/common/c_cpp/src/c/linux/machine.c b/common/c_cpp/src/c/linux/machine.c
new file mode 100644
index 0000000..375734c
--- /dev/null
+++ b/common/c_cpp/src/c/linux/machine.c
@@ -0,0 +1,599 @@
+/* $Id: machine.c,v 1.50.16.9 2011/08/10 14:53:24 nicholasmarriott Exp $
+ *
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "port.h"
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "wombat/machine.h"
+#include "wombat/wtable.h"
+
+/* Macros for extract VSIZE and RSS from /proc/pid/stats files */
+#define bytetok(x) (((x) + 512) >> 10)
+
+#define MAXPROCSARRAY 1000 /* need to keep track of processes */
+
+extern int useLWP;
+static int numProc = 0;
+static pid_t procTable[MAXPROCSARRAY];
+static int flagTable[MAXPROCSARRAY];
+
+static char* skip_ws (char* p);
+static char* skip_token (char* p);
+static int uniqueSet (int lhs, int rhs);
+static int isInSet (int lhs, int rhs, int pid);
+void searchDirs (int procChildren[],
+ int dirNames[],
+ int count,
+ cpuVals* cpv,
+ int tempPid);
+pid_t getParentPid (pid_t pid,
+ int childFlag);
+
+time_t getTimeSinceEpoch(void)
+{
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ return tv.tv_sec;
+}
+
+static char* skip_ws(char* p)
+{
+ while (isspace(*p))
+ p++;
+ return p;
+}
+
+static char* skip_token(char* p)
+{
+ while (isspace(*p))
+ p++;
+ while (*p && !isspace(*p))
+ p++;
+ return p;
+}
+
+void getProcAndChildCpu(int pid, cpuVals* cpv)
+{
+ int i=0;
+ struct cpuVals tempCpu;
+ tempCpu.userTime=0;
+ tempCpu.sysTime=0;
+ cpv->userTime=0;
+ cpv->sysTime=0;
+ for(i = 0; i < numProc; i++)
+ {
+ getProcessInfo(procTable[i],NULL,&tempCpu,flagTable[i]);
+ cpv->userTime += tempCpu.userTime;
+ cpv->sysTime += tempCpu.sysTime;
+ }
+}
+
+int getNumCpu(void)
+{
+ return sysconf (_SC_NPROCESSORS_ONLN);
+}
+
+void initProcTable(int pid, int debuginfo)
+{
+ DIR *dir = NULL;
+ char buffer[4096] = "";
+ struct dirent *ent = NULL;
+ pid_t allPpidTable[MAXPROCSARRAY];
+ pid_t allProcTable[MAXPROCSARRAY];
+ int allFlagTable[MAXPROCSARRAY];
+ pid_t tempPid = 0;
+ int numAllProc = 0;
+ int childFlag = 0;
+ int i = 0;
+ int currentIndex = 0;
+ int childrenIndex = 0;
+ pid_t pgrp = 0;
+ char *dirNamePtr = NULL;
+
+ /* Trying to find all child process by using ppid and pid relationship.*/
+ dir = opendir("/proc/");
+ while ((ent = readdir(dir)) != NULL)
+ {
+ dirNamePtr = ent->d_name;
+ if (ent->d_name[0] == '.')
+ {
+ dirNamePtr += 1;
+ childFlag = 1;
+ }
+ if (isdigit(dirNamePtr[0]))
+ {
+ tempPid=(pid_t)strtol(dirNamePtr,NULL,10);
+
+ if(tempPid!=pid)
+ {
+ allPpidTable[numAllProc] = getParentPid(tempPid,childFlag);
+ if (allPpidTable[numAllProc] == 0)
+ {
+ /* process must have exited, do not store information reg
+ this pid */
+ continue;
+ }
+ allProcTable[numAllProc] = tempPid;
+ allFlagTable[numAllProc] = childFlag;
+ numAllProc++;
+
+ }
+ }
+ childFlag = 0;
+ }
+ closedir(dir);
+
+ procTable[0]=pid;
+ flagTable[0]=0;
+ numProc=1;
+ while(1)
+ {
+ for(i=0;i<numAllProc;i++)
+ {
+ if(allPpidTable[i]==procTable[currentIndex])
+ {
+ childrenIndex++;
+ procTable[childrenIndex]=allProcTable[i];
+ flagTable[childrenIndex]=allFlagTable[i];
+ numProc++;
+ }
+ }
+ if(currentIndex==childrenIndex)
+ {
+ break;
+ }
+ currentIndex++;
+ }
+
+
+ /* Trying to find all child processes by using group pid. */
+ dir = opendir("/proc/");
+ while ((ent = readdir(dir)) != NULL)
+ {
+ /* get pgrp related processes*/
+ dirNamePtr = ent->d_name;
+ childFlag = 0;
+ if (ent->d_name[0] == '.')
+ {
+ dirNamePtr += 1;
+ childFlag = 1;
+ }
+ if (isdigit(dirNamePtr[0]))
+ {
+ tempPid=(int) strtol(dirNamePtr,NULL,10);
+ if (tempPid==pid)
+ continue;
+ pgrp = getpgid (tempPid);
+ if (pgrp == pid)
+ {
+ procTable[numProc]=tempPid;
+ flagTable[numProc]=childFlag;
+ numProc++;
+ }
+ }
+ }
+ closedir(dir);
+
+ /* Trying to find all child processes via LWP on 64 bit */
+ if (useLWP)
+ {
+ sprintf(buffer, "/proc/%d/task", pid);
+ dir = opendir(buffer);
+ if (dir != NULL)
+ {
+ while ((ent = readdir(dir)) != NULL)
+ {
+ dirNamePtr = ent->d_name;
+ childFlag = 0;
+ if (isdigit(dirNamePtr[0]))
+ {
+ tempPid=(int) strtol(dirNamePtr,NULL,10);
+ if (tempPid==pid)
+ continue;
+ procTable[numProc]=tempPid;
+ flagTable[numProc]=childFlag;
+ numProc++;
+ }
+ }
+ closedir(dir);
+ }
+ }
+
+ /* On some linux kernels only one of above methods works. On other kernel
+ * versons both work. So we need to remove duplicated entries
+ */
+
+ numProc = uniqueSet (0, numProc);
+
+ if(debuginfo)
+ {
+ printf("Debug Info for Stats - Processes Table\n");
+ for(i=0;i<numProc;i++)
+ {
+ printf("%d-%d\n",procTable[i],flagTable[i]);
+ }
+ }
+}
+
+/* Take out duplicated entries. So the result is a unique set of pids.*/
+static int uniqueSet (int lhs, int rhs)
+{
+ int curProc = procTable[lhs];
+ int dup = 0;
+
+ if (lhs == rhs - 1)
+ {
+ if (procTable [lhs] == procTable [rhs])
+ return lhs;
+ else
+ return rhs;
+ }
+ rhs = uniqueSet (lhs + 1, rhs);
+ dup = isInSet (lhs + 1, rhs, curProc);
+ if (dup != -1)
+ {
+ procTable[dup] = procTable[rhs];
+ flagTable[dup] = flagTable[rhs];
+ rhs --;
+ }
+ return rhs;
+}
+
+static int isInSet (int lhs, int rhs, int pid)
+{
+ int i = 0;
+ for (i = lhs; i <= rhs; i++)
+ {
+ if (pid == procTable[i])
+ return i;
+ }
+ return -1;
+}
+
+pid_t getParentPid(pid_t pid, int childFlag)
+{
+ char buffer[4096], *p, *q;
+ int state =0;
+ pid_t ppid=0;
+ char name[64];
+ int len = 0;
+ /* grab the proc stat info in one go */
+ {
+ int fd, len;
+ if(childFlag==1)
+ sprintf(buffer, "/proc/.%d/stat", pid);
+ else
+ sprintf(buffer, "/proc/%d/stat", pid);
+
+ fd = open(buffer, 0);
+
+ if (fd==-1)
+ {
+ return 0;
+ }
+
+ len = read(fd, buffer, sizeof(buffer)-1);
+ close(fd);
+ if (len==-1)
+ {
+ return 0;
+ }
+ buffer[len] = '\0';
+ }
+ /* parse out the status */
+ p = buffer;
+ p = strchr(p, '('); /* skip pid */
+ if (p==NULL)
+ {
+ /* Process has exited since the pid was initially obtained */
+ return 0;
+ }
+ {
+ ++p; /* increment past the '(' char */
+ q = strrchr(p, ')'); /*process name*/
+ len = q-p;
+ if (len >= sizeof(name))
+ len = sizeof(name)-1;
+ memcpy(name, p, len);
+ name[len] = 0;
+ p = q+1;
+ }
+ p = skip_ws(p);
+ switch (*p++)
+ {
+ case 'R': state = 1; break;
+ case 'S': state = 2; break;
+ case 'D': state = 3; break;
+ case 'Z': state = 4; break;
+ case 'T': state = 5; break;
+ case 'W': state = 6; break;
+ }
+ ppid = (pid_t)strtol(p,&p,10); /* skip ppid */
+ return ppid;
+}
+
+void searchDirs(int procChildren[], int dirNames[],
+ int count,cpuVals *cpv,int tempPid)
+{
+ int x=0,ppid=0;
+ struct cpuVals tempCpu;
+ for(x = 0; x < count; x++)
+ {
+ ppid = getProcessInfo(dirNames[x],NULL,&tempCpu,procChildren[x]);
+ if(ppid==tempPid)
+ {
+ cpv->userTime += tempCpu.userTime;
+ cpv->sysTime += tempCpu.sysTime;
+ searchDirs(procChildren,dirNames,count,cpv,dirNames[x]);
+ }
+ else
+ {
+ tempCpu.userTime=0;
+ tempCpu.sysTime=0;
+ }
+ }
+}
+
+static long pagetok(long x)
+{
+ /*
+ * This replaces:
+ *
+ * #include <asm/page.h>
+ *
+ * #define pagetok(x) ((x) << (PAGE_SHIFT - 10))
+ *
+ * which is deprecated according to RedHat
+ */
+ static int initDone = 0;
+ static int pageShift = 0;
+
+ if (!initDone) {
+ int pgSize = sysconf(_SC_PAGESIZE);
+
+ /* We have to calc the power-of-2 that the page size represents */
+ for (pageShift = 0; !(pgSize & 0x01); pageShift++, pgSize >>= 1)
+ ;
+
+ /* Convert to 1K units */
+ pageShift -= 10;
+ initDone = 1;
+ }
+ return (x << pageShift);
+}
+
+int getProcessInfo(int pid ,memVals *memV,cpuVals *cpuV,int childFlag)
+{
+ char buffer[4096], *p;
+ int state =0;
+ int ppid=0;
+ long totalMem = getTotalSystemMem();
+ double cpuClockTicksPerSecond = (double)sysconf(_SC_CLK_TCK);
+ /* grab the proc stat info in one go */
+ {
+ int fd, len;
+ if(childFlag==1)
+ sprintf(buffer, "/proc/.%d/stat", pid);
+ else
+ sprintf(buffer, "/proc/%d/stat", pid);
+
+ fd = open(buffer, 0);
+ if (fd == -1)
+ {
+ if (cpuV)
+ {
+ cpuV->userTime = 0;
+ cpuV->sysTime = 0;
+ }
+ if(memV)
+ {
+ memV->vsize = 0;
+ memV->rss = 0;
+ memV->memPercent = 0;
+ }
+ return 0;
+ }
+ len = read(fd, buffer, sizeof(buffer)-1);
+ close(fd);
+ buffer[len] = '\0';
+ }
+ /* parse out the status */
+ p = buffer;
+ p = strchr(p, '(')+1; /* skip pid */
+ {
+ char name[64];
+ char *q = strrchr(p, ')'); /*process name*/
+ int len = q-p;
+ if (len >= sizeof(name))
+ len = sizeof(name)-1;
+ memcpy(name, p, len);
+ name[len] = 0;
+ p = q+1;
+ }
+ p = skip_ws(p);
+ switch (*p++)
+ {
+ case 'R': state = 1; break;
+ case 'S': state = 2; break;
+ case 'D': state = 3; break;
+ case 'Z': state = 4; break;
+ case 'T': state = 5; break;
+ case 'W': state = 6; break;
+ }
+
+ ppid = (int)strtol(p,&p,10); /* skip ppid */
+ p = skip_token(p); /* skip pgrp */
+ p = skip_token(p); /* skip session */
+ p = skip_token(p); /* skip tty */
+ p = skip_token(p); /* skip tty pgrp */
+ p = skip_token(p); /* skip flags */
+ p = skip_token(p); /* skip min flt */
+ p = skip_token(p); /* skip cmin flt */
+ p = skip_token(p); /* skip maj flt */
+ p = skip_token(p); /* skip cmaj flt */
+ if(cpuV)
+ {
+ cpuV->userTime = ((double)strtoul(p, &p, 10))/cpuClockTicksPerSecond; /* utime */
+ cpuV->sysTime = ((double)strtoul(p, &p, 10))/cpuClockTicksPerSecond; /* stime */
+ }
+ else
+ {
+ p = skip_token(p); /* skip utime */
+ p = skip_token(p); /* skip stime */
+ }
+ p = skip_token(p); /* skip cutime */
+ p = skip_token(p); /* skip cstime */
+
+ p = skip_token(p); /* skip priority */
+ p = skip_token(p); /* skip nice */
+
+ p = skip_token(p); /* skip timeout */
+ p = skip_token(p); /* skip it_real_val */
+ p = skip_token(p); /* skip start_time */
+
+ if(memV)
+ {
+ memV->vsize = bytetok(strtoul(p, &p, 10)); /* vsize */
+ memV->rss = pagetok(strtoul(p, &p, 10)); /* rss */
+ memV->memPercent =(double)(memV->rss*100.0)/(double)totalMem;
+ }
+
+ return ppid;
+}
+
+int getSystemMemory (systemMemVals* mem)
+{
+ FILE* fp;
+ char buffer[4096];
+ size_t bytes_read;
+ char* match;
+ long totalMem=-1,freeMem=-1,totalSwap=-1,freeSwap=-1;
+
+ fp = fopen ("/proc/meminfo","r");
+ if (fp==NULL)
+ return -1;
+ bytes_read = fread(buffer, 1, sizeof (buffer), fp);
+ fclose(fp);
+
+ if (bytes_read==0 || bytes_read == sizeof (buffer))
+ return -1;
+ buffer[bytes_read] = '\0';
+
+ match = strstr (buffer, "MemTotal:");
+ if (match == NULL)
+ return -1;
+ sscanf (match, "MemTotal:%ld", &totalMem);
+ match = strstr (buffer, "MemFree:");
+ if (match == NULL)
+ return -1;
+ sscanf (match, "MemFree:%ld", &freeMem);
+ match = strstr (buffer, "SwapTotal:");
+ if (match == NULL)
+ return -1;
+ sscanf (match, "SwapTotal:%ld", &totalSwap);
+ match = strstr (buffer, "SwapFree:");
+ if (match == NULL)
+ return -1;
+ sscanf (match, "SwapFree:%ld", &freeSwap);
+
+ mem->totalMem=totalMem;
+ mem->freeMem=freeMem;
+ mem->totalSwap=totalSwap;
+ mem->freeSwap=freeSwap;
+ return 0;
+}
+
+long getTotalSystemMem(void)
+{
+ /* get system wide memory usage */
+ FILE* fp;
+ char buffer[4096];
+ size_t bytes_read;
+ char* match;
+ long totalMem=-1;
+
+ fp = fopen ("/proc/meminfo","r");
+ if (fp==NULL)
+ return totalMem;
+ bytes_read = fread(buffer, 1, sizeof (buffer), fp);
+ fclose(fp);
+
+ if (bytes_read==0 || bytes_read == sizeof (buffer))
+ return totalMem;
+ buffer[bytes_read] = '\0';
+
+ match = strstr (buffer, "MemTotal:");
+ if (match == NULL)
+ return totalMem;
+
+ sscanf (match, "MemTotal:%ld", &totalMem);
+ return totalMem;
+}
+
+void getSystemTime(double* upTime,double* idleTime)
+{
+ FILE* fp;
+ *upTime = 0;
+ *idleTime = 0;
+ fp = fopen("/proc/uptime", "r");
+ if (fp==NULL)
+ return;
+ fscanf (fp, "%lf %lf\n", upTime, idleTime);
+ fclose (fp);
+}
+
+void getProcessorTime(long* usageTime,long* idleTime,int processor)
+{
+ FILE* fp;
+ char buffer[4096];
+ char cpu[10];
+ size_t bytes_read;
+ char* match;
+ long user_read, system_read, nice_read, idle_read;
+ *usageTime = 0;
+ *idleTime = 0;
+
+ fp = fopen ("/proc/stat","r");
+ if (fp==NULL)
+ return;
+ bytes_read = fread(buffer, 1, sizeof (buffer), fp);
+ fclose(fp);
+ if (bytes_read==0 || bytes_read == sizeof (buffer))
+ return;
+ buffer[bytes_read] = '\0';
+ sprintf(cpu,"cpu%d ",processor);
+ match = strstr (buffer, cpu);
+ if (match == NULL)
+ return;
+ sscanf(match, "%*s %ld %ld %ld %ld", &user_read,&system_read,&nice_read,&idle_read);
+ *usageTime = user_read + system_read + nice_read;
+ *idleTime = idle_read;
+}
diff --git a/common/c_cpp/src/c/machine.c b/common/c_cpp/src/c/machine.c
index 512e1ab..fc43143 100644
--- a/common/c_cpp/src/c/machine.c
+++ b/common/c_cpp/src/c/machine.c
@@ -1,5 +1,4 @@
-/* $Id: machine.c,v 1.50.16.9 2011/08/10 14:53:24 nicholasmarriott Exp $
- *
+/*
* OpenMAMA: The open middleware agnostic messaging API
* Copyright (C) 2011 NYSE Inc.
*
@@ -35,28 +34,7 @@
#include "wombat/machine.h"
#include "wombat/wtable.h"

-static int useLWP = 1;
-
-/* Macros for extract VSIZE and RSS from /proc/pid/stats files */
-#define bytetok(x) (((x) + 512) >> 10)
-
-#define MAXPROCSARRAY 1000 /* need to keep track of processes */
-
-static int numProc = 0;
-static pid_t procTable[MAXPROCSARRAY];
-static int flagTable[MAXPROCSARRAY];
-
-static char* skip_ws (char* p);
-static char* skip_token (char* p);
-static int uniqueSet (int lhs, int rhs);
-static int isInSet (int lhs, int rhs, int pid);
-void searchDirs (int procChildren[],
- int dirNames[],
- int count,
- cpuVals* cpv,
- int tempPid);
-pid_t getParentPid (pid_t pid,
- int childFlag);
+int useLWP = 1;

void enableLWP(void)
{
@@ -76,543 +54,3 @@ void getMemVals(int pid, memVals *memV)
getProcessInfo(pid,memV,NULL,0);
}

-time_t getTimeSinceEpoch(void)
-{
- struct timeval tv;
- gettimeofday(&tv,NULL);
- return tv.tv_sec;
-}
-
-static char* skip_ws(char* p)
-{
- while (isspace(*p))
- p++;
- return p;
-}
-
-static char* skip_token(char* p)
-{
- while (isspace(*p))
- p++;
- while (*p && !isspace(*p))
- p++;
- return p;
-}
-
-void getProcAndChildCpu(int pid, cpuVals* cpv)
-{
- int i=0;
- struct cpuVals tempCpu;
- tempCpu.userTime=0;
- tempCpu.sysTime=0;
- cpv->userTime=0;
- cpv->sysTime=0;
- for(i = 0; i < numProc; i++)
- {
- getProcessInfo(procTable[i],NULL,&tempCpu,flagTable[i]);
- cpv->userTime += tempCpu.userTime;
- cpv->sysTime += tempCpu.sysTime;
- }
-}
-
-int getNumCpu(void)
-{
- return sysconf (_SC_NPROCESSORS_ONLN);
-}
-
-void initProcTable(int pid, int debuginfo)
-{
- DIR *dir = NULL;
- char buffer[4096] = "";
- struct dirent *ent = NULL;
- pid_t allPpidTable[MAXPROCSARRAY];
- pid_t allProcTable[MAXPROCSARRAY];
- int allFlagTable[MAXPROCSARRAY];
- pid_t tempPid = 0;
- int numAllProc = 0;
- int childFlag = 0;
- int i = 0;
- int currentIndex = 0;
- int childrenIndex = 0;
- pid_t pgrp = 0;
- char *dirNamePtr = NULL;
-
- /* Trying to find all child process by using ppid and pid relationship.*/
- dir = opendir("/proc/");
- while ((ent = readdir(dir)) != NULL)
- {
- dirNamePtr = ent->d_name;
- if (ent->d_name[0] == '.')
- {
- dirNamePtr += 1;
- childFlag = 1;
- }
- if (isdigit(dirNamePtr[0]))
- {
- tempPid=(pid_t)strtol(dirNamePtr,NULL,10);
-
- if(tempPid!=pid)
- {
- allPpidTable[numAllProc] = getParentPid(tempPid,childFlag);
- if (allPpidTable[numAllProc] == 0)
- {
- /* process must have exited, do not store information reg
- this pid */
- continue;
- }
- allProcTable[numAllProc] = tempPid;
- allFlagTable[numAllProc] = childFlag;
- numAllProc++;
-
- }
- }
- childFlag = 0;
- }
- closedir(dir);
-
- procTable[0]=pid;
- flagTable[0]=0;
- numProc=1;
- while(1)
- {
- for(i=0;i<numAllProc;i++)
- {
- if(allPpidTable[i]==procTable[currentIndex])
- {
- childrenIndex++;
- procTable[childrenIndex]=allProcTable[i];
- flagTable[childrenIndex]=allFlagTable[i];
- numProc++;
- }
- }
- if(currentIndex==childrenIndex)
- {
- break;
- }
- currentIndex++;
- }
-
-
- /* Trying to find all child processes by using group pid. */
- dir = opendir("/proc/");
- while ((ent = readdir(dir)) != NULL)
- {
- /* get pgrp related processes*/
- dirNamePtr = ent->d_name;
- childFlag = 0;
- if (ent->d_name[0] == '.')
- {
- dirNamePtr += 1;
- childFlag = 1;
- }
- if (isdigit(dirNamePtr[0]))
- {
- tempPid=(int) strtol(dirNamePtr,NULL,10);
- if (tempPid==pid)
- continue;
- pgrp = getpgid (tempPid);
- if (pgrp == pid)
- {
- procTable[numProc]=tempPid;
- flagTable[numProc]=childFlag;
- numProc++;
- }
- }
- }
- closedir(dir);
-
- /* Trying to find all child processes via LWP on 64 bit */
- if (useLWP)
- {
- sprintf(buffer, "/proc/%d/task", pid);
- dir = opendir(buffer);
- if (dir != NULL)
- {
- while ((ent = readdir(dir)) != NULL)
- {
- dirNamePtr = ent->d_name;
- childFlag = 0;
- if (isdigit(dirNamePtr[0]))
- {
- tempPid=(int) strtol(dirNamePtr,NULL,10);
- if (tempPid==pid)
- continue;
- procTable[numProc]=tempPid;
- flagTable[numProc]=childFlag;
- numProc++;
- }
- }
- closedir(dir);
- }
- }
-
- /* On some linux kernels only one of above methods works. On other kernel
- * versons both work. So we need to remove duplicated entries
- */
-
- numProc = uniqueSet (0, numProc);
-
- if(debuginfo)
- {
- printf("Debug Info for Stats - Processes Table\n");
- for(i=0;i<numProc;i++)
- {
- printf("%d-%d\n",procTable[i],flagTable[i]);
- }
- }
-}
-
-/* Take out duplicated entries. So the result is a unique set of pids.*/
-static int uniqueSet (int lhs, int rhs)
-{
- int curProc = procTable[lhs];
- int dup = 0;
-
- if (lhs == rhs - 1)
- {
- if (procTable [lhs] == procTable [rhs])
- return lhs;
- else
- return rhs;
- }
- rhs = uniqueSet (lhs + 1, rhs);
- dup = isInSet (lhs + 1, rhs, curProc);
- if (dup != -1)
- {
- procTable[dup] = procTable[rhs];
- flagTable[dup] = flagTable[rhs];
- rhs --;
- }
- return rhs;
-}
-
-static int isInSet (int lhs, int rhs, int pid)
-{
- int i = 0;
- for (i = lhs; i <= rhs; i++)
- {
- if (pid == procTable[i])
- return i;
- }
- return -1;
-}
-
-pid_t getParentPid(pid_t pid, int childFlag)
-{
- char buffer[4096], *p, *q;
- int state =0;
- pid_t ppid=0;
- char name[64];
- int len = 0;
- /* grab the proc stat info in one go */
- {
- int fd, len;
- if(childFlag==1)
- sprintf(buffer, "/proc/.%d/stat", pid);
- else
- sprintf(buffer, "/proc/%d/stat", pid);
-
- fd = open(buffer, 0);
-
- if (fd==-1)
- {
- return 0;
- }
-
- len = read(fd, buffer, sizeof(buffer)-1);
- close(fd);
- if (len==-1)
- {
- return 0;
- }
- buffer[len] = '\0';
- }
- /* parse out the status */
- p = buffer;
- p = strchr(p, '('); /* skip pid */
- if (p==NULL)
- {
- /* Process has exited since the pid was initially obtained */
- return 0;
- }
- {
- ++p; /* increment past the '(' char */
- q = strrchr(p, ')'); /*process name*/
- len = q-p;
- if (len >= sizeof(name))
- len = sizeof(name)-1;
- memcpy(name, p, len);
- name[len] = 0;
- p = q+1;
- }
- p = skip_ws(p);
- switch (*p++)
- {
- case 'R': state = 1; break;
- case 'S': state = 2; break;
- case 'D': state = 3; break;
- case 'Z': state = 4; break;
- case 'T': state = 5; break;
- case 'W': state = 6; break;
- }
- ppid = (pid_t)strtol(p,&p,10); /* skip ppid */
- return ppid;
-}
-
-void searchDirs(int procChildren[], int dirNames[],
- int count,cpuVals *cpv,int tempPid)
-{
- int x=0,ppid=0;
- struct cpuVals tempCpu;
- for(x = 0; x < count; x++)
- {
- ppid = getProcessInfo(dirNames[x],NULL,&tempCpu,procChildren[x]);
- if(ppid==tempPid)
- {
- cpv->userTime += tempCpu.userTime;
- cpv->sysTime += tempCpu.sysTime;
- searchDirs(procChildren,dirNames,count,cpv,dirNames[x]);
- }
- else
- {
- tempCpu.userTime=0;
- tempCpu.sysTime=0;
- }
- }
-}
-
-static long pagetok(long x)
-{
- /*
- * This replaces:
- *
- * #include <asm/page.h>
- *
- * #define pagetok(x) ((x) << (PAGE_SHIFT - 10))
- *
- * which is deprecated according to RedHat
- */
- static int initDone = 0;
- static int pageShift = 0;
-
- if (!initDone) {
- int pgSize = sysconf(_SC_PAGESIZE);
-
- /* We have to calc the power-of-2 that the page size represents */
- for (pageShift = 0; !(pgSize & 0x01); pageShift++, pgSize >>= 1)
- ;
-
- /* Convert to 1K units */
- pageShift -= 10;
- initDone = 1;
- }
- return (x << pageShift);
-}
-
-int getProcessInfo(int pid ,memVals *memV,cpuVals *cpuV,int childFlag)
-{
- char buffer[4096], *p;
- int state =0;
- int ppid=0;
- long totalMem = getTotalSystemMem();
- double cpuClockTicksPerSecond = (double)sysconf(_SC_CLK_TCK);
- /* grab the proc stat info in one go */
- {
- int fd, len;
- if(childFlag==1)
- sprintf(buffer, "/proc/.%d/stat", pid);
- else
- sprintf(buffer, "/proc/%d/stat", pid);
-
- fd = open(buffer, 0);
- if (fd == -1)
- {
- if (cpuV)
- {
- cpuV->userTime = 0;
- cpuV->sysTime = 0;
- }
- if(memV)
- {
- memV->vsize = 0;
- memV->rss = 0;
- memV->memPercent = 0;
- }
- return 0;
- }
- len = read(fd, buffer, sizeof(buffer)-1);
- close(fd);
- buffer[len] = '\0';
- }
- /* parse out the status */
- p = buffer;
- p = strchr(p, '(')+1; /* skip pid */
- {
- char name[64];
- char *q = strrchr(p, ')'); /*process name*/
- int len = q-p;
- if (len >= sizeof(name))
- len = sizeof(name)-1;
- memcpy(name, p, len);
- name[len] = 0;
- p = q+1;
- }
- p = skip_ws(p);
- switch (*p++)
- {
- case 'R': state = 1; break;
- case 'S': state = 2; break;
- case 'D': state = 3; break;
- case 'Z': state = 4; break;
- case 'T': state = 5; break;
- case 'W': state = 6; break;
- }
-
- ppid = (int)strtol(p,&p,10); /* skip ppid */
- p = skip_token(p); /* skip pgrp */
- p = skip_token(p); /* skip session */
- p = skip_token(p); /* skip tty */
- p = skip_token(p); /* skip tty pgrp */
- p = skip_token(p); /* skip flags */
- p = skip_token(p); /* skip min flt */
- p = skip_token(p); /* skip cmin flt */
- p = skip_token(p); /* skip maj flt */
- p = skip_token(p); /* skip cmaj flt */
- if(cpuV)
- {
- cpuV->userTime = ((double)strtoul(p, &p, 10))/cpuClockTicksPerSecond; /* utime */
- cpuV->sysTime = ((double)strtoul(p, &p, 10))/cpuClockTicksPerSecond; /* stime */
- }
- else
- {
- p = skip_token(p); /* skip utime */
- p = skip_token(p); /* skip stime */
- }
- p = skip_token(p); /* skip cutime */
- p = skip_token(p); /* skip cstime */
-
- p = skip_token(p); /* skip priority */
- p = skip_token(p); /* skip nice */
-
- p = skip_token(p); /* skip timeout */
- p = skip_token(p); /* skip it_real_val */
- p = skip_token(p); /* skip start_time */
-
- if(memV)
- {
- memV->vsize = bytetok(strtoul(p, &p, 10)); /* vsize */
- memV->rss = pagetok(strtoul(p, &p, 10)); /* rss */
- memV->memPercent =(double)(memV->rss*100.0)/(double)totalMem;
- }
-
- return ppid;
-}
-
-int getSystemMemory (systemMemVals* mem)
-{
- FILE* fp;
- char buffer[4096];
- size_t bytes_read;
- char* match;
- long totalMem=-1,freeMem=-1,totalSwap=-1,freeSwap=-1;
-
- fp = fopen ("/proc/meminfo","r");
- if (fp==NULL)
- return -1;
- bytes_read = fread(buffer, 1, sizeof (buffer), fp);
- fclose(fp);
-
- if (bytes_read==0 || bytes_read == sizeof (buffer))
- return -1;
- buffer[bytes_read] = '\0';
-
- match = strstr (buffer, "MemTotal:");
- if (match == NULL)
- return -1;
- sscanf (match, "MemTotal:%ld", &totalMem);
- match = strstr (buffer, "MemFree:");
- if (match == NULL)
- return -1;
- sscanf (match, "MemFree:%ld", &freeMem);
- match = strstr (buffer, "SwapTotal:");
- if (match == NULL)
- return -1;
- sscanf (match, "SwapTotal:%ld", &totalSwap);
- match = strstr (buffer, "SwapFree:");
- if (match == NULL)
- return -1;
- sscanf (match, "SwapFree:%ld", &freeSwap);
-
- mem->totalMem=totalMem;
- mem->freeMem=freeMem;
- mem->totalSwap=totalSwap;
- mem->freeSwap=freeSwap;
- return 0;
-}
-
-long getTotalSystemMem(void)
-{
- /* get system wide memory usage */
- FILE* fp;
- char buffer[4096];
- size_t bytes_read;
- char* match;
- long totalMem=-1;
-
- fp = fopen ("/proc/meminfo","r");
- if (fp==NULL)
- return totalMem;
- bytes_read = fread(buffer, 1, sizeof (buffer), fp);
- fclose(fp);
-
- if (bytes_read==0 || bytes_read == sizeof (buffer))
- return totalMem;
- buffer[bytes_read] = '\0';
-
- match = strstr (buffer, "MemTotal:");
- if (match == NULL)
- return totalMem;
-
- sscanf (match, "MemTotal:%ld", &totalMem);
- return totalMem;
-}
-
-void getSystemTime(double* upTime,double* idleTime)
-{
- FILE* fp;
- *upTime = 0;
- *idleTime = 0;
- fp = fopen("/proc/uptime", "r");
- if (fp==NULL)
- return;
- fscanf (fp, "%lf %lf\n", upTime, idleTime);
- fclose (fp);
-}
-
-void getProcessorTime(long* usageTime,long* idleTime,int processor)
-{
- FILE* fp;
- char buffer[4096];
- char cpu[10];
- size_t bytes_read;
- char* match;
- long user_read, system_read, nice_read, idle_read;
- *usageTime = 0;
- *idleTime = 0;
-
- fp = fopen ("/proc/stat","r");
- if (fp==NULL)
- return;
- bytes_read = fread(buffer, 1, sizeof (buffer), fp);
- fclose(fp);
- if (bytes_read==0 || bytes_read == sizeof (buffer))
- return;
- buffer[bytes_read] = '\0';
- sprintf(cpu,"cpu%d ",processor);
- match = strstr (buffer, cpu);
- if (match == NULL)
- return;
- sscanf(match, "%*s %ld %ld %ld %ld", &user_read,&system_read,&nice_read,&idle_read);
- *usageTime = user_read + system_read + nice_read;
- *idleTime = idle_read;
-}
--
1.7.7.6


[PATCH 03/30] Moved environment.c to linux/environment.c

Michael Schonberg <mschonberg@...>
 

The funcitons for manipulating environement variables are os-specific. We
may want to add a generic directory for a default implemenation.

This is in preparation for the windows port.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/configure.ac | 3 +-
common/c_cpp/src/c/environment.c | 59 --------------------------------
common/c_cpp/src/c/linux/environment.c | 59 ++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 60 deletions(-)
delete mode 100644 common/c_cpp/src/c/environment.c
create mode 100644 common/c_cpp/src/c/linux/environment.c

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index 9b08055..b6f537a 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -46,7 +46,8 @@ AC_CANONICAL_BUILD()
# Set up symbolic links for os-specific files
AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
case $build_os in
- linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h]) ;;
+ linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h
+ src/c/environment.c:src/c/linux/environment.c]) ;;
esac

# Checks for programs.
diff --git a/common/c_cpp/src/c/environment.c b/common/c_cpp/src/c/environment.c
deleted file mode 100644
index 34affc0..0000000
--- a/common/c_cpp/src/c/environment.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $Id: environment.c,v 1.2.2.3.12.2 2011/08/10 14:53:23 nicholasmarriott Exp $
- *
- * OpenMAMA: The open middleware agnostic messaging API
- * Copyright (C) 2011 NYSE Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-/* ********************************************************** */
-/* Includes. */
-/* ********************************************************** */
-#include "stdlib.h"
-#include "wombat/environment.h"
-
-int environment_deleteVariable(const char *name)
-{
- return unsetenv(name);
-}
-
-const char *environment_getVariable(const char *name)
-{
- /* Returns. */
- const char *ret = NULL;
-
- /* Check the argument. */
- if(name != NULL)
- {
- ret = getenv(name);
- }
-
- return ret;
-}
-
-int environment_setVariable(const char *name, const char *value)
-{
- /* Returns. */
- int ret = -1;
-
- /* Check the arguments. */
- if((name != NULL) && (value != NULL))
- {
- ret = setenv(name, value, 1);
- }
-
- return ret;
-}
diff --git a/common/c_cpp/src/c/linux/environment.c b/common/c_cpp/src/c/linux/environment.c
new file mode 100644
index 0000000..34affc0
--- /dev/null
+++ b/common/c_cpp/src/c/linux/environment.c
@@ -0,0 +1,59 @@
+/* $Id: environment.c,v 1.2.2.3.12.2 2011/08/10 14:53:23 nicholasmarriott Exp $
+ *
+ * OpenMAMA: The open middleware agnostic messaging API
+ * Copyright (C) 2011 NYSE Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* ********************************************************** */
+/* Includes. */
+/* ********************************************************** */
+#include "stdlib.h"
+#include "wombat/environment.h"
+
+int environment_deleteVariable(const char *name)
+{
+ return unsetenv(name);
+}
+
+const char *environment_getVariable(const char *name)
+{
+ /* Returns. */
+ const char *ret = NULL;
+
+ /* Check the argument. */
+ if(name != NULL)
+ {
+ ret = getenv(name);
+ }
+
+ return ret;
+}
+
+int environment_setVariable(const char *name, const char *value)
+{
+ /* Returns. */
+ int ret = -1;
+
+ /* Check the arguments. */
+ if((name != NULL) && (value != NULL))
+ {
+ ret = setenv(name, value, 1);
+ }
+
+ return ret;
+}
--
1.7.7.6


[PATCH 02/30] Moved Calling Convention from wConfig.h to linux/port.h

Michael Schonberg <mschonberg@...>
 

These are OS specific. wConfig remains for backwards compatibilit; however, it
may be removed in the future. They all default to a no-op for Linux, but are
required for different Windows builds (dynamic, static, debug, etc).

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

diff --git a/common/c_cpp/src/c/wombat/wConfig.h b/common/c_cpp/src/c/wombat/wConfig.h
index c2137df..c7cf7af 100644
--- a/common/c_cpp/src/c/wombat/wConfig.h
+++ b/common/c_cpp/src/c/wombat/wConfig.h
@@ -22,76 +22,8 @@
#ifndef _WOMBAT_WCONFIG_H
#define _WOMBAT_WCONFIG_H

-/* This section defines export semantics for functions exported or
- * imported from Windows libraries. All exported functions must
- * be decorated with the appropriate modifier.
- */
-
-#if defined( WIN32 ) && defined( COMMON_DLL )
- /* We are building common dll */
-# define COMMONExpDLL __declspec( dllexport )
-#elif defined( WIN32 ) && defined( MAMA_DLL ) && defined( MAMA )
- /* We are building mama as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL __declspec( dllexport )
-#elif defined( WIN32 ) && 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
-#elif defined( WIN32 ) && defined( MAMA_DLL ) && defined( MAMACPP )
- /* We are building mamacpp as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL
-#elif defined( WIN32 ) && defined( MAMDA_DLL ) && defined( MAMDA )
- /* We are building mamda as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllimport )
-# define MAMDAExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL
-#elif defined( WIN32 ) && defined( MAMDA_DLL ) && defined( MAMDAOPT )
- /* We are building extra mamda as a dll */
-# define COMMONExpDLL __declspec( dllimport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllimport )
-# define MAMDAExpDLL __declspec( dllimport )
-# define MAMDAOPTExpDLL __declspec( dllexport )
-# define MAMAExpBridgeDLL
-#elif defined( WIN32 ) && !defined ( MAMA_STATIC ) && !defined ( WMW_STATIC ) && !defined (WIRECACHE_STATIC)
- /* We are building mama apps (non static) */
-# define COMMONExpDLL __declspec( dllimport )
-# define WMWExpDLL __declspec( dllexport )
-# define MAMAExpDLL __declspec( dllimport )
-# define MAMACPPExpDLL __declspec( dllimport )
-# define MAMDAExpDLL __declspec( dllimport )
-# define MAMDAOPTExpDLL __declspec( dllimport )
-# define MAMAExpBridgeDLL
-#else
- /* We are building on linux or statically */
-# define COMMONExpDLL
-# define WMWExpDLL
-# define MAMAExpDLL
-# define MAMACPPExpDLL
-# define MAMDAExpDLL
-# define MAMDAOPTExpDLL
-# define MAMAExpBridgeDLL
-#endif /* WIN32 */
-
-/*
- * Windows callback functions require the standard call type.
- */
-#ifdef WIN32
-#define MAMACALLTYPE __stdcall
-#else
-#define MAMACALLTYPE
-#endif
+/* Moved to _os_/port/h */
+#include "port.h"

#endif /* _WOMBAT_WCONFIG_H */

--
1.7.7.6


[PATCH 01/30] Move Linux Specific #includes and Macros #includes

Michael Schonberg <mschonberg@...>
 

This is the first in a series of patches to add Windows suport. Rather
than peppering the source with #ifdef osXXX blocks, os specific headers
and source files go into directory with the same name as the OS. Ideally,
there will be one linux directory in common, one windows, etc.; however,
the same approach should be used in other modules that require os specific
implementations. "#ifdef OS" should be avoided whenever possible.

Each OS directory must at least contain a file "port.h". This file
contains os-specific includes and macros. At some point, it might make
sense to subdivide port.h into several headers (one for networking,
threads, etc.). For the moement we will stick with one until the process
is complete.

We may also want to move some of the linux/ that is common to other os's
like Solaris and BSD to a /unix directory when we start adding support for
other unix-like platforms.

This change creates common/c_cpp/src/c/linux/port.h. All of the #includes
that are not found by the windows compiler are in port.h as well as some
of the obvious linux specific macros.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/configure.ac | 6 ++
common/c_cpp/src/c/MRSWLock.c | 2 +-
common/c_cpp/src/c/Makefile.am | 1 +
common/c_cpp/src/c/destroyHandle.c | 1 +
common/c_cpp/src/c/linux/port.h | 136 ++++++++++++++++++++++++++++++++
common/c_cpp/src/c/list.c | 6 +-
common/c_cpp/src/c/machine.c | 9 +--
common/c_cpp/src/c/platform.c | 5 +-
common/c_cpp/src/c/platform.h | 21 -----
common/c_cpp/src/c/property.c | 4 +-
common/c_cpp/src/c/queue.c | 22 +-----
common/c_cpp/src/c/strutils.c | 7 +-
common/c_cpp/src/c/systree.h | 4 -
common/c_cpp/src/c/timers.h | 3 +-
common/c_cpp/src/c/wSemaphore.c | 8 +--
common/c_cpp/src/c/wlock.c | 3 +-
common/c_cpp/src/c/wlock.h | 5 -
common/c_cpp/src/c/wombat/queue.h | 15 +---
common/c_cpp/src/c/wombat/strutils.h | 7 --
common/c_cpp/src/c/wombat/wSemaphore.h | 51 +------------
common/c_cpp/src/c/wombat/wincompat.h | 1 +
21 files changed, 163 insertions(+), 154 deletions(-)
create mode 100644 common/c_cpp/src/c/linux/port.h

diff --git a/common/c_cpp/configure.ac b/common/c_cpp/configure.ac
index a95eb91..9b08055 100755
--- a/common/c_cpp/configure.ac
+++ b/common/c_cpp/configure.ac
@@ -43,6 +43,12 @@ AM_INIT_AUTOMAKE([foreign])
AM_CONFIG_HEADER([config.h])
AC_CANONICAL_BUILD()

+# Set up symbolic links for os-specific files
+AC_MSG_NOTICE([Configuring symbolic links for $build_os in $srcdir])
+case $build_os in
+ linux*-*) AC_CONFIG_LINKS([src/c/port.h:src/c/linux/port.h]) ;;
+esac
+
# Checks for programs.
AC_PROG_CXX

diff --git a/common/c_cpp/src/c/MRSWLock.c b/common/c_cpp/src/c/MRSWLock.c
index b7d84c3..8cccb7c 100644
--- a/common/c_cpp/src/c/MRSWLock.c
+++ b/common/c_cpp/src/c/MRSWLock.c
@@ -22,8 +22,8 @@
/* ********************************************************** */
/* Includes. */
/* ********************************************************** */
+#include "port.h"
#include "wombat/MRSWLock.h"
-#include "wombat/wincompat.h"
#include <stdlib.h>

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

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
new file mode 100644
index 0000000..a1de75d
--- /dev/null
+++ b/common/c_cpp/src/c/linux/port.h
@@ -0,0 +1,136 @@
+/*
+ * 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
+ */
+
+/* Linux Specific macros, #includes, and prototypes.
+ *
+ * For Linux, most should be macros. Some of the contents of this file may be
+ * moved to a common "unix.h' file when we port to Solaris and other unix
+ * variants.
+ */
+
+#ifndef PORT_LINUX_H__
+#define PORT_LINUX_H__
+
+#if defined (__cplusplus)
+extern "C"
+{
+#endif
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/vfs.h>
+#include <sys/param.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <netinet/in.h>
+#include <semaphore.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <inttypes.h>
+
+/* Call Types */
+#define COMMONExpDLL
+#define WMWExpDLL
+#define MAMAExpDLL
+#define MAMACPPExpDLL
+#define MAMDAExpDLL
+#define MAMDAOPTExpDLL
+#define MAMAExpBridgeDLL
+#define MAMACALLTYPE
+
+/* Type for handle to dynamically loaded library */
+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) \
+ ((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)
+#else
+#define htonll(x) ((uint64_t)(x))
+#define ntohll(x) ((uint64_t)(x))
+#endif
+
+/* For delimiting multiple paths in env variables properties */
+#define PATH_DELIM ':'
+
+/* Use Posix semaphores for Linux */
+#define wsem_t sem_t
+#define wsem_init sem_init
+#define wsem_post sem_post
+#define wsem_wait sem_wait
+#define wsem_trywait sem_trywait
+#define wsem_destroy sem_destroy
+#define wsem_getvalue sem_getvalue
+
+int wsem_timedwait (wsem_t* sem, unsigned int ts);
+
+/* User pthreads for linux */
+#define wthread_mutex_t pthread_mutex_t
+#define wthread_mutex_init pthread_mutex_init
+#define wthread_mutex_unlock pthread_mutex_unlock
+#define wthread_mutex_lock pthread_mutex_lock
+#define wthread_mutex_destroy pthread_mutex_destroy
+#define wthread_t pthread_t
+#define wthread_detach pthread_detach
+#define wthread_self pthread_self
+#define wthread_equal pthread_equal
+#define wthread_cleanup_push pthread_cleanup_push
+#define wthread_cleanup_pop pthread_cleanup_pop
+#define wthread_join pthread_join
+#define wthread_create pthread_create
+#define wthread_exit pthread_exit
+
+#define wthread_cond_t pthread_cond_t
+#define wthread_cond_init pthread_cond_init
+#define wthread_cond_signal pthread_cond_signal
+#define wthread_cond_destroy pthread_cond_destroy
+#define wthread_cond_wait pthread_cond_wait
+
+#define wthread_spinlock_t pthread_spinlock_t
+#define wthread_spin_init pthread_spin_init
+#define wthread_spin_unlock pthread_spin_unlock
+#define wthread_spin_lock pthread_spin_lock
+#define wthread_spin_destroy pthread_spin_destroy
+#define wthread_attr_t pthread_attr_t
+#define wthread_attr_init pthread_attr_init
+#define wthread_attr_setdetachstate pthread_attr_setdetachstate
+
+#define wthread_mutexattr_t pthread_mutexattr_t
+#define wthread_mutexattr_init pthread_mutexattr_init
+#define wthread_mutexattr_settype pthread_mutexattr_settype
+
+#define wGetCurrentThreadId pthread_self
+
+#if defined (__cplusplus)
+} /* extern "c" */
+#endif
+
+#endif /* LINUX_H__ */
diff --git a/common/c_cpp/src/c/list.c b/common/c_cpp/src/c/list.c
index e37b4b0..ef3a00d 100644
--- a/common/c_cpp/src/c/list.c
+++ b/common/c_cpp/src/c/list.c
@@ -19,11 +19,7 @@
* 02110-1301 USA
*/

-#ifndef WIN32
-#include <pthread.h>
-#else
-#include "wombat/wincompat.h"
-#endif
+#include "port.h"

#include <stdlib.h>
#include <stdio.h>
diff --git a/common/c_cpp/src/c/machine.c b/common/c_cpp/src/c/machine.c
index 42bd9de..512e1ab 100644
--- a/common/c_cpp/src/c/machine.c
+++ b/common/c_cpp/src/c/machine.c
@@ -19,14 +19,10 @@
* 02110-1301 USA
*/

-#include <sys/param.h>
-#include <sys/resource.h>
+#include "port.h"
#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/times.h>

#include <ctype.h>
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -34,10 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/vfs.h>
#include <time.h>
-#include <unistd.h>
-#include <unistd.h>

#include "wombat/machine.h"
#include "wombat/wtable.h"
diff --git a/common/c_cpp/src/c/platform.c b/common/c_cpp/src/c/platform.c
index 0ed6d18..8bf7f4e 100644
--- a/common/c_cpp/src/c/platform.c
+++ b/common/c_cpp/src/c/platform.c
@@ -19,6 +19,7 @@
* 02110-1301 USA
*/

+#include "port.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -27,10 +28,6 @@
#include "platform.h"
#include "wombat/wincompat.h"

-
-#define LIB_EXTENSION ".so"
-
-
/**
* Functions relating to DLLs/shared objects
*/
diff --git a/common/c_cpp/src/c/platform.h b/common/c_cpp/src/c/platform.h
index c3b17d6..440f962 100644
--- a/common/c_cpp/src/c/platform.h
+++ b/common/c_cpp/src/c/platform.h
@@ -25,16 +25,6 @@
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
-#include "wombat/wincompat.h"
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#ifdef WIN32
-typedef HINSTANCE LIB_HANDLE;
-#else
-typedef void* LIB_HANDLE;
-#endif

/* The platform specific prefix and postfix will automatically be added to the libname
e.g on Linux "mamaImpl" will load "libmamaimpl.so" */
@@ -50,17 +40,6 @@ void* loadLibFunc (LIB_HANDLE handle, const char* funcName);
COMMONExpDLL
char* getLibError (void);

-/* Network conversion function */
-#if defined(WIN32) || __BYTE_ORDER == __LITTLE_ENDIAN
-#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)
-#else
-#define htonll(x) ((uint64_t)(x))
-#define ntohll(x) ((uint64_t)(x))
-#endif
-
#if defined(__cplusplus)
}
#endif /* __cplusplus */
diff --git a/common/c_cpp/src/c/property.c b/common/c_cpp/src/c/property.c
index 456c08f..a5271ec 100644
--- a/common/c_cpp/src/c/property.c
+++ b/common/c_cpp/src/c/property.c
@@ -19,6 +19,8 @@
* 02110-1301 USA
*/

+#include "port.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -32,8 +34,6 @@

#define KEY_BLOCK_SIZE 64

-#define PATH_DELIM ':'
-
int gPropertyDebug = 0;

typedef struct
diff --git a/common/c_cpp/src/c/queue.c b/common/c_cpp/src/c/queue.c
index ce960d1..03cf678 100644
--- a/common/c_cpp/src/c/queue.c
+++ b/common/c_cpp/src/c/queue.c
@@ -19,16 +19,9 @@
* 02110-1301 USA
*/

-#ifndef WIN32
-#include <pthread.h>
-#else
-#include "wombat/wincompat.h"
-#define pthread_mutex_t wthread_mutex_t
-#define pthread_mutex_init wthread_mutex_init
-#define pthread_mutex_destroy wthread_mutex_destroy
-#define pthread_mutex_lock wthread_mutex_lock
-#define pthread_mutex_unlock wthread_mutex_unlock
-#endif
+
+#include "port.h"
+
#include "wombat/wSemaphore.h"

#include <errno.h>
@@ -120,14 +113,10 @@ wombatQueue_create (wombatQueue queue, uint32_t maxSize, uint32_t initialSize,
return WOMBAT_QUEUE_SEM_ERR;
}

-#ifndef WIN32
if (pthread_mutex_init( &impl->mLock, NULL) != 0)
{
return WOMBAT_QUEUE_MTX_ERR;
}
-#else
- wthread_mutex_init( &impl->mLock, NULL);
-#endif

initialSize = initialSize == 0 ? WOMBAT_QUEUE_CHUNK_SIZE : initialSize;
wombatQueueImpl_allocChunk (impl, initialSize);
@@ -173,15 +162,10 @@ wombatQueue_destroy (wombatQueue queue)
result = WOMBAT_QUEUE_SEM_ERR;
}

-#ifndef WIN32
if (pthread_mutex_destroy( &impl->mLock) != 0)
{
result = WOMBAT_QUEUE_MTX_ERR;
}
-#else
- wthread_mutex_destroy( &impl->mLock);
-#endif
-

free (impl);
return WOMBAT_QUEUE_OK;
diff --git a/common/c_cpp/src/c/strutils.c b/common/c_cpp/src/c/strutils.c
index 1fae9b7..4874fe6 100644
--- a/common/c_cpp/src/c/strutils.c
+++ b/common/c_cpp/src/c/strutils.c
@@ -23,17 +23,14 @@
#define __STDC_FORMAT_MACROS
#endif

+#include "port.h"
+
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
-#ifndef WIN32
-#include <inttypes.h>
-#else
-#include <wombat/wincompat.h>
-#endif
#include <wombat/strutils.h>

static const char* gIntegerStrings[] = {
diff --git a/common/c_cpp/src/c/systree.h b/common/c_cpp/src/c/systree.h
index f5a15cc..818be5a 100644
--- a/common/c_cpp/src/c/systree.h
+++ b/common/c_cpp/src/c/systree.h
@@ -24,10 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

-#ifdef WIN32
-#define __attribute__(a)
-#endif
-
#ifndef _SYS_TREE_H_
#define _SYS_TREE_H_

diff --git a/common/c_cpp/src/c/timers.h b/common/c_cpp/src/c/timers.h
index a653dc4..38a3732 100644
--- a/common/c_cpp/src/c/timers.h
+++ b/common/c_cpp/src/c/timers.h
@@ -22,8 +22,7 @@
#ifndef TIMERS_INTERNAL_
#define TIMERS_INTERNAL_

-#include <sys/time.h>
-#include <pthread.h>
+#include "port.h"

typedef void* timerElement;
typedef void* timerHeap;
diff --git a/common/c_cpp/src/c/wSemaphore.c b/common/c_cpp/src/c/wSemaphore.c
index 04b526f..df2bae1 100644
--- a/common/c_cpp/src/c/wSemaphore.c
+++ b/common/c_cpp/src/c/wSemaphore.c
@@ -19,15 +19,11 @@
* 02110-1301 USA
*/

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

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

int wsem_timedwait (wsem_t* sem, unsigned int timeoutval)
{
diff --git a/common/c_cpp/src/c/wlock.c b/common/c_cpp/src/c/wlock.c
index 309b89d..9cd7d21 100644
--- a/common/c_cpp/src/c/wlock.c
+++ b/common/c_cpp/src/c/wlock.c
@@ -19,7 +19,8 @@
* 02110-1301 USA
*/

-#include <pthread.h>
+#include "port.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/common/c_cpp/src/c/wlock.h b/common/c_cpp/src/c/wlock.h
index 4c5a82c..199dad8 100644
--- a/common/c_cpp/src/c/wlock.h
+++ b/common/c_cpp/src/c/wlock.h
@@ -22,11 +22,6 @@
#ifndef _WOMBAT_WLOCK_H
#define _WOMBAT_WLOCK_H

-
-#include "wombat/wincompat.h"
-
-
-
typedef void * wLock;

COMMONExpDLL wLock wlock_create( void );
diff --git a/common/c_cpp/src/c/wombat/queue.h b/common/c_cpp/src/c/wombat/queue.h
index 36590d0..e9e2093 100644
--- a/common/c_cpp/src/c/wombat/queue.h
+++ b/common/c_cpp/src/c/wombat/queue.h
@@ -25,20 +25,7 @@
/*
* Fully thread safe queue implementation.
*/
-
-#ifndef WIN32
-#include <semaphore.h>
-#include <inttypes.h>
-#else
-#include "wombat/wincompat.h"
-#endif
-
-#ifndef WIN32
-/* For Forte */
-#ifndef SEM_VALUE_MAX
-#define SEM_VALUE_MAX 2147483647 /* from headers */
-#endif
-
+#ifdef SEM_VALUE_MAX
#define WOMBAT_QUEUE_MAX_SIZE SEM_VALUE_MAX /* 2_147_483_647 on Linux */
#else
#define WOMBAT_QUEUE_MAX_SIZE 2147483647 /* max possible size */
diff --git a/common/c_cpp/src/c/wombat/strutils.h b/common/c_cpp/src/c/wombat/strutils.h
index b20e712..d5d1fb8 100644
--- a/common/c_cpp/src/c/wombat/strutils.h
+++ b/common/c_cpp/src/c/wombat/strutils.h
@@ -30,13 +30,6 @@ extern "C" {


typedef unsigned long int w_u32_t;
-#ifndef WIN32
-typedef unsigned long long int w_u64_t;
-typedef long long int w_i64_t;
-#else
-typedef unsigned __int64 w_u64_t;
-typedef __int64 w_i64_t;
-#endif
typedef long int w_i32_t;
typedef float w_f32_t;
typedef double w_f64_t;
diff --git a/common/c_cpp/src/c/wombat/wSemaphore.h b/common/c_cpp/src/c/wombat/wSemaphore.h
index 89949a6..9adb8d2 100644
--- a/common/c_cpp/src/c/wombat/wSemaphore.h
+++ b/common/c_cpp/src/c/wombat/wSemaphore.h
@@ -22,55 +22,6 @@
#ifndef WSEMAPHORE_H__
#define WSEMAPHORE_H__

-#ifndef WIN32
-
-#include <pthread.h>
-#include <semaphore.h>
-#include <time.h>
-
-#define wsem_t sem_t
-#define wsem_init sem_init
-#define wsem_post sem_post
-#define wsem_wait sem_wait
-#define wsem_trywait sem_trywait
-#define wsem_destroy sem_destroy
-#define wsem_getvalue sem_getvalue
-
-int wsem_timedwait (wsem_t* sem, unsigned int ts);
-
-#else
-#include "wombat/wincompat.h"
-
-/**
- * Waiting on Win32 semaphore involves a system call and is very inefficient.
- * When we test to determine if the queue is empty with a Win32 semaphore
- * WaitForSingleObject consumes all the CPU. We can be much more efficient
- * using a critical section and not call WaitForSingleObject when there is
- * nothing on the Queue.
- */
-typedef 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);
-
-#endif
+#include "port.h"

#endif /* WSEMAPHORE_H__ */
diff --git a/common/c_cpp/src/c/wombat/wincompat.h b/common/c_cpp/src/c/wombat/wincompat.h
index 5c78acb..756ecea 100644
--- a/common/c_cpp/src/c/wombat/wincompat.h
+++ b/common/c_cpp/src/c/wombat/wincompat.h
@@ -22,6 +22,7 @@
#ifndef _WOMBAT_WINCOMPAT_H
#define _WOMBAT_WINCOMPAT_H

+#include "port.h"
#include "wConfig.h"

#define PATHSEP "/"
--
1.7.7.6


[PATCH 00/30] Preparing for Windows Support

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

This rather large patch set introduces the changes required for Windows support.
Prior to OpenMAMA, MAMA supported other operating systems (Windows and Solaris)
through conditional compilation with ifdef's. This approach proved messy and
difficult to maintain.

For OpenMAMA, we removed most of the "#ifdef WIN32" blocks with the intention of
reintroducing Windows support in a better way. The following patches move all of
the Windows specific code to the windows subdirectory in common and puts the
Linux equivalents in a linux subdirectory when necessary. Most of the
portability layer consists of macros and small inline functions and is almost
entirely identical to the old #ifdef code; however, rather than scattering it
throughout the code base we have it all in one place.

This should greatly simplify future ports to Solaris and other platform:
implementors only need to reproduce the compatibility layer for the new
platform.

NOTE: The build infrastructure for Windows is not part of this patch set. It
will be checked in with the C++, Java and MAMDA support in the next few weeks.

Michael Schonberg (29):
Move Linux Specific #includes and Macros
Moved Calling Convention from wConfig.h to linux/port.h
Moved environment.c to linux/environment.c
Moved linux code from machine.c to linux/machine.c
Moved platform.c to linux/platform.c
Moved wincompat.h contents to _os_/port.h
Changes for queue.c to build on windows
wlock.c changes for windows support
Preparing timer.c and timer.c for windows support
Move wSemaphore.c to linx/wSemaphroe.c
Moved macros for inline functions to _os_/port.h
Added wthread_global_mutex macros
Header changes for windows support
Prepare ft.c for Windows support
Removed PATHSEP macro
Added Thread Local Storage
Added getHostName and getIpAddress.
mama.c changes for windows support
Add wtimegm macro for poritning timegm
Correct Method Signatures for Linking On Windows
Correct windows calling convention for queue
Conflation manager fixes for windows
Replaced numerous #ifdef WIN32 with port.h
Removed #ifdef WIN32 from playbackFileParser
Adding new common/../windows/* files
Changes for Windows
Added wdlXXX macos to linux/port.h
Moved port.h to wombat sub directory
Renamed resolve_ip to wresolve_ip

Mike Schonberg (1):
Moved wombat/wInterlocked.h to Linux directory

common/c_cpp/configure.ac | 13 +
common/c_cpp/src/c/MRSWLock.c | 2 +-
common/c_cpp/src/c/Makefile.am | 3 +
common/c_cpp/src/c/destroyHandle.c | 1 +
common/c_cpp/src/c/environment.c | 59 --
common/c_cpp/src/c/linux/environment.c | 59 ++
common/c_cpp/src/c/linux/machine.c | 599 ++++++++++++++++++++
common/c_cpp/src/c/linux/network.c | 195 +++++++
common/c_cpp/src/c/linux/platform.c | 84 +++
common/c_cpp/src/c/linux/port.h | 181 ++++++
common/c_cpp/src/c/linux/wConfig.h | 40 ++
common/c_cpp/src/c/linux/wInterlocked.h | 142 +++++
common/c_cpp/src/c/linux/wSemaphore.c | 57 ++
common/c_cpp/src/c/list.c | 6 +-
common/c_cpp/src/c/machine.c | 575 +-------------------
common/c_cpp/src/c/platform.c | 88 ---
common/c_cpp/src/c/platform.h | 21 -
common/c_cpp/src/c/properties.l | 16 +-
common/c_cpp/src/c/property.c | 4 +-
common/c_cpp/src/c/queue.c | 110 ++---
common/c_cpp/src/c/strutils.c | 7 +-
common/c_cpp/src/c/systree.h | 4 -
common/c_cpp/src/c/timers.c | 176 +++---
common/c_cpp/src/c/timers.h | 5 +-
common/c_cpp/src/c/wSemaphore.c | 192 -------
common/c_cpp/src/c/windows/environment.c | 81 +++
common/c_cpp/src/c/windows/lock.h | 82 +++
common/c_cpp/src/c/windows/machine_win.c | 213 +++++++
common/c_cpp/src/c/windows/mmap.h | 28 +
common/c_cpp/src/c/windows/network.c | 87 +++
common/c_cpp/src/c/windows/platform.c | 84 +++
common/c_cpp/src/c/windows/port.c | 276 +++++++++
common/c_cpp/src/c/windows/port.h | 251 ++++++++
common/c_cpp/src/c/windows/wSemaphore.c | 147 +++++
common/c_cpp/src/c/windows/wombat/targetsxs.h | 38 ++
common/c_cpp/src/c/windows/wombat/wConfig.h | 101 ++++
common/c_cpp/src/c/windows/wombat/wInterlocked.h | 97 ++++
common/c_cpp/src/c/wlock.c | 11 +-
common/c_cpp/src/c/wlock.h | 5 -
common/c_cpp/src/c/wombat/queue.h | 67 +--
common/c_cpp/src/c/wombat/strutils.h | 7 -
common/c_cpp/src/c/wombat/wCommon.h | 27 +-
common/c_cpp/src/c/wombat/wConfig.h | 99 +----
common/c_cpp/src/c/wombat/wInterlocked.h | 142 -----
common/c_cpp/src/c/wombat/wSemaphore.h | 51 +--
common/c_cpp/src/c/wombat/wincompat.h | 49 +--
mama/c_cpp/src/c/bridge/avis/bridge.c | 5 +-
mama/c_cpp/src/c/bridge/avis/msg.c | 5 +-
mama/c_cpp/src/c/bridge/avis/transportbridge.c | 5 +-
mama/c_cpp/src/c/conflation/connection.c | 4 +-
mama/c_cpp/src/c/conflation/connection_int.h | 10 +-
mama/c_cpp/src/c/conflation/manager.c | 10 +-
mama/c_cpp/src/c/conflation/manager_int.h | 4 +-
mama/c_cpp/src/c/conflation/serverconnection_int.h | 8 +-
mama/c_cpp/src/c/datetime.c | 5 +-
mama/c_cpp/src/c/fileutils.c | 1 -
mama/c_cpp/src/c/ft.c | 203 ++------
mama/c_cpp/src/c/imagerequest.c | 2 +-
mama/c_cpp/src/c/imagerequest.h | 2 +-
mama/c_cpp/src/c/mama.c | 163 ++----
mama/c_cpp/src/c/mama/conflation/manager.h | 16 +-
mama/c_cpp/src/c/mama/datetime.h | 4 +-
mama/c_cpp/src/c/mama/fielddesc.h | 4 +-
mama/c_cpp/src/c/mama/ft.h | 4 +-
mama/c_cpp/src/c/mama/mama.h | 14 +-
mama/c_cpp/src/c/mama/msg.h | 14 +-
mama/c_cpp/src/c/mama/msgfield.h | 4 +-
mama/c_cpp/src/c/mama/subscriptiontype.h | 3 +-
mama/c_cpp/src/c/mama/timezone.h | 4 +-
mama/c_cpp/src/c/mama/types.h | 2 +-
mama/c_cpp/src/c/msg.c | 2 +-
mama/c_cpp/src/c/payload/avismsg/avismsgimpl.c | 4 +-
mama/c_cpp/src/c/playback/playbackFileParser.c | 31 +-
mama/c_cpp/src/c/playback/playbackFileParser.h | 10 +-
mama/c_cpp/src/c/playback/playbackpublisher.h | 5 +-
mama/c_cpp/src/c/priceimpl.c | 19 +-
mama/c_cpp/src/c/queue.c | 2 +-
mama/c_cpp/src/c/senderId.c | 7 +-
mama/c_cpp/src/c/stat.c | 2 +-
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 | 36 +-
mama/c_cpp/src/examples/c/mamainboxc.c | 15 +-
mama/c_cpp/src/examples/c/mamaio.c | 9 +-
mama/c_cpp/src/examples/c/mamalistenc.c | 56 +-
mama/c_cpp/src/examples/c/mamaproxyc.c | 46 +-
mama/c_cpp/src/examples/c/mamapublisherc.c | 19 +-
mama/c_cpp/src/examples/c/mamasubscriberc.c | 20 +-
.../src/examples/c/mamasymbollistsubscriberc.c | 44 +-
mama/c_cpp/src/regression/c/tools/basicinbox.c | 31 +-
mama/c_cpp/src/regression/c/tools/basicpub.c | 50 +--
mama/c_cpp/src/regression/c/tools/basicsub.c | 61 +--
93 files changed, 3329 insertions(+), 2228 deletions(-)
delete mode 100644 common/c_cpp/src/c/environment.c
create mode 100644 common/c_cpp/src/c/linux/environment.c
create mode 100644 common/c_cpp/src/c/linux/machine.c
create mode 100644 common/c_cpp/src/c/linux/network.c
create mode 100644 common/c_cpp/src/c/linux/platform.c
create mode 100644 common/c_cpp/src/c/linux/port.h
create mode 100644 common/c_cpp/src/c/linux/wConfig.h
create mode 100644 common/c_cpp/src/c/linux/wInterlocked.h
create mode 100644 common/c_cpp/src/c/linux/wSemaphore.c
delete mode 100644 common/c_cpp/src/c/platform.c
delete mode 100644 common/c_cpp/src/c/wSemaphore.c
create mode 100644 common/c_cpp/src/c/windows/environment.c
create mode 100644 common/c_cpp/src/c/windows/lock.h
create mode 100644 common/c_cpp/src/c/windows/machine_win.c
create mode 100644 common/c_cpp/src/c/windows/mmap.h
create mode 100644 common/c_cpp/src/c/windows/network.c
create mode 100644 common/c_cpp/src/c/windows/platform.c
create mode 100644 common/c_cpp/src/c/windows/port.c
create mode 100644 common/c_cpp/src/c/windows/port.h
create mode 100644 common/c_cpp/src/c/windows/wSemaphore.c
create mode 100644 common/c_cpp/src/c/windows/wombat/targetsxs.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wConfig.h
create mode 100644 common/c_cpp/src/c/windows/wombat/wInterlocked.h
mode change 100644 => 120000 common/c_cpp/src/c/wombat/wConfig.h
delete mode 100644 common/c_cpp/src/c/wombat/wInterlocked.h

--
1.7.7.6


[PATCH] [mama] Use "ft" as default FT transport name

Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

When setting up fault tolerance use "ft" as the transport name for reading
properties if the call does not provide a transport.

Signed-off-by: Michael Schonberg <mschonberg@...>
---
mama/c_cpp/src/c/ft.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/mama/c_cpp/src/c/ft.c b/mama/c_cpp/src/c/ft.c
index efbc16d..0a7931c 100644
--- a/mama/c_cpp/src/c/ft.c
+++ b/mama/c_cpp/src/c/ft.c
@@ -946,18 +946,23 @@ multicastFt_setup (

mamaFtMemberImpl* impl = (mamaFtMemberImpl*) member;

- if (!impl || !groupName || !transport)
+ if (!impl || !groupName)
return MAMA_STATUS_INVALID_ARG;

/* Get the transport name. */
- status = mamaTransport_getName(transport, &transportName);
- if((MAMA_STATUS_OK != status) || (NULL == transportName) || ('\0' ==
- transportName[0]))
+ if(transport)
{
- mama_log (MAMA_LOG_LEVEL_ERROR, "MAMA multicast FT: the transport name "
- "is invalid");
- return MAMA_STATUS_INVALID_ARG;
+ status = mamaTransport_getName(transport, &transportName);
+ if((MAMA_STATUS_OK != status) || (NULL == transportName) || ('\0' ==
+ transportName[0]))
+ {
+ mama_log (MAMA_LOG_LEVEL_ERROR, "MAMA multicast FT: the transport name "
+ "is invalid");
+ return MAMA_STATUS_INVALID_ARG;
+ }
}
+ else
+ transportName = "ft";

ftInterface = multicastFt_getProperty(propertyName,
"mama.multicast.transport.%s.interface", transportName);
--
1.7.7.6


Re: Getting a bridge build version

Mark Spielman
 

Mike,

I believe it makes most sense for me to use the mama/version.h as it seems to be the correct place to get version information. One follow on question. Why even in the tar package I downloaded from OpenMAMA for 1.1 is the following still present in mama/version.h.

#define MAMA_VERSION "openmama DEVRELEASE.."

And this is the value I get when I print the global mama_version. To me this should be set to something like 5.0.3rc11 which would be the concat of:

#define MAMA_VERSION_MAJOR 5
#define MAMA_VERSION_MINOR 0
#define MAMA_VERSION_RELEASE 3rc11

Cheers,
Mark

-----Original Message-----
From: Michael Schonberg [mailto:mikeschonberg@...] On Behalf Of Michael Schonberg
Sent: Tuesday, March 27, 2012 5:00 PM
To: Mark Spielman
Cc: openmama-dev@...
Subject: Re: [Openmama-dev] Getting a bridge build version

On 03/27/2012 01:12 PM, Mark Spielman wrote:
I'm interested in any best practices for getting a build version to report as part of the bridgeImpl->bridgeGetVersion() method. I've found what looks to be a reasonable version in the file: mama/c_cpp/config.h. I believe this is what AVIS is using. In OpenMAMA 1.1 it's currently set to:
It is largely up to the bridge implementor; however, it makes sense to identify both the version of the bridge code and the underlying middleware if it is available.

/* Version number of package */
#define VERSION "5.0.3rc11"
Avis does not provide version information through the API so the implementor simply used the MAMA version that was current at the time. Future releases of the Avis bridge will return "not implemented" for this method.

Or it seems I could just reuse the version from mama/c_cpp/c/src/c/mama/version.h as the equivalent of a bridge build version. Any suggestions? I'd like to be able to track a version that identifies a particular build of bridge code to correlate this for bug tracking.

Cheers,
Mark


Mark Spielman
Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021
mark.spielman@...<mailto:mark.spielman@...
www.solacesystems.com<http://www.solacesystems.com/>




_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
http://lists.openmama.org/listinfo/openmama-dev
Regards,
-Mike


Re: [Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

Mark Spielman
 

Hi Mike,

I appreciate the feedback. Below is an updated patch. Let me know if there are any other suggested edits.

Cheers,
Mark

---------

This patch introduces a .gitignore file to force git to skip known build artifacts when displaying status information.

Signed-off-by: Mark Spielman <mark.spielman@...>

---

iff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d018ef3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,76 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+*.lo
+*.la
+
+# Temporary Directories #
+#########################
+.dep*
+.lib*
+
+# GNU Automake #
+################
+Makefile
+Makefile.in
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+*~
+*.swp
+
+# OpenMAMA Specific #
+# ###################
+common/c_cpp/aclocal.m4
+common/c_cpp/autom4te.cache/
+common/c_cpp/config.h
+common/c_cpp/config.h.in
+common/c_cpp/config.status
+common/c_cpp/configure
+common/c_cpp/etc/
+common/c_cpp/libtool
+common/c_cpp/src/c/properties.c
+common/c_cpp/src/c/version.h
+common/c_cpp/stamp-h1
+mama/c_cpp/aclocal.m4
+mama/c_cpp/autom4te.cache/
+mama/c_cpp/config.h
+mama/c_cpp/config.h.in
+mama/c_cpp/config.status
+mama/c_cpp/configure
+mama/c_cpp/doc/c/
+mama/c_cpp/doxyconfig-c
+mama/c_cpp/etc/
+mama/c_cpp/libtool
+mama/c_cpp/src/c/bridge/solace/Makefile.am
+mama/c_cpp/src/c/mama/version.h
+mama/c_cpp/src/c/version.c
+mama/c_cpp/stamp-h1

-----Original Message-----
From: openmama-dev-bounces@... [mailto:openmama-dev-bounces@...] On Behalf Of Michael Schonberg
Sent: Tuesday, March 27, 2012 8:03 PM
To: openmama-dev@...
Subject: Re: [Openmama-dev] [Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

This is very useful.

I would remove mama/c_cpp/config.h.in~ and add *~ and *.swp for temporary files generated by vi.

-Mike

[snip]

_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
http://lists.openmama.org/listinfo/openmama-dev


Re: [Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

Michael Schonberg <mschonberg@...>
 

This is very useful.

I would remove mama/c_cpp/config.h.in~ and add *~ and *.swp for temporary
files generated by vi.

-Mike

On 03/27/2012 01:53 PM, Mark Spielman wrote:
This patch introduces a .gitignore file to force git to skip known build artifacts when displaying status information.

Signed-off-by: Mark Spielman <mark.spielman@...>

---

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..182bfd9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,75 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+*.lo
+*.la
+
+# Temporary Directories #
+#########################
+.dep*
+.lib*
+
# Temporary Files
#################
*.swp
*~

+# GNU Automake #
+################
+Makefile
+Makefile.in
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+
+# OpenMAMA Specific #
+# ###################
+common/c_cpp/aclocal.m4
+common/c_cpp/autom4te.cache/
+common/c_cpp/config.h
+common/c_cpp/config.h.in
+common/c_cpp/config.status
+common/c_cpp/configure
+common/c_cpp/etc/
+common/c_cpp/libtool
+common/c_cpp/src/c/properties.c
+common/c_cpp/src/c/version.h
+common/c_cpp/stamp-h1
+mama/c_cpp/aclocal.m4
+mama/c_cpp/autom4te.cache/
+mama/c_cpp/config.h
+mama/c_cpp/config.h.in
+mama/c_cpp/config.status
+mama/c_cpp/configure
+mama/c_cpp/doc/c/
+mama/c_cpp/doxyconfig-c
+mama/c_cpp/etc/
+mama/c_cpp/libtool
+mama/c_cpp/src/c/bridge/solace/Makefile.am
+mama/c_cpp/src/c/mama/version.h
+mama/c_cpp/src/c/version.c
+mama/c_cpp/stamp-h1
_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
http://lists.openmama.org/listinfo/openmama-dev


Re: Getting a bridge build version

Michael Schonberg <mschonberg@...>
 

On 03/27/2012 01:12 PM, Mark Spielman wrote:
I'm interested in any best practices for getting a build version to report as part of the bridgeImpl->bridgeGetVersion() method. I've found what looks to be a reasonable version in the file: mama/c_cpp/config.h. I believe this is what AVIS is using. In OpenMAMA 1.1 it's currently set to:
It is largely up to the bridge implementor; however, it makes sense to identify both the version of the bridge code and the underlying middleware if it is available.

/* Version number of package */
#define VERSION "5.0.3rc11"
Avis does not provide version information through the API so the implementor simply used the MAMA version that was current at the time. Future releases of the Avis bridge will return "not implemented" for this method.

Or it seems I could just reuse the version from mama/c_cpp/c/src/c/mama/version.h as the equivalent of a bridge build version. Any suggestions? I'd like to be able to track a version that identifies a particular build of bridge code to correlate this for bug tracking.

Cheers,
Mark


Mark Spielman
Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021
mark.spielman@...<mailto:mark.spielman@...>
www.solacesystems.com<http://www.solacesystems.com/>





_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
http://lists.openmama.org/listinfo/openmama-dev
Regards,
-Mike


[Patch 1.1 1/1] OpenMAMA (C): Adding .gitignore to force git to skip known build artifacts in status summary

Mark Spielman
 

This patch introduces a .gitignore file to force git to skip known build artifacts when displaying status information.

Signed-off-by: Mark Spielman <mark.spielman@...>

---

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..182bfd9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,75 @@
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+*.lo
+*.la
+
+# Temporary Directories #
+#########################
+.dep*
+.lib*
+
+# GNU Automake #
+################
+Makefile
+Makefile.in
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store*
+ehthumbs.db
+Icon?
+Thumbs.db
+
+# OpenMAMA Specific #
+# ###################
+common/c_cpp/aclocal.m4
+common/c_cpp/autom4te.cache/
+common/c_cpp/config.h
+common/c_cpp/config.h.in
+common/c_cpp/config.status
+common/c_cpp/configure
+common/c_cpp/etc/
+common/c_cpp/libtool
+common/c_cpp/src/c/properties.c
+common/c_cpp/src/c/version.h
+common/c_cpp/stamp-h1
+mama/c_cpp/aclocal.m4
+mama/c_cpp/autom4te.cache/
+mama/c_cpp/config.h
+mama/c_cpp/config.h.in
+mama/c_cpp/config.h.in~
+mama/c_cpp/config.status
+mama/c_cpp/configure
+mama/c_cpp/doc/c/
+mama/c_cpp/doxyconfig-c
+mama/c_cpp/etc/
+mama/c_cpp/libtool
+mama/c_cpp/src/c/bridge/solace/Makefile.am
+mama/c_cpp/src/c/mama/version.h
+mama/c_cpp/src/c/version.c
+mama/c_cpp/stamp-h1


Getting a bridge build version

Mark Spielman
 

I’m interested in any best practices for getting a build version to report as part of the bridgeImpl->bridgeGetVersion() method.  I’ve found what looks to be a reasonable version in the file: mama/c_cpp/config.h.  I believe this is what AVIS is using.  In OpenMAMA 1.1 it’s currently set to:

 

/* Version number of package */

#define VERSION "5.0.3rc11"

 

Or it seems I could just reuse the version from mama/c_cpp/c/src/c/mama/version.h as the equivalent of a bridge build version.  Any suggestions?  I’d like to be able to track a version that identifies a particular build of bridge code to correlate this for bug tracking.

 

Cheers,

Mark

 

 

Mark Spielman

Development Lead, Solace Systems Professional Services
+1-613-271-1010 x1021

mark.spielman@...

www.solacesystems.com

 

 

2221 - 2240 of 2312