mbed TLS v2.7.6
threading.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * This file is part of mbed TLS (https://tls.mbed.org)
23  */
24 #ifndef MBEDTLS_THREADING_H
25 #define MBEDTLS_THREADING_H
26 
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32 
33 #include <stdlib.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A
40 #define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA -0x001C
41 #define MBEDTLS_ERR_THREADING_MUTEX_ERROR -0x001E
43 #if defined(MBEDTLS_THREADING_PTHREAD)
44 #include <pthread.h>
45 typedef struct
46 {
47  pthread_mutex_t mutex;
48  char is_valid;
50 #endif
51 
52 #if defined(MBEDTLS_THREADING_ALT)
53 /* You should define the mbedtls_threading_mutex_t type in your header */
54 #include "threading_alt.h"
55 
74 void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ),
75  void (*mutex_free)( mbedtls_threading_mutex_t * ),
76  int (*mutex_lock)( mbedtls_threading_mutex_t * ),
77  int (*mutex_unlock)( mbedtls_threading_mutex_t * ) );
78 
82 void mbedtls_threading_free_alt( void );
83 #endif /* MBEDTLS_THREADING_ALT */
84 
85 #if defined(MBEDTLS_THREADING_C)
86 /*
87  * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
88  *
89  * All these functions are expected to work or the result will be undefined.
90  */
91 extern void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t *mutex );
92 extern void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t *mutex );
93 extern int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t *mutex );
94 extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
95 
96 /*
97  * Global mutexes
98  */
99 #if defined(MBEDTLS_FS_IO)
101 #endif
102 #if defined(MBEDTLS_HAVE_TIME_DATE)
104 #endif
105 #endif /* MBEDTLS_THREADING_C */
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* threading.h */
mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex
int(* mbedtls_mutex_unlock)(mbedtls_threading_mutex_t *mutex)
Configuration options (set of defines)
mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex
void(* mbedtls_mutex_init)(mbedtls_threading_mutex_t *mutex)
pthread_mutex_t mutex
Definition: threading.h:47
void(* mbedtls_mutex_free)(mbedtls_threading_mutex_t *mutex)
int(* mbedtls_mutex_lock)(mbedtls_threading_mutex_t *mutex)