diff options
Diffstat (limited to 'CRTKit')
| -rw-r--r-- | CRTKit/README.md | 5 | ||||
| -rw-r--r-- | CRTKit/__mpcc_defines.hxx | 23 | ||||
| -rw-r--r-- | CRTKit/__mpcc_exception.hxx | 12 | ||||
| -rw-r--r-- | CRTKit/__mpcc_iostream.hxx | 32 | ||||
| -rw-r--r-- | CRTKit/__mpcc_malloc.hxx | 8 | ||||
| -rw-r--r-- | CRTKit/__mpcc_runtime.cxx | 10 | ||||
| -rw-r--r-- | CRTKit/build.json | 10 |
7 files changed, 90 insertions, 10 deletions
diff --git a/CRTKit/README.md b/CRTKit/README.md new file mode 100644 index 00000000..c7058527 --- /dev/null +++ b/CRTKit/README.md @@ -0,0 +1,5 @@ +# ZKA C++ RunTime
+
+This is the public interface of ZKA' RT, please check libNDK.dll instead.
+
+###### (c) ZKA Technologies, all rights reserved.
\ No newline at end of file diff --git a/CRTKit/__mpcc_defines.hxx b/CRTKit/__mpcc_defines.hxx index 9dfe51af..dbd20493 100644 --- a/CRTKit/__mpcc_defines.hxx +++ b/CRTKit/__mpcc_defines.hxx @@ -95,4 +95,27 @@ typedef union double_cast { #endif // ifdef __STD_CXX__ +namespace std +{ + /// @brief Forward object. + /// @tparam Args the object type. + /// @param arg the object. + /// @return object's rvalue + template <typename Args> + inline Args&& forward(Args& arg) + { + return static_cast<Args&&>(arg); + } + + /// @brief Move object. + /// @tparam Args the object type. + /// @param arg the object. + /// @return object's rvalue + template <typename Args> + inline Args&& move(Args&& arg) + { + return static_cast<Args&&>(arg); + } +} // namespace std + #endif /* __MPCC_DEFINES_HXX__ */ diff --git a/CRTKit/__mpcc_exception.hxx b/CRTKit/__mpcc_exception.hxx index 012ff43f..23b4a99a 100644 --- a/CRTKit/__mpcc_exception.hxx +++ b/CRTKit/__mpcc_exception.hxx @@ -6,14 +6,16 @@ #pragma once +#include <CRTKit/__mpcc_iostream.hxx> + +/// @brief CRT exit, with exit code (!!! exits all threads. !!!) +/// @param code +/// @return extern "C" int __exit(int code); + /// @brief Standard C++ namespace namespace std { - class ofstream; - - extern ofstream cout; - inline void __throw_general(void) { __exit(33); @@ -21,14 +23,12 @@ namespace std inline void __throw_domain_error(const char* error) { - cout << "ZKA C++: Domain error: " << error << "\r"; __throw_general(); __builtin_unreachable(); // prevent from continuing. } inline void __throw_bad_array_new_length(void) { - cout << "ZKAC C++: Bad array length.\r"; __throw_general(); __builtin_unreachable(); // prevent from continuing. } diff --git a/CRTKit/__mpcc_iostream.hxx b/CRTKit/__mpcc_iostream.hxx new file mode 100644 index 00000000..1d93f1e4 --- /dev/null +++ b/CRTKit/__mpcc_iostream.hxx @@ -0,0 +1,32 @@ +/* -------------------------------------------
+
+ Copyright ZKA Technologies
+
+------------------------------------------- */
+
+#pragma once
+
+/// @brief CRT exit, with exit code (!!! exits all threads. !!!)
+/// @param code
+/// @return
+extern "C" int __exit(int code);
+
+/// @brief Standard C++ namespace
+namespace std
+{
+ template <typename Encoding>
+ class ofstream;
+
+ template <typename Encoding>
+ class ostream
+ {
+ public:
+ ostream() = default;
+ virtual ~ostream() = default;
+
+ virtual ostream<Encoding>& operator<<(const Encoding* input_streamable) = 0;
+ virtual ostream<Encoding>& operator<<(Encoding* input_streamable) = 0;
+ };
+
+ extern ofstream<char> cout;
+};
\ No newline at end of file diff --git a/CRTKit/__mpcc_malloc.hxx b/CRTKit/__mpcc_malloc.hxx index 95a27f86..794cd5b4 100644 --- a/CRTKit/__mpcc_malloc.hxx +++ b/CRTKit/__mpcc_malloc.hxx @@ -6,22 +6,22 @@ #pragma once -#include <NewKit/Defines.hxx> +#include <CRTKit/__mpcc_defines.hxx> namespace stdx { /// @brief allocate a new class. /// @tparam KindClass the class type to allocate. template <typename KindClass, typename... Args> - inline Kernel::VoidPtr allocate(Args&&... args) + inline void* allocate(Args&&... args) { - return new KindClass(Kernel::forward(args)...); + return new KindClass(forward(args)...); } /// @brief free a class. /// @tparam KindClass the class type to allocate. template <typename KindClass> - inline Kernel::Void release(KindClass ptr) + inline void release(KindClass ptr) { if (!ptr) return; diff --git a/CRTKit/__mpcc_runtime.cxx b/CRTKit/__mpcc_runtime.cxx new file mode 100644 index 00000000..ba9bf8a7 --- /dev/null +++ b/CRTKit/__mpcc_runtime.cxx @@ -0,0 +1,10 @@ +/* -------------------------------------------
+
+ Copyright ZKA Technologies
+
+------------------------------------------- */
+
+#include <CRTKit/__mpcc_alloca.hxx>
+#include <CRTKit/__mpcc_defines.hxx>
+#include <CRTKit/__mpcc_malloc.hxx>
+#include <CRTKit/__mpcc_exception.hxx>
diff --git a/CRTKit/build.json b/CRTKit/build.json new file mode 100644 index 00000000..f9d69a57 --- /dev/null +++ b/CRTKit/build.json @@ -0,0 +1,10 @@ +{
+ "compiler_path": "x86_64-w64-mingw32-g++",
+ "compiler_std": "c++20",
+ "headers_path": ["../", "./"],
+ "sources_path": ["*.cxx"],
+ "output_name": "libCRT.dll",
+ "compiler_flags": ["-ffreestanding", "-shared", "-std=c17", "-std=c++20", "-fno-rtti", "-fno-exceptions", " -Wl,--subsystem=17"],
+ "cpp_macros": ["__CRT_AMD64__", "cCRTVersion=0x0100"]
+ }
+
\ No newline at end of file |
