diff options
Diffstat (limited to 'dev/ZKAKit/src/CRuntimeLibrary.cc')
| -rw-r--r-- | dev/ZKAKit/src/CRuntimeLibrary.cc | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/dev/ZKAKit/src/CRuntimeLibrary.cc b/dev/ZKAKit/src/CRuntimeLibrary.cc new file mode 100644 index 00000000..efdc4b33 --- /dev/null +++ b/dev/ZKAKit/src/CRuntimeLibrary.cc @@ -0,0 +1,75 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#include <KernelKit/DebugOutput.h> + +#include <stdint.h> +#include <stddef.h> + +using namespace Kernel; + +/// @brief memset definition in C++. +/// @param dst destination pointer. +/// @param byte value to fill in. +/// @param len length of of src. +EXTERN_C VoidPtr memset(void* dst, int byte, long long unsigned int len) +{ + for (size_t i = 0UL; i < len; ++i) + { + ((int*)dst)[i] = byte; + } + + return dst; +} + +/// @brief memcpy definition in C++. +/// @param dst destination pointer. +/// @param src source pointer. +/// @param len length of of src. +EXTERN_C VoidPtr memcpy(void* dst, const void* src, long long unsigned int len) +{ + for (size_t i = 0UL; i < len; ++i) + { + ((int*)dst)[i] = ((int*)src)[i]; + } + + return dst; +} + +/// @brief strlen definition in C++. +EXTERN_C size_t strlen(const char* whatToCheck) +{ + if (!whatToCheck) + return 0; + + SizeT len = 0; + + while (whatToCheck[len] != 0) + { + ++len; + } + + return len; +} + +/// @brief strcmp definition in C++. +EXTERN_C int strcmp(const char* whatToCheck, const char* whatToCheckRight) +{ + if (!whatToCheck || *whatToCheck == 0) + return 0; + + SizeT len = 0; + + while (whatToCheck[len] == whatToCheckRight[len]) + { + if (whatToCheck[len] == 0) + return 0; + + ++len; + } + + return len; +} |
