This package includes the SharkSSL lite library and header files.

Dependents:   WebSocket-Client-Example SharkMQ-LED-Demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TargConfig.h Source File

TargConfig.h

00001 /**
00002  *     ____             _________                __                _
00003  *    / __ \___  ____ _/ /_  __(_)___ ___  ___  / /   ____  ____ _(_)____
00004  *   / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ /   / __ \/ __ `/ / ___/
00005  *  / _, _/  __/ /_/ / / / / / / / / / / /  __/ /___/ /_/ / /_/ / / /__
00006  * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
00007  *                                                       /____/
00008  *
00009  *                 SharkSSL Embedded SSL/TLS Stack
00010  ****************************************************************************
00011  *   PROGRAM MODULE
00012  *
00013  *   $Id$
00014  *
00015  *   COPYRIGHT:  Real Time Logic LLC, 2016
00016  *
00017  *   This software is copyrighted by and is the sole property of Real
00018  *   Time Logic LLC.  All rights, title, ownership, or other interests in
00019  *   the software remain the property of Real Time Logic LLC.  This
00020  *   software may only be used in accordance with the terms and
00021  *   conditions stipulated in the corresponding license agreement under
00022  *   which the software has been supplied.  Any unauthorized use,
00023  *   duplication, transmission, distribution, or disclosure of this
00024  *   software is expressly forbidden.
00025  *
00026  *   This Copyright notice may not be removed or modified without prior
00027  *   written consent of Real Time Logic LLC.
00028  *
00029  *   Real Time Logic LLC. reserves the right to modify this software
00030  *   without notice.
00031  *
00032  *               http://www.realtimelogic.com
00033  *               http://www.sharkssl.com
00034  ****************************************************************************
00035  *
00036  */
00037 #ifndef _SharkSsl_TargConfig_h
00038 #define _SharkSsl_TargConfig_h
00039 
00040 #include <cmsis_os.h>
00041 #include <time.h>
00042 
00043 
00044 #ifndef NDEBUG
00045 #define baAssert(x)        ((x) ? 0 : sharkAssert(__FILE__, __LINE__))
00046 #else
00047 #define baAssert(x)
00048 #endif
00049 
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053 int sharkAssert(const char* file, int line);
00054 #ifdef __cplusplus
00055 }
00056 #endif
00057 
00058 #ifdef _SHARKSSL_C_
00059 const char* assert_file;
00060 int assert_line;
00061 int sharkAssert(const char* file, int line)
00062 {
00063    assert_file = file;
00064    assert_line = line;
00065    for(;;);
00066 }
00067 #endif
00068 
00069 
00070 
00071 /* The following is not required by SharkSSL, but is used by some of
00072    the examples.
00073 */
00074 
00075 #ifndef TRUE
00076 #define TRUE  1
00077 #endif
00078 
00079 #ifndef FALSE
00080 #define FALSE 0
00081 #endif
00082 
00083 /**
00084  *  baMalloc  should return 32-bit aligned addresses when succesful,
00085  *                          (void*)0 when not succesful.
00086  *  baRealloc should return 32-bit aligned addresses when succesful,
00087  *                          (void*)0 when not succesful or NOT available.
00088  */
00089 
00090 #ifdef UMM_MALLOC
00091 #include "../../../examples/malloc/umm_malloc.h"
00092 #define baMalloc(s)        umm_malloc(s)
00093 #define baRealloc(m, s)    umm_realloc(m, s)
00094 #define baFree(m)          umm_free(m)
00095 #else
00096 #include <stdlib.h>
00097 #define baMalloc(s)        malloc(s) /* should return 32-bit aligned address */
00098 #define baRealloc(m, s)    realloc(m, s)  /* as above */
00099 #define baFree(m)          free(m)
00100 #endif
00101 
00102 /* Some mbed releases use conflicting types. Undo the two macro
00103    definitions commented out below if you get 'undefined' compile
00104    errors.
00105 */
00106 /* #ifndef __MBED__ */
00107 
00108 #ifndef INTEGRAL_TYPES
00109 #define INTEGRAL_TYPES
00110 #if (__STDC_VERSION__ >= 199901L) || defined( __GNUC__)
00111 #include <stdint.h>
00112 typedef uint8_t            U8;
00113 typedef int8_t             S8;
00114 typedef uint16_t           U16;
00115 typedef int16_t            S16;
00116 typedef uint32_t           U32;
00117 typedef int32_t            S32;
00118 typedef uint64_t           U64;
00119 typedef int64_t            S64;
00120 #else
00121 typedef unsigned char      U8;
00122 typedef signed   char      S8;
00123 typedef unsigned short     U16;
00124 typedef signed   short     S16;
00125 typedef unsigned int       U32;
00126 typedef signed   int       S32;
00127 typedef unsigned long long U64;
00128 typedef signed   long long S64;
00129 #endif
00130 #endif
00131 
00132 /* #endif */ /* __MBED__ */
00133 
00134 typedef U8 BaBool;
00135 
00136 #ifdef EXT_SHARK_LIB
00137 U32 baGetUnixTime(void);
00138 char *sharkStrchr(const char *s, int c);
00139 char *sharkStrstr(const char *haystack, const char *needle);
00140 #else
00141 #define baGetUnixTime()    time(0)
00142 #endif
00143 
00144 typedef struct ThreadMutexBase
00145 {
00146    osMutexId sharkMutex;
00147 } ThreadMutexBase;
00148 
00149 void ThreadMutex_destructor(ThreadMutexBase* o);
00150 void ThreadMutex_set(ThreadMutexBase* o);
00151 void ThreadMutex_release(ThreadMutexBase* o);
00152 void ThreadMutex_constructor(ThreadMutexBase* o);
00153 
00154 #ifdef _SHARKSSL_C_
00155 osMutexDef(sharkMutexDef);
00156 void ThreadMutex_destructor(ThreadMutexBase* o)
00157 {
00158    osMutexDelete(o->sharkMutex);
00159 }
00160 void ThreadMutex_set(ThreadMutexBase* o)
00161 {
00162    osMutexWait(o->sharkMutex, osWaitForever);
00163 }
00164 void ThreadMutex_release(ThreadMutexBase* o)
00165 {
00166    osMutexRelease(o->sharkMutex);
00167 }
00168 void ThreadMutex_constructor(ThreadMutexBase* o)
00169 {
00170    o->sharkMutex=osMutexCreate(osMutex(sharkMutexDef));
00171 }
00172 #endif
00173 
00174 
00175 #endif  /* _SharkSsl_TargConfig_h */