Browse Source

fix: g++ compilation errors

master
Dnomd343 2 months ago
parent
commit
9aa81250ef
  1. 2
      src/core/common_code/internal/common_code.inl
  2. 6
      src/core/group/internal/hash.inl
  3. 2
      src/core/raw_code/internal/raw_code.inl
  4. 2
      src/core/short_code/internal/short_code.inl
  5. 9
      src/core/utils/utility.h
  6. 6
      src/core_ffi/py_ffi/include/py_ffi/common_code.h
  7. 6
      src/core_ffi/py_ffi/include/py_ffi/short_code.h

2
src/core/common_code/internal/common_code.inl

@ -144,7 +144,7 @@ constexpr auto operator<=>(const CommonCode &lhs, const CommonCode &rhs) {
namespace std {
template <>
struct std::hash<klotski::codec::CommonCode> {
struct hash<klotski::codec::CommonCode> {
constexpr std::size_t operator()(const klotski::codec::CommonCode &c) const noexcept {
return std::hash<uint64_t>{}(c.unwrap());
}

6
src/core/group/internal/hash.inl

@ -3,7 +3,7 @@
namespace std {
template <>
struct std::hash<klotski::group::Group> {
struct hash<klotski::group::Group> {
constexpr std::size_t operator()(const klotski::group::Group &g) const noexcept {
// TODO: perf hash alg
return std::hash<uint64_t>{}(g.type_id() ^ g.pattern_id() ^ (int)g.toward());
@ -11,14 +11,14 @@ struct std::hash<klotski::group::Group> {
};
template <>
struct std::hash<klotski::group::GroupUnion> {
struct hash<klotski::group::GroupUnion> {
constexpr std::size_t operator()(const klotski::group::GroupUnion &gu) const noexcept {
return std::hash<uint32_t>{}(gu.unwrap());
}
};
template <>
struct std::hash<klotski::group::CaseInfo> {
struct hash<klotski::group::CaseInfo> {
constexpr std::size_t operator()(const klotski::group::CaseInfo &info) const noexcept {
// TODO: perf hash alg
const auto h1 = std::hash<klotski::group::Group>{}(info.group());

2
src/core/raw_code/internal/raw_code.inl

@ -100,7 +100,7 @@ constexpr auto operator<=>(const RawCode &lhs, const RawCode &rhs) {
namespace std {
template <>
struct std::hash<klotski::codec::RawCode> {
struct hash<klotski::codec::RawCode> {
constexpr std::size_t operator()(const klotski::codec::RawCode &r) const noexcept {
return std::hash<uint64_t>{}(r.unwrap());
}

2
src/core/short_code/internal/short_code.inl

@ -122,7 +122,7 @@ constexpr auto operator<=>(const ShortCode &lhs, const ShortCode &rhs) {
namespace std {
template <>
struct std::hash<klotski::codec::ShortCode> {
struct hash<klotski::codec::ShortCode> {
constexpr std::size_t operator()(const klotski::codec::ShortCode &s) const noexcept {
return std::hash<uint32_t>{}(s.unwrap());
}

9
src/core/utils/utility.h

@ -2,6 +2,7 @@
#include <bit>
#include <list>
#include <utility>
#include <cstdint>
#include <numeric>
#include <functional>
@ -32,10 +33,16 @@
#define KLSK_UNREACHABLE __builtin_unreachable() // TODO: using `std::unreachable`
/// Force function declaration to be inline.
#define KLSK_INLINE __attribute__ ((always_inline))
#if defined(__clang__)
#define KLSK_INLINE __attribute__ ((always_inline))
#else
#define KLSK_INLINE // NOTE: make sure that function can be inline
#endif
#define KLSK_INLINE_H KLSK_INLINE inline
#define KLSK_INLINE_CE KLSK_INLINE constexpr
// TODO: using `#pragma GCC unroll`
/// Prevent reordering for both compiler and processor.
#define KLSK_MEM_BARRIER std::atomic_thread_fence(std::memory_order_seq_cst)

6
src/core_ffi/py_ffi/include/py_ffi/common_code.h

@ -96,11 +96,15 @@ constexpr auto operator<=>(const PyCommonCode &lhs, const PyCommonCode &rhs) {
// ----------------------------------------------------------------------------------------- //
namespace std {
template <>
struct ::std::hash<klotski::ffi::PyCommonCode> {
struct hash<klotski::ffi::PyCommonCode> {
size_t operator()(const klotski::ffi::PyCommonCode &common_code) const noexcept {
return std::hash<uint64_t>{}(common_code.value());
}
};
} // namespace std
// ----------------------------------------------------------------------------------------- //

6
src/core_ffi/py_ffi/include/py_ffi/short_code.h

@ -86,11 +86,15 @@ constexpr auto operator<=>(const PyShortCode &lhs, const PyShortCode &rhs) {
// ----------------------------------------------------------------------------------------- //
namespace std {
template <>
struct ::std::hash<klotski::ffi::PyShortCode> {
struct hash<klotski::ffi::PyShortCode> {
size_t operator()(const klotski::ffi::PyShortCode &short_code) const noexcept {
return std::hash<uint32_t>{}(short_code.value());
}
};
} // namespace std
// ----------------------------------------------------------------------------------------- //

Loading…
Cancel
Save