hp-timing.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* High precision, low overhead timing functions. Generic version.
  2. Copyright (C) 1998, 2000 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
  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. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _HP_TIMING_H
  17. #define _HP_TIMING_H 1
  18. /* There are no generic definitions for the times. We could write something
  19. using the `gettimeofday' system call where available but the overhead of
  20. the system call might be too high.
  21. In case a platform supports timers in the hardware the following macros
  22. and types must be defined:
  23. - HP_TIMING_AVAIL: test for availability.
  24. - HP_TIMING_INLINE: this macro is non-zero if the functionality is not
  25. implemented using function calls but instead uses some inlined code
  26. which might simply consist of a few assembler instructions. We have to
  27. know this since we might want to use the macros here in places where we
  28. cannot make function calls.
  29. - hp_timing_t: This is the type for variables used to store the time
  30. values.
  31. - HP_TIMING_ZERO: clear `hp_timing_t' object.
  32. - HP_TIMING_NOW: place timestamp for current time in variable given as
  33. parameter.
  34. - HP_TIMING_DIFF_INIT: do whatever is necessary to be able to use the
  35. HP_TIMING_DIFF macro.
  36. - HP_TIMING_DIFF: compute difference between two times and store it
  37. in a third. Source and destination might overlap.
  38. - HP_TIMING_ACCUM: add time difference to another variable. This might
  39. be a bit more complicated to implement for some platforms as the
  40. operation should be thread-safe and 64bit arithmetic on 32bit platforms
  41. is not.
  42. - HP_TIMING_ACCUM_NT: this is the variant for situations where we know
  43. there are no threads involved.
  44. - HP_TIMING_PRINT: write decimal representation of the timing value into
  45. the given string. This operation need not be inline even though
  46. HP_TIMING_INLINE is specified.
  47. */
  48. /* Provide dummy definitions. */
  49. #define HP_TIMING_AVAIL (0)
  50. #define HP_TIMING_INLINE (0)
  51. typedef int hp_timing_t;
  52. #define HP_TIMING_ZERO(Var)
  53. #define HP_TIMING_NOW(var)
  54. #define HP_TIMING_DIFF_INIT()
  55. #define HP_TIMING_DIFF(Diff, Start, End)
  56. #define HP_TIMING_ACCUM(Sum, Diff)
  57. #define HP_TIMING_ACCUM_NT(Sum, Diff)
  58. #define HP_TIMING_PRINT(Buf, Len, Val)
  59. /* Since this implementation is not available we tell the user about it. */
  60. #define HP_TIMING_NONAVAIL 1
  61. #endif /* hp-timing.h */