X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttng-events.c;h=cc932bf61643d04095c5d198e297a153d2fbd7f7;hb=edfdcb685c3f56dde803244449f79ad7bed03798;hp=1ccbffd67fe60a961de18cf6b4c58d7334d1c155;hpb=d1f652f8d4f6d1de8f6d32ae8711d6469c38892c;p=lttng-modules.git diff --git a/lttng-events.c b/lttng-events.c index 1ccbffd6..cc932bf6 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -43,6 +43,7 @@ #include #include #include +#include #define METADATA_CACHE_DEFAULT_SIZE 4096 @@ -2483,6 +2484,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) @@ -2490,13 +2494,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); @@ -2517,7 +2529,7 @@ int64_t measure_clock_offset(void) static int print_escaped_ctf_string(struct lttng_session *session, const char *string) { - int ret; + int ret = 0; size_t i; char cur;