Moved stdlib to a seperate folder and added some more headers that are required for compiling libgcc (no implementation yet).
This commit is contained in:
27
targets/_any/stdlib/include/assert.h
Normal file
27
targets/_any/stdlib/include/assert.h
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_ASSERT_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_ASSERT_H_INCLUDED
|
||||
|
||||
#include "./detail/common.h"
|
||||
|
||||
BA_EXTERN_C_BEGIN
|
||||
|
||||
#if defined(NDEBUG)
|
||||
#define assert(condition) ((void) 0)
|
||||
#else
|
||||
#define assert(condition) \
|
||||
if (!(condition)) \
|
||||
{ \
|
||||
__ba__assert_fail(__FILE__, __LINE__, #condition); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
BA_CXX_NORETURN void __ba__assert_fail(const char* filename, int line, const char* condition) BA_CXX_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
BA_EXTERN_C_END
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_ASSERT_H_INCLUDED)
|
||||
23
targets/_any/stdlib/include/detail/common.h
Normal file
23
targets/_any/stdlib/include/detail/common.h
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_DETAIL_ATTRIBUTES_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_DETAIL_ATTRIBUTES_H_INCLUDED
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define BA_CXX_NODISCARD [[nodiscard]]
|
||||
#define BA_CXX_NORETURN [[noreturn]]
|
||||
#define BA_CXX_NOEXCEPT noexcept
|
||||
#define BA_EXTERN_C_BEGIN extern "C" {
|
||||
#define BA_EXTERN_C_END }
|
||||
#define BA_C_RESTRICT
|
||||
#else
|
||||
#define BA_CXX_NODISCARD
|
||||
#define BA_CXX_NORETURN
|
||||
#define BA_CXX_NOEXCEPT
|
||||
#define BA_EXTERN_C_BEGIN
|
||||
#define BA_EXTERN_C_END
|
||||
#define BA_C_RESTRICT restrict
|
||||
#endif
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_DETAIL_ATTRIBUTES_H_INCLUDED)
|
||||
7
targets/_any/stdlib/include/errno.h
Normal file
7
targets/_any/stdlib/include/errno.h
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_ERRNO_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_ERRNO_H_INCLUDED
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_ERRNO_H_INCLUDED)
|
||||
43
targets/_any/stdlib/include/math.h
Normal file
43
targets/_any/stdlib/include/math.h
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_MATH_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_MATH_H_INCLUDED
|
||||
|
||||
#if !defined(HUGE_VALF)
|
||||
#define HUGE_VALF (__builtin_inff())
|
||||
#endif
|
||||
|
||||
#if !defined(FLT_QNAN)
|
||||
#define FLT_QNAN (__builtin_nanf(""))
|
||||
#endif
|
||||
|
||||
#if !defined(FLT_SNAN)
|
||||
#define FLT_SNAN (__builtin_nansf(""))
|
||||
#endif
|
||||
|
||||
#if !defined(HUGE_VAL)
|
||||
#define HUGE_VAL (__builtin_inf())
|
||||
#endif
|
||||
|
||||
#if !defined(DBL_QNAN)
|
||||
#define DBL_QNAN (__builtin_nan(""))
|
||||
#endif
|
||||
|
||||
#if !defined(DBL_SNAN)
|
||||
#define DBL_SNAN (__builtin_nans(""))
|
||||
#endif
|
||||
|
||||
#if !defined(HUGE_VALL)
|
||||
#define HUGE_VALL (__builtin_infl())
|
||||
#endif
|
||||
|
||||
#if !defined(LDBL_QNAN)
|
||||
#define LDBL_QNAN (__builtin_nanl(""))
|
||||
#endif
|
||||
|
||||
#if !defined(LDBL_SNAN)
|
||||
#define LDBL_SNAN (__builtin_nansl(""))
|
||||
#endif
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_MATH_H_INCLUDED)
|
||||
9
targets/_any/stdlib/include/stdint.h
Normal file
9
targets/_any/stdlib/include/stdint.h
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_STDINT_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_STDINT_H_INCLUDED
|
||||
|
||||
#include "stdint-gcc.h" // TODO?
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_STDINT_H_INCLUDED)
|
||||
47
targets/_any/stdlib/include/stdio.h
Normal file
47
targets/_any/stdlib/include/stdio.h
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_STDIO_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_STDIO_H_INCLUDED
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include "./detail/common.h"
|
||||
|
||||
#define stdin __stdin
|
||||
|
||||
BA_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct __file FILE;
|
||||
|
||||
extern FILE* __stdin;
|
||||
|
||||
static int EOF = -1;
|
||||
|
||||
int putchar(int chr) BA_CXX_NOEXCEPT;
|
||||
int puts(const char* str) BA_CXX_NOEXCEPT;
|
||||
int printf(const char* BA_C_RESTRICT format, ...) BA_CXX_NOEXCEPT __attribute__((format(printf, 1, 2)));
|
||||
int vprintf(const char* BA_C_RESTRICT format, va_list vlist) BA_CXX_NOEXCEPT;
|
||||
int sprintf(char* BA_C_RESTRICT buffer, const char* BA_C_RESTRICT format, ...) BA_CXX_NOEXCEPT;
|
||||
int snprintf(char* BA_C_RESTRICT buffer, size_t bufferSize, const char* BA_C_RESTRICT format, ...) BA_CXX_NOEXCEPT __attribute__((format(printf, 3, 4)));
|
||||
int vsnprintf(char* BA_C_RESTRICT buffer, size_t bufferSize, const char* BA_C_RESTRICT format, va_list vlist) BA_CXX_NOEXCEPT;
|
||||
|
||||
int fclose(FILE* stream) BA_CXX_NOEXCEPT;
|
||||
int fflush(FILE* stream) BA_CXX_NOEXCEPT;
|
||||
int fgetc(FILE* stream) BA_CXX_NOEXCEPT;
|
||||
FILE* fopen(const char* BA_C_RESTRICT filename, const char* BA_C_RESTRICT mode) BA_CXX_NOEXCEPT;
|
||||
char* fgets(char* buffer, int count, FILE* stream) BA_CXX_NOEXCEPT;
|
||||
int fprintf(FILE* BA_C_RESTRICT stream, const char* BA_C_RESTRICT format, ...) BA_CXX_NOEXCEPT __attribute__((format(printf, 2, 3)));
|
||||
size_t fread(void* BA_C_RESTRICT buffer, size_t size, size_t count, FILE* BA_C_RESTRICT stream) BA_CXX_NOEXCEPT;
|
||||
int fseek(FILE* stream, long offset, int origin) BA_CXX_NOEXCEPT;
|
||||
long ftell(FILE* stream) BA_CXX_NOEXCEPT;
|
||||
size_t fwrite(const void* BA_C_RESTRICT buffer, size_t size, size_t count, FILE* BA_C_RESTRICT stream) BA_CXX_NOEXCEPT;
|
||||
void setbuf(FILE* BA_C_RESTRICT stream, char* BA_C_RESTRICT buffer) BA_CXX_NOEXCEPT;
|
||||
int vfprintf(FILE* BA_C_RESTRICT stream, const char* BA_C_RESTRICT format, va_list vlist) BA_CXX_NOEXCEPT;
|
||||
|
||||
inline int getc(FILE* stream) BA_CXX_NOEXCEPT { return fgetc(stream); }
|
||||
inline int getchar() BA_CXX_NOEXCEPT { return fgetc(stdin); }
|
||||
|
||||
BA_EXTERN_C_END
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_STDIO_H_INCLUDED)
|
||||
25
targets/_any/stdlib/include/stdlib.h
Normal file
25
targets/_any/stdlib/include/stdlib.h
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_STDLIB_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_STDLIB_H_INCLUDED
|
||||
|
||||
#include <stddef.h>
|
||||
#include "./detail/common.h"
|
||||
|
||||
BA_EXTERN_C_BEGIN
|
||||
|
||||
BA_CXX_NORETURN void abort();
|
||||
int atexit(void (*func)()) BA_CXX_NOEXCEPT;
|
||||
BA_CXX_NODISCARD char* getenv(const char* name) BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_CXX_NODISCARD int abs(int n) BA_CXX_NOEXCEPT;
|
||||
BA_CXX_NODISCARD int atoi(const char* str) BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_CXX_NODISCARD void* calloc(size_t num, size_t size) BA_CXX_NOEXCEPT;
|
||||
BA_CXX_NODISCARD void* malloc(size_t size) BA_CXX_NOEXCEPT;
|
||||
void free(void* ptr) BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_EXTERN_C_END
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_STDLIB_H_INCLUDED)
|
||||
25
targets/_any/stdlib/include/string.h
Normal file
25
targets/_any/stdlib/include/string.h
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_STRING_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_STRING_H_INCLUDED
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "./detail/common.h"
|
||||
|
||||
BA_EXTERN_C_BEGIN
|
||||
|
||||
BA_CXX_NODISCARD int memcmp(const void* lhs, const void* rhs, size_t count) BA_CXX_NOEXCEPT;
|
||||
void* memcpy(void* dest, const void* src, size_t count) BA_CXX_NOEXCEPT;
|
||||
void* memmove(void* dest, const void* src, size_t count) BA_CXX_NOEXCEPT;
|
||||
void* memset(void* dest, int value, size_t count) BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_CXX_NODISCARD char* strcat(char* BA_C_RESTRICT dest, const char* BA_C_RESTRICT src) BA_CXX_NOEXCEPT;
|
||||
BA_CXX_NODISCARD char* strchr(const char* str, int ch) BA_CXX_NOEXCEPT;
|
||||
BA_CXX_NODISCARD char* strcpy(char* BA_C_RESTRICT dest, const char* BA_C_RESTRICT src) BA_CXX_NOEXCEPT;
|
||||
BA_CXX_NODISCARD size_t strlen(const char* str) BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_EXTERN_C_END
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_STRING_H_INCLUDED)
|
||||
9
targets/_any/stdlib/include/sys/types.h
Normal file
9
targets/_any/stdlib/include/sys/types.h
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_SYS_TYPES_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_SYS_TYPES_H_INCLUDED
|
||||
|
||||
typedef int pid_t;
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_SYS_TYPES_H_INCLUDED)
|
||||
7
targets/_any/stdlib/include/time.h
Normal file
7
targets/_any/stdlib/include/time.h
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_TIME_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_TIME_H_INCLUDED
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_TIME_H_INCLUDED)
|
||||
22
targets/_any/stdlib/include/unistd.h
Normal file
22
targets/_any/stdlib/include/unistd.h
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_UNISTD_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_UNISTD_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "./detail/common.h"
|
||||
|
||||
BA_EXTERN_C_BEGIN
|
||||
|
||||
pid_t fork() BA_CXX_NOEXCEPT;
|
||||
int execv(const char* pathname, char* const argv[]) BA_CXX_NOEXCEPT;
|
||||
int execve(const char* pathname, char* const argv[], char* const envp[]) BA_CXX_NOEXCEPT;
|
||||
int execvp(const char* file, char* const argv[]) BA_CXX_NOEXCEPT;
|
||||
pid_t getpid() BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_EXTERN_C_END
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_UNISTD_H_INCLUDED)
|
||||
Reference in New Issue
Block a user