1 .\" Copyright (c) 2012, IBM Corporation.
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of
9 .\" this manual under the conditions for verbatim copying, provided that
10 .\" the entire resulting derived work is distributed under the terms of
11 .\" a permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume.
15 .\" no responsibility for errors or omissions, or for damages resulting.
16 .\" from the use of the information contained herein. The author(s) may.
17 .\" not have taken the same level of care in the production of this.
18 .\" manual, which is licensed free of charge, as they might when working.
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH __PPC_GET_TIMEBASE 3 2019-03-06 "GNU C Library" "Linux Programmer's\
28 __ppc_get_timebase, __ppc_get_timebase_freq \- get the current value
29 of the Time Base Register on Power architecture and its frequency.
31 .B #include <sys/platform/ppc.h>
33 .BI "uint64_t __ppc_get_timebase(void)"
35 .BI "uint64_t __ppc_get_timebase_freq(void);"
37 .BR __ppc_get_timebase ()
38 reads the current value of the Time Base Register and returns its
40 .BR __ppc_get_timebase_freq ()
41 returns the frequency in which the Time Base Register is updated.
43 The Time Base Register is a 64-bit register provided by Power Architecture
45 It stores a monotonically incremented value that is updated at a
46 system-dependent frequency that may be different from the processor
49 .BR __ppc_get_timebase ()
50 returns a 64-bit unsigned integer that represents the current value of the
53 .BR __ppc_get_timebase_freq ()
54 returns a 64-bit unsigned integer that represents the frequency at
55 which the Time Base Register is updated.
57 GNU C Library support for
58 .\" commit d9dc34cd569bcfe714fe8c708e58c028106e8b2e
59 .BR __ppc_get_timebase ()
60 has been provided since version 2.16 and
61 .\" commit 8ad11b9a9cf1de82bd7771306b42070b91417c11
62 .BR __ppc_get_timebase_freq ()
63 has been available since version 2.17.
65 Both functions are nonstandard GNU extensions.
67 The following program will calculate the time, in microseconds, spent
69 .BR __ppc_get_timebase ().
77 #include <sys/platform/ppc.h>
79 /* Maximum value of the Time Base Register: 2^60 \- 1.
81 #define MAX_TB 0xFFFFFFFFFFFFFFF
86 uint64_t tb1, tb2, diff;
88 uint64_t freq = __ppc_get_timebase_freq();
89 printf("Time Base frequency = %"PRIu64" Hz\en", freq);
91 tb1 = __ppc_get_timebase();
95 tb2 = __ppc_get_timebase();
100 /* Treat Time Base Register overflow. */
101 diff = (MAX_TB \- tb2) + tb1;
104 printf("Elapsed time = %1.2f usecs\en",
105 (double) diff * 1000000 / freq );