Port: Remove _GNU_SOURCE, defined in config.h
[lttng-tools.git] / src / bin / lttng-sessiond / ust-metadata.c
index f4f273b16cc7021e2f4869e52b42dfd7f14799dd..71bcf7e7d325f61764de8832b8877a0b5e7e30ed 100644 (file)
@@ -19,7 +19,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <stdint.h>
 #include <string.h>
@@ -38,6 +37,7 @@
 #define max_t(type, a, b)      ((type) ((a) > (b) ? (a) : (b)))
 #endif
 
+#define NSEC_PER_SEC                   1000000000ULL
 #define NR_CLOCK_OFFSET_SAMPLES                10
 
 struct offset_sample {
@@ -358,7 +358,7 @@ int ust_metadata_event_statedump(struct ust_registry_session *session,
 
        ret = lttng_metadata_printf(session,
                "       loglevel = %d;\n",
-               event->loglevel);
+               event->loglevel_value);
        if (ret)
                goto end;
 
@@ -370,23 +370,6 @@ int ust_metadata_event_statedump(struct ust_registry_session *session,
                        goto end;
        }
 
-#if 0 /* context for events not supported */
-       if (event->ctx) {
-               ret = lttng_metadata_printf(session,
-                       "       context := struct {\n");
-               if (ret)
-                       goto end;
-       }
-       ret = _lttng_context_metadata_statedump(session, event->ctx);
-       if (ret)
-               goto end;
-       if (event->ctx) {
-               ret = lttng_metadata_printf(session,
-                       "       };\n");
-               if (ret)
-                       goto end;
-       }
-#endif
        ret = lttng_metadata_printf(session,
                "       fields := struct {\n"
                );
@@ -524,6 +507,7 @@ static
 int measure_single_clock_offset(struct offset_sample *sample)
 {
        uint64_t offset, monotonic[2], measure_delta, realtime;
+       uint64_t tcf = trace_clock_freq();
        struct timespec rts = { 0, 0 };
        int ret;
 
@@ -542,8 +526,12 @@ int measure_single_clock_offset(struct offset_sample *sample)
                return 0;
        }
        offset = (monotonic[0] + monotonic[1]) >> 1;
-       realtime = (uint64_t) rts.tv_sec * 1000000000ULL;
-       realtime += rts.tv_nsec;
+       realtime = (uint64_t) rts.tv_sec * tcf;
+       if (tcf == NSEC_PER_SEC) {
+               realtime += rts.tv_nsec;
+       } else {
+               realtime += (uint64_t) rts.tv_nsec * tcf / NSEC_PER_SEC;
+       }
        offset = realtime - offset;
        sample->offset = offset;
        sample->measure_delta = measure_delta;
@@ -685,8 +673,8 @@ int ust_metadata_session_statedump(struct ust_registry_session *session,
 
        ret = lttng_metadata_printf(session,
                "clock {\n"
-               "       name = %s;\n",
-               "monotonic"
+               "       name = \"%s\";\n",
+               trace_clock_name()
                );
        if (ret)
                goto end;
@@ -701,11 +689,12 @@ int ust_metadata_session_statedump(struct ust_registry_session *session,
        }
 
        ret = lttng_metadata_printf(session,
-               "       description = \"Monotonic Clock\";\n"
+               "       description = \"%s\";\n"
                "       freq = %" PRIu64 "; /* Frequency, in Hz */\n"
                "       /* clock value offset from Epoch is: offset * (1/freq) */\n"
                "       offset = %" PRIu64 ";\n"
                "};\n\n",
+               trace_clock_description(),
                trace_clock_freq(),
                measure_clock_offset()
                );
@@ -715,20 +704,23 @@ int ust_metadata_session_statedump(struct ust_registry_session *session,
        ret = lttng_metadata_printf(session,
                "typealias integer {\n"
                "       size = 27; align = 1; signed = false;\n"
-               "       map = clock.monotonic.value;\n"
+               "       map = clock.%s.value;\n"
                "} := uint27_clock_monotonic_t;\n"
                "\n"
                "typealias integer {\n"
                "       size = 32; align = %u; signed = false;\n"
-               "       map = clock.monotonic.value;\n"
+               "       map = clock.%s.value;\n"
                "} := uint32_clock_monotonic_t;\n"
                "\n"
                "typealias integer {\n"
                "       size = 64; align = %u; signed = false;\n"
-               "       map = clock.monotonic.value;\n"
+               "       map = clock.%s.value;\n"
                "} := uint64_clock_monotonic_t;\n\n",
+               trace_clock_name(),
                session->uint32_t_alignment,
-               session->uint64_t_alignment
+               trace_clock_name(),
+               session->uint64_t_alignment,
+               trace_clock_name()
                );
        if (ret)
                goto end;
This page took 0.026451 seconds and 5 git commands to generate.