wasm: support more vendor libraries

Adds support for:
- box2d
- cgltf
- stb image
- stb rect pack
This commit is contained in:
Laytan Laats
2024-09-09 18:49:13 +02:00
parent d783bca297
commit 5ae27c6ebc
45 changed files with 2828 additions and 231 deletions
+16
View File
@@ -0,0 +1,16 @@
#ifdef NDEBUG
#define assert(e) ((void)0)
#else
#ifdef __FILE_NAME__
#define __ASSERT_FILE_NAME __FILE_NAME__
#else /* __FILE_NAME__ */
#define __ASSERT_FILE_NAME __FILE__
#endif /* __FILE_NAME__ */
void __odin_libc_assert_fail(const char *, const char *, int, const char *);
#define assert(e) \
(__builtin_expect(!(e), 0) ? __odin_libc_assert_fail(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
#endif /* NDEBUG */
+21
View File
@@ -0,0 +1,21 @@
#include <stdbool.h>
float sqrtf(float);
float cosf(float);
float sinf(float);
float atan2f(float, float);
bool isnan(float);
bool isinf(float);
double floor(double x);
double ceil(double x);
double sqrt(double x);
double pow(double x, double y);
double fmod(double x, double y);
double cos(double x);
double acos(double x);
double fabs(double x);
int abs(int);
double ldexp(double, int);
double exp(double);
float log(float);
float sin(float);
+47
View File
@@ -0,0 +1,47 @@
#include <stddef.h>
#include <stdarg.h>
#pragma once
typedef struct {} FILE;
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define stdout ((FILE *)2)
#define stderr ((FILE *)3)
FILE *fopen(const char *, char *);
int fclose(FILE *);
int fseek(FILE *, long, int);
long ftell(FILE *);
size_t fread(void *, size_t, size_t, FILE *);
size_t fwrite(const void *, size_t, size_t, FILE *);
int vfprintf(FILE *, const char *, va_list);
int vsnprintf(char *, size_t, const char *, va_list);
static inline int snprintf(char *buf, size_t size, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
int result = vsnprintf(buf, size, fmt, args);
va_end(args);
return result;
}
static inline int fprintf(FILE *f, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
int result = vfprintf(f, fmt, args);
va_end(args);
return result;
}
static inline int printf(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
int result = vfprintf(stdout, fmt, args);
va_end(args);
return result;
}
+19
View File
@@ -0,0 +1,19 @@
#include <stddef.h>
void *malloc(size_t size);
void *aligned_alloc(size_t alignment, size_t size);
void free(void *);
void *realloc(void *, size_t);
void qsort(void* base, size_t num, size_t size, int (*compare)(const void*, const void*));
int atoi(const char *);
long atol(const char *);
long long atoll(const char *);
double atof(const char *);
long strtol(const char *, char **, int);
+21
View File
@@ -0,0 +1,21 @@
#include <stddef.h>
void *memcpy(void *, const void *, size_t);
void *memset(void *, int, size_t);
void *memmove(void *, void *, size_t);
int memcmp(const void *, const void *, size_t);
unsigned long strlen(const char *str);
char *strchr(const char *, int);
char *strrchr(const char *, int);
char *strncpy(char *, const char *, size_t);
char *strcpy(char *, const char *);
size_t strcspn(const char *, const char *);
int strcmp(const char *, const char *);
int strncmp(const char *, const char *, size_t);
char *strstr(const char *, const char *);