Back to index

glibc  2.9
hp-timing.h
Go to the documentation of this file.
00001 /* High precision, low overhead timing functions.  Linux/PPC32 version.
00002    Copyright (C) 2005 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _HP_TIMING_H
00021 #define _HP_TIMING_H 1
00022 
00023 
00024 /* There are no generic definitions for the times.  We could write something
00025    using the `gettimeofday' system call where available but the overhead of
00026    the system call might be too high.
00027 
00028    In case a platform supports timers in the hardware the following macros
00029    and types must be defined:
00030 
00031    - HP_TIMING_AVAIL: test for availability.
00032 
00033    - HP_TIMING_INLINE: this macro is non-zero if the functionality is not
00034      implemented using function calls but instead uses some inlined code
00035      which might simply consist of a few assembler instructions.  We have to
00036      know this since we might want to use the macros here in places where we
00037      cannot make function calls.
00038 
00039    - hp_timing_t: This is the type for variables used to store the time
00040      values.
00041 
00042    - HP_TIMING_ZERO: clear `hp_timing_t' object.
00043 
00044    - HP_TIMING_NOW: place timestamp for current time in variable given as
00045      parameter.
00046 
00047    - HP_TIMING_DIFF_INIT: do whatever is necessary to be able to use the
00048      HP_TIMING_DIFF macro.
00049 
00050    - HP_TIMING_DIFF: compute difference between two times and store it
00051      in a third.  Source and destination might overlap.
00052 
00053    - HP_TIMING_ACCUM: add time difference to another variable.  This might
00054      be a bit more complicated to implement for some platforms as the
00055      operation should be thread-safe and 64bit arithmetic on 32bit platforms
00056      is not.
00057 
00058    - HP_TIMING_ACCUM_NT: this is the variant for situations where we know
00059      there are no threads involved.
00060 
00061    - HP_TIMING_PRINT: write decimal representation of the timing value into
00062      the given string.  This operation need not be inline even though
00063      HP_TIMING_INLINE is specified.
00064 
00065 */
00066 
00067 /* Provide dummy definitions.  */
00068 #define HP_TIMING_AVAIL            (0)
00069 #define HP_TIMING_INLINE    (0)
00070 typedef unsigned long long int hp_timing_t;
00071 #define HP_TIMING_ZERO(Var)
00072 #define HP_TIMING_NOW(var)
00073 #define HP_TIMING_DIFF_INIT()
00074 #define HP_TIMING_DIFF(Diff, Start, End)
00075 #define HP_TIMING_ACCUM(Sum, Diff)
00076 #define HP_TIMING_ACCUM_NT(Sum, Diff)
00077 #define HP_TIMING_PRINT(Buf, Len, Val)
00078 
00079 /* Since this implementation is not available we tell the user about it.  */
00080 #define HP_TIMING_NONAVAIL  1
00081 
00082 #endif /* hp-timing.h */