166 lines
5.0 KiB
HTML
166 lines
5.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of __PPC_GET_TIMEBASE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>__PPC_GET_TIMEBASE</H1>
|
|
Section: Linux Programmer'sManual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
__ppc_get_timebase, __ppc_get_timebase_freq - get the current value
|
|
<BR> of the Time Base Register on Power architecture and its frequency.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/sys/platform/ppc.h">sys/platform/ppc.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>uint64_t __ppc_get_timebase(void)</B>
|
|
|
|
<P>
|
|
|
|
<B>uint64_t __ppc_get_timebase_freq(void);</B>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>__ppc_get_timebase</B>()
|
|
|
|
reads the current value of the Time Base Register and returns its
|
|
value, while
|
|
<B>__ppc_get_timebase_freq</B>()
|
|
|
|
returns the frequency in which the Time Base Register is updated.
|
|
<P>
|
|
|
|
The Time Base Register is a 64-bit register provided by Power Architecture
|
|
processors.
|
|
It stores a monotonically incremented value that is updated at a
|
|
system-dependent frequency that may be different from the processor
|
|
frequency.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
<B>__ppc_get_timebase</B>()
|
|
|
|
returns a 64-bit unsigned integer that represents the current value of the
|
|
Time Base Register.
|
|
<P>
|
|
|
|
<B>__ppc_get_timebase_freq</B>()
|
|
|
|
returns a 64-bit unsigned integer that represents the frequency at
|
|
which the Time Base Register is updated.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
GNU C Library support for
|
|
|
|
<B>__ppc_get_timebase</B>()
|
|
|
|
has been provided since version 2.16 and
|
|
|
|
<B>__ppc_get_timebase_freq</B>()
|
|
|
|
has been available since version 2.17.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
Both functions are nonstandard GNU extensions.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
The following program will calculate the time, in microseconds, spent
|
|
between two calls to
|
|
<B>__ppc_get_timebase</B>().
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Program source</H3>
|
|
|
|
|
|
|
|
#include <<A HREF="file:///usr/include/inttypes.h">inttypes.h</A>>
|
|
#include <<A HREF="file:///usr/include/stdint.h">stdint.h</A>>
|
|
#include <<A HREF="file:///usr/include/stdio.h">stdio.h</A>>
|
|
#include <<A HREF="file:///usr/include/stdlib.h">stdlib.h</A>>
|
|
#include <<A HREF="file:///usr/include/sys/platform/ppc.h">sys/platform/ppc.h</A>>
|
|
<P>
|
|
/* Maximum value of the Time Base Register: 2^60 - 1.
|
|
<BR> Source: POWER ISA. */
|
|
#define MAX_TB 0xFFFFFFFFFFFFFFF
|
|
<P>
|
|
int
|
|
main(void)
|
|
{
|
|
<BR> uint64_t tb1, tb2, diff;
|
|
<P>
|
|
<BR> uint64_t freq = __ppc_get_timebase_freq();
|
|
<BR> printf("Time Base frequency = %"PRIu64" Hz\n", freq);
|
|
<P>
|
|
<BR> tb1 = __ppc_get_timebase();
|
|
<P>
|
|
<BR> // Do some stuff...
|
|
<P>
|
|
<BR> tb2 = __ppc_get_timebase();
|
|
<P>
|
|
<BR> if (tb2 > tb1) {
|
|
<BR> diff = tb2 - tb1;
|
|
<BR> } else {
|
|
<BR> /* Treat Time Base Register overflow. */
|
|
<BR> diff = (MAX_TB - tb2) + tb1;
|
|
<BR> }
|
|
<P>
|
|
<BR> printf("Elapsed time = %1.2f usecs\n",
|
|
<BR> (double) diff * 1000000 / freq );
|
|
<P>
|
|
<BR> exit(EXIT_SUCCESS);
|
|
}
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+time">time</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+usleep">usleep</A></B>(3)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">VERSIONS</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">EXAMPLE</A><DD>
|
|
<DL>
|
|
<DT id="8"><A HREF="#lbAI">Program source</A><DD>
|
|
</DL>
|
|
<DT id="9"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:52 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|