Added mem_realloc and string functions
This commit is contained in:
parent
56c522d05a
commit
12c9b4fdcc
10 changed files with 278 additions and 15 deletions
|
@ -26,7 +26,9 @@
|
|||
#define BOOTLOADER_VERSION_STR "0.1"
|
||||
|
||||
#ifndef UNREACHABLE
|
||||
#define UNREACHABLE()
|
||||
#define UNREACHABLE() __builtin_unreachable()
|
||||
#endif
|
||||
|
||||
void axboot_init(void);
|
||||
|
||||
#endif /* _AXBOOT_H */
|
|
@ -24,11 +24,19 @@
|
|||
|
||||
size_t mbstowcs(wchar_t *dest, const char **src, size_t len);
|
||||
|
||||
size_t strspn(const char *s, const char *accept);
|
||||
size_t strcspn(const char *s, const char *reject);
|
||||
size_t strlen(const char *str);
|
||||
int strcmp(const char *s1, const char *s2);
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
char *strcpy(char *dest, const char *src);
|
||||
char *strdup(const char *s);
|
||||
char *strtok(char *str, const char *delim);
|
||||
char *strchr(char *s, int c);
|
||||
char *strrchr(char *s, int c);
|
||||
|
||||
void *memset(void *dest, int val, size_t len);
|
||||
void *memcpy(void *dest, void *src, size_t len);
|
||||
void *memcpy(void *dest, const void *src, size_t len);
|
||||
int memcmp(const void *a, const void *b, size_t len);
|
||||
|
||||
#endif /* _LIB_STRING_H */
|
|
@ -22,9 +22,18 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
// NOTE: If any allocations fail, try increasing this number.
|
||||
#define MAX_ALLOCATIONS 256
|
||||
|
||||
struct alloc_header {
|
||||
void *addr;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
void *mem_alloc(size_t n);
|
||||
int mem_allocat(void *addr, size_t npages);
|
||||
void *mem_realloc(void *addr, size_t n);
|
||||
|
||||
void mem_free(void **addr);
|
||||
void mem_free(void *addr);
|
||||
|
||||
#endif /* _MEM_MMAN_H */
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef _PRINT_H
|
||||
#define _PRINT_H
|
||||
|
||||
#include "nanoprintf.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -29,4 +30,6 @@ void debug(const char *fmt, ...);
|
|||
|
||||
void printstr(const char *str);
|
||||
|
||||
void snprintf(char *buf, size_t size, const char *fmt, ...);
|
||||
|
||||
#endif /* _PRINT_H */
|
Loading…
Add table
Add a link
Reference in a new issue