timing.h 1.8 KB

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