X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Flttng%2Fclock.h;fp=include%2Flttng%2Fclock.h;h=ebcd624ff74e77d28e4ef6b220d4d4c55ed31826;hb=4318ae1be57eb7983ab4857a7a8eeb4a030a8216;hp=0000000000000000000000000000000000000000;hpb=d4419b81b243bc3a6bdd4a09b3ca2216d044a1c7;p=lttng-ust.git diff --git a/include/lttng/clock.h b/include/lttng/clock.h new file mode 100644 index 00000000..ebcd624f --- /dev/null +++ b/include/lttng/clock.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2010 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of + * the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _UST_CLOCK_H +#define _UST_CLOCK_H + +#include +#include +#include +#include +#include + +/* TRACE CLOCK */ + +/* + * Currently using the kernel MONOTONIC clock, waiting for kernel-side + * LTTng to implement mmap'd trace clock. + */ + +/* Choosing correct trace clock */ + +static __inline__ uint64_t trace_clock_read64(void) +{ + struct timespec ts; + uint64_t retval; + + clock_gettime(CLOCK_MONOTONIC, &ts); + retval = ts.tv_sec; + retval *= 1000000000; + retval += ts.tv_nsec; + + return retval; +} + +#if __i386__ || __x86_64__ +static __inline__ uint64_t trace_clock_frequency(void) +{ + return 1000000000LL; +} +#endif /* #else #if __i386__ || __x86_64__ */ + +static __inline__ uint32_t trace_clock_freq_scale(void) +{ + return 1; +} + +#endif /* _UST_CLOCK_H */