timing.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * \file timing.h
  3. *
  4. * \brief Portable interface to the CPU cycle counter
  5. *
  6. * Copyright (C) 2006-2010, Brainspark B.V.
  7. *
  8. * This file is part of PolarSSL (http://www.polarssl.org)
  9. * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
  10. *
  11. * All rights reserved.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #ifndef POLARSSL_TIMING_H
  28. #define POLARSSL_TIMING_H
  29. /**
  30. * \brief timer structure
  31. */
  32. struct hr_time
  33. {
  34. unsigned char opaque[32];
  35. };
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. extern volatile int alarmed;
  40. /**
  41. * \brief Return the CPU cycle counter value
  42. */
  43. unsigned long hardclock( void );
  44. /**
  45. * \brief Return the elapsed time in milliseconds
  46. *
  47. * \param val points to a timer structure
  48. * \param reset if set to 1, the timer is restarted
  49. */
  50. unsigned long get_timer( struct hr_time *val, int reset );
  51. /**
  52. * \brief Setup an alarm clock
  53. *
  54. * \param seconds delay before the "alarmed" flag is set
  55. */
  56. void set_alarm( int seconds );
  57. /**
  58. * \brief Sleep for a certain amount of time
  59. *
  60. * \param milliseconds delay in milliseconds
  61. */
  62. void m_sleep( int milliseconds );
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* timing.h */