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