Refresh 3

This commit is contained in:
n64
2019-11-03 14:36:27 -05:00
parent 6b8bc9b9ec
commit a7c423cb43
4603 changed files with 475500 additions and 437701 deletions

13
include/libc/math.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef MATH_H
#define MATH_H
#define M_PI 3.14159265358979323846
float sinf(float);
double sin(double);
float cosf(float);
double cos(double);
float sqrtf(float);
#endif

42
include/libc/stdarg.h Normal file
View File

@@ -0,0 +1,42 @@
#ifndef STDARG_H
#define STDARG_H
// When not building with IDO, use the builtin vaarg macros for portability.
#ifndef __sgi
#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) (((unsigned int)(((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) \
( \
(((long)list & 0x1) /* 1 byte aligned? */ \
? (list = (char *)((long)list + 7), (char *)((long)list - 6 - _VA_FP_SAVE_AREA)) \
: (((long)list & 0x2) /* 2 byte aligned? */ \
? (list = (char *)((long)list + 10), (char *)((long)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(double)) \
? __va_double_arg(list, mode) \
: __va_stack_arg(list, mode))))[-1]
#define va_end(__list)
#endif
#endif

10
include/libc/stddef.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef STDDEF_H
#define STDDEF_H
#include "PR/ultratypes.h"
#ifndef offsetof
#define offsetof(st, m) ((size_t)&(((st *)0)->m))
#endif
#endif

6
include/libc/stdio.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef STDIO_H
#define STDIO_H
extern int sprintf(char *s, const char *fmt, ...);
#endif

19
include/libc/stdlib.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef STDLIB_H
#define STDLIB_H
typedef struct lldiv_t
{
long long quot;
long long rem;
} lldiv_t;
typedef struct ldiv_t
{
long quot;
long rem;
} ldiv_t;
lldiv_t lldiv(long long num, long long denom);
ldiv_t ldiv(long num, long denom);
#endif

10
include/libc/string.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef STRING_H
#define STRING_H
#include "PR/ultratypes.h"
void *memcpy(void *dst, const void *src, size_t size);
size_t strlen(const char *str);
char *strchr(const char *str, s32 ch);
#endif