aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-07-13 15:46:01 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-07-13 16:44:13 +0200
commit2ab7061438040c68346124268ecf4081c835cbf2 (patch)
treeea9c4ce4d13e7f570a2b13e02b18524f9d53d386
parent65141ebcb134f670a87233a88b8d51e4a671272e (diff)
afb-trace: Fix compiling error on old json-c
Versions of json-c older than 0.12 doesn't have the function json_object_new_double_s. Change-Id: If34c36ddcfabb3796aeb6739cd150e2b3e763679 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-trace.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/afb-trace.c b/src/afb-trace.c
index e7ae9fc0..1b82f2b2 100644
--- a/src/afb-trace.c
+++ b/src/afb-trace.c
@@ -169,6 +169,7 @@ static int get_flag(const char *name, struct flag flags[], int count)
/* timestamp */
static struct json_object *timestamp(const struct afb_hookid *hookid)
{
+#if JSON_C_MAJOR_VERSION > 0 || JSON_C_MINOR_VERSION >= 12
char ts[50];
snprintf(ts, sizeof ts, "%llu.%06lu",
@@ -176,9 +177,9 @@ static struct json_object *timestamp(const struct afb_hookid *hookid)
(long unsigned)((hookid->time.tv_nsec + 500) / 1000));
return json_object_new_double_s(0.0f, ts); /* the real value isn't used */
-#if 0
- return json_object_new_string(ts);
- return json_object_new_double_s(0f, ts); /* the real value isn't used */
+#else
+ return json_object_new_double((double)hookid->time.tv_sec +
+ (double)hookid->time.tv_nsec * .000000001);
#endif
}