summaryrefslogtreecommitdiff
path: root/src/bin/exactness
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2020-03-09 17:25:03 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-12 16:41:07 +0100
commitb69bc02c022955c00243cbcdd1b97276fb470190 (patch)
treeee90b3011354e89533d2c196f2fe549a1647bee1 /src/bin/exactness
parent525113650d7551f57d1b7e2006fbb071232b0f5f (diff)
downloadefl-b69bc02c022955c00243cbcdd1b97276fb470190.tar.gz
exactness: factor out duplicated code for debug session handling
No need to have these macros ducplicated in two file, we can just share them and reduce maintenance. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D11459
Diffstat (limited to 'src/bin/exactness')
-rw-r--r--src/bin/exactness/common.h91
-rw-r--r--src/bin/exactness/injector.c75
-rw-r--r--src/bin/exactness/player.c76
3 files changed, 91 insertions, 151 deletions
diff --git a/src/bin/exactness/common.h b/src/bin/exactness/common.h
index 1f84d80db7..2581c63392 100644
--- a/src/bin/exactness/common.h
+++ b/src/bin/exactness/common.h
@@ -6,4 +6,95 @@
#include <Exactness.h>
#include <exactness_private.h>
+typedef struct
+{
+ Eina_Debug_Session *session;
+ int srcid;
+ void *buffer;
+ unsigned int size;
+} _Main_Loop_Info;
+
+#define WRAPPER_TO_XFER_MAIN_LOOP(foo) \
+static void \
+_intern_main_loop ## foo(void *data) \
+{ \
+ _Main_Loop_Info *info = data; \
+ _main_loop ## foo(info->session, info->srcid, info->buffer, info->size); \
+ free(info->buffer); \
+ free(info); \
+} \
+static Eina_Bool \
+foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \
+{ \
+ _Main_Loop_Info *info = calloc(1, sizeof(*info)); \
+ info->session = session; \
+ info->srcid = srcid; \
+ info->size = size; \
+ if (info->size) \
+ { \
+ info->buffer = malloc(info->size); \
+ memcpy(info->buffer, buffer, info->size); \
+ } \
+ ecore_main_loop_thread_safe_call_async(_intern_main_loop ## foo, info); \
+ return EINA_TRUE; \
+}
+
+#ifndef WORDS_BIGENDIAN
+#define SWAP_64(x) x
+#define SWAP_32(x) x
+#define SWAP_16(x) x
+#define SWAP_DBL(x) x
+#else
+#define SWAP_64(x) eina_swap64(x)
+#define SWAP_32(x) eina_swap32(x)
+#define SWAP_16(x) eina_swap16(x)
+#define SWAP_DBL(x) SWAP_64(x)
+#endif
+
+#define EXTRACT_INT(_buf) \
+({ \
+ int __i; \
+ memcpy(&__i, _buf, sizeof(int)); \
+ _buf += sizeof(int); \
+ SWAP_32(__i); \
+})
+
+#define EXTRACT_DOUBLE(_buf) \
+({ \
+ double __d; \
+ memcpy(&__d, _buf, sizeof(double)); \
+ _buf += sizeof(double); \
+ SWAP_DBL(__d); \
+})
+
+#define EXTRACT_STRING(_buf) \
+({ \
+ char *__s = _buf ? strdup(_buf) : NULL; \
+ int __len = (__s ? strlen(__s) : 0) + 1; \
+ _buf += __len; \
+ __s; \
+})
+
+#define STORE_INT(_buf, __i) \
+({ \
+ int __si = SWAP_32(__i); \
+ memcpy(_buf, &__si, sizeof(int)); \
+ _buf += sizeof(int); \
+})
+
+#define STORE_DOUBLE(_buf, __d) \
+{ \
+ double __d2 = SWAP_DBL(__d); \
+ memcpy(_buf, &__d2, sizeof(double)); \
+ _buf += sizeof(double); \
+}
+
+#define STORE_STRING(_buf, __s) \
+{ \
+ int __len = (__s ? strlen(__s) : 0) + 1; \
+ if (__s) memcpy(_buf, __s, __len); \
+ else *_buf = '\0'; \
+ _buf += __len; \
+}
+
void ex_printf(int verbose, const char *fmt, ...);
diff --git a/src/bin/exactness/injector.c b/src/bin/exactness/injector.c
index 882752620d..928de47a62 100644
--- a/src/bin/exactness/injector.c
+++ b/src/bin/exactness/injector.c
@@ -16,81 +16,6 @@
#include <Exactness.h>
#include "common.h"
-typedef struct
-{
- Eina_Debug_Session *session;
- int srcid;
- void *buffer;
- unsigned int size;
-} _Main_Loop_Info;
-
-#define WRAPPER_TO_XFER_MAIN_LOOP(foo) \
-static void \
-_intern_main_loop ## foo(void *data) \
-{ \
- _Main_Loop_Info *info = data; \
- _main_loop ## foo(info->session, info->srcid, info->buffer, info->size); \
- free(info->buffer); \
- free(info); \
-} \
-static Eina_Bool \
-foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \
-{ \
- _Main_Loop_Info *info = calloc(1, sizeof(*info)); \
- info->session = session; \
- info->srcid = srcid; \
- info->size = size; \
- if (info->size) \
- { \
- info->buffer = malloc(info->size); \
- memcpy(info->buffer, buffer, info->size); \
- } \
- ecore_main_loop_thread_safe_call_async(_intern_main_loop ## foo, info); \
- return EINA_TRUE; \
-}
-
-#ifndef WORDS_BIGENDIAN
-#define SWAP_64(x) x
-#define SWAP_32(x) x
-#define SWAP_16(x) x
-#define SWAP_DBL(x) x
-#else
-#define SWAP_64(x) eina_swap64(x)
-#define SWAP_32(x) eina_swap32(x)
-#define SWAP_16(x) eina_swap16(x)
-#define SWAP_DBL(x) SWAP_64(x)
-#endif
-
-#define EXTRACT_INT(_buf) \
-({ \
- int __i; \
- memcpy(&__i, _buf, sizeof(int)); \
- _buf += sizeof(int); \
- SWAP_32(__i); \
-})
-
-#define STORE_INT(_buf, __i) \
-{ \
- int __i2 = SWAP_32(__i); \
- memcpy(_buf, &__i2, sizeof(int)); \
- _buf += sizeof(int); \
-}
-
-#define STORE_DOUBLE(_buf, __d) \
-{ \
- double __d2 = SWAP_DBL(__d); \
- memcpy(_buf, &__d2, sizeof(double)); \
- _buf += sizeof(double); \
-}
-
-#define STORE_STRING(_buf, __s) \
-{ \
- int __len = (__s ? strlen(__s) : 0) + 1; \
- if (__s) memcpy(_buf, __s, __len); \
- else *_buf = '\0'; \
- _buf += __len; \
-}
-
static Eina_Stringshare *_src_filename = NULL;
static Exactness_Unit *_src_unit = NULL;
static int _verbose = 0;
diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c
index b11a843205..fa9f0c63d3 100644
--- a/src/bin/exactness/player.c
+++ b/src/bin/exactness/player.c
@@ -36,82 +36,6 @@
#define IMAGE_FILENAME_EXT ".png"
#define PAUSE_KEY_STR "F2"
-typedef struct
-{
- Eina_Debug_Session *session;
- int srcid;
- void *buffer;
- unsigned int size;
-} _Main_Loop_Info;
-
-#define WRAPPER_TO_XFER_MAIN_LOOP(foo) \
-static void \
-_intern_main_loop ## foo(void *data) \
-{ \
- _Main_Loop_Info *info = data; \
- _main_loop ## foo(info->session, info->srcid, info->buffer, info->size); \
- free(info->buffer); \
- free(info); \
-} \
-static Eina_Bool \
-foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \
-{ \
- _Main_Loop_Info *info = calloc(1, sizeof(*info)); \
- info->session = session; \
- info->srcid = srcid; \
- info->size = size; \
- if (info->size) \
- { \
- info->buffer = malloc(info->size); \
- memcpy(info->buffer, buffer, info->size); \
- } \
- ecore_main_loop_thread_safe_call_async(_intern_main_loop ## foo, info); \
- return EINA_TRUE; \
-}
-
-#ifndef WORDS_BIGENDIAN
-#define SWAP_64(x) x
-#define SWAP_32(x) x
-#define SWAP_16(x) x
-#define SWAP_DBL(x) x
-#else
-#define SWAP_64(x) eina_swap64(x)
-#define SWAP_32(x) eina_swap32(x)
-#define SWAP_16(x) eina_swap16(x)
-#define SWAP_DBL(x) SWAP_64(x)
-#endif
-
-#define EXTRACT_INT(_buf) \
-({ \
- int __i; \
- memcpy(&__i, _buf, sizeof(int)); \
- _buf += sizeof(int); \
- SWAP_32(__i); \
-})
-
-#define EXTRACT_DOUBLE(_buf) \
-({ \
- double __d; \
- memcpy(&__d, _buf, sizeof(double)); \
- _buf += sizeof(double); \
- SWAP_DBL(__d); \
-})
-
-#define EXTRACT_STRING(_buf) \
-({ \
- char *__s = _buf ? strdup(_buf) : NULL; \
- int __len = (__s ? strlen(__s) : 0) + 1; \
- _buf += __len; \
- __s; \
-})
-
-#define STORE_INT(_buf, __i) \
-({ \
- int __si = SWAP_32(__i); \
- memcpy(_buf, &__si, sizeof(int)); \
- _buf += sizeof(int); \
-})
-
typedef enum
{
FTYPE_UNKNOWN,