PolarSSL v1.3.9
platform.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_PLATFORM_H
28 #define POLARSSL_PLATFORM_H
29 
30 #if !defined(POLARSSL_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include POLARSSL_CONFIG_FILE
34 #endif
35 
36 #include <stdio.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
50 #if !defined(POLARSSL_PLATFORM_NO_STD_FUNCTIONS)
51 #include <stdlib.h>
52 #if !defined(POLARSSL_PLATFORM_STD_PRINTF)
53 #define POLARSSL_PLATFORM_STD_PRINTF printf
54 #endif
55 #if !defined(POLARSSL_PLATFORM_STD_FPRINTF)
56 #define POLARSSL_PLATFORM_STD_FPRINTF fprintf
57 #endif
58 #if !defined(POLARSSL_PLATFORM_STD_MALLOC)
59 #define POLARSSL_PLATFORM_STD_MALLOC malloc
60 #endif
61 #if !defined(POLARSSL_PLATFORM_STD_FREE)
62 #define POLARSSL_PLATFORM_STD_FREE free
63 #endif
64 #else /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
65 #if defined(POLARSSL_PLATFORM_STD_MEM_HDR)
66 #include POLARSSL_PLATFORM_STD_MEM_HDR
67 #endif
68 #endif /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
69 
70 /* \} name SECTION: Module settings */
71 
72 /*
73  * The function pointers for malloc and free
74  */
75 #if defined(POLARSSL_PLATFORM_MEMORY)
76 extern void * (*polarssl_malloc)( size_t len );
77 extern void (*polarssl_free)( void *ptr );
78 
87 int platform_set_malloc_free( void * (*malloc_func)( size_t ),
88  void (*free_func)( void * ) );
89 #else /* POLARSSL_PLATFORM_ENTROPY */
90 #define polarssl_malloc malloc
91 #define polarssl_free free
92 #endif /* POLARSSL_PLATFORM_ENTROPY */
93 
94 /*
95  * The function pointers for printf
96  */
97 #if defined(POLARSSL_PLATFORM_PRINTF_ALT)
98 extern int (*polarssl_printf)( const char *format, ... );
99 
107 int platform_set_printf( int (*printf_func)( const char *, ... ) );
108 #else /* POLARSSL_PLATFORM_PRINTF_ALT */
109 #define polarssl_printf printf
110 #endif /* POLARSSL_PLATFORM_PRINTF_ALT */
111 
112 /*
113  * The function pointers for fprintf
114  */
115 #if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
116 extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... );
117 
118 int platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *,
119  ... ) );
120 #else
121 #define polarssl_fprintf fprintf
122 #endif
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* platform.h */
#define polarssl_free
Definition: platform.h:91
Configuration options (set of defines)
#define polarssl_printf
Definition: platform.h:109
#define polarssl_fprintf
Definition: platform.h:121