From 3152a4efed2b249b82351049d1bb452b920d0420 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 21:25:28 +0100 Subject: [PATCH 01/17] wip --- .github/workflows/build-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 2d897c07..819679de 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, ubuntu-22.04] + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] arch: [amd64, i386, arm64, armhf] cpurev: [legacy, default, modern] steps: @@ -39,7 +39,7 @@ jobs: # Cross-Compile Support - name: Cross-Compile Support - uses: cyberjunk/gha-ubuntu-cross@v4 + uses: cyberjunk/gha-ubuntu-cross@v5 if: matrix.arch != 'amd64' with: arch: ${{ matrix.arch }} From 13ae9c700da3d75483d570f5c0d1b367dd88e3a9 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 21:35:18 +0100 Subject: [PATCH 02/17] wip --- dist/ubuntu-24.04/.gitignore | 3 +++ .../CppCore.Example.Client.Resources.control | 9 +++++++++ dist/ubuntu-24.04/CppCore.Example.Client.control | 10 ++++++++++ dist/ubuntu-24.04/CppCore.Example.Client.desktop | 10 ++++++++++ .../CppCore.Example.Server.Resources.control | 9 +++++++++ dist/ubuntu-24.04/CppCore.Example.Server.control | 10 ++++++++++ dist/ubuntu-24.04/CppCore.Example.Server.desktop | 10 ++++++++++ .../CppCore.Example.UI.Resources.control | 9 +++++++++ dist/ubuntu-24.04/CppCore.Example.UI.control | 15 +++++++++++++++ dist/ubuntu-24.04/CppCore.Example.UI.desktop | 10 ++++++++++ dist/ubuntu-24.04/CppCore.Interface.C.control | 10 ++++++++++ 11 files changed, 105 insertions(+) create mode 100644 dist/ubuntu-24.04/.gitignore create mode 100644 dist/ubuntu-24.04/CppCore.Example.Client.Resources.control create mode 100644 dist/ubuntu-24.04/CppCore.Example.Client.control create mode 100644 dist/ubuntu-24.04/CppCore.Example.Client.desktop create mode 100644 dist/ubuntu-24.04/CppCore.Example.Server.Resources.control create mode 100644 dist/ubuntu-24.04/CppCore.Example.Server.control create mode 100644 dist/ubuntu-24.04/CppCore.Example.Server.desktop create mode 100644 dist/ubuntu-24.04/CppCore.Example.UI.Resources.control create mode 100644 dist/ubuntu-24.04/CppCore.Example.UI.control create mode 100644 dist/ubuntu-24.04/CppCore.Example.UI.desktop create mode 100644 dist/ubuntu-24.04/CppCore.Interface.C.control diff --git a/dist/ubuntu-24.04/.gitignore b/dist/ubuntu-24.04/.gitignore new file mode 100644 index 00000000..ce456278 --- /dev/null +++ b/dist/ubuntu-24.04/.gitignore @@ -0,0 +1,3 @@ +**/ +*.deb +*.whl diff --git a/dist/ubuntu-24.04/CppCore.Example.Client.Resources.control b/dist/ubuntu-24.04/CppCore.Example.Client.Resources.control new file mode 100644 index 00000000..d6a8eb25 --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.Client.Resources.control @@ -0,0 +1,9 @@ +Package: CppCore.Example.Client.Resources +Version: {VERSION}-1 +Section: base +Priority: optional +Architecture: all +Maintainer: Clint Banzhaf +Description: CppCore.Example.Client Resources + Resources of CppCore.Example.Client. + diff --git a/dist/ubuntu-24.04/CppCore.Example.Client.control b/dist/ubuntu-24.04/CppCore.Example.Client.control new file mode 100644 index 00000000..188ca582 --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.Client.control @@ -0,0 +1,10 @@ +Package: CppCore.Example.Client +Version: {VERSION}-1 +Section: base +Priority: optional +Architecture: {ARCH} +Depends: libc6:{ARCH} (>= 2.39) +Maintainer: Clint Banzhaf +Description: CppCore Example Client + Just an example to demonstrate Client code of CppCore. + diff --git a/dist/ubuntu-24.04/CppCore.Example.Client.desktop b/dist/ubuntu-24.04/CppCore.Example.Client.desktop new file mode 100644 index 00000000..17f67245 --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.Client.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name={DISPLAYNAME} +Comment=Example Client of CppCore +Exec=/usr/bin/CppCore.Example.Client +Icon=/usr/share/pixmaps/CppCore.Example.Client.png +Terminal=true +Type=Application +Categories=Development; +StartupNotify=true +NoDisplay=false diff --git a/dist/ubuntu-24.04/CppCore.Example.Server.Resources.control b/dist/ubuntu-24.04/CppCore.Example.Server.Resources.control new file mode 100644 index 00000000..af8a8aa2 --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.Server.Resources.control @@ -0,0 +1,9 @@ +Package: CppCore.Example.Server.Resources +Version: {VERSION}-1 +Section: base +Priority: optional +Architecture: all +Maintainer: Clint Banzhaf +Description: CppCore.Example.Server Resources + Resources of CppCore.Example.Server. + diff --git a/dist/ubuntu-24.04/CppCore.Example.Server.control b/dist/ubuntu-24.04/CppCore.Example.Server.control new file mode 100644 index 00000000..96c5227b --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.Server.control @@ -0,0 +1,10 @@ +Package: CppCore.Example.Server +Version: {VERSION}-1 +Section: base +Priority: optional +Architecture: {ARCH} +Depends: libc6:{ARCH} (>= 2.39) +Maintainer: Clint Banzhaf +Description: CppCore Example Server + Just an example to demonstrate server code of CppCore. + diff --git a/dist/ubuntu-24.04/CppCore.Example.Server.desktop b/dist/ubuntu-24.04/CppCore.Example.Server.desktop new file mode 100644 index 00000000..04837a17 --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.Server.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name={DISPLAYNAME} +Comment=Example Server of CppCore +Exec=/usr/bin/CppCore.Example.Server +Icon=/usr/share/pixmaps/CppCore.Example.Server.png +Terminal=true +Type=Application +Categories=Development; +StartupNotify=true +NoDisplay=false diff --git a/dist/ubuntu-24.04/CppCore.Example.UI.Resources.control b/dist/ubuntu-24.04/CppCore.Example.UI.Resources.control new file mode 100644 index 00000000..6d03625e --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.UI.Resources.control @@ -0,0 +1,9 @@ +Package: CppCore.Example.UI.Resources +Version: {VERSION}-1 +Section: base +Priority: optional +Architecture: all +Maintainer: Clint Banzhaf +Description: CppCore.Example.UI Resources + Resources of CppCore.Example.UI. + diff --git a/dist/ubuntu-24.04/CppCore.Example.UI.control b/dist/ubuntu-24.04/CppCore.Example.UI.control new file mode 100644 index 00000000..4271ac85 --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.UI.control @@ -0,0 +1,15 @@ +Package: CppCore.Example.UI +Version: {VERSION}-1 +Section: base +Priority: optional +Architecture: {ARCH} +Depends: libc6:{ARCH} (>= 2.39), + libbsd0:{ARCH} (>= 0.12.1), + libxau6:{ARCH} (>= 1.0.9), + libxcb1:{ARCH} (>= 1.15), + libxdmcp6:{ARCH} (>= 1.1.3), + libx11-6:{ARCH} (>= 1.8.7) +Maintainer: Clint Banzhaf +Description: CppCore Example UI + Just an example to demonstrate UI code of CppCore. + diff --git a/dist/ubuntu-24.04/CppCore.Example.UI.desktop b/dist/ubuntu-24.04/CppCore.Example.UI.desktop new file mode 100644 index 00000000..10e456d6 --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Example.UI.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name={DISPLAYNAME} +Comment=Example UI of CppCore +Exec=/usr/bin/CppCore.Example.UI +Icon=/usr/share/pixmaps/CppCore.Example.UI.png +Terminal=true +Type=Application +Categories=Development; +StartupNotify=true +NoDisplay=false diff --git a/dist/ubuntu-24.04/CppCore.Interface.C.control b/dist/ubuntu-24.04/CppCore.Interface.C.control new file mode 100644 index 00000000..f3412efe --- /dev/null +++ b/dist/ubuntu-24.04/CppCore.Interface.C.control @@ -0,0 +1,10 @@ +Package: CppCore.Interface.C +Version: {VERSION}-1 +Section: base +Priority: optional +Architecture: {ARCH} +Depends: libc6:{ARCH} (>= 2.39) +Maintainer: Clint Banzhaf +Description: CppCore Interface for C + Provides access to CppCore from C + From bd82341d4260d00a25c9efbebeb6f5cc8d78b428 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 22:06:26 +0100 Subject: [PATCH 03/17] wip --- build/make/CppCore.Test.mk | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build/make/CppCore.Test.mk b/build/make/CppCore.Test.mk index 3dde5299..e1429fb7 100644 --- a/build/make/CppCore.Test.mk +++ b/build/make/CppCore.Test.mk @@ -26,6 +26,10 @@ VERSIONMACROMAJOR = CPPCORE_VERSION_MAJOR VERSIONMACROMINOR = CPPCORE_VERSION_MINOR VERSIONMACROPATCH = CPPCORE_VERSION_PATCH +DEC64MB := 67108864 +HEX8MB := 0x00800000 +DEC8MB := 8388608 + ################################################################################################ # CPU Specific @@ -65,7 +69,9 @@ OUTDIST := $(DISTDIR)/$(NAME).app/Contents/MacOS/$(NAME)$(EXTBIN) DEFINES := $(DEFINES) CXXFLAGS := $(CXXFLAGS) -fdeclspec -ObjC++ CFLAGS := $(CFLAGS) -LINKFLAGS := $(LINKFLAGS) -Wl,-object_path_lto,$(OBJDIR)/lto.o +LINKFLAGS := $(LINKFLAGS) \ + -Wl,-object_path_lto,$(OBJDIR)/lto.o \ + -Wl,-stack_size -Wl,$(HEX8MB) LINKLIBS := $(LINKLIBS) -framework AppKit RESO := $(RESO) endif @@ -75,7 +81,7 @@ OUTDIST := $(DISTDIR)/$(NAME)-$(TARGET_ARCH)/usr/bin/$(NAME)$(EXTBIN) DEFINES := $(DEFINES) CXXFLAGS := $(CXXFLAGS) CFLAGS := $(CFLAGS) -LINKFLAGS := $(LINKFLAGS) +LINKFLAGS := $(LINKFLAGS) -Wl,-z,stack-size=$(DEC8MB) LINKLIBS := $(LINKLIBS) -lpthread RESO := $(RESO) endif @@ -105,8 +111,6 @@ OUTDIST := $(DISTDIR)/$(NAME)$(EXTBIN) DEFINES := $(DEFINES) CXXFLAGS := $(CXXFLAGS) CFLAGS := $(CFLAGS) -DEC64MB := 67108864 -HEX8MB := 0x00800000 LINKFLAGS := $(LINKFLAGS) \ -Wl,-z,stack-size=$(HEX8MB) \ -Wl,--initial-heap=$(DEC64MB) \ From c95d810c1f2a89c1b45535bb2c3ce091d4713a28 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 22:21:55 +0100 Subject: [PATCH 04/17] test --- src/CppCore.Test/Test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CppCore.Test/Test.cpp b/src/CppCore.Test/Test.cpp index f5041c85..bd273c54 100644 --- a/src/CppCore.Test/Test.cpp +++ b/src/CppCore.Test/Test.cpp @@ -425,7 +425,7 @@ int main() TEST(CppCore::Test::Memory::copy256, "copy256: ", std::endl); TEST(CppCore::Test::Memory::copy512, "copy512: ", std::endl); TEST(CppCore::Test::Memory::copy, "copy: ", std::endl); - TEST(CppCore::Test::Memory::copybackwards, "copybackwards: ", std::endl); + //TEST(CppCore::Test::Memory::copybackwards, "copybackwards: ", std::endl); TEST(CppCore::Test::Memory::streamcopy128, "streamcopy128: ", std::endl); TEST(CppCore::Test::Memory::streamcopy128x1, "streamcopy128x1: ", std::endl); TEST(CppCore::Test::Memory::streamcopy128x2, "streamcopy128x2: ", std::endl); From f7c343e0c78024a65d84ec0e3e296be16024becb Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 22:23:57 +0100 Subject: [PATCH 05/17] test --- .github/workflows/build-linux.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 819679de..9ebe49e0 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -55,6 +55,11 @@ jobs: if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' run: sudo apt-get install qemu-user qemu-user-static + # QEMU Version (ARM64/ARMHF) + - name: QEMU Version (ARM64/ARMHF) + if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' + run: kvm -version + # Set Environment Vars - name: Set Environment Vars run: | From d148ef53ffb0e39b60cb75a9bb43a5181ace99c3 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 22:27:56 +0100 Subject: [PATCH 06/17] wip --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 9ebe49e0..aa7a1dd9 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -58,7 +58,7 @@ jobs: # QEMU Version (ARM64/ARMHF) - name: QEMU Version (ARM64/ARMHF) if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' - run: kvm -version + run: /usr/bin/qemu-system-x86_64 --version # Set Environment Vars - name: Set Environment Vars From 0880358fbe3d193a3269ec8cb184cdd4dc2acfba Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 22:32:08 +0100 Subject: [PATCH 07/17] wip --- .github/workflows/build-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index aa7a1dd9..e3bb9c4e 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -58,7 +58,7 @@ jobs: # QEMU Version (ARM64/ARMHF) - name: QEMU Version (ARM64/ARMHF) if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' - run: /usr/bin/qemu-system-x86_64 --version + run: /usr/bin/qemu-amd64-static --version # Set Environment Vars - name: Set Environment Vars From 67f80157473ffb0c414ed877934133618493d99b Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 22:34:18 +0100 Subject: [PATCH 08/17] wip --- .github/workflows/build-linux.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index e3bb9c4e..3916a80b 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -56,9 +56,9 @@ jobs: run: sudo apt-get install qemu-user qemu-user-static # QEMU Version (ARM64/ARMHF) - - name: QEMU Version (ARM64/ARMHF) - if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' - run: /usr/bin/qemu-amd64-static --version + #- name: QEMU Version (ARM64/ARMHF) + # if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' + # run: /usr/bin/qemu-amd64-static --version # Set Environment Vars - name: Set Environment Vars From 1e26cc09ef586a546d9b21712b0fb40e441f0a95 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 22:58:08 +0100 Subject: [PATCH 09/17] test --- src/CppCore.Test/Test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CppCore.Test/Test.cpp b/src/CppCore.Test/Test.cpp index bd273c54..5f5f7c3d 100644 --- a/src/CppCore.Test/Test.cpp +++ b/src/CppCore.Test/Test.cpp @@ -572,7 +572,7 @@ int main() std::cout << "-------------------------------" << std::endl; std::cout << " CppCore::Hash::MD5" << std::endl; std::cout << "-------------------------------" << std::endl; - TEST(CppCore::Test::Hash::MD5::test1, "test1: ", " "); + //TEST(CppCore::Test::Hash::MD5::test1, "test1: ", " "); TEST(CppCore::Test::Hash::MD5::test2, "test2: ", std::endl); TEST(CppCore::Test::Hash::MD5::test3, "test3: ", " "); TEST(CppCore::Test::Hash::MD5::test4, "test4: ", std::endl); From 56299ce664eeacb20afae844b24b81e30013723c Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Mon, 11 Nov 2024 23:09:52 +0100 Subject: [PATCH 10/17] wip --- build/make/platforms/linux-all-linux-arm.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/make/platforms/linux-all-linux-arm.mk b/build/make/platforms/linux-all-linux-arm.mk index 0150f4f3..3574219c 100644 --- a/build/make/platforms/linux-all-linux-arm.mk +++ b/build/make/platforms/linux-all-linux-arm.mk @@ -10,7 +10,7 @@ TARGET = arm-linux-gnueabihf DEFINES = INCLUDES = -I/usr/$(TARGET)/include CXX = clang++ -CXXFLAGS = -target $(TARGET) -fPIC -static -fno-strict-aliasing +CXXFLAGS = -target $(TARGET) -fPIC -static -fno-strict-aliasing -mstack-alignment=16 -mstackrealign CC = clang CFLAGS = -target $(TARGET) -fPIC -static -fno-strict-aliasing AR = llvm-ar @@ -25,6 +25,9 @@ DEBARCH = armhf LSBREL = $(shell lsb_release -r -s) DISTDIR = ../../dist/ubuntu-$(LSBREL) +#-mstack-alignment=n // sets the alignment to n bytes +#-mstackrealign // forces the previous set alignment + # CPU Flags ifeq ($(TARGET_CPUREV),legacy) CPUFLAGS = -march=armv7-a -mfloat-abi=hard -mfpu=neon-fp16 From 41a22591e7e35493b196872cb69a7e6bf5dc9cff Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Tue, 12 Nov 2024 17:39:16 +0100 Subject: [PATCH 11/17] fix alignment issues in Memory.h for old 32bit --- include/CppCore/Memory.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/include/CppCore/Memory.h b/include/CppCore/Memory.h index d73a94b8..a98de540 100644 --- a/include/CppCore/Memory.h +++ b/include/CppCore/Memory.h @@ -52,6 +52,18 @@ #define CPPCORE_MEMORY_PROCESS_64X8( len, op64, op32, op16, op8) \ CPPCORE_MEMORY_PROCESS_512( len, op64;op64;op64;op64;op64;op64;op64;op64;, op64;op64;op64;op64;, op64;op64;, op64, op32, op16, op8) +// decreases len in 64 byte steps executing sixteen op32 each time +// then handles the 0-63 remaining bytes using op32 to op8 +#define CPPCORE_MEMORY_PROCESS_32X16( len, op32, op16, op8) \ + CPPCORE_MEMORY_PROCESS_512( len, \ + op32;op32;op32;op32;op32;op32;op32;op32;op32;op32;op32;op32;op32;op32;op32;op32;, \ + op32;op32;op32;op32;op32;op32;op32;op32;, \ + op32;op32;op32;op32;, \ + op32;op32, \ + op32, \ + op16, \ + op8) + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// namespace CppCore @@ -1972,12 +1984,17 @@ namespace CppCore *((uint32_t*)memd) = *((uint32_t*)mems); memd += 4U; mems += 4U;, *((uint16_t*)memd) = *((uint16_t*)mems); memd += 2U; mems += 2U;, *((uint8_t*) memd) = *((uint8_t*) mems); memd += 1U; mems += 1U;); - #else + #elif defined(CPPCORE_CPU_64BIT) CPPCORE_MEMORY_PROCESS_64X8(len, *((uint64_t*)memd) = *((uint64_t*)mems); memd += 8U; mems += 8U;, *((uint32_t*)memd) = *((uint32_t*)mems); memd += 4U; mems += 4U;, *((uint16_t*)memd) = *((uint16_t*)mems); memd += 2U; mems += 2U;, *((uint8_t*) memd) = *((uint8_t*) mems); memd += 1U; mems += 1U;); + #else + CPPCORE_MEMORY_PROCESS_32X16(len, + *((uint32_t*)memd) = *((uint32_t*)mems); memd += 4U; mems += 4U;, + *((uint16_t*)memd) = *((uint16_t*)mems); memd += 2U; mems += 2U;, + *((uint8_t*) memd) = *((uint8_t*) mems); memd += 1U; mems += 1U;); #endif } @@ -2012,12 +2029,17 @@ namespace CppCore memd -= 4U; mems -= 4U; *((uint32_t*)memd) = *((uint32_t*)mems);, memd -= 2U; mems -= 2U; *((uint16_t*)memd) = *((uint16_t*)mems);, memd -= 1U; mems -= 1U; *((uint8_t*) memd) = *((uint8_t*) mems);) - #else + #elif defined(CPPCORE_CPU_64BIT) CPPCORE_MEMORY_PROCESS_64X8(len, memd -= 8U; mems -= 8U; *((uint64_t*)memd) = *((uint64_t*)mems);, memd -= 4U; mems -= 4U; *((uint32_t*)memd) = *((uint32_t*)mems);, memd -= 2U; mems -= 2U; *((uint16_t*)memd) = *((uint16_t*)mems);, memd -= 1U; mems -= 1U; *((uint8_t*) memd) = *((uint8_t*) mems);) + #else + CPPCORE_MEMORY_PROCESS_32X16(len, + memd -= 4U; mems -= 4U; *((uint32_t*)memd) = *((uint32_t*)mems);, + memd -= 2U; mems -= 2U; *((uint16_t*)memd) = *((uint16_t*)mems);, + memd -= 1U; mems -= 1U; *((uint8_t*) memd) = *((uint8_t*) mems);) #endif } From 39d67d772a521249f2d8889acf69c4733b12fc38 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Tue, 12 Nov 2024 19:07:46 +0100 Subject: [PATCH 12/17] fixes and improvements in AES.h --- include/CppCore/Crypto/AES.h | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/include/CppCore/Crypto/AES.h b/include/CppCore/Crypto/AES.h index 95cf61fb..d48fe6b0 100644 --- a/include/CppCore/Crypto/AES.h +++ b/include/CppCore/Crypto/AES.h @@ -35,10 +35,21 @@ namespace CppCore uint8_t* cenc = (uint8_t*)enc; if (cin + 8U <= cend) { + #if defined(CPPCORE_CPU_64BIT) *(uint64_t*)cout = *(uint64_t*)cenc ^ *(uint64_t*)cin; cin += 8U; cout += 8U; cenc += 8U; + #else + *(uint32_t*)cout = *(uint32_t*)cenc ^ *(uint32_t*)cin; + cin += 4U; + cout += 4U; + cenc += 4U; + *(uint32_t*)cout = *(uint32_t*)cenc ^ *(uint32_t*)cin; + cin += 4U; + cout += 4U; + cenc += 4U; + #endif } if (cin + 4U <= cend) { @@ -319,7 +330,7 @@ namespace CppCore Block t; // initial round key addition on input - out = in ^ this->ekb[0]; + CppCore::xor_(in, this->ekb[0], out); // n rounds CPPCORE_UNROLL @@ -347,7 +358,7 @@ namespace CppCore t.u32[3] ^= CppCore::rotl32(te[CppCore::getbits32(out.u32[2], 24, 8)], 24); // round key addition - out = t ^ this->ekb[i]; + CppCore::xor_(t,this->ekb[i],out); } // last round @@ -372,7 +383,7 @@ namespace CppCore t.u32[3] |= sbox[CppCore::getbits32(out.u32[2], 24, 8)] << 24; // last round key addition - out = t ^ this->ekb[N]; + CppCore::xor_(t, this->ekb[N], out); } /// @@ -383,7 +394,7 @@ namespace CppCore Block t; // initial round key addition on input - out = in ^ this->dkb[N]; + CppCore::xor_(in, this->dkb[N], out); // n rounds CPPCORE_UNROLL @@ -411,7 +422,7 @@ namespace CppCore t.u32[3] ^= CppCore::rotl32(td[CppCore::getbits32(out.u32[0], 24, 8)], 24); // round key addition - out = t ^ this->dkb[i]; + CppCore::xor_(t, this->dkb[i], out); } // last round @@ -436,7 +447,7 @@ namespace CppCore t.u32[3] |= isbox[CppCore::getbits32(out.u32[0], 24, 8)] << 24; // last round key addition - out = t ^ this->dkb[0]; + CppCore::xor_(t, this->dkb[0], out); } /// @@ -444,9 +455,9 @@ namespace CppCore /// INLINE void encrypt(const Block& in, Block& out, Block& iv) { - out = in ^ iv; + CppCore::xor_(in, iv, out); encrypt(out, out); - iv = out; + CppCore::clone(iv, out); } /// @@ -455,8 +466,8 @@ namespace CppCore INLINE void decrypt(const Block& in, Block& out, Block& iv) { decrypt(in, out); - out = out ^ iv; - iv = in; + CppCore::xor_(out, iv, out); + CppCore::clone(iv, in); } /////////////////////////////////////////////////////////////// @@ -549,7 +560,9 @@ namespace CppCore if (len >= 16U) { // xor encrypted iv with input - *bout++ = enc ^ *bin++; + CppCore::xor_(enc, *bin, *bout); + bin++; + bout++; len -= 16U; } else From 44dda0cfb1c11f93197ea33b7cc3b0803cfc76a2 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Tue, 12 Nov 2024 20:27:13 +0100 Subject: [PATCH 13/17] update --- include/CppCore/Block.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/CppCore/Block.h b/include/CppCore/Block.h index 514f11f9..170a6399 100644 --- a/include/CppCore/Block.h +++ b/include/CppCore/Block.h @@ -71,12 +71,6 @@ namespace CppCore } public: - INLINE T operator ^ (const T& v) const - { - T r; - CppCore::xor_(v, *(T*)this, r); - return r; - } INLINE void operator ^= (const T& v) { CppCore::xor_(v, *(T*)this, *(T*)this); From 2815efe0058b1d3c093cb026f3d599422bfdb5a3 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Wed, 13 Nov 2024 19:42:33 +0100 Subject: [PATCH 14/17] update Encoding.h --- include/CppCore/Encoding.h | 80 ++++++-------------------------------- 1 file changed, 12 insertions(+), 68 deletions(-) diff --git a/include/CppCore/Encoding.h b/include/CppCore/Encoding.h index 8c0f93d9..0f5c13f3 100644 --- a/include/CppCore/Encoding.h +++ b/include/CppCore/Encoding.h @@ -324,7 +324,7 @@ namespace CppCore /// INLINE static uint8_t valueofhexchar(const uint8_t c) { - static const uint8_t table[] = + CPPCORE_ALIGN64 static constexpr uint8_t table[] = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // ........ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // ........ @@ -412,7 +412,7 @@ namespace CppCore /// INLINE static uint16_t bytetohexint16(const uint8_t byte) { - static const uint16_t table[] = + CPPCORE_ALIGN64 static constexpr uint16_t table[] = { 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730, 0x3830, 0x3930, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530, 0x4630, @@ -724,85 +724,29 @@ namespace CppCore /// Creates hex string for memory of certain length. /// Requires len*2 (or len*2+1 if writeterm=true) free bytes in parameter s. /// - INLINE static void tostring(const void* m, const size_t len, char* s, const bool bigendian = true, const bool writeterm = true) + INLINE static void tostring(const void* m, size_t len, char* s, const bool bigendian = true, const bool writeterm = true) { - const char* mem = (const char*)m; - uint32_t* p = (uint32_t*)s; + const uint8_t* mem = (const uint8_t*)m; + uint16_t* p16 = (uint16_t*)s; if (bigendian) { - const char* end = mem + len; - #if defined(CPPCORE_CPU_64BIT) - while (mem + 8U <= end) - { - const uint64_t t = *((uint64_t*)mem); - *p++ = Util::valuetohexint32(t, 0ULL, 8ULL); - *p++ = Util::valuetohexint32(t, 16ULL, 24ULL); - *p++ = Util::valuetohexint32(t, 32ULL, 40ULL); - *p++ = Util::valuetohexint32(t, 48ULL, 56ULL); - mem += 8U; - } - if (mem + 4U <= end) - #else - while (mem + 4U <= end) - #endif - { - const uint32_t t = *((uint32_t*)mem); - *p++ = Util::valuetohexint32(t, 0U, 8U); - *p++ = Util::valuetohexint32(t, 16U, 24U); - mem += 4U; - } - if (mem + 2U <= end) - { - const uint16_t t = *((uint16_t*)mem); - *p++ = Util::valuetohexint32((uint32_t)t, 0U, 8U); - mem += 2U; - } - if (mem + 1U <= end) + while(len) { - uint16_t* pt = (uint16_t*)p; - *pt++ = Util::bytetohexint16(*mem); - p = (uint32_t*)pt; + *p16++ = Util::bytetohexint16(*mem++); + len--; } } else { - const char* end = mem; mem += len; - #if defined(CPPCORE_CPU_64BIT) - while (mem - 8U >= end) + while(len) { - mem -= 8U; - const uint64_t t = *((uint64_t*)mem); - *p++ = Util::valuetohexint32(t, 56ULL, 48ULL); - *p++ = Util::valuetohexint32(t, 40ULL, 32ULL); - *p++ = Util::valuetohexint32(t, 24ULL, 16ULL); - *p++ = Util::valuetohexint32(t, 8ULL, 0ULL); - } - if (mem - 4U >= end) - #else - while (mem - 4U >= end) - #endif - { - mem -= 4U; - const uint32_t t = *((uint32_t*)mem); - *p++ = Util::valuetohexint32(t, 24U, 16U); - *p++ = Util::valuetohexint32(t, 8U, 0U); - } - if (mem - 2U >= end) - { - mem -= 2U; - const uint16_t t = *((uint16_t*)mem); - *p++ = Util::valuetohexint32((uint32_t)t, 8U, 0U); - } - if (mem - 1U >= end) - { - uint16_t* pt = (uint16_t*)p; - *pt++ = Util::bytetohexint16(*(mem-1U)); - p = (uint32_t*)pt; + *p16++ = Util::bytetohexint16(*--mem); + len--; } } if (writeterm) - *((char*)p) = (char)0x00; + *((uint8_t*)p16) = (uint8_t)0x00; } /// From eb9296006c7881697013dcd1a27d4f1a73797b0e Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Wed, 13 Nov 2024 19:42:52 +0100 Subject: [PATCH 15/17] update Test.cpp --- src/CppCore.Test/Test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CppCore.Test/Test.cpp b/src/CppCore.Test/Test.cpp index 5f5f7c3d..4ec3dac8 100644 --- a/src/CppCore.Test/Test.cpp +++ b/src/CppCore.Test/Test.cpp @@ -425,7 +425,7 @@ int main() TEST(CppCore::Test::Memory::copy256, "copy256: ", std::endl); TEST(CppCore::Test::Memory::copy512, "copy512: ", std::endl); TEST(CppCore::Test::Memory::copy, "copy: ", std::endl); - //TEST(CppCore::Test::Memory::copybackwards, "copybackwards: ", std::endl); + TEST(CppCore::Test::Memory::copybackwards, "copybackwards: ", std::endl); TEST(CppCore::Test::Memory::streamcopy128, "streamcopy128: ", std::endl); TEST(CppCore::Test::Memory::streamcopy128x1, "streamcopy128x1: ", std::endl); TEST(CppCore::Test::Memory::streamcopy128x2, "streamcopy128x2: ", std::endl); @@ -572,7 +572,7 @@ int main() std::cout << "-------------------------------" << std::endl; std::cout << " CppCore::Hash::MD5" << std::endl; std::cout << "-------------------------------" << std::endl; - //TEST(CppCore::Test::Hash::MD5::test1, "test1: ", " "); + TEST(CppCore::Test::Hash::MD5::test1, "test1: ", " "); TEST(CppCore::Test::Hash::MD5::test2, "test2: ", std::endl); TEST(CppCore::Test::Hash::MD5::test3, "test3: ", " "); TEST(CppCore::Test::Hash::MD5::test4, "test4: ", std::endl); @@ -600,13 +600,13 @@ int main() TEST(CppCore::Test::Crypto::DH::test1, "test1dh256: ", std::endl); TEST(CppCore::Test::Crypto::DH::test1, "test1dh512: ", std::endl); TEST(CppCore::Test::Crypto::DH::test1, "test1dh1024: ", std::endl); - TEST(CppCore::Test::Crypto::DH::test1, "test1dh2048: ", std::endl); + //TEST(CppCore::Test::Crypto::DH::test1, "test1dh2048: ", std::endl); //TEST(CppCore::Test::Crypto::DH::test1, "test1dh4096: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh128: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh256: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh512: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh1024: ", std::endl); - TEST(CppCore::Test::Crypto::DH::test2, "test2dh2048: ", std::endl); + //TEST(CppCore::Test::Crypto::DH::test2, "test2dh2048: ", std::endl); //TEST(CppCore::Test::Crypto::DH::test2, "test2dh4096: ", std::endl); std::cout << "-------------------------------" << std::endl; From 5302008965a21ff52bf6bbce04bc2ac8af02f57f Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Fri, 15 Nov 2024 17:04:34 +0100 Subject: [PATCH 16/17] cleanup --- .github/workflows/build-linux.yml | 5 ----- src/CppCore.Test/Test.cpp | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 3916a80b..819679de 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -55,11 +55,6 @@ jobs: if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' run: sudo apt-get install qemu-user qemu-user-static - # QEMU Version (ARM64/ARMHF) - #- name: QEMU Version (ARM64/ARMHF) - # if: matrix.arch == 'arm64' || matrix.arch == 'armhf' || matrix.arch == 'armel' - # run: /usr/bin/qemu-amd64-static --version - # Set Environment Vars - name: Set Environment Vars run: | diff --git a/src/CppCore.Test/Test.cpp b/src/CppCore.Test/Test.cpp index 4ec3dac8..f5041c85 100644 --- a/src/CppCore.Test/Test.cpp +++ b/src/CppCore.Test/Test.cpp @@ -600,13 +600,13 @@ int main() TEST(CppCore::Test::Crypto::DH::test1, "test1dh256: ", std::endl); TEST(CppCore::Test::Crypto::DH::test1, "test1dh512: ", std::endl); TEST(CppCore::Test::Crypto::DH::test1, "test1dh1024: ", std::endl); - //TEST(CppCore::Test::Crypto::DH::test1, "test1dh2048: ", std::endl); + TEST(CppCore::Test::Crypto::DH::test1, "test1dh2048: ", std::endl); //TEST(CppCore::Test::Crypto::DH::test1, "test1dh4096: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh128: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh256: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh512: ", std::endl); TEST(CppCore::Test::Crypto::DH::test2, "test2dh1024: ", std::endl); - //TEST(CppCore::Test::Crypto::DH::test2, "test2dh2048: ", std::endl); + TEST(CppCore::Test::Crypto::DH::test2, "test2dh2048: ", std::endl); //TEST(CppCore::Test::Crypto::DH::test2, "test2dh4096: ", std::endl); std::cout << "-------------------------------" << std::endl; From 9d48cdfc4d73fdd50f0becf993a96edf8212f590 Mon Sep 17 00:00:00 2001 From: Clint Banzhaf Date: Fri, 15 Nov 2024 17:07:29 +0100 Subject: [PATCH 17/17] cleanup --- build/make/platforms/linux-all-linux-arm.mk | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build/make/platforms/linux-all-linux-arm.mk b/build/make/platforms/linux-all-linux-arm.mk index 3574219c..0150f4f3 100644 --- a/build/make/platforms/linux-all-linux-arm.mk +++ b/build/make/platforms/linux-all-linux-arm.mk @@ -10,7 +10,7 @@ TARGET = arm-linux-gnueabihf DEFINES = INCLUDES = -I/usr/$(TARGET)/include CXX = clang++ -CXXFLAGS = -target $(TARGET) -fPIC -static -fno-strict-aliasing -mstack-alignment=16 -mstackrealign +CXXFLAGS = -target $(TARGET) -fPIC -static -fno-strict-aliasing CC = clang CFLAGS = -target $(TARGET) -fPIC -static -fno-strict-aliasing AR = llvm-ar @@ -25,9 +25,6 @@ DEBARCH = armhf LSBREL = $(shell lsb_release -r -s) DISTDIR = ../../dist/ubuntu-$(LSBREL) -#-mstack-alignment=n // sets the alignment to n bytes -#-mstackrealign // forces the previous set alignment - # CPU Flags ifeq ($(TARGET_CPUREV),legacy) CPUFLAGS = -march=armv7-a -mfloat-abi=hard -mfpu=neon-fp16