Skip to content

Commit

Permalink
Merge pull request #4 from Samuel-Tyler/devel
Browse files Browse the repository at this point in the history
Significant Compilation Improvements
  • Loading branch information
Samuel-Tyler authored Aug 18, 2019
2 parents 2a32c3f + 17affd2 commit dbd9ef2
Show file tree
Hide file tree
Showing 40 changed files with 11,278 additions and 7,434 deletions.
2 changes: 1 addition & 1 deletion 3rd_party/abseil-cpp
Submodule abseil-cpp updated 784 files
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(default_build_type Release)
set(SKIP_AUTO_GENERATION false) # Set to true to avoid bison / asn1c autogeneration (use checked in files instead)
set(BENCHMARKS_INCLUDE_ASN1C true)

if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER MATCHES ".*clang")
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options("-O3" "-Wall" "-Wextra" "-pedantic" "-Wcast-align" "-Wpointer-arith" "-Wshadow")
add_compile_options("-Wfloat-equal" "-Wuninitialized")
add_compile_options("-Wno-missing-field-initializers") # Stop spam on g++-4.8
Expand All @@ -29,8 +29,9 @@ else()
set(BENCHMARKS_INCLUDE_ASN1C false)
set(CTEST_CONFIGURATION_TYPE "${CMAKE_BUILD_TYPE}")
add_compile_options("/W4")
add_compile_options("-DNOMINMAX")
if (CMAKE_BUILD_TYPE MATCHES "Release")
add_compile_options("/O2" "-DNOMINMAX")
add_compile_options("/O2")
endif ()
endif()

Expand Down
12 changes: 7 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
platform:
- x86
- x64

configuration:
- Debug
- Release

image:
- Visual Studio 2017


init:
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

build_script:
- cmd: >-
git submodule update --init
Expand All @@ -17,9 +18,10 @@ build_script:
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake .. -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles"
cmake --build . --config Release
test_script:
- ctest -C Release
- ctest -C Release -j 8

7 changes: 6 additions & 1 deletion include/fast_ber/ber_types/All.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "InstanceOf.hpp"
#include "Integer.hpp"
#include "Null.hpp"
#include "ObjectField.hpp"
#include "ObjectIdentifier.hpp"
#include "OctetString.hpp"
#include "Optional.hpp"
Expand All @@ -32,3 +31,9 @@
#include "TimeOfDay.hpp"
#include "UTCTime.hpp"
#include "VisibleString.hpp"

namespace fast_ber
{
using Any = fast_ber::Choice<BitString, Boolean, CharacterString, Date, DateTime, Duration, GeneralizedTime, Integer,
Null, ObjectIdentifier, OctetString, Real, Time, TimeOfDay, UTCTime, VisibleString>;
}
5 changes: 5 additions & 0 deletions include/fast_ber/ber_types/Any.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "fast_ber/ber_types/choice.hpp"

}
5 changes: 2 additions & 3 deletions include/fast_ber/ber_types/Date.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#pragma once

#include "fast_ber/ber_types/GeneralizedTime.hpp"
namespace fast_ber
{

class Date
{
};
using Date = GeneralizedTime;

} // namespace fast_ber
9 changes: 9 additions & 0 deletions include/fast_ber/ber_types/DateTime.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "fast_ber/ber_types/GeneralizedTime.hpp"
namespace fast_ber
{

using DateTime = GeneralizedTime;

} // namespace fast_ber
8 changes: 8 additions & 0 deletions include/fast_ber/ber_types/Duration.hpp
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
#pragma once

#include "fast_ber/ber_types/GeneralizedTime.hpp"
namespace fast_ber
{

using Duration = GeneralizedTime;

} // namespace fast_ber
52 changes: 52 additions & 0 deletions include/fast_ber/ber_types/Real.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once

#include "fast_ber/util/BerView.hpp"
#include "fast_ber/util/EncodeHelpers.hpp"

namespace fast_ber
{

class Real
{
public:
Real() noexcept : m_data{} {}
Real(double num) noexcept { assign(num); }
Real(BerView& view) noexcept { assign_ber(view); }

explicit Real(absl::Span<const uint8_t> ber_data) noexcept { assign_ber(ber_data); }

// Implicit conversion to double
operator double() const noexcept { return value(); }
double value() const noexcept;

Real& operator=(double rhs) noexcept;
Real& operator=(const Real& rhs) noexcept;
Real& operator=(const BerView& rhs) noexcept;
void assign(double val) noexcept;
void assign(const Real& rhs) noexcept;
size_t assign_ber(const BerView& rhs) noexcept;
size_t assign_ber(absl::Span<const uint8_t> buffer) noexcept;

bool operator==(const Real&) const
{
// TODO: fuzzy equality here
return true;
}
bool operator!=(const Real& rhs) const { return !(*this == rhs); }

EncodeResult encode_content_and_length(absl::Span<uint8_t> buffer) const noexcept;

private:
void set_content_length(uint64_t length) noexcept
{
assert(length <= std::numeric_limits<uint8_t>::max());
m_data[0] = static_cast<uint8_t>(length);
}
uint8_t content_length() const noexcept { return m_data[0]; }
size_t encoded_length() const noexcept { return 1 + content_length(); }

std::array<uint8_t, sizeof(int64_t) + sizeof(uint8_t)> m_data;
};

constexpr inline ExplicitIdentifier<UniversalTag::real> identifier(const Real*) noexcept { return {}; }
} // namespace fast_ber
7 changes: 4 additions & 3 deletions include/fast_ber/ber_types/Time.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "fast_ber/ber_types/GeneralizedTime.hpp"
namespace fast_ber
{
class Time
{
};

using Time = GeneralizedTime;

} // namespace fast_ber
7 changes: 4 additions & 3 deletions include/fast_ber/ber_types/TimeOfDay.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "fast_ber/ber_types/GeneralizedTime.hpp"
namespace fast_ber
{
class TimeOfDay
{
};

using TimeOfDay = GeneralizedTime;

} // namespace fast_ber
7 changes: 4 additions & 3 deletions include/fast_ber/ber_types/UTCTime.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "fast_ber/ber_types/GeneralizedTime.hpp"
namespace fast_ber
{
class UTCTime
{
};

using UTCTime = GeneralizedTime;

} // namespace fast_ber
Loading

0 comments on commit dbd9ef2

Please sign in to comment.