diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-04 21:36:54 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-04 21:48:09 +0100 |
| commit | 6cda526bd4efcee31b1ea7405dc46d7985ba64e6 (patch) | |
| tree | f7d138fd5652cdc0e7a2c4918b36d754969d6cf5 /CompilerKit/Defines.hpp | |
| parent | 60271b79a91a06772241aed737426f5d097ca533 (diff) | |
masm: fix assembler bug where addr1, 0x0 (add r1, 0x0) doesn't error
out.
cc/ccplus: minor compiler changes, will get to them very soon...
refactor: rename C++Kit to CompilerKit.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'CompilerKit/Defines.hpp')
| -rw-r--r-- | CompilerKit/Defines.hpp | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/CompilerKit/Defines.hpp b/CompilerKit/Defines.hpp new file mode 100644 index 0000000..00c75f6 --- /dev/null +++ b/CompilerKit/Defines.hpp @@ -0,0 +1,135 @@ +/* + * ======================================================== + * + * C++Kit + * Copyright Western Company, all rights reserved. + * + * ======================================================== + */ + +#ifndef __CXXKIT_DEFINES_HPP__ +#define __CXXKIT_DEFINES_HPP__ + +#ifndef Yes +#define Yes true +#endif // ifndef Yes + +#ifndef No +#define No false +#endif // ifndef No + +#include <stdint.h> + +#define SizeType size_t + +#define VoidPtr void* +#define voidPtr VoidPtr + +#define UIntPtr uintptr_t + +#define Int64 int64_t +#define UInt64 uint64_t + +#define Int32 int32_t +#define UInt32 uint32_t + +#define Bool bool + +#define Int16 int16_t +#define UInt16 uint16_t + +#define Int8 int8_t +#define UInt8 uint8_t + +#define CharType char +#define Boolean bool + +#include <new> +#include <cstring> +#include <cassert> + +#define nullPtr std::nullptr_t + +#define MUST_PASS(E) assert(E) + +#ifndef __FORCE_STRLEN +# define __FORCE_STRLEN 1 + +# define string_length(len) strlen(len) +#endif + +#ifndef __FORCE_MEMCPY +# define __FORCE_MEMCPY 1 + +# define rt_copy_memory(dst, src, len) memcpy(dst, src, len) +#endif + +#define CXXKIT_COPY_DELETE(KLASS) \ + KLASS &operator=(const KLASS &) = delete; \ + KLASS(const KLASS &) = delete; + + +#define CXXKIT_COPY_DEFAULT(KLASS) \ + KLASS &operator=(const KLASS &) = default; \ + KLASS(const KLASS &) = default; + + +#define CXXKIT_MOVE_DELETE(KLASS) \ + KLASS &operator=(KLASS &&) = delete; \ + KLASS(KLASS &&) = delete; + + +#define CXXKIT_MOVE_DEFAULT(KLASS) \ + KLASS &operator=(KLASS &&) = default; \ + KLASS(KLASS &&) = default; + + + +#include <ctime> +#include <string> + +namespace CompilerKit +{ + inline constexpr int BASE_YEAR = 1900; + + inline std::string current_date() + { + auto time_data = time(nullptr); + auto time_struct = gmtime(&time_data); + + std::string fmt = std::to_string(BASE_YEAR + time_struct->tm_year); + fmt += "-"; + fmt += std::to_string(time_struct->tm_mon + 1); + fmt += "-"; + fmt += std::to_string(time_struct->tm_mday); + + return fmt; + } + + inline bool to_str(CharType *str, Int32 limit, Int32 base) + { + if (limit == 0) + return false; + + Int32 copy_limit = limit; + Int32 cnt = 0; + Int32 ret = base; + + while (limit != 1) { + ret = ret % 10; + str[cnt] = ret; + + ++cnt; + --limit; + --ret; + } + + str[copy_limit] = '\0'; + return true; + } +} + +#define kObjectFileExt ".o" +#define kAsmFileExt64x0 ".64x" + +#endif /* ifndef __CXXKIT_DEFINES_HPP__ */ |
