From 9614163a48dda8c06fab31e1c66e66c4d978d645 Mon Sep 17 00:00:00 2001 From: Reece Date: Thu, 20 May 2021 17:29:39 +0100 Subject: [PATCH] Initial Commit --- AuroraCommon.h | 14 ++++ AuroraCommon.hpp | 14 ++++ AuroraConfiguration.h | 10 +++ AuroraConfiguration.hpp | 15 ++++ AuroraEnvrionment.h | 106 +++++++++++++++++++++++++ AuroraEnvrionment.hpp | 166 ++++++++++++++++++++++++++++++++++++++++ AuroraTypes.h | 45 +++++++++++ AuroraTypes.hpp | 48 ++++++++++++ README.md | 4 +- 9 files changed, 420 insertions(+), 2 deletions(-) create mode 100644 AuroraCommon.h create mode 100644 AuroraCommon.hpp create mode 100644 AuroraConfiguration.h create mode 100644 AuroraConfiguration.hpp create mode 100644 AuroraEnvrionment.h create mode 100644 AuroraEnvrionment.hpp create mode 100644 AuroraTypes.h create mode 100644 AuroraTypes.hpp diff --git a/AuroraCommon.h b/AuroraCommon.h new file mode 100644 index 0000000..b35586c --- /dev/null +++ b/AuroraCommon.h @@ -0,0 +1,14 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraCommon.h + Date: 2020-:( + Originator: Reece + Purpose: +***/ +#pragma once + +#include "AuroraConfiguration.h" +#include "AuroraEnvrionment.h" +#include "AuroraTypes.h" \ No newline at end of file diff --git a/AuroraCommon.hpp b/AuroraCommon.hpp new file mode 100644 index 0000000..cbb1926 --- /dev/null +++ b/AuroraCommon.hpp @@ -0,0 +1,14 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraCommon.hpp + Date: 2020-6-10 + Originator: Reece + Purpose: +***/ +#pragma once + +#include "AuroraConfiguration.hpp" +#include "AuroraEnvrionment.hpp" +#include "AuroraTypes.hpp" \ No newline at end of file diff --git a/AuroraConfiguration.h b/AuroraConfiguration.h new file mode 100644 index 0000000..189870c --- /dev/null +++ b/AuroraConfiguration.h @@ -0,0 +1,10 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraConfiguration.h + Date: 2020-6-9 + Originator: Reece + Purpose: +***/ +#pragma once diff --git a/AuroraConfiguration.hpp b/AuroraConfiguration.hpp new file mode 100644 index 0000000..04d962f --- /dev/null +++ b/AuroraConfiguration.hpp @@ -0,0 +1,15 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraConfiguration.hpp + Date: 2020-6-9 + Originator: Reece + Purpose: +***/ +#pragma once + +extern "C" +{ + #include "AuroraConfiguration.h" +} \ No newline at end of file diff --git a/AuroraEnvrionment.h b/AuroraEnvrionment.h new file mode 100644 index 0000000..d8cb4c9 --- /dev/null +++ b/AuroraEnvrionment.h @@ -0,0 +1,106 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraEnvrionment.h + Date: 2020-6-9 + Originator: Reece + Purpose: +***/ +#pragma once + +#if defined(__clang_major__) + #define AURORA_COMPILER_CLANG +#elif defined(_MSC_VER) + #define AURORA_COMPILER_MSVC +#elif __GNUC__ > 8 || __GNUC__ == 8 + #define AURORA_COMPILER_GCC +#elif __GNUC__ + #error GCC outdated +#else + #error Illegal Compiler +#endif + +#if defined(_LINUX_KERNEL_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_KERNEL_LINUX +#elif defined(_NTOS_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_NTOS +#elif defined(_WINDOWS) || defined(_WIN32) || defined(_WIN64) + #define AURORA_PLATFORM_WIN32 +#elif defined(__ANDROID__) || defined(_ANDROID_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_ANDROID +#elif defined(__linux__) || defined(_LINUX_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_LINUX +#elif (defined(__APPLE__) && defined(__MACH__)) || defined(_APPLE_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_APPLE +#elif (defined(__APPLE__) && defined(TARGET_OS_IPHONE)) || defined(_APPLE_MOBILE_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_IOS +#elif defined(_SWITCH_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_SWITCH +#elif defined(_PS4_AURORA_PREPROCESSOR) || defined(__ORBIS__) + #define AURORA_PLATFORM_PS4 +#elif defined(_PS5_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_PS5 +#elif defined(_XBONE_AURORA_PREPROCESSOR) || defined(_XBOX_ONE) + #define AURORA_PLATFORM_XBONE +#elif defined(_WII_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_WII +#elif defined(_WII_U_AURORA_PREPROCESSOR) + #define AURORA_PLATFORM_WII_U +#endif + +#if defined(_GAMING_XBOX) + #define VENDOR_CONSOLE_MICROSOFT +#elif defined(__APPLE__) + #define VENDOR_GENERIC_APPLE +#elif defined(AURORA_PLATFORM_PS4) || defined(AURORA_PLATFORM_PS5) + #define VENDOR_CONSOLE_SONY +#elif defined(AURORA_PLATFORM_SWITCH) || defined(AURORA_PLATFORM_WII)|| defined(AURORA_PLATFORM_WII_U) + #define VENDOR_CONSOLE_NINTENDO +#elif defined(AURORA_PLATFORM_NTOS) || defined(AURORA_PLATFORM_WIN32) + #define VENDOR_GENERIC_MICROSOFT +#else + #define VENDOR_UNKNOWN +#endif + +#if defined(AURORA_COMPILER_MSVC) + + #if defined(_M_X64) + #define AURORA_ABI_MSFT_64 + #define AURORA_ARCH_X64 + #elif defined(__aarch64__) + #define AURORA_ARCH_ARM + #define AURORA_ABI_MS_ARM + #else + #define AURORA_ARCH_X86 + #define AURORA_ABI_CDECL + #endif + + #define AURORA_SYMBOL_IMPORT __declspec(dllimport) + #define AURORA_SYMBOL_EXPORT __declspec(dllexport) + +#elif defined(AURORA_COMPILER_COMMUNISM) || defined(AURORA_COMPILER_CLANG) + + #if defined(__x86_64__) + #define AURORA_ARCH_X64 + #if defined(AURORA_PLATFORM_WIN32) || defined(AURORA_PLATFORM_NTOS) + #define AURORA_ABI_MSFT_64 + #else + #define AURORA_ABI_SYSV + #endif + #elif defined(__aarch64__) + #define AURORA_ARCH_ARM + #if defined(__APPLE__) + #define AURORA_ABI_APPLE_ARM + #else + #define AURORA_ABI_LLVM_ARM + #endif + #else + #define AURORA_ARCH_X86 + #define AURORA_ABI_CDECL + #endif + + #define AURORA_SYMBOL_IMPORT + #define AURORA_SYMBOL_EXPORT __attribute__((visibility("default"))) + +#endif diff --git a/AuroraEnvrionment.hpp b/AuroraEnvrionment.hpp new file mode 100644 index 0000000..5a48688 --- /dev/null +++ b/AuroraEnvrionment.hpp @@ -0,0 +1,166 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraEnvrionment.h + Date: 2020-6-9 + Originator: Reece + Purpose: +***/ +#pragma once + +extern "C" +{ + #include "AuroraEnvrionment.h" +} + +namespace Aurora::Build +{ + enum class ECompiler + { + kInvaild = -1, + kMSVC, + kClang, + kGCC + }; + + #if defined(AURORA_COMPILER_CLANG) + static const ECompiler kCurrentECompiler = ECompiler::kClang; + #elif defined(AURORA_COMPILER_MSVC) + static const ECompiler kCurrentECompiler = ECompiler::kMSVC; + #elif defined(AURORA_COMPILER_GCC) + static const ECompiler kCurrentECompiler = ECompiler::kGCC; + #else + static const ECompiler kCurrentECompiler = ECompiler::kInvaild; + #endif + + enum class EPlatform + { + kInvalid = -1, + + kKernelLinux, + kKernelNtos, + + kPlatformWin32, + kPlatformAndroid, + kPlatformLinux, + kPlatformApple, + kPlatformIos, + kPlatformSwitch, + kPlatformPS4, + kPlatformPS5, + kPlatformXbone, + kPlatformWii, + kPlatformWiiU + }; + + #if defined(AURORA_PLATFORM_KERNEL_LINUX) + static const EPlatform kCurrentPlatform = EPlatform::kKernelLinux; + #elif defined(AURORA_PLATFORM_NTOS) + static const EPlatform kCurrentPlatform = EPlatform::kKernelNtos; + #elif defined(AURORA_PLATFORM_WIN32) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformWin32; + #elif defined(AURORA_PLATFORM_ANDROID) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformAndroid; + #elif defined(AURORA_PLATFORM_LINUX) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformLinux; + #elif defined(AURORA_PLATFORM_APPLE) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformApple; + #elif defined(AURORA_PLATFORM_IOS) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformIos; + #elif defined(AURORA_PLATFORM_SWITCH) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformSwitch; + #elif defined(AURORA_PLATFORM_PS4) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformPS4; + #elif defined(AURORA_PLATFORM_PS5) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformPS5; + #elif defined(AURORA_PLATFORM_XBONE) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformXbone; + #elif defined(AURORA_PLATFORM_WII) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformWii; + #elif defined(AURORA_PLATFORM_WII_U) + static const EPlatform kCurrentPlatform = EPlatform::kPlatformWiiU; + #else + static const EPlatform kCurrentPlatform = EPlatform::kInvalid; + #endif + + enum class EVendor + { + kInvalid = -1, + kUnknown = 0, + + kConsoleMicrosft, + kConsoleSony, + kConsoleNintendo, + + kGenericApple, + kGenericMicrosoft, + }; + + #if defined(VENDOR_CONSOLE_MICROSOFT) + static const EVendor kCurrentVendor = EVendor::kConsoleMicrosft; + #elif defined(VENDOR_GENERIC_APPLE) + static const EVendor kCurrentVendor = EVendor::kGenericApple; + #elif defined(VENDOR_CONSOLE_SONY) + static const EVendor kCurrentVendor = EVendor::kConsoleSony; + #elif defined(VENDOR_CONSOLE_NINTENDO) + static const EVendor kCurrentVendor = EVendor::kConsoleNintendo; + #elif defined(VENDOR_GENERIC_MICROSOFT) + static const EVendor kCurrentVendor = EVendor::kGenericMicrosoft; + #elif defined(VENDOR_UNKNOWN) + static const EVendor kCurrentVendor = EVendor::kUnknown; + #else + static const EVendor kCurrentVendor = EVendor::kInvalid; + #endif + + enum class EArchitecture + { + kInvalid = -1, + kX86_32, + kX86_64, + kAArch64 + }; + + #if defined(AURORA_ARCH_X86) + static const EArchitecture kCurrentArchitecture = EArchitecture::kX86_32; + #elif defined(AURORA_ARCH_X64) + static const EArchitecture kCurrentArchitecture = EArchitecture::kX86_64; + #elif defined(AURORA_ARCH_ARM) + static const EArchitecture kCurrentArchitecture = EArchitecture::kAArch64; + #else + static const EArchitecture kCurrentArchitecture = EArchitecture::kInvalid; + #endif + + enum class EABI + { + kInvalid = -1, + // MSFTs in house amd64 abi + kMSFT64, + // MSFTs in house aarch64 abi + kMSFTArm, + // x86 sysv and microsoft only deviate with fastcall and thiscall :( + kCdeclIntel, + // x86_64 others + kSysV, + // tim apple is special + kAppleArm, + // other arm EPlatforms... + kLLVMArm + }; + + #if defined(AURORA_ABI_MSFT_64) + static const EABI kCurrentABI = EABI::kMSFT64; + #elif defined(AURORA_ABI_MS_ARM) + static const EABI kCurrentABI = EABI::kMSFTArm; + #elif defined(AURORA_ABI_LLVM_ARM) + static const EABI kCurrentABI = EABI::kLLVMArm; + #elif defined(AURORA_ABI_CDECL) + static const EABI kCurrentABI = EABI::kCdeclIntel; + #elif defined(AURORA_ABI_SYSV) + static const EABI kCurrentABI = EABI::kSysV; + #elif defined(AURORA_ABI_APPLE) + static const EABI kCurrentABI = EABI::kAppleArm; + #else + static const EABI kCurrentABI = EABI::kInvalid; + #endif +} \ No newline at end of file diff --git a/AuroraTypes.h b/AuroraTypes.h new file mode 100644 index 0000000..311ee9f --- /dev/null +++ b/AuroraTypes.h @@ -0,0 +1,45 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraTypes.h + Date: 2020-6-12 + Originator: Reece + Purpose: +***/ +#pragma once + +#if defined(AURORA_COMPILER_MSVC) + typedef signed char int8_ct; + typedef short int16_ct; + typedef int int32_ct; + typedef long long int64_ct; + typedef unsigned char uint8_ct; + typedef unsigned short uint16_ct; + typedef unsigned int uint32_ct; + typedef unsigned long long uint64_ct; +#elif defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC) + typedef __INT8_TYPE__ int8_ct; + typedef __INT16_TYPE__ int16_ct; + typedef __INT32_TYPE__ int32_ct; + typedef __INT64_TYPE__ int64_ct; + typedef __UINT8_TYPE__ uint8_ct; + typedef __UINT16_TYPE__ uint16_ct; + typedef __UINT32_TYPE__ uint32_ct; + typedef __UINT64_TYPE__ uint64_ct; +#endif + +#if defined(AURORA_ARCH_X86) + typedef uint32_ct size_ct; + typedef int32_ct ssize_ct; +#elif defined(AURORA_ARCH_X64) + typedef uint64_ct size_ct; + typedef int64_ct ssize_ct; +#elif defined(AURORA_ARCH_ARM) + typedef uint64_ct size_ct; + typedef int64_ct ssize_ct; +#else + #error unsupported architecture. currently supports: aarch64 x86_64 x86_32 +#endif + +typedef size_t Handle_ct; \ No newline at end of file diff --git a/AuroraTypes.hpp b/AuroraTypes.hpp new file mode 100644 index 0000000..5ac3d22 --- /dev/null +++ b/AuroraTypes.hpp @@ -0,0 +1,48 @@ +/*** + Copyright (©) 2020 Reece Wilson (a/k/a "Reece"). + All rights reserved. + + File: AuroraTypes.hpp + Date: 2020-6-12 + Originator: Reece + Purpose: +***/ +#pragma once + +namespace Aurora::Types +{ + #if defined(AURORA_COMPILER_MSVC) + using int8_t = signed char; + using int16_t = short; + using int32_t = int; + using int64_t = long long; + using uint8_t = unsigned char; + using uint16_t = unsigned short; + using uint32_t = unsigned int; + using uint64_t = unsigned long long; + #elif defined(AURORA_COMPILER_CLANG) || defined(AURORA_COMPILER_GCC) + using int8_t = __INT8_TYPE__; + using int16_t = __INT16_TYPE__; + using int32_t = __INT32_TYPE__; + using int64_t = __INT64_TYPE__; + using uint8_t = __UINT8_TYPE__; + using uint16_t = __UINT16_TYPE__; + using uint32_t = __UINT32_TYPE__; + using uint64_t = __UINT64_TYPE__; + #endif + + #if defined(AURORA_ARCH_X86) + using size_t = uint32_t; + using ssize_t = int32_t; + #elif defined(AURORA_ARCH_X64) + using size_t = uint64_t; + using ssize_t = int64_t; + #elif defined(AURORA_ARCH_ARM) + using size_t = uint64_t; + using ssize_t = int64_t; + #else + #error unsupported architecture. currently supports: aarch64, x86_64, x86_32 + #endif + + using Handle = size_t; +} \ No newline at end of file diff --git a/README.md b/README.md index 2a41eda..1b42975 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# Include +# Common boilerplate -Common include headers for various software packages. Provides stdint alternative. Also provides macros for platform (+ fallback tied to /Build), compiler, platform, vendor, and partial ABI detection. Compiler/Runtime agnostic \ No newline at end of file +Provides platform macros and standard primitive datatypes to translation units without any other external includes (no stdlib/stl) \ No newline at end of file