Back to index

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