Newer
Older
rtlibc / inc / stdlib.h
@Razvan Turiac Razvan Turiac on 1 Jan 2021 698 bytes Added rand() and srand()
#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);

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

void abort(void);

void srand(uint32_t seed);
int32_t rand(void);


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


#ifdef __cplusplus
}
#endif

#endif