blob: 785feed2fc5ecc6f83fe127b639e1a47316ec33c [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file timing.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker37ca75d2011-01-06 12:28:03 +00004 * \brief Portable interface to the CPU cycle counter
5 *
Manuel Pégourié-Gonnard0edee5e2015-01-26 15:29:40 +00006 * Copyright (C) 2006-2010, ARM Limited, All Rights Reserved
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
Manuel Pégourié-Gonnarde12abf92015-01-28 17:13:45 +00008 * This file is part of mbed TLS (https://polarssl.org)
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00009 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000023 */
Paul Bakker40e46942009-01-03 21:51:57 +000024#ifndef POLARSSL_TIMING_H
25#define POLARSSL_TIMING_H
Paul Bakker5121ce52009-01-03 21:22:43 +000026
27/**
28 * \brief timer structure
29 */
30struct hr_time
31{
32 unsigned char opaque[32];
33};
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
Paul Bakker2eee9022011-04-24 15:28:55 +000039extern volatile int alarmed;
Paul Bakker5121ce52009-01-03 21:22:43 +000040
41/**
42 * \brief Return the CPU cycle counter value
43 */
44unsigned long hardclock( void );
45
46/**
47 * \brief Return the elapsed time in milliseconds
48 *
49 * \param val points to a timer structure
50 * \param reset if set to 1, the timer is restarted
51 */
52unsigned long get_timer( struct hr_time *val, int reset );
53
54/**
55 * \brief Setup an alarm clock
56 *
57 * \param seconds delay before the "alarmed" flag is set
58 */
59void set_alarm( int seconds );
60
61/**
62 * \brief Sleep for a certain amount of time
Paul Bakker13e2dfe2009-07-28 07:18:38 +000063 *
Paul Bakker37ca75d2011-01-06 12:28:03 +000064 * \param milliseconds delay in milliseconds
Paul Bakker5121ce52009-01-03 21:22:43 +000065 */
66void m_sleep( int milliseconds );
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* timing.h */