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