Newer
Older
rtlibc / inc / stdlib.h
@Razvan Turiac Razvan Turiac on 27 Aug 2020 622 bytes Simplified malloc() implementation.
#ifndef _RTLIBC_STDLIB_H
#define _RTLIBC_STDLIB_H


#include <stdint.h>
#include <stddef.h>


#define alloca(...) __builtin_alloca(__VA_ARGS__)



#ifdef __cplusplus
extern "C"
{
#endif


void malloc_init(void *heap, size_t size, size_t alignment);
size_t msize(void *p);

void* malloc(size_t size);
void free(void *p);


uint64_t strtoul(const char *str, char **endptr, int32_t base);
int64_t strtol(const char *str, char **endptr, int32_t base);

float strtof(const char *str, char **endptr);

void abort(void);


static inline int32_t abs(int32_t a)
{
	return (a < 0) ? -a : a;
}


#ifdef __cplusplus
}
#endif

#endif