42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/*
|
|
File: stdlib.h
|
|
Author: Taylor Robbins
|
|
Date: 08\28\2025
|
|
*/
|
|
|
|
#ifndef _STDLIB_H
|
|
#define _STDLIB_H
|
|
|
|
#include <stdint.h>
|
|
|
|
MAYBE_START_EXTERN_C
|
|
|
|
int abs(int value);
|
|
_Noreturn void exit(int exitCode);
|
|
_Noreturn void abort();
|
|
//NOTE: This is not a standard function but we want to pass a message to jsStdAbort so we added this
|
|
_Noreturn void abort_msg(const char* message);
|
|
|
|
//NOTE: These are intentionally not available on WebAssembly because our memory model only allows for growth and
|
|
// it's better to have the application decide how to manage memory on top of that simple model
|
|
// void* malloc(size_t numBytes);
|
|
// void* calloc(size_t numElements, size_t elemSize);
|
|
// void* realloc(void* prevAllocPntr, size_t newSize);
|
|
// void free(void* allocPntr);
|
|
// void* aligned_alloc(size_t numBytes, size_t alignmentSize);
|
|
|
|
//These are our own std-like functions for interacting with WebAssembly memory
|
|
void* grow_mem(size_t numBytes);
|
|
size_t get_mem();
|
|
|
|
// TODO: double atof(const char* str);
|
|
// TODO: void* alloca(size_t numBytes);
|
|
|
|
// typedef int (StdCompareFunc_f)(const void* left, const void* right);
|
|
// typedef int (StdCompareFuncEx_f)(const void* left, const void* right, void* compareFunc);
|
|
//TODO: void qsort(void* basePntr, size_t numItems, size_t itemSize, StdCompareFunc_f* compareFunc);
|
|
|
|
MAYBE_END_EXTERN_C
|
|
|
|
#endif // _STDLIB_H
|