source: trunk/include/polarssl/timing.h @ 1016

Revision 1016, 1.9 KB checked in by paul, 13 months ago (diff)
  • Better timer for Windows platforms
  • Made alarmed volatile for better Windows compatibility
Line 
1/**
2 * \file timing.h
3 *
4 * \brief Portable interface to the CPU cycle counter
5 *
6 *  Copyright (C) 2006-2010, Brainspark B.V.
7 *
8 *  This file is part of PolarSSL (http://www.polarssl.org)
9 *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 *  All rights reserved.
12 *
13 *  This program is free software; you can redistribute it and/or modify
14 *  it under the terms of the GNU General Public License as published by
15 *  the Free Software Foundation; either version 2 of the License, or
16 *  (at your option) any later version.
17 *
18 *  This program is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License along
24 *  with this program; if not, write to the Free Software Foundation, Inc.,
25 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27#ifndef POLARSSL_TIMING_H
28#define POLARSSL_TIMING_H
29
30/**
31 * \brief          timer structure
32 */
33struct hr_time
34{
35    unsigned char opaque[32];
36};
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42extern volatile int alarmed;
43
44/**
45 * \brief          Return the CPU cycle counter value
46 */
47unsigned long hardclock( void );
48
49/**
50 * \brief          Return the elapsed time in milliseconds
51 *
52 * \param val      points to a timer structure
53 * \param reset    if set to 1, the timer is restarted
54 */
55unsigned long get_timer( struct hr_time *val, int reset );
56
57/**
58 * \brief          Setup an alarm clock
59 *
60 * \param seconds  delay before the "alarmed" flag is set
61 */
62void set_alarm( int seconds );
63
64/**
65 * \brief          Sleep for a certain amount of time
66 *
67 * \param milliseconds  delay in milliseconds
68 */
69void m_sleep( int milliseconds );
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif /* timing.h */
Note: See TracBrowser for help on using the repository browser.

What are you looking for?