Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.12)

project(libtoolchain
VERSION 1.0.0
LANGUAGES CXX C
)

# Set C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Platform detection
if(WIN32)
set(PLATFORM_NAME "win32")
elseif(APPLE)
set(PLATFORM_NAME "macos")
else()
set(PLATFORM_NAME "linux")
endif()

# Output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${PLATFORM_NAME})

# Collect source files from all subdirectories
file(GLOB_RECURSE TOOLCHAIN_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
)

# Create static library
add_library(toolchain STATIC ${TOOLCHAIN_SOURCES})

# Include directories
target_include_directories(toolchain
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)

# Link dependencies
target_link_libraries(toolchain
PUBLIC
mbedtls
fmt
)

# Compiler flags
if(NOT MSVC)
target_compile_options(toolchain PRIVATE -Wall -Wno-unused-value -Wno-unused-but-set-variable -fPIC)
if(APPLE)
target_compile_options(toolchain PRIVATE -Wno-unused-private-field)
endif()
endif()
2 changes: 1 addition & 1 deletion include/tc/crypto/detail/CmacImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class CmacImpl
if (mState == State::Initialized)
{
// finalise mac, and tranisition to done state
std::array<byte_t, kBlockSize> M_last;
std::array<byte_t, kBlockSize> M_last = {};

// 1) transform last unprocessed to M_last block
if (mUnprocessedBlockPos == kBlockSize)
Expand Down
2 changes: 1 addition & 1 deletion include/tc/io/FileStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <tc/io/PathTooLongException.h>

#ifdef _WIN32
#include <Windows.h>
#include <windows.h>
#else
#include <cstdio>
#endif
Expand Down
4 changes: 3 additions & 1 deletion include/tc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include <tc/bn.h>

#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#endif

/// Alias uint8_t to byte_t to more explicity indicate its role in memory related contexts
Expand Down Expand Up @@ -62,4 +64,4 @@ namespace tc {

/// Returns if a value of type uint64_t is too large to be stored as size_t.
bool is_uint64_t_too_large_for_size_t(uint64_t val);
}
}
6 changes: 5 additions & 1 deletion src/io/FileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ void tc::io::FileStream::dispose()

#ifdef _WIN32

#ifdef _MSC_VER
#pragma warning(disable : 4065) // disable warning for switch case with only default case
#endif

void tc::io::FileStream::open_impl(const tc::io::Path& path, FileMode mode, FileAccess access)
{
Expand Down Expand Up @@ -272,7 +274,7 @@ void tc::io::FileStream::open_impl(const tc::io::Path& path, FileMode mode, File
}

// append can only open in write only mode
if (mode == tc::io::FileMode::Append && (access_flag & GENERIC_READ | GENERIC_WRITE) != GENERIC_WRITE)
if (mode == tc::io::FileMode::Append && (access_flag & (GENERIC_READ | GENERIC_WRITE)) != GENERIC_WRITE)
{
throw tc::ArgumentException(kClassName + "::open()", "Stream opened in Append mode can only work with Write access. ReadWrite is not permitted");
}
Expand Down Expand Up @@ -443,7 +445,9 @@ void tc::io::FileStream::flush_impl()
}
}

#ifdef _MSC_VER
#pragma warning(default : 4065) // reenable warning for switch case with only default case
#endif

#else
void tc::io::FileStream::open_impl(const tc::io::Path& path, FileMode mode, FileAccess access)
Expand Down
6 changes: 5 additions & 1 deletion src/io/LocalFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <direct.h>
#include <cstdlib>

#ifdef _MSC_VER
#pragma warning(disable : 4065) // disable warning for switch case with only default case
#endif

#else
#include <sys/stat.h>
Expand Down Expand Up @@ -580,6 +582,8 @@ void tc::io::LocalFileSystem::getDirectoryChildren(const std::string& method_nam

#ifdef _WIN32

#ifdef _MSC_VER
#pragma warning(default : 4065) // reenable warning for switch case with only default case
#endif

#endif
#endif