Skip to content

Commit

Permalink
added ci for msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdcvlsc committed May 28, 2024
1 parent d86243e commit c28af52
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 14 deletions.
43 changes: 43 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
BasedOnStyle: Microsoft
IndentWidth: 4

Language: Cpp
SortIncludes: false

UseTab: Never
TabWidth: 2
AlignConsecutiveDeclarations: true
ContinuationIndentWidth: 2

# LINES
AllowShortEnumsOnASingleLine: true
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
EmptyLineAfterAccessModifier: Always

# BRACE WRAPPINGS
BraceWrapping:
AfterControlStatement: Never
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterFunction: false
AfterClass: false
BeforeCatch: false
BeforeElse: false
BeforeWhile: false
# AfterCaseLabel: false

# INDENTATIONS
AlignAfterOpenBracket: BlockIndent
NamespaceIndentation: All
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
# IndentAccessModifiers: true
AccessModifierOffset: 0

# SPACES
FixNamespaceComments: true
SpaceBeforeRangeBasedForLoopColon: false
SpaceAfterCStyleCast: true
17 changes: 17 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
InlayHints:
Designators: No
Enabled: Yes
ParameterNames: No
DeducedTypes: Yes

CompileFlags:
Add: [-std=c++11, -I"include/epi", -I"benchmark/boost/include", -Wall, -Wextra, -Wpedantic, -Werror]
Compiler: clang++

Diagnostics:
ClangTidy:
Add: [modernize*, cppcoreguidelines*, performance*, bugprone*, clang-analyzer*, darwin*, abseil* ]
Remove: [
modernize-use-trailing-return-type,
cppcoreguidelines-avoid-magic-numbers
]
34 changes: 34 additions & 0 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: msvc

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
header-mode-tests:

name: ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}

strategy:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019, os: windows-2019, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Debug }
- { name: Windows VS2022, os: windows-2022, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Debug }
- { name: Windows VS2022, os: windows-latest, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Debug }
- { name: Windows Clang, os: windows-latest, flags: -DBUILD_SHARED_LIBS=FALSE -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }

steps:
- uses: actions/checkout@v3

- name: Configure test executables
run: cmake -S tests -B tests ${{matrix.platform.flags}}

- name: Build ${{matrix.platform.bin}} test executables
run: cmake --build tests --config Debug

- name: Run ${{matrix.platform.bin}} test executables
run: ctest --test-dir tests
3 changes: 2 additions & 1 deletion ChaCha20-Poly1305.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ typedef unsigned long long ulongint;
typedef unsigned long ulongint;
#define PRINT_LIMBHEX "%016lx "
#else
#error not supported
#define PRINT_LIMBHEX "%016lx "
#define _PURE_CPP
#endif

/// for intel & amd x86_64 & x64 architectures only.
Expand Down
5 changes: 3 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ header_test: $(OBJ)
# -------------------------- test program compilation ---------------------------

$(SRC)/%.out: $(SRC)/%.cpp
@echo "compiling test program - compiler : $(CC)"
@$(CC) $(TESTFLAGS) $(CXXFLAGS) -o $@ $<
# @echo "compiling test program - compiler : $(CC)"
# @echo "flags: $<"
$(CC) $(TESTFLAGS) $(CXXFLAGS) -o $@ $<

clean:
ifeq ($(OS), Linux)
Expand Down
34 changes: 34 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.16)

file(GLOB SOURCES "*.cpp")

message("=========================")
# message(CMAKE_C_COMPILER="${CMAKE_C_COMPILER}")
# message(CMAKE_CPP_COMPILER="${CMAKE_CPP_COMPILER}")
# message(CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}")
# message(CMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}")
message("=========================")


set(CMAKE_VERBOSE_MAKEFILE ON)

enable_testing()

add_compile_definitions(_HIDE_WARNING)

foreach(test_src_code ${SOURCES})
get_filename_component(test_exec_name ${test_src_code} NAME_WE)
message("Source Code = ${test_src_code} | ${test_exec_name}")
add_executable(${test_exec_name} ${test_src_code})
target_compile_features(${test_exec_name} PRIVATE cxx_std_11)
target_compile_options(${test_exec_name} PRIVATE -fsanitize=address)
target_link_options(${test_exec_name} PRIVATE -fsanitize=address)

# message(CMAKE_C_COMPILER="${CMAKE_C_COMPILER}")
# message(CMAKE_CPP_COMPILER="${CMAKE_CPP_COMPILER}")

add_test(
NAME ${test_exec_name}
COMMAND $<TARGET_FILE:${test_exec_name}>
)
endforeach(test_src_code ${SOURCES})
26 changes: 15 additions & 11 deletions uint320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "ChaCha20-Poly1305.hpp"
#endif

#include "ChaCha20-Poly1305.hpp"

uint320::uint320(ulongint num) {
limbs[0] = num;
limbs[1] = 0UL;
Expand Down Expand Up @@ -59,7 +61,9 @@ uint320& uint320::operator=(const uint320& src) {
return *this;
}

uint320::~uint320(){}
uint320::~uint320(){
memset(limbs, 0x00, UINT320BYTES);
}

/// @return returns; 0 : if uint320 == 0, 1 : if uint320 == 1, and -1 : if uint320 != to 0 or 1.
int uint320::one_or_zero() const {
Expand Down Expand Up @@ -154,11 +158,11 @@ uint320& uint320::operator+=(const uint320& add) {
"adcq %[adn3], %[sum3]\n\t"
"adcq %[adn4], %[sum4]"
:
[sum0]"+r"(limbs[0]),
[sum1]"+r"(limbs[1]),
[sum2]"+r"(limbs[2]),
[sum3]"+r"(limbs[3]),
[sum4]"+r"(limbs[4])
[sum0]"+g"(limbs[0]),
[sum1]"+g"(limbs[1]),
[sum2]"+g"(limbs[2]),
[sum3]"+g"(limbs[3]),
[sum4]"+g"(limbs[4])
:
[adn0]"m"(add.limbs[0]),
[adn1]"m"(add.limbs[1]),
Expand Down Expand Up @@ -361,11 +365,11 @@ uint320 uint320::operator*(const uint320& mr) const {
"addq %%rax, %[pd4]\n\t"

:
[pd0]"+r"(pd.limbs[0]),
[pd1]"+r"(pd.limbs[1]),
[pd2]"+r"(pd.limbs[2]),
[pd3]"+r"(pd.limbs[3]),
[pd4]"+r"(pd.limbs[4])
[pd0]"+g"(pd.limbs[0]),
[pd1]"+g"(pd.limbs[1]),
[pd2]"+g"(pd.limbs[2]),
[pd3]"+g"(pd.limbs[3]),
[pd4]"+g"(pd.limbs[4])
:
[mr0]"m"(mr.limbs[0]),
[mr1]"m"(mr.limbs[1]),
Expand Down

0 comments on commit c28af52

Please sign in to comment.