blob: 3a88815e04e0e52fd24b7abd2df2e2c46a8713bb [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file timing.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker84f12b72010-07-18 10:13:04 +00004 * Copyright (C) 2006-2010, Brainspark B.V.
5 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakker77b385e2009-07-28 17:23:11 +00006 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00007 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00008 * 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 Bakker5121ce52009-01-03 21:22:43 +000021 */
Paul Bakker40e46942009-01-03 21:51:57 +000022#ifndef POLARSSL_TIMING_H
23#define POLARSSL_TIMING_H
Paul Bakker5121ce52009-01-03 21:22:43 +000024
25/**
26 * \brief timer structure
27 */
28struct hr_time
29{
30 unsigned char opaque[32];
31};
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37extern int alarmed;
38
39/**
40 * \brief Return the CPU cycle counter value
41 */
42unsigned 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 */
50unsigned 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 */
57void set_alarm( int seconds );
58
59/**
60 * \brief Sleep for a certain amount of time
Paul Bakker13e2dfe2009-07-28 07:18:38 +000061 *
62 * \param Delay in milliseconds
Paul Bakker5121ce52009-01-03 21:22:43 +000063 */
64void m_sleep( int milliseconds );
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif /* timing.h */