Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
port.h
00001 /* port.h 00002 * 00003 * Copyright (C) 2006-2013 wolfSSL Inc. 00004 * 00005 * This file is part of CyaSSL. 00006 * 00007 * CyaSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * CyaSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00020 */ 00021 00022 00023 #ifndef CTAO_CRYPT_PORT_H 00024 #define CTAO_CRYPT_PORT_H 00025 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 00032 #ifdef USE_WINDOWS_API 00033 #ifdef CYASSL_GAME_BUILD 00034 #include "system/xtl.h" 00035 #else 00036 #ifndef WIN32_LEAN_AND_MEAN 00037 #define WIN32_LEAN_AND_MEAN 00038 #endif 00039 #if defined(_WIN32_WCE) || defined(WIN32_LEAN_AND_MEAN) 00040 /* On WinCE winsock2.h must be included before windows.h */ 00041 #include <winsock2.h> 00042 #endif 00043 #include <windows.h> 00044 #endif 00045 #elif defined(THREADX) 00046 #ifndef SINGLE_THREADED 00047 #include "tx_api.h" 00048 #endif 00049 #elif defined(MICRIUM) 00050 /* do nothing, just don't pick Unix */ 00051 #elif defined(FREERTOS) || defined(CYASSL_SAFERTOS) 00052 /* do nothing */ 00053 #elif defined(EBSNET) 00054 /* do nothing */ 00055 #elif defined(FREESCALE_MQX) 00056 /* do nothing */ 00057 #elif defined(CYASSL_MDK_ARM) 00058 #if defined(CYASSL_MDK5) 00059 #include "cmsis_os.h" 00060 #else 00061 #include <rtl.h> 00062 #endif 00063 #elif defined(CYASSL_CMSIS_RTOS) 00064 #include "cmsis_os.h" 00065 #else 00066 #ifndef SINGLE_THREADED 00067 #define CYASSL_PTHREADS 00068 #include <pthread.h> 00069 #endif 00070 #if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS) 00071 #include <unistd.h> /* for close of BIO */ 00072 #endif 00073 #endif 00074 00075 00076 #ifdef SINGLE_THREADED 00077 typedef int CyaSSL_Mutex; 00078 #else /* MULTI_THREADED */ 00079 /* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */ 00080 #ifdef FREERTOS 00081 typedef xSemaphoreHandle CyaSSL_Mutex; 00082 #elif defined(CYASSL_SAFERTOS) 00083 typedef struct CyaSSL_Mutex { 00084 signed char mutexBuffer[portQUEUE_OVERHEAD_BYTES]; 00085 xSemaphoreHandle mutex; 00086 } CyaSSL_Mutex; 00087 #elif defined(USE_WINDOWS_API) 00088 typedef CRITICAL_SECTION CyaSSL_Mutex; 00089 #elif defined(CYASSL_PTHREADS) 00090 typedef pthread_mutex_t CyaSSL_Mutex; 00091 #elif defined(THREADX) 00092 typedef TX_MUTEX CyaSSL_Mutex; 00093 #elif defined(MICRIUM) 00094 typedef OS_MUTEX CyaSSL_Mutex; 00095 #elif defined(EBSNET) 00096 typedef RTP_MUTEX CyaSSL_Mutex; 00097 #elif defined(FREESCALE_MQX) 00098 typedef MUTEX_STRUCT CyaSSL_Mutex; 00099 #elif defined(CYASSL_MDK_ARM) 00100 #if defined(CYASSL_CMSIS_RTOS) 00101 typedef osMutexId CyaSSL_Mutex; 00102 #else 00103 typedef OS_MUT CyaSSL_Mutex; 00104 #endif 00105 #elif defined(CYASSL_CMSIS_RTOS) 00106 typedef osMutexId CyaSSL_Mutex; 00107 #else 00108 #error Need a mutex type in multithreaded mode 00109 #endif /* USE_WINDOWS_API */ 00110 #endif /* SINGLE_THREADED */ 00111 00112 CYASSL_LOCAL int InitMutex(CyaSSL_Mutex*); 00113 CYASSL_LOCAL int FreeMutex(CyaSSL_Mutex*); 00114 CYASSL_LOCAL int LockMutex(CyaSSL_Mutex*); 00115 CYASSL_LOCAL int UnLockMutex(CyaSSL_Mutex*); 00116 00117 00118 /* filesystem abstraction layer, used by ssl.c */ 00119 #ifndef NO_FILESYSTEM 00120 00121 #if defined(EBSNET) 00122 #define XFILE int 00123 #define XFOPEN(NAME, MODE) vf_open((const char *)NAME, VO_RDONLY, 0); 00124 #define XFSEEK vf_lseek 00125 #define XFTELL vf_tell 00126 #define XREWIND vf_rewind 00127 #define XFREAD(BUF, SZ, AMT, FD) vf_read(FD, BUF, SZ*AMT) 00128 #define XFWRITE(BUF, SZ, AMT, FD) vf_write(FD, BUF, SZ*AMT) 00129 #define XFCLOSE vf_close 00130 #define XSEEK_END VSEEK_END 00131 #define XBADFILE -1 00132 #elif defined(LSR_FS) 00133 #include <fs.h> 00134 #define XFILE struct fs_file* 00135 #define XFOPEN(NAME, MODE) fs_open((char*)NAME); 00136 #define XFSEEK(F, O, W) (void)F 00137 #define XFTELL(F) (F)->len 00138 #define XREWIND(F) (void)F 00139 #define XFREAD(BUF, SZ, AMT, F) fs_read(F, (char*)BUF, SZ*AMT) 00140 #define XFWRITE(BUF, SZ, AMT, F) fs_write(F, (char*)BUF, SZ*AMT) 00141 #define XFCLOSE fs_close 00142 #define XSEEK_END 0 00143 #define XBADFILE NULL 00144 #elif defined(FREESCALE_MQX) 00145 #define XFILE MQX_FILE_PTR 00146 #define XFOPEN fopen 00147 #define XFSEEK fseek 00148 #define XFTELL ftell 00149 #define XREWIND(F) fseek(F, 0, IO_SEEK_SET) 00150 #define XFREAD fread 00151 #define XFWRITE fwrite 00152 #define XFCLOSE fclose 00153 #define XSEEK_END IO_SEEK_END 00154 #define XBADFILE NULL 00155 #elif defined(MICRIUM) 00156 #include <fs.h> 00157 #define XFILE FS_FILE* 00158 #define XFOPEN fs_fopen 00159 #define XFSEEK fs_fseek 00160 #define XFTELL fs_ftell 00161 #define XREWIND fs_rewind 00162 #define XFREAD fs_fread 00163 #define XFWRITE fs_fwrite 00164 #define XFCLOSE fs_fclose 00165 #define XSEEK_END FS_SEEK_END 00166 #define XBADFILE NULL 00167 #else 00168 /* stdio, default case */ 00169 #define XFILE FILE* 00170 #if defined(CYASSL_MDK_ARM) 00171 extern FILE * CyaSSL_fopen(const char *name, const char *mode) ; 00172 #define XFOPEN CyaSSL_fopen 00173 #else 00174 #define XFOPEN fopen 00175 #endif 00176 #define XFSEEK fseek 00177 #define XFTELL ftell 00178 #define XREWIND rewind 00179 #define XFREAD fread 00180 #define XFWRITE fwrite 00181 #define XFCLOSE fclose 00182 #define XSEEK_END SEEK_END 00183 #define XBADFILE NULL 00184 #endif 00185 00186 #endif /* NO_FILESYSTEM */ 00187 00188 00189 #ifdef __cplusplus 00190 } /* extern "C" */ 00191 #endif 00192 00193 #endif /* CTAO_CRYPT_PORT_H */ 00194
Generated on Tue Jul 12 2022 20:12:51 by
