Liba cleanup

This commit is contained in:
Romain Goyet
2015-05-31 13:51:41 +02:00
parent 803ffda5bc
commit 872efea4d1
16 changed files with 38 additions and 27 deletions

View File

@@ -50,7 +50,6 @@ products := boot.elf boot.hex boot.bin
#objs += $(addprefix external/newlib/libc/, string/memset.o string/memcpy.o string/strlen.o)
lib/private/mem5.o: CFLAGS += -w
objs += lib/errno.o lib/private/mem5.o lib/cxx_new.o
objs += src/hello.o
@@ -58,6 +57,7 @@ objs += src/hello.o
default: clean boot.elf
include liba/Makefile
include libaxx/Makefile
include platform/Makefile
include kandinsky/Makefile
include poincare/Makefile

View File

@@ -1,12 +0,0 @@
/*#ifndef LIB_MALLOC_H
#define LIB_MALLOC_H*/
extern "C" {
#include <malloc.h>
}
void * operator new (unsigned int size) {
return malloc(size);
}
/*#endif*/

View File

@@ -1,7 +0,0 @@
int errno = 0;
/* Invalid argument */
#define EINVAL 22
/* Not enough space */
#define ENOMEM 12

View File

@@ -1,2 +1,5 @@
SFLAGS += -Iliba/include
objs += $(addprefix liba/src/, assert.o memcpy.o memset.o malloc.o)
liba/src/external/sqlite/mem5.o: CFLAGS += -w
objs += $(addprefix liba/src/, assert.o errno.o malloc.o memcpy.o memset.o external/sqlite/mem5.o)

View File

@@ -1,7 +1,12 @@
extern int errno;
#ifndef LIBA_ERRNO_H
#define LIBA_ERRNO_H
/* Invalid argument */
#define EINVAL 22
/* Not enough space */
#define ENOMEM 12
extern int errno;
#endif

View File

@@ -1,5 +1,5 @@
#ifndef LIB_MEM5CONFIG_H
#define LIB_MEM5CONFIG_H
#ifndef LIBA_MEMCONFIG_H
#define LIBA_MEMCONFIG_H
/* This structure contains all the configuration data for the mem5 allocator.
* Before using mem5, the HeapConfig global variable should be created

View File

@@ -1,5 +1,9 @@
typedef void FILE;
#ifndef LIBA_STDIO_H
#define LIBA_STDIO_H
#define stdin 0
#define stdout 0
typedef void FILE;
#endif

3
liba/src/errno.c Normal file
View File

@@ -0,0 +1,3 @@
#include <errno.h>
int errno = 0;

View File

@@ -5,7 +5,7 @@
* That file provides a tested implementation of malloc/free/realloc. */
#define sqlite3GlobalConfig HeapConfig
#include "mem5config.h"
#include <liba/include/private/memconfig.h>
/* SQLite wants to use its own integer types. Let's define them based from the
* stdint ones */

View File

@@ -1,6 +1,11 @@
#include <stdlib.h>
#include <string.h>
void memsys5FreeUnsafe(void *pOld);
void * memsys5MallocUnsafe(int nByte);
void * memsys5Realloc(void *pPrior, int nBytes);
int memsys5Roundup(int n);
void free(void *ptr) {
if (ptr != NULL) {
memsys5FreeUnsafe(ptr);

View File

@@ -5,4 +5,5 @@ void * memset(void * b, int c, size_t len) {
while (len--) {
*destination++ = (unsigned char)c;
}
return b;
}

1
libaxx/Makefile Normal file
View File

@@ -0,0 +1 @@
objs += $(addprefix libaxx/src/, new.o)

3
libaxx/README.txt Normal file
View File

@@ -0,0 +1,3 @@
libaxx is an adhoc libc++, just like liba is an adhoc libc.
See liba for more informations.

5
libaxx/src/new.cpp Normal file
View File

@@ -0,0 +1,5 @@
#include <stdlib.h>
void * operator new (unsigned int size) {
return malloc(size);
}

View File

@@ -1,5 +1,5 @@
#include "init_lcd.h"
#include <lib/private/mem5config.h>
#include <private/memconfig.h>
extern char _ccm_heap_start;
extern char _ccm_heap_end;