blob: ff9ceef6f2a1c649eaab2a458335cf6227a264aa [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.
Paul Bakkerb96f1542010-07-18 20:36:00 +00005 *
6 * This file is part of PolarSSL (http://www.polarssl.org)
Paul Bakker84f12b72010-07-18 10:13:04 +00007 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakkerb96f1542010-07-18 20:36:00 +00008 *
Paul Bakker77b385e2009-07-28 17:23:11 +00009 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000010 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000011 * 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.
Paul Bakker5121ce52009-01-03 21:22:43 +000024 */
Paul Bakker40e46942009-01-03 21:51:57 +000025#ifndef POLARSSL_TIMING_H
26#define POLARSSL_TIMING_H
Paul Bakker5121ce52009-01-03 21:22:43 +000027
28/**
29 * \brief timer structure
30 */
31struct hr_time
32{
33 unsigned char opaque[32];
34};
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40extern int alarmed;
41
42/**
43 * \brief Return the CPU cycle counter value
44 */
45unsigned long hardclock( void );
46
47/**
48 * \brief Return the elapsed time in milliseconds
49 *
50 * \param val points to a timer structure
51 * \param reset if set to 1, the timer is restarted
52 */
53unsigned long get_timer( struct hr_time *val, int reset );
54
55/**
56 * \brief Setup an alarm clock
57 *
58 * \param seconds delay before the "alarmed" flag is set
59 */
60void set_alarm( int seconds );
61
62/**
63 * \brief Sleep for a certain amount of time
Paul Bakker13e2dfe2009-07-28 07:18:38 +000064 *
65 * \param Delay in milliseconds
Paul Bakker5121ce52009-01-03 21:22:43 +000066 */
67void m_sleep( int milliseconds );
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* timing.h */