insert nonsensical useragent for sourceshit, so it won't try to show its idiotic...
[syren.git] / src / libpolarssl / timing.h
blob383120efea991a6d62e0584b18f25a5ab25a6f06
1 /**
2 * \file timing.h
4 * \brief Portable interface to the CPU cycle counter
6 * Copyright (C) 2006-2014, Brainspark B.V.
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
11 * All rights reserved.
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.
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.
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.
27 #ifndef POLARSSL_TIMING_H
28 #define POLARSSL_TIMING_H
30 #if !defined(POLARSSL_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include POLARSSL_CONFIG_FILE
34 #endif
36 #if !defined(POLARSSL_TIMING_ALT)
37 // Regular implementation
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /**
45 * \brief timer structure
47 struct hr_time
49 unsigned char opaque[32];
52 extern volatile int alarmed;
54 /**
55 * \brief Return the CPU cycle counter value
57 unsigned long hardclock( void );
59 /**
60 * \brief Return the elapsed time in milliseconds
62 * \param val points to a timer structure
63 * \param reset if set to 1, the timer is restarted
65 unsigned long get_timer( struct hr_time *val, int reset );
67 /**
68 * \brief Setup an alarm clock
70 * \param seconds delay before the "alarmed" flag is set
72 void set_alarm( int seconds );
74 /**
75 * \brief Sleep for a certain amount of time
77 * \param milliseconds delay in milliseconds
79 void m_sleep( int milliseconds );
81 #if defined(POLARSSL_SELF_TEST)
82 /**
83 * \brief Checkup routine
85 * \return 0 if successful, or 1 if a test failed
87 int timing_self_test( int verbose );
88 #endif
90 #ifdef __cplusplus
92 #endif
94 #else /* POLARSSL_TIMING_ALT */
95 #include "timing_alt.h"
96 #endif /* POLARSSL_TIMING_ALT */
98 #endif /* timing.h */