/* Copyright (C) Thornwave Labs Inc - All Rights Reserved * Unauthorized copying of this file, via any medium is strictly prohibited * Proprietary and confidential * Written by Razvan Turiac <razvan.turiac@thornwave.com> */ #ifndef _RTLIBC_STDLIB_H #define _RTLIBC_STDLIB_H #include <stdint.h> #include <stddef.h> #define alloca(...) __builtin_alloca(__VA_ARGS__) #define RAND_MAX UINT32_MAX #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); int32_t atoi(const char* str); int64_t atol(const char* str); char* utoa(uint32_t n, char* buffer, uint32_t radix); char* ultoa(uint64_t n, char* buffer, uint32_t radix); char* itoa(int32_t n, char* buffer, uint32_t radix); char* ltoa(int64_t n, char* buffer, uint32_t radix); float strtof(const char *str, char **endptr); void abort(void); void srand(uint32_t seed); int32_t rand(void); void getrandom(void* buffer, size_t size); static inline int32_t abs(int32_t a) { return (a < 0) ? -a : a; } #ifdef __cplusplus } #endif #endif