summaryrefslogtreecommitdiffhomepage
path: root/dev/lib
diff options
context:
space:
mode:
Diffstat (limited to 'dev/lib')
-rw-r--r--dev/lib/fix/fix.hpp8
-rw-r--r--dev/lib/logic/equiv.hpp2
-rw-r--r--dev/lib/logic/math.hpp8
-rw-r--r--dev/lib/logic/opt.hpp2
-rw-r--r--dev/lib/net/modem.hpp11
-rw-r--r--dev/lib/net/url.hpp12
-rw-r--r--dev/lib/simd/basic_simd.hpp10
-rw-r--r--dev/lib/simd/simd.hpp14
-rw-r--r--dev/lib/tests/hpptest.hpp71
9 files changed, 108 insertions, 30 deletions
diff --git a/dev/lib/fix/fix.hpp b/dev/lib/fix/fix.hpp
index 4f02e28..08360d5 100644
--- a/dev/lib/fix/fix.hpp
+++ b/dev/lib/fix/fix.hpp
@@ -35,22 +35,22 @@ namespace ocl::fix
namespace detail
{
template <typename char_type = char>
- const char_type* begin_fix();
+ const char_type* begin_fix() noexcept;
template <>
- inline const char* begin_fix<char>()
+ inline const char* begin_fix<char>() noexcept
{
return "FIX.4.2";
}
template <>
- inline const char16_t* begin_fix<char16_t>()
+ inline const char16_t* begin_fix<char16_t>() noexcept
{
return u"FIX.4.2";
}
template <>
- inline const char8_t* begin_fix<char8_t>()
+ inline const char8_t* begin_fix<char8_t>() noexcept
{
return u8"FIX.4.2";
}
diff --git a/dev/lib/logic/equiv.hpp b/dev/lib/logic/equiv.hpp
index 1d16958..1bdb6d9 100644
--- a/dev/lib/logic/equiv.hpp
+++ b/dev/lib/logic/equiv.hpp
@@ -1,6 +1,6 @@
/*
* File: equiv.hpp
- * Purpose: Equivalence runtime c++ header.
+ * Purpose: Equivalence header.
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
*/
diff --git a/dev/lib/logic/math.hpp b/dev/lib/logic/math.hpp
index ce73aa6..52f4535 100644
--- a/dev/lib/logic/math.hpp
+++ b/dev/lib/logic/math.hpp
@@ -7,11 +7,9 @@
#pragma once
-#include <cmath>
-
namespace ocl
{
- template <std::size_t T>
+ template <__SIZE_TYPE__ T>
struct is_non_boolean_integer final
{
static constexpr const bool value = true;
@@ -29,7 +27,7 @@ namespace ocl
static constexpr const bool value = false;
};
- constexpr inline auto not_a_number = NAN;
- constexpr inline auto positive_infinity = INFINITY;
+ constexpr inline auto not_a_number = __builtin_nanf ("");
+ constexpr inline auto positive_infinity = __builtin_inff ();
constexpr inline auto negative_infinity = -positive_infinity;
} // namespace ocl \ No newline at end of file
diff --git a/dev/lib/logic/opt.hpp b/dev/lib/logic/opt.hpp
index 19f02df..07a3227 100644
--- a/dev/lib/logic/opt.hpp
+++ b/dev/lib/logic/opt.hpp
@@ -51,7 +51,7 @@ namespace ocl
}
private:
- return_type m_ret;
+ return_type m_ret{return_type::invalid};
};
template <typename Teller, typename... Lst>
diff --git a/dev/lib/net/modem.hpp b/dev/lib/net/modem.hpp
index a498f2e..fd64f72 100644
--- a/dev/lib/net/modem.hpp
+++ b/dev/lib/net/modem.hpp
@@ -5,8 +5,7 @@
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
*/
-#ifndef _OCL_NET_NETWORK_HPP
-#define _OCL_NET_NETWORK_HPP
+#pragma once
#include <lib/tests/hpptest.hpp>
@@ -22,13 +21,14 @@ namespace ocl::net
{
class modem;
- using socket_type = int64_t;
-
/// =============================================================================
/// @brief Modem container concept, a container to read and write on a network stream.
/// =============================================================================
class modem final
{
+ public:
+ using socket_type = int64_t;
+
private:
socket_type fd_{};
bool server_fd_{false};
@@ -145,7 +145,7 @@ namespace ocl::net
int ret = ::bind(fd_, (struct sockaddr*)&addr_, sizeof(addr_));
bad_ = ret == -1;
-
+
::listen(fd_, modem::backlog_count);
return bad_ == false;
@@ -166,4 +166,3 @@ namespace ocl::net
};
} // namespace ocl::net
-#endif // ifndef _OCL_NET_NETWORK_HPP
diff --git a/dev/lib/net/url.hpp b/dev/lib/net/url.hpp
index 4bbc271..60440ad 100644
--- a/dev/lib/net/url.hpp
+++ b/dev/lib/net/url.hpp
@@ -24,6 +24,8 @@ namespace ocl::net
http,
https,
mailto,
+ ftp,
+ tel,
bad = 0xff,
};
@@ -53,6 +55,16 @@ namespace ocl::net
m_protocol_ = url_protocol::mailto;
this->operator/=(protocol.substr(std::size("mailto:")));
}
+ else if (protocol.starts_with("tel:"))
+ {
+ m_protocol_ = url_protocol::tel;
+ this->operator/=(protocol.substr(std::size("tel:")));
+ }
+ else if (protocol.starts_with("ftp:"))
+ {
+ m_protocol_ = url_protocol::ftp;
+ this->operator/=(protocol.substr(std::size("ftp:")));
+ }
}
~basic_url() = default;
diff --git a/dev/lib/simd/basic_simd.hpp b/dev/lib/simd/basic_simd.hpp
index f14d977..975ab2b 100644
--- a/dev/lib/simd/basic_simd.hpp
+++ b/dev/lib/simd/basic_simd.hpp
@@ -19,9 +19,9 @@ using simd_type = __m256;
using simd_type = float32x4_t;
#endif
-namespace ocl::snu::simd
+namespace ocl::simd
{
- struct basic_simd_backend final
+ struct basic_simd final
{
struct simd_traits final
{
@@ -29,7 +29,7 @@ namespace ocl::snu::simd
private:
static bool bad;
- friend class basic_simd_backend;
+ friend class basic_simd;
};
using register_type = simd_traits;
@@ -41,7 +41,7 @@ namespace ocl::snu::simd
std::basic_string<char> isa()
{
- return "basic_simd_backend";
+ return "basic_simd";
}
};
-} // namespace ocl::snu::simd
+} // namespace ocl::simd
diff --git a/dev/lib/simd/simd.hpp b/dev/lib/simd/simd.hpp
index 7a40adc..239e512 100644
--- a/dev/lib/simd/simd.hpp
+++ b/dev/lib/simd/simd.hpp
@@ -12,10 +12,10 @@
/// @author Amlal El Mahrouss
/// @brief Basic SIMD processor.
-namespace ocl::snu::simd
+namespace ocl::simd
{
template <typename backend_type>
- class basic_simd_processor
+ class real_type
{
private:
backend_type backend_;
@@ -30,11 +30,11 @@ namespace ocl::snu::simd
};
public:
- basic_simd_processor() = default;
- virtual ~basic_simd_processor() = default;
+ real_type() = default;
+ virtual ~real_type() = default;
- basic_simd_processor& operator=(const basic_simd_processor&) = delete;
- basic_simd_processor(const basic_simd_processor&) = delete;
+ real_type& operator=(const real_type&) = delete;
+ real_type(const real_type&) = delete;
typename backend_type::register_type& call(const opcode& op, typename backend_type::register_type& lhs, typename backend_type::register_type& rhs)
{
@@ -58,4 +58,4 @@ namespace ocl::snu::simd
return backend_.isa();
}
};
-} // namespace ocl::snu::simd
+} // namespace ocl::simd
diff --git a/dev/lib/tests/hpptest.hpp b/dev/lib/tests/hpptest.hpp
index 05f985a..a3136b7 100644
--- a/dev/lib/tests/hpptest.hpp
+++ b/dev/lib/tests/hpptest.hpp
@@ -7,8 +7,36 @@
#pragma once
+#include <lib/io/print.hpp>
+#include <cstdlib>
+
namespace ocl::hpptest
{
+ /// @brief Standard termination error handler, called when a test fails.
+ struct standard_terminate final
+ {
+ template <bool stop_execution = true>
+ static void error() noexcept
+ {
+ ocl::io::print("standard_terminate::error, terminating...\n");
+
+ if (stop_execution)
+ std::terminate();
+ }
+ };
+
+ struct posix_terminate final
+ {
+ template <bool stop_execution = true, errno_t args>
+ static void error(errno_t err) noexcept
+ {
+ ocl::io::print("posix_terminate::error: expected=", strerror(args), ", got=", strerror(err), "\n");
+
+ if (stop_execution)
+ std::terminate();
+ }
+ };
+
typedef bool condition_type;
template <condition_type expr = true>
@@ -16,6 +44,47 @@ namespace ocl::hpptest
{
#ifdef OCL_HPPTEST
OCL_HPPTEST_ASSERT(expr);
-#endif
+#endif // _WIN32
+ }
+
+ template <condition_type expect, typename on_fail>
+ inline void must_pass(condition_type cond) noexcept
+ {
+ if (cond != expect)
+ {
+ on_fail::template error<true>();
+ }
+ }
+
+ template <errno_t expect = 0>
+ inline void must_pass(errno_t ern) noexcept
+ {
+ if (ern != expect)
+ {
+ posix_terminate::error<true, expect>(ern);
+ }
+ }
+
+#ifdef _WIN32
+ struct win32_terminate final
+ {
+ template <bool stop_execution = false>
+ static void error(HRESULT err) noexcept
+ {
+ ocl::io::print("win32_terminate::error: expected=S_OK, got=", err, "\n");
+
+ if (stop_execution)
+ std::terminate();
+ }
+ };
+
+ template <HRESULT expect = S_OK>
+ inline void must_pass(HRESULT hr) noexcept
+ {
+ if (hr != expect)
+ {
+ win32_terminate::error<true>(hr);
+ }
}
+#endif // _WIN32
} // namespace ocl::hpptest