Example program to test AES-GCM functionality. Used for a workshop

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers threading.h Source File

threading.h

Go to the documentation of this file.
00001 /**
00002  * \file threading.h
00003  *
00004  * \brief Threading abstraction layer
00005  *
00006  *  Copyright (C) 2006-2013, Brainspark B.V.
00007  *
00008  *  This file is part of PolarSSL (http://www.polarssl.org)
00009  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
00010  *
00011  *  All rights reserved.
00012  *
00013  *  This program is free software; you can redistribute it and/or modify
00014  *  it under the terms of the GNU General Public License as published by
00015  *  the Free Software Foundation; either version 2 of the License, or
00016  *  (at your option) any later version.
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU General Public License for more details.
00022  *
00023  *  You should have received a copy of the GNU General Public License along
00024  *  with this program; if not, write to the Free Software Foundation, Inc.,
00025  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00026  */
00027 #ifndef POLARSSL_THREADING_H
00028 #define POLARSSL_THREADING_H
00029 
00030 #if !defined(POLARSSL_CONFIG_FILE)
00031 #include "config.h"
00032 #else
00033 #include POLARSSL_CONFIG_FILE
00034 #endif
00035 
00036 #include <stdlib.h>
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 #define POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE         -0x001A  /**< The selected feature is not available. */
00043 #define POLARSSL_ERR_THREADING_BAD_INPUT_DATA              -0x001C  /**< Bad input parameters to function. */
00044 #define POLARSSL_ERR_THREADING_MUTEX_ERROR                 -0x001E  /**< Locking / unlocking / free failed with error code. */
00045 
00046 #if defined(POLARSSL_THREADING_PTHREAD)
00047 #include <pthread.h>
00048 typedef pthread_mutex_t threading_mutex_t;
00049 #endif
00050 
00051 #if defined(POLARSSL_THREADING_ALT)
00052 /* You should define the threading_mutex_t type in your header */
00053 #include "threading_alt.h"
00054 
00055 /**
00056  * \brief           Set your alternate threading implementation function
00057  *                  pointers
00058  *
00059  * \param mutex_init    the init function implementation
00060  * \param mutex_free    the free function implementation
00061  * \param mutex_lock    the lock function implementation
00062  * \param mutex_unlock  the unlock function implementation
00063  *
00064  * \return              0 if successful
00065  */
00066 int threading_set_alt( int (*mutex_init)( threading_mutex_t * ),
00067                        int (*mutex_free)( threading_mutex_t * ),
00068                        int (*mutex_lock)( threading_mutex_t * ),
00069                        int (*mutex_unlock)( threading_mutex_t * ) );
00070 #endif /* POLARSSL_THREADING_ALT_C */
00071 
00072 /*
00073  * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
00074  *
00075  * All these functions are expected to work or the result will be undefined.
00076  */
00077 extern int (*polarssl_mutex_init)( threading_mutex_t *mutex );
00078 extern int (*polarssl_mutex_free)( threading_mutex_t *mutex );
00079 extern int (*polarssl_mutex_lock)( threading_mutex_t *mutex );
00080 extern int (*polarssl_mutex_unlock)( threading_mutex_t *mutex );
00081 
00082 #ifdef __cplusplus
00083 }
00084 #endif
00085 
00086 #endif /* threading.h */
00087 
00088