X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttng-events.c;h=1308d949f73460e9b4fb13291828d67a7015a985;hb=17c413953603f063f2a9d6c3788bec914ce6f955;hp=46a8fe1b11e969b93b2bb06b962c648bf7758142;hpb=deba832d311fa65dabc814948ef37caa39e26862;p=lttng-modules.git diff --git a/lttng-events.c b/lttng-events.c index 46a8fe1b..1308d949 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -43,6 +43,7 @@ #include #include #include +#include #define METADATA_CACHE_DEFAULT_SIZE 4096 @@ -2448,6 +2449,9 @@ int _lttng_event_header_declare(struct lttng_session *session) * in future versions. * This function may return a negative offset. It may happen if the * system sets the REALTIME clock to 0 after boot. + * + * Use 64bit timespec on kernels that have it, this makes 32bit arch + * y2038 compliant. */ static int64_t measure_clock_offset(void) @@ -2455,13 +2459,21 @@ int64_t measure_clock_offset(void) uint64_t monotonic_avg, monotonic[2], realtime; uint64_t tcf = trace_clock_freq(); int64_t offset; - struct timespec rts = { 0, 0 }; unsigned long flags; +#ifdef LTTNG_KERNEL_HAS_TIMESPEC64 + struct timespec64 rts = { 0, 0 }; +#else + struct timespec rts = { 0, 0 }; +#endif /* Disable interrupts to increase correlation precision. */ local_irq_save(flags); monotonic[0] = trace_clock_read64(); +#ifdef LTTNG_KERNEL_HAS_TIMESPEC64 + ktime_get_real_ts64(&rts); +#else getnstimeofday(&rts); +#endif monotonic[1] = trace_clock_read64(); local_irq_restore(flags); @@ -2515,15 +2527,16 @@ error: } static -int print_metadata_session_name(struct lttng_session *session) +int print_metadata_escaped_field(struct lttng_session *session, const char *field, + const char *field_value) { int ret; - ret = lttng_metadata_printf(session, " trace_name = \""); + ret = lttng_metadata_printf(session, " %s = \"", field); if (ret) goto error; - ret = print_escaped_ctf_string(session, session->name); + ret = print_escaped_ctf_string(session, field_value); if (ret) goto error; @@ -2620,7 +2633,11 @@ int _lttng_session_metadata_statedump(struct lttng_session *session) if (ret) goto end; - ret = print_metadata_session_name(session); + ret = print_metadata_escaped_field(session, "trace_name", session->name); + if (ret) + goto end; + ret = print_metadata_escaped_field(session, "trace_creation_datetime", + session->creation_time); if (ret) goto end;