mbed TLS library

Dependents:   HTTPClient-SSL WS_SERVER

Committer:
ansond
Date:
Thu Jun 11 03:27:03 2015 +0000
Revision:
0:137634ff4186
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:137634ff4186 1 /**
ansond 0:137634ff4186 2 * \file threading.h
ansond 0:137634ff4186 3 *
ansond 0:137634ff4186 4 * \brief Threading abstraction layer
ansond 0:137634ff4186 5 *
ansond 0:137634ff4186 6 * Copyright (C) 2006-2013, ARM Limited, All Rights Reserved
ansond 0:137634ff4186 7 *
ansond 0:137634ff4186 8 * This file is part of mbed TLS (https://tls.mbed.org)
ansond 0:137634ff4186 9 *
ansond 0:137634ff4186 10 * This program is free software; you can redistribute it and/or modify
ansond 0:137634ff4186 11 * it under the terms of the GNU General Public License as published by
ansond 0:137634ff4186 12 * the Free Software Foundation; either version 2 of the License, or
ansond 0:137634ff4186 13 * (at your option) any later version.
ansond 0:137634ff4186 14 *
ansond 0:137634ff4186 15 * This program is distributed in the hope that it will be useful,
ansond 0:137634ff4186 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ansond 0:137634ff4186 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ansond 0:137634ff4186 18 * GNU General Public License for more details.
ansond 0:137634ff4186 19 *
ansond 0:137634ff4186 20 * You should have received a copy of the GNU General Public License along
ansond 0:137634ff4186 21 * with this program; if not, write to the Free Software Foundation, Inc.,
ansond 0:137634ff4186 22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ansond 0:137634ff4186 23 */
ansond 0:137634ff4186 24 #ifndef POLARSSL_THREADING_H
ansond 0:137634ff4186 25 #define POLARSSL_THREADING_H
ansond 0:137634ff4186 26
ansond 0:137634ff4186 27 #if !defined(POLARSSL_CONFIG_FILE)
ansond 0:137634ff4186 28 #include "config.h"
ansond 0:137634ff4186 29 #else
ansond 0:137634ff4186 30 #include POLARSSL_CONFIG_FILE
ansond 0:137634ff4186 31 #endif
ansond 0:137634ff4186 32
ansond 0:137634ff4186 33 #include <stdlib.h>
ansond 0:137634ff4186 34
ansond 0:137634ff4186 35 #ifdef __cplusplus
ansond 0:137634ff4186 36 extern "C" {
ansond 0:137634ff4186 37 #endif
ansond 0:137634ff4186 38
ansond 0:137634ff4186 39 #define POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A /**< The selected feature is not available. */
ansond 0:137634ff4186 40 #define POLARSSL_ERR_THREADING_BAD_INPUT_DATA -0x001C /**< Bad input parameters to function. */
ansond 0:137634ff4186 41 #define POLARSSL_ERR_THREADING_MUTEX_ERROR -0x001E /**< Locking / unlocking / free failed with error code. */
ansond 0:137634ff4186 42
ansond 0:137634ff4186 43 #if defined(POLARSSL_THREADING_PTHREAD)
ansond 0:137634ff4186 44 #include <pthread.h>
ansond 0:137634ff4186 45 typedef pthread_mutex_t threading_mutex_t;
ansond 0:137634ff4186 46 #endif
ansond 0:137634ff4186 47
ansond 0:137634ff4186 48 #if defined(POLARSSL_THREADING_ALT)
ansond 0:137634ff4186 49 /* You should define the threading_mutex_t type in your header */
ansond 0:137634ff4186 50 #include "threading_alt.h"
ansond 0:137634ff4186 51
ansond 0:137634ff4186 52 /**
ansond 0:137634ff4186 53 * \brief Set your alternate threading implementation function
ansond 0:137634ff4186 54 * pointers
ansond 0:137634ff4186 55 *
ansond 0:137634ff4186 56 * \param mutex_init the init function implementation
ansond 0:137634ff4186 57 * \param mutex_free the free function implementation
ansond 0:137634ff4186 58 * \param mutex_lock the lock function implementation
ansond 0:137634ff4186 59 * \param mutex_unlock the unlock function implementation
ansond 0:137634ff4186 60 *
ansond 0:137634ff4186 61 * \return 0 if successful
ansond 0:137634ff4186 62 */
ansond 0:137634ff4186 63 int threading_set_alt( int (*mutex_init)( threading_mutex_t * ),
ansond 0:137634ff4186 64 int (*mutex_free)( threading_mutex_t * ),
ansond 0:137634ff4186 65 int (*mutex_lock)( threading_mutex_t * ),
ansond 0:137634ff4186 66 int (*mutex_unlock)( threading_mutex_t * ) );
ansond 0:137634ff4186 67 #endif /* POLARSSL_THREADING_ALT_C */
ansond 0:137634ff4186 68
ansond 0:137634ff4186 69 /*
ansond 0:137634ff4186 70 * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
ansond 0:137634ff4186 71 *
ansond 0:137634ff4186 72 * All these functions are expected to work or the result will be undefined.
ansond 0:137634ff4186 73 */
ansond 0:137634ff4186 74 extern int (*polarssl_mutex_init)( threading_mutex_t *mutex );
ansond 0:137634ff4186 75 extern int (*polarssl_mutex_free)( threading_mutex_t *mutex );
ansond 0:137634ff4186 76 extern int (*polarssl_mutex_lock)( threading_mutex_t *mutex );
ansond 0:137634ff4186 77 extern int (*polarssl_mutex_unlock)( threading_mutex_t *mutex );
ansond 0:137634ff4186 78
ansond 0:137634ff4186 79 #ifdef __cplusplus
ansond 0:137634ff4186 80 }
ansond 0:137634ff4186 81 #endif
ansond 0:137634ff4186 82
ansond 0:137634ff4186 83 #endif /* threading.h */
ansond 0:137634ff4186 84