2.5-18.1
[jlayton/glibc.git] / sysdeps / powerpc / powerpc32 / hp-timing.h
1 /* High precision, low overhead timing functions.  Linux/PPC32 version.
2    Copyright (C) 2005 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #ifndef _HP_TIMING_H
21 #define _HP_TIMING_H    1
22
23
24 /* There are no generic definitions for the times.  We could write something
25    using the `gettimeofday' system call where available but the overhead of
26    the system call might be too high.
27
28    In case a platform supports timers in the hardware the following macros
29    and types must be defined:
30
31    - HP_TIMING_AVAIL: test for availability.
32
33    - HP_TIMING_INLINE: this macro is non-zero if the functionality is not
34      implemented using function calls but instead uses some inlined code
35      which might simply consist of a few assembler instructions.  We have to
36      know this since we might want to use the macros here in places where we
37      cannot make function calls.
38
39    - hp_timing_t: This is the type for variables used to store the time
40      values.
41
42    - HP_TIMING_ZERO: clear `hp_timing_t' object.
43
44    - HP_TIMING_NOW: place timestamp for current time in variable given as
45      parameter.
46
47    - HP_TIMING_DIFF_INIT: do whatever is necessary to be able to use the
48      HP_TIMING_DIFF macro.
49
50    - HP_TIMING_DIFF: compute difference between two times and store it
51      in a third.  Source and destination might overlap.
52
53    - HP_TIMING_ACCUM: add time difference to another variable.  This might
54      be a bit more complicated to implement for some platforms as the
55      operation should be thread-safe and 64bit arithmetic on 32bit platforms
56      is not.
57
58    - HP_TIMING_ACCUM_NT: this is the variant for situations where we know
59      there are no threads involved.
60
61    - HP_TIMING_PRINT: write decimal representation of the timing value into
62      the given string.  This operation need not be inline even though
63      HP_TIMING_INLINE is specified.
64
65 */
66
67 /* Provide dummy definitions.  */
68 #define HP_TIMING_AVAIL         (0)
69 #define HP_TIMING_INLINE        (0)
70 typedef unsigned long long int hp_timing_t;
71 #define HP_TIMING_ZERO(Var)
72 #define HP_TIMING_NOW(var)
73 #define HP_TIMING_DIFF_INIT()
74 #define HP_TIMING_DIFF(Diff, Start, End)
75 #define HP_TIMING_ACCUM(Sum, Diff)
76 #define HP_TIMING_ACCUM_NT(Sum, Diff)
77 #define HP_TIMING_PRINT(Buf, Len, Val)
78
79 /* Since this implementation is not available we tell the user about it.  */
80 #define HP_TIMING_NONAVAIL      1
81
82 #endif /* hp-timing.h */