From 745656eb2d8b512b195d2db0be7ee73a82562b43 Mon Sep 17 00:00:00 2001 From: Nigel Date: Sat, 25 Feb 2023 20:04:34 +0100 Subject: [PATCH] Fixup C++ compiler path in makefile of CoreLib memcpy implementation added --- CoreLib/Makefile | 3 ++- CoreLib/Memory.cpp | 11 +++++++++++ CoreLib/Memory.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CoreLib/Makefile b/CoreLib/Makefile index a37ab45..74159a8 100644 --- a/CoreLib/Makefile +++ b/CoreLib/Makefile @@ -1,4 +1,4 @@ -CPP = ${HOME}/opt/cross/bin/i686-elf-g++ +CPP = /opt/cross/bin/i686-elf-g++ CFLAGS = -ffreestanding -Og -ggdb -Wall -Wextra BUILD_DIR = ../build/CoreLib @@ -12,6 +12,7 @@ all: $(OUTPUTFILE) cp *.h $(BUILD_DIR)/include/CoreLib $(OUTPUTFILE): $(OFILES) + pwd ar -rc $(OUTPUTFILE) $(OFILES) $(OBJ_FOLDER)/memory.o: Memory.cpp diff --git a/CoreLib/Memory.cpp b/CoreLib/Memory.cpp index 830a346..4559461 100644 --- a/CoreLib/Memory.cpp +++ b/CoreLib/Memory.cpp @@ -32,6 +32,17 @@ int memcmp( const void* ptr1, const void* ptr2, size_t num) } +void memcpy (void* dest, const void* src, size_t count ){ + for( int i = 0; i < count; i++){ + ((char *)dest)[i] = ((const char*)src)[i]; + } +} + + + + + + size_t strlen(const char* str) { size_t len = 0; while(str[len]){ diff --git a/CoreLib/Memory.h b/CoreLib/Memory.h index a4cc9d5..e0a1d67 100644 --- a/CoreLib/Memory.h +++ b/CoreLib/Memory.h @@ -7,6 +7,8 @@ void* memset (void* ptr, int value, size_t num); int memcmp( const void* ptr1, const void* ptr2, size_t num); +void memcpy (void* dest, const void* src, size_t count ); + size_t strlen(const char* str); int strncmp ( const char* str1, const char* str2, size_t num );