PolarSSL v1.3.8
Main Page
Modules
Data Structures
Files
File List
Globals
library
platform.c
Go to the documentation of this file.
1
/*
2
* Platform abstraction layer
3
*
4
* Copyright (C) 2006-2014, Brainspark B.V.
5
*
6
* This file is part of PolarSSL (http://www.polarssl.org)
7
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
8
*
9
* All rights reserved.
10
*
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.
15
*
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.
20
*
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.
24
*/
25
26
#if !defined(POLARSSL_CONFIG_FILE)
27
#include "
polarssl/config.h
"
28
#else
29
#include POLARSSL_CONFIG_FILE
30
#endif
31
32
#if defined(POLARSSL_PLATFORM_C)
33
34
#include "
polarssl/platform.h
"
35
36
#if defined(POLARSSL_PLATFORM_MEMORY)
37
#if !defined(POLARSSL_PLATFORM_STD_MALLOC)
38
static
void
*platform_malloc_uninit(
size_t
len )
39
{
40
((void) len);
41
return
( NULL );
42
}
43
44
#define POLARSSL_PLATFORM_STD_MALLOC platform_malloc_uninit
45
#endif
/* !POLARSSL_PLATFORM_STD_MALLOC */
46
47
#if !defined(POLARSSL_PLATFORM_STD_FREE)
48
static
void
platform_free_uninit(
void
*ptr )
49
{
50
((void) ptr);
51
}
52
53
#define POLARSSL_PLATFORM_STD_FREE platform_free_uninit
54
#endif
/* !POLARSSL_PLATFORM_STD_FREE */
55
56
void
* (*polarssl_malloc)( size_t ) =
POLARSSL_PLATFORM_STD_MALLOC
;
57
void (*
polarssl_free
)(
void
* ) =
POLARSSL_PLATFORM_STD_FREE
;
58
59
int
platform_set_malloc_free(
void
* (*malloc_func)(
size_t
),
60
void
(*free_func)(
void
* ) )
61
{
62
polarssl_malloc
= malloc_func;
63
polarssl_free
= free_func;
64
return
( 0 );
65
}
66
#endif
/* POLARSSL_PLATFORM_MEMORY */
67
68
#if defined(POLARSSL_PLATFORM_PRINTF_ALT)
69
#if !defined(POLARSSL_PLATFORM_STD_PRINTF)
70
/*
71
* Make dummy function to prevent NULL pointer dereferences
72
*/
73
static
int
platform_printf_uninit(
const
char
*format, ... )
74
{
75
((void) format);
76
return
( 0 );
77
}
78
79
#define POLARSSL_PLATFORM_STD_PRINTF platform_printf_uninit
80
#endif
/* !POLARSSL_PLATFORM_STD_PRINTF */
81
82
int (*
polarssl_printf
)(
const
char
*, ... ) =
POLARSSL_PLATFORM_STD_PRINTF
;
83
84
int
platform_set_printf(
int
(*printf_func)(
const
char
*, ... ) )
85
{
86
polarssl_printf
= printf_func;
87
return
( 0 );
88
}
89
#endif
/* POLARSSL_PLATFORM_PRINTF_ALT */
90
91
#if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
92
#if !defined(POLARSSL_PLATFORM_STD_FPRINTF)
93
/*
94
* Make dummy function to prevent NULL pointer dereferences
95
*/
96
static
int
platform_fprintf_uninit( FILE *stream,
const
char
*format, ... )
97
{
98
((void) stream);
99
((void) format);
100
return
( 0 );
101
}
102
103
#define POLARSSL_PLATFORM_STD_FPRINTF platform_fprintf_uninit
104
#endif
/* !POLARSSL_PLATFORM_STD_FPRINTF */
105
106
int (*
polarssl_fprintf
)( FILE *,
const
char
*, ... ) =
107
POLARSSL_PLATFORM_STD_FPRINTF
;
108
109
int
platform_set_fprintf(
int
(*fprintf_func)( FILE *,
const
char
*, ... ) )
110
{
111
polarssl_fprintf
= fprintf_func;
112
return
( 0 );
113
}
114
#endif
/* POLARSSL_PLATFORM_FPRINTF_ALT */
115
116
#endif
/* POLARSSL_PLATFORM_C */
Generated on Thu Jul 31 2014 11:36:46 for PolarSSL v1.3.8 by
1.8.3