Split up source and added basic support for different targets.
This commit is contained in:
27
targets/_any/include/assert.h
Normal file
27
targets/_any/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)
|
||||
21
targets/_any/include/detail/common.h
Normal file
21
targets/_any/include/detail/common.h
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
#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 }
|
||||
#else
|
||||
#define BA_CXX_NODISCARD
|
||||
#define BA_CXX_NORETURN
|
||||
#define BA_CXX_NOEXCEPT
|
||||
#define BA_EXTERN_C_BEGIN
|
||||
#define BA_EXTERN_C_END
|
||||
#endif
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_DETAIL_ATTRIBUTES_H_INCLUDED)
|
||||
10
targets/_any/include/os/panic.hpp
Normal file
10
targets/_any/include/os/panic.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_PANIC_HPP_INCLUDED)
|
||||
#define BAD_APPLE_OS_PANIC_HPP_INCLUDED
|
||||
|
||||
[[noreturn]] void panic(const char* message) noexcept;
|
||||
[[noreturn]] void panicf(const char* format, ...) noexcept;
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_PANIC_HPP_INCLUDED)
|
||||
46
targets/_any/include/os/tty.hpp
Normal file
46
targets/_any/include/os/tty.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(OS_TTY_HPP_INCLUDED)
|
||||
#define OS_TTY_HPP_INCLUDED 1
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace tty
|
||||
{
|
||||
enum class VgaColor : uint8_t
|
||||
{
|
||||
BLACK = 0,
|
||||
BLUE = 1,
|
||||
GREEN = 2,
|
||||
CYAN = 3,
|
||||
RED = 4,
|
||||
MAGENTA = 5,
|
||||
BROWN = 6,
|
||||
LIGHT_GREY = 7,
|
||||
DARK_GREY = 8,
|
||||
LIGHT_BLUE = 9,
|
||||
LIGHT_GREEN = 10,
|
||||
LIGHT_CYAN = 11,
|
||||
LIGHT_RED = 12,
|
||||
LIGHT_MAGENTA = 13,
|
||||
LIGHT_BROWN = 14,
|
||||
WHITE = 15
|
||||
};
|
||||
|
||||
struct VgaDoubleColor
|
||||
{
|
||||
VgaColor foreground : 4 = VgaColor::LIGHT_GREY;
|
||||
VgaColor background : 4 = VgaColor::BLACK;
|
||||
};
|
||||
|
||||
void initialize();
|
||||
void setColor(VgaDoubleColor color);
|
||||
void putEntryAt(char chr, VgaDoubleColor color, size_t posX, size_t posY);
|
||||
void putChar(char chr);
|
||||
void write(const char* data, size_t size);
|
||||
void write(const char* data);
|
||||
} // namespace tty
|
||||
|
||||
#endif // OS_TTY_HPP_INCLUDED
|
||||
19
targets/_any/include/stdio.h
Normal file
19
targets/_any/include/stdio.h
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(BAD_APPLE_OS_STDIO_H_INCLUDED)
|
||||
#define BAD_APPLE_OS_STDIO_H_INCLUDED
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "./detail/common.h"
|
||||
|
||||
BA_EXTERN_C_BEGIN
|
||||
|
||||
int putchar(int chr) BA_CXX_NOEXCEPT;
|
||||
int puts(const char* str) BA_CXX_NOEXCEPT;
|
||||
int printf(const char* format, ...) BA_CXX_NOEXCEPT;
|
||||
int vprintf(const char* format, va_list vlist) BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_EXTERN_C_END
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_STDIO_H_INCLUDED)
|
||||
18
targets/_any/include/stdlib.h
Normal file
18
targets/_any/include/stdlib.h
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
#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();
|
||||
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)
|
||||
21
targets/_any/include/string.h
Normal file
21
targets/_any/include/string.h
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
#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 size_t strlen(const char* str) BA_CXX_NOEXCEPT;
|
||||
|
||||
BA_EXTERN_C_END
|
||||
|
||||
#endif // !defined(BAD_APPLE_OS_STRING_H_INCLUDED)
|
||||
Reference in New Issue
Block a user