#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include <stddef.h>
#include <stdint.h>
#ifdef LIBC_TARGET_ARCH_IS_AARCH64
#include "src/sys/auxv/getauxval.h"
#endif
namespace LIBC_NAMESPACE_DECL {
int bcmp(const void *lhs, const void *rhs, size_t count);
void bzero(void *ptr, size_t count);
int memcmp(const void *lhs, const void *rhs, size_t count);
void *memcpy(void *__restrict, const void *__restrict, size_t);
void *memmove(void *dst, const void *src, size_t count);
void *memset(void *ptr, int value, size_t count);
int atexit(void (*func)(void));
}
extern "C" {
int bcmp(const void *lhs, const void *rhs, size_t count) {
return LIBC_NAMESPACE::bcmp(lhs, rhs, count);
}
void bzero(void *ptr, size_t count) { LIBC_NAMESPACE::bzero(ptr, count); }
int memcmp(const void *lhs, const void *rhs, size_t count) {
return LIBC_NAMESPACE::memcmp(lhs, rhs, count);
}
void *memcpy(void *__restrict dst, const void *__restrict src, size_t count) {
return LIBC_NAMESPACE::memcpy(dst, src, count);
}
void *memmove(void *dst, const void *src, size_t count) {
return LIBC_NAMESPACE::memmove(dst, src, count);
}
void *memset(void *ptr, int value, size_t count) {
return LIBC_NAMESPACE::memset(ptr, value, count);
}
int atexit(void (*func)(void)) { return LIBC_NAMESPACE::atexit(func); }
}
static constexpr uint64_t MEMORY_SIZE = 16384;
static uint8_t memory[MEMORY_SIZE];
static uint8_t *ptr = memory;
extern "C" {
void *malloc(size_t s) {
void *mem = ptr;
ptr += s;
return static_cast<uint64_t>(ptr - memory) >= MEMORY_SIZE ? nullptr : mem;
}
void free(void *) {}
void *realloc(void *ptr, size_t s) {
free(ptr);
return malloc(s);
}
void *__dso_handle = nullptr;
#ifdef LIBC_TARGET_ARCH_IS_AARCH64
unsigned long __getauxval(unsigned long id) {
return LIBC_NAMESPACE::getauxval(id);
}
#endif
}