Don't provide stdlib.h, but provide gnuk-malloc.h.

This commit is contained in:
NIIBE Yutaka
2017-10-03 16:04:43 +09:00
parent 289d3db8c4
commit eff0c7077d
5 changed files with 21 additions and 24 deletions

View File

@@ -1,5 +1,9 @@
2017-10-03 NIIBE Yutaka <gniibe@fsij.org>
* polarssl/library/rsa.c: Don't include stdlib.h.
* src/gnuk-malloc.h: Rename from stdlib.h.
* polarssl/library/bignum.c: Include gnuk-malloc.h.
* src/Makefile (build/flash.data): Generate.
* src/main.c (flash_addr_key_storage_start)

View File

@@ -37,7 +37,7 @@
#include "polarssl/bignum.h"
#include "polarssl/bn_mul.h"
#include <stdlib.h>
#include <gnuk-malloc.h>
#define ciL (sizeof(t_uint)) /* chars in limb */
#define biL (ciL << 3) /* bits in limb */

View File

@@ -39,7 +39,6 @@
#include "polarssl/md.h"
#endif
#include <stdlib.h>
#include <stdio.h>
/*

16
src/gnuk-malloc.h Normal file
View File

@@ -0,0 +1,16 @@
/*
* Gnuk uses its own malloc functions.
*
* The intention is no-dependency to C library. But, we provide
* malloc and free here, since RSA routines uses malloc/free
* internally.
*
*/
#include <stddef.h> /* NULL and size_t */
#define malloc(size) gnuk_malloc (size)
#define free(p) gnuk_free (p)
void *gnuk_malloc (size_t);
void gnuk_free (void *);

View File

@@ -1,22 +0,0 @@
/*
* stdlib.h replacement to replace malloc functions
*
* The intention is that no dependency to C library. But since RSA
* routines uses malloc/free, we provide malloc and free.
*
* For GNU/Linux emulation, we can use C library.
*/
#include <stddef.h> /* NULL and size_t */
#define malloc(size) gnuk_malloc (size)
#define free(p) gnuk_free (p)
void *gnuk_malloc (size_t);
void gnuk_free (void *);
#ifdef GNU_LINUX_EMULATION
long int random(void);
void srandom(unsigned int seed);
void exit(int status);
#endif