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