diff options
| author | M4xw <m4x@m4xw.net> | 2022-03-22 02:51:23 +0100 |
|---|---|---|
| committer | M4xw <m4x@m4xw.net> | 2022-03-22 02:51:23 +0100 |
| commit | 39cc86c2608e2f75ace33fc7f43bc4f2ad743f1a (patch) | |
| tree | 0d3fd9e995d7484eaaeb158ac808bd6a39121189 /soh/include/libc | |
| parent | 0bb0e7b53bd80bdc7f78e08c441691737e039b2b (diff) | |
git subrepo clone https://github.com/HarbourMasters/soh.git
subrepo:
subdir: "soh"
merged: "ba904bbd0"
upstream:
origin: "https://github.com/HarbourMasters/soh.git"
branch: "master"
commit: "ba904bbd0"
git-subrepo:
version: "0.4.1"
origin: "???"
commit: "???"
Diffstat (limited to 'soh/include/libc')
| -rw-r--r-- | soh/include/libc/math.h | 29 | ||||
| -rw-r--r-- | soh/include/libc/stdarg.h | 43 | ||||
| -rw-r--r-- | soh/include/libc/stdbool.h | 14 | ||||
| -rw-r--r-- | soh/include/libc/stddef.h | 14 | ||||
| -rw-r--r-- | soh/include/libc/stdlib.h | 21 |
5 files changed, 121 insertions, 0 deletions
diff --git a/soh/include/libc/math.h b/soh/include/libc/math.h new file mode 100644 index 000000000..bceffad22 --- /dev/null +++ b/soh/include/libc/math.h @@ -0,0 +1,29 @@ +#ifndef MATH_H +#define MATH_H + +#include "ultra64/types.h" + +#define M_PI 3.14159265358979323846f +#define M_SQRT2 1.41421356237309504880f +#define FLT_MAX 340282346638528859811704183484516925440.0f +#define SHT_MAX 32767.0f +#define SHT_MINV (1.0f / SHT_MAX) +#define DEGTORAD(x) (x * M_PI / 180.0f) + +typedef union { + struct { + u32 hi; + u32 lo; + } word; + + f64 d; +} du; + +typedef union { + u32 i; + f32 f; +} fu; + +extern f32 __libm_qnan_f; + +#endif diff --git a/soh/include/libc/stdarg.h b/soh/include/libc/stdarg.h new file mode 100644 index 000000000..daf456bb3 --- /dev/null +++ b/soh/include/libc/stdarg.h @@ -0,0 +1,43 @@ +#ifndef STDARG_H +#define STDARG_H + +// When building with GCC, use the official vaarg macros to avoid warnings +// and possibly bad codegen. +#ifdef __GNUC__ +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end +#else + +typedef char* va_list; +#define _FP 1 +#define _INT 0 +#define _STRUCT 2 + +#define _VA_FP_SAVE_AREA 0x10 +#define _VA_ALIGN(p, a) (((uintptr_t)(((char*)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4)) +#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) + +#define __va_stack_arg(list, mode) \ + ( \ + ((list) = (char*)_VA_ALIGN(list, __builtin_alignof(mode)) + \ + _VA_ALIGN(sizeof(mode), 4)), \ + (((char*)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode)))) + +#define __va_double_arg(list, mode) \ + ( \ + (((s32)list & 0x1) /* 1 byte aligned? */ \ + ? (list = (char*)((s32)list + 7), (char*)((s32)list - 6 - _VA_FP_SAVE_AREA)) \ + : (((s32)list & 0x2) /* 2 byte aligned? */ \ + ? (list = (char*)((s32)list + 10), (char*)((s32)list - 24 - _VA_FP_SAVE_AREA)) \ + : __va_stack_arg(list, mode)))) + +#define va_arg(list, mode) ((mode*)(((__builtin_classof(mode) == _FP && \ + __builtin_alignof(mode) == sizeof(f64)) \ + ? __va_double_arg(list, mode) \ + : __va_stack_arg(list, mode))))[-1] +#define va_end(__list) + +#endif +#endif diff --git a/soh/include/libc/stdbool.h b/soh/include/libc/stdbool.h new file mode 100644 index 000000000..4495977a9 --- /dev/null +++ b/soh/include/libc/stdbool.h @@ -0,0 +1,14 @@ +#ifndef STDBOOL_H +#define STDBOOL_H + +#define __bool_true_false_are_defined 1 + +#ifndef __cplusplus + +#define bool u32 +#define false 0 +#define true 1 + +#endif /* __cplusplus */ + +#endif /* STDBOOL */ diff --git a/soh/include/libc/stddef.h b/soh/include/libc/stddef.h new file mode 100644 index 000000000..c30e392f8 --- /dev/null +++ b/soh/include/libc/stddef.h @@ -0,0 +1,14 @@ +#ifndef STDDEF_H +#define STDDEF_H + +#define NULL ((void*)0) +#if 0 +#define size_t unsigned long +#define ssize_t long + +#endif + +//typedef unsigned long size_t; +//typedef long ssize_t; + +#endif diff --git a/soh/include/libc/stdlib.h b/soh/include/libc/stdlib.h new file mode 100644 index 000000000..00418278a --- /dev/null +++ b/soh/include/libc/stdlib.h @@ -0,0 +1,21 @@ +#ifndef STDLIB_H +#define STDLIB_H + +#include "ultra64.h" + +#if 0 + +#ifndef __cplusplus +typedef struct lldiv_t { + s64 quot; + s64 rem; +} lldiv_t; + +typedef struct ldiv_t { + s32 quot; + s32 rem; +} ldiv_t; +#endif +#endif + +#endif |
