mbed TLS library

Dependents:   HTTPClient-SSL WS_SERVER

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers timing.h Source File

timing.h

Go to the documentation of this file.
00001 /**
00002  * \file timing.h
00003  *
00004  * \brief Portable interface to the CPU cycle counter
00005  *
00006  *  Copyright (C) 2006-2014, ARM Limited, All Rights Reserved
00007  *
00008  *  This file is part of mbed TLS (https://tls.mbed.org)
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License along
00021  *  with this program; if not, write to the Free Software Foundation, Inc.,
00022  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00023  */
00024 #ifndef POLARSSL_TIMING_H
00025 #define POLARSSL_TIMING_H
00026 
00027 #if !defined(POLARSSL_CONFIG_FILE)
00028 #include "config.h"
00029 #else
00030 #include POLARSSL_CONFIG_FILE
00031 #endif
00032 
00033 #if !defined(POLARSSL_TIMING_ALT)
00034 // Regular implementation
00035 //
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 /**
00042  * \brief          timer structure
00043  */
00044 struct hr_time
00045 {
00046     unsigned char opaque[32];
00047 };
00048 
00049 extern volatile int alarmed;
00050 
00051 /**
00052  * \brief          Return the CPU cycle counter value
00053  */
00054 unsigned long hardclock( void );
00055 
00056 /**
00057  * \brief          Return the elapsed time in milliseconds
00058  *
00059  * \param val      points to a timer structure
00060  * \param reset    if set to 1, the timer is restarted
00061  */
00062 unsigned long get_timer( struct hr_time *val, int reset );
00063 
00064 /**
00065  * \brief          Setup an alarm clock
00066  *
00067  * \param seconds  delay before the "alarmed" flag is set
00068  *
00069  * \warning        Only one alarm at a time  is supported. In a threaded
00070  *                 context, this means one for the whole process, not one per
00071  *                 thread.
00072  */
00073 void set_alarm( int seconds );
00074 
00075 /**
00076  * \brief          Sleep for a certain amount of time
00077  *
00078  * \param milliseconds  delay in milliseconds
00079  */
00080 void m_sleep( int milliseconds );
00081 
00082 #if defined(POLARSSL_SELF_TEST)
00083 /**
00084  * \brief          Checkup routine
00085  *
00086  * \return         0 if successful, or 1 if a test failed
00087  */
00088 int timing_self_test( int verbose );
00089 #endif
00090 
00091 #ifdef __cplusplus
00092 }
00093 #endif
00094 
00095 #else  /* POLARSSL_TIMING_ALT */
00096 #include "timing_alt.h"
00097 #endif /* POLARSSL_TIMING_ALT */
00098 
00099 #endif /* timing.h */
00100