diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2024-11-01 19:41:55 +0100 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2024-11-01 19:41:55 +0100 |
| commit | 9832d04842245987a1af284866628c5f9bb1fa1b (patch) | |
| tree | 68ce21ad31b164c15d841e85451540292b624348 /dev/LibC++ | |
| parent | 65fb4a1abc5ad8b0dd4f2f31199f53a748167f24 (diff) | |
IMP: Fixes and improvements to LibC++, add shell script to generate standard C+ headers.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/LibC++')
| -rw-r--r-- | dev/LibC++/base_exception.h | 6 | ||||
| -rw-r--r-- | dev/LibC++/base_math.h (renamed from dev/LibC++/math.h) | 4 | ||||
| -rw-r--r-- | dev/LibC++/defines.h | 34 | ||||
| -rw-r--r-- | dev/LibC++/make_cxx_headers.sh | 0 | ||||
| -rw-r--r-- | dev/LibC++/process_base.h (renamed from dev/LibC++/exit.h) | 8 | ||||
| -rw-r--r-- | dev/LibC++/utility.h | 34 |
6 files changed, 45 insertions, 41 deletions
diff --git a/dev/LibC++/base_exception.h b/dev/LibC++/base_exception.h index 9b34470..1e91e67 100644 --- a/dev/LibC++/base_exception.h +++ b/dev/LibC++/base_exception.h @@ -7,9 +7,9 @@ #pragma once #include <LibC++/defines.h> -#include <LibC++/exit.h> +#include <LibC++/process_base.h> -namespace std +namespace std::base_exception { inline void __throw_general(void) { @@ -27,4 +27,4 @@ namespace std __throw_general(); __builtin_unreachable(); // prevent from continuing. } -} // namespace std +} // namespace std::base_exception diff --git a/dev/LibC++/math.h b/dev/LibC++/base_math.h index 7a831da..bee116a 100644 --- a/dev/LibC++/math.h +++ b/dev/LibC++/base_math.h @@ -17,7 +17,7 @@ typedef double real_type; typedef float real_type; #endif -namespace std::math +namespace std::base_math { /// @brief Power function, with Repeat argument. template <size_t Exponent> @@ -59,4 +59,4 @@ namespace std::math real_type diff = (to - from); return from + (diff * stat); } -} // namespace std::math +} // namespace std::base_math diff --git a/dev/LibC++/defines.h b/dev/LibC++/defines.h index 687d401..5a3ed64 100644 --- a/dev/LibC++/defines.h +++ b/dev/LibC++/defines.h @@ -7,8 +7,10 @@ #ifndef __TOOLCHAINKIT_DEFINES_H__ #define __TOOLCHAINKIT_DEFINES_H__ +extern "C" { #include <stdint.h> #include <stddef.h> +} #ifndef __GNUC__ @@ -90,36 +92,4 @@ typedef union double_cast { #endif // ifndef __GNUC__ -/// Include these helpers as well. - -#ifdef __STD_CXX__ - -#include <LibC++/base_exception.h> -#include <LibC++/base_alloc.h> - -#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 /* __TOOLCHAINKIT_DEFINES_H__ */ diff --git a/dev/LibC++/make_cxx_headers.sh b/dev/LibC++/make_cxx_headers.sh new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/dev/LibC++/make_cxx_headers.sh diff --git a/dev/LibC++/exit.h b/dev/LibC++/process_base.h index fea1539..9d7c95c 100644 --- a/dev/LibC++/exit.h +++ b/dev/LibC++/process_base.h @@ -7,15 +7,15 @@ #pragma once /// @brief CRT exit, with exit code (!!! exits all threads. !!!) -/// @param code -/// @return +/// @param code the exit code. +/// @return the return > 0 for non successful. extern "C" int exit(int code); /// @brief Standard C++ namespace -namespace std +namespace std::process_base { inline int exit(int code) { exit(code); } -} // namespace std +} // namespace std::process_base diff --git a/dev/LibC++/utility.h b/dev/LibC++/utility.h new file mode 100644 index 0000000..7f80212 --- /dev/null +++ b/dev/LibC++/utility.h @@ -0,0 +1,34 @@ +/* ------------------------------------------- + \ + Copyright EL Mahrouss Logic. \ + \ +------------------------------------------- */ + +#ifndef LIBCXX_UTILITY_H +#define LIBCXX_UTILITY_H + +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 // LIBCXX_UTILITY_H |
