2 * Platform abstraction layer
4 * Copyright (C) 2006-2014, Brainspark B.V.
6 * This file is part of PolarSSL (http://www.polarssl.org)
7 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #if !defined(POLARSSL_CONFIG_FILE)
29 #include POLARSSL_CONFIG_FILE
32 #if defined(POLARSSL_PLATFORM_C)
36 #if defined(POLARSSL_PLATFORM_MEMORY)
37 #if !defined(POLARSSL_PLATFORM_STD_MALLOC)
38 static void *platform_malloc_uninit( size_t len
)
44 #define POLARSSL_PLATFORM_STD_MALLOC platform_malloc_uninit
45 #endif /* !POLARSSL_PLATFORM_STD_MALLOC */
47 #if !defined(POLARSSL_PLATFORM_STD_FREE)
48 static void platform_free_uninit( void *ptr
)
53 #define POLARSSL_PLATFORM_STD_FREE platform_free_uninit
54 #endif /* !POLARSSL_PLATFORM_STD_FREE */
56 void * (*polarssl_malloc
)( size_t ) = POLARSSL_PLATFORM_STD_MALLOC
;
57 void (*polarssl_free
)( void * ) = POLARSSL_PLATFORM_STD_FREE
;
59 int platform_set_malloc_free( void * (*malloc_func
)( size_t ),
60 void (*free_func
)( void * ) )
62 polarssl_malloc
= malloc_func
;
63 polarssl_free
= free_func
;
66 #endif /* POLARSSL_PLATFORM_MEMORY */
68 #if defined(POLARSSL_PLATFORM_PRINTF_ALT)
69 #if !defined(POLARSSL_PLATFORM_STD_PRINTF)
71 * Make dummy function to prevent NULL pointer dereferences
73 static int platform_printf_uninit( const char *format
, ... )
79 #define POLARSSL_PLATFORM_STD_PRINTF platform_printf_uninit
80 #endif /* !POLARSSL_PLATFORM_STD_PRINTF */
82 int (*polarssl_printf
)( const char *, ... ) = POLARSSL_PLATFORM_STD_PRINTF
;
84 int platform_set_printf( int (*printf_func
)( const char *, ... ) )
86 polarssl_printf
= printf_func
;
89 #endif /* POLARSSL_PLATFORM_PRINTF_ALT */
91 #if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
92 #if !defined(POLARSSL_PLATFORM_STD_FPRINTF)
94 * Make dummy function to prevent NULL pointer dereferences
96 static int platform_fprintf_uninit( FILE *stream
, const char *format
, ... )
103 #define POLARSSL_PLATFORM_STD_FPRINTF platform_fprintf_uninit
104 #endif /* !POLARSSL_PLATFORM_STD_FPRINTF */
106 int (*polarssl_fprintf
)( FILE *, const char *, ... ) =
107 POLARSSL_PLATFORM_STD_FPRINTF
;
109 int platform_set_fprintf( int (*fprintf_func
)( FILE *, const char *, ... ) )
111 polarssl_fprintf
= fprintf_func
;
114 #endif /* POLARSSL_PLATFORM_FPRINTF_ALT */
116 #endif /* POLARSSL_PLATFORM_C */