1__ppc_get_timebase(3)      Library Functions Manual      __ppc_get_timebase(3)
2
3
4

NAME

6       __ppc_get_timebase,  __ppc_get_timebase_freq - get the current value of
7       the Time Base Register on Power architecture and its frequency.
8

LIBRARY

10       Standard C library (libc, -lc)
11

SYNOPSIS

13       #include <sys/platform/ppc.h>
14
15       uint64_t __ppc_get_timebase(void);
16       uint64_t __ppc_get_timebase_freq(void);
17

DESCRIPTION

19       __ppc_get_timebase() reads the current value of the Time Base  Register
20       and returns its value, while __ppc_get_timebase_freq() returns the fre‐
21       quency in which the Time Base Register is updated.
22
23       The Time Base Register is a 64-bit register provided by Power Architec‐
24       ture  processors.   It stores a monotonically incremented value that is
25       updated at a system-dependent frequency that may be different from  the
26       processor frequency.
27

RETURN VALUE

29       __ppc_get_timebase()  returns a 64-bit unsigned integer that represents
30       the current value of the Time Base Register.
31
32       __ppc_get_timebase_freq() returns a 64-bit unsigned integer that repre‐
33       sents the frequency at which the Time Base Register is updated.
34

STANDARDS

36       GNU.
37

HISTORY

39       __ppc_get_timebase()
40              glibc 2.16.
41
42       __ppc_get_timebase_freq()
43              glibc 2.17.
44

EXAMPLES

46       The  following  program will calculate the time, in microseconds, spent
47       between two calls to __ppc_get_timebase().
48
49   Program source
50
51       #include <inttypes.h>
52       #include <stdint.h>
53       #include <stdio.h>
54       #include <stdlib.h>
55       #include <sys/platform/ppc.h>
56
57       /* Maximum value of the Time Base Register: 2^60 - 1.
58          Source: POWER ISA.  */
59       #define MAX_TB 0xFFFFFFFFFFFFFFF
60
61       int
62       main(void)
63       {
64           uint64_t tb1, tb2, diff;
65           uint64_t freq;
66
67           freq = __ppc_get_timebase_freq();
68           printf("Time Base frequency = %"PRIu64" Hz\n", freq);
69
70           tb1 = __ppc_get_timebase();
71
72           // Do some stuff...
73
74           tb2 = __ppc_get_timebase();
75
76           if (tb2 > tb1) {
77               diff = tb2 - tb1;
78           } else {
79               /* Treat Time Base Register overflow.  */
80               diff = (MAX_TB - tb2) + tb1;
81           }
82
83           printf("Elapsed time  = %1.2f usecs\n",
84                  (double) diff * 1000000 / freq);
85
86           exit(EXIT_SUCCESS);
87       }
88

SEE ALSO

90       time(2), usleep(3)
91
92
93
94Linux man-pages 6.05              2023-05-03             __ppc_get_timebase(3)
Impressum