aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-08-29 14:02:10 +0400
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-08-29 14:02:10 +0400
commit78d7fa0f6ddfbd7f5ef36c8063c1d68091364573 (patch)
tree6355b242b9a9e37f21204ad813578b2f61fe8336
parentfd51ae550f4501767d3af727612d7bd5a16ef5c7 (diff)
Debug: Update RTMD with Thread ID storage support.
-rw-r--r--Transceiver52M/RTMD.c25
-rw-r--r--Transceiver52M/RTMD.h32
2 files changed, 46 insertions, 11 deletions
diff --git a/Transceiver52M/RTMD.c b/Transceiver52M/RTMD.c
index a6b77d1..fcb35d5 100644
--- a/Transceiver52M/RTMD.c
+++ b/Transceiver52M/RTMD.c
@@ -201,11 +201,30 @@ void RTMD_InitCycleTime(const char* name)
}
-void RTMD_SetInt(const char* name, int clineNumber, int cval)
+#ifdef __linux
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+inline void RTMD_SetIntThread(const char* name, int clineNumber, int cval)
{
-// if (mem == NULL)
-// return;
+ static __thread pid_t stid; // __thread variables can't be initialized (zeroed on clone)
+ if (stid == 0) {
+ stid = (pid_t) syscall (SYS_gettid);
+ }
+
+ int s = -(int)stid;
+
+ RTMD_SetInt(name, s, cval);
+ return;
+}
+#endif
+
+
+void RTMD_SetInt(const char* name, int clineNumber, int cval)
+{
if (ptr < count)
{
unsigned slot;
diff --git a/Transceiver52M/RTMD.h b/Transceiver52M/RTMD.h
index 3659c8e..09d1dfe 100644
--- a/Transceiver52M/RTMD.h
+++ b/Transceiver52M/RTMD.h
@@ -27,6 +27,8 @@ void RTMD_SetTime(const char* name, int lineNumber, int val, const struct timeva
void RTMD_SetCycleTime(const char* name, int lineNumber, int val);
void RTMD_InitCycleTime(const char* name);
+void RTMD_SetIntThread(const char* name, int clineNumber, int cval);
+
int RTMD_IsFull(void);
#define RTMD_MAX_NAME 16
@@ -34,6 +36,7 @@ int RTMD_IsFull(void);
#define RTMD_FLAG_GTOFDAY 'G'
#define RTMD_FLAG_CYCLE 'C'
#define RTMD_FLAG_CYCLEINI 'I'
+#define RTMD_FLAG_THREADNM 'N'
typedef struct RTMD_Node {
char name[RTMD_MAX_NAME-1];
@@ -57,21 +60,34 @@ typedef struct RTMD_Node {
} RTMD_Node_t;
+# define RTMD_VAL(a, v) RTMD_SetInt((a), __LINE__, (v))
+# define RTMD_SET(a) RTMD_SetInt((a), __LINE__, 1)
+# define RTMD_CLEAR(a) RTMD_SetInt((a), __LINE__, 0)
+# define RTMD_PULSE(a) ( RTMD_SET(a), RTMD_CLEAR(a))
+
+# define RTMD_TH_NAME(a) RTMD_SetThreadName(a)
+# define RTMD_TH_VAL(a, v) RTMD_SetIntThread((a), __LINE__, (v))
+# define RTMD_TH_SET(a) RTMD_SetIntThread((a), __LINE__, 1)
+# define RTMD_TH_CLEAR(a) RTMD_SetIntThread((a), __LINE__, 0)
+# define RTMD_TH_PULSE(a) ( RTMD_TH_SET(a), RTMD_TH_CLEAR(a))
-# define RTMD_VAL(a, v) RTMD_SetInt((a), __LINE__, (v))
-# define RTMD_SET(a) RTMD_SetInt((a), __LINE__, 1)
-# define RTMD_CLEAR(a) RTMD_SetInt((a), __LINE__, 0)
-# define RTMD_PULSE(a) ( RTMD_SET(a), RTMD_CLEAR(a))
-# define RTMD_INIT(x) RTMD_InitStorage((x))
-# define RTMD_FLUSH(x) RTMD_FlushStorage((x))
-# define RTMD_SETTIME(a, tv) RTMD_SetTime((a), __LINE__, 1, tv);
+# define RTMD_INIT(x) RTMD_InitStorage((x))
+# define RTMD_FLUSH(x) RTMD_FlushStorage((x))
+# define RTMD_SETTIME(a, tv) RTMD_SetTime((a), __LINE__, 1, tv);
# define RTMD_CLEARTIME(a, tv) RTMD_SetTime((a), __LINE__, 0, tv);
-# define RTMD_FULL RTMD_IsFull
+# define RTMD_FULL RTMD_IsFull
#else
# define RTMD_VAL(a, v)
# define RTMD_SET(a)
# define RTMD_CLEAR(a)
# define RTMD_PULSE(a)
+
+# define RTMD_TH_NAME(a)
+# define RTMD_TH_VAL(a, v)
+# define RTMD_TH_SET(a)
+# define RTMD_TH_CLEAR(a)
+# define RTMD_TH_PULSE(a)
+
# define RTMD_INIT(x)
# define RTMD_FLUSH(x)
# define RTMD_SETTIME(a, tv)