Skip to content

Commit

Permalink
Attempt to fix Github CI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jwellbelove committed Feb 3, 2025
1 parent 7aa7c87 commit 574da35
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 402 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,4 @@ examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/v17
test/etl_error_handler/assert_errors/build-make
test/etl_error_handler/assert_function/build-make
test/syntax_check/bgcc
test/syntax_check/bclang
53 changes: 28 additions & 25 deletions include/etl/atomic/atomic_gcc_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,30 @@ namespace etl
// Only integral and pointer types are supported.
//***************************************************************************

enum memory_order
typedef enum memory_order
{
memory_order_relaxed = __ATOMIC_RELAXED,
memory_order_consume = __ATOMIC_CONSUME,
memory_order_acquire = __ATOMIC_ACQUIRE,
memory_order_release = __ATOMIC_RELEASE,
memory_order_acq_rel = __ATOMIC_ACQ_REL,
memory_order_seq_cst = __ATOMIC_SEQ_CST
} memory_order;

template <bool Is_Always_Lock_Free>
struct atomic_traits
{
static ETL_CONSTANT bool is_always_lock_free = Is_Always_Lock_Free;
};

template <bool Is_Always_Lock_Free>
ETL_CONSTANT bool atomic_traits<Is_Always_Lock_Free>::is_always_lock_free;

//***************************************************************************
/// For all types except bool, pointers and types that are always lock free.
//***************************************************************************
template <typename T, bool integral_type = etl::is_integral<T>::value>
class atomic
class atomic : public atomic_traits<integral_type>
{
public:

Expand Down Expand Up @@ -377,8 +386,6 @@ namespace etl
return __atomic_compare_exchange_n(&value, &expected, desired, false, success, failure);
}

static ETL_CONSTANT bool is_always_lock_free = true;

private:

atomic& operator =(const atomic&) ETL_DELETE;
Expand All @@ -391,7 +398,7 @@ namespace etl
/// Specialisation for pointers
//***************************************************************************
template <typename T>
class atomic<T*, false>
class atomic<T*, false> : public atomic_traits<true>
{
public:

Expand Down Expand Up @@ -621,8 +628,6 @@ namespace etl
return __atomic_compare_exchange_n(&value, &expected_v, uintptr_t(desired), false, success, failure);
}

static ETL_CONSTANT bool is_always_lock_free = true;

private:

atomic& operator =(const atomic&) ETL_DELETE;
Expand All @@ -635,7 +640,7 @@ namespace etl
/// Specialisation for bool
//***************************************************************************
template <>
class atomic<bool, true>
class atomic<bool, true> : public atomic_traits<true>
{
public:

Expand Down Expand Up @@ -785,8 +790,6 @@ namespace etl
return __atomic_compare_exchange_n(&value, &expected_v, desired_v, false, success, failure);
}

static ETL_CONSTANT bool is_always_lock_free = true;

private:

atomic& operator =(const atomic&) ETL_DELETE;
Expand All @@ -800,7 +803,7 @@ namespace etl
/// Uses a mutex to control access.
//***************************************************************************
template <typename T>
class atomic<T, false>
class atomic<T, false> : public atomic_traits<false>
{
public:

Expand Down Expand Up @@ -1005,8 +1008,6 @@ namespace etl
return compare_exchange_weak(expected, desired);
}

static ETL_CONSTANT bool is_always_lock_free = false;

private:

mutable char flag;
Expand Down Expand Up @@ -1038,11 +1039,20 @@ namespace etl
memory_order_seq_cst
} memory_order;

template <bool Is_Always_Lock_Free>
struct atomic_traits
{
static ETL_CONSTANT bool is_always_lock_free = Is_Always_Lock_Free;
};

template <bool Is_Always_Lock_Free>
ETL_CONSTANT bool atomic_traits<Is_Always_Lock_Free>::is_always_lock_free;

//***************************************************************************
/// For all types except bool and pointers
//***************************************************************************
template <typename T, bool integral_type = etl::is_integral<T>::value>
class atomic
class atomic : public atomic_traits<integral_type>
{
public:

Expand Down Expand Up @@ -1436,8 +1446,6 @@ namespace etl
return true;
}

static ETL_CONSTANT bool is_always_lock_free = true;

private:

atomic& operator =(const atomic&) ETL_DELETE;
Expand All @@ -1450,7 +1458,7 @@ namespace etl
/// Specialisation for pointers
//***************************************************************************
template <typename T>
class atomic<T*, false>
class atomic<T*, false> : public atomic_traits<true>
{
public:

Expand Down Expand Up @@ -1748,8 +1756,6 @@ namespace etl
return true;
}

static ETL_CONSTANT bool is_always_lock_free = true;

private:

atomic& operator =(const atomic&) ETL_DELETE;
Expand All @@ -1762,7 +1768,7 @@ namespace etl
/// Specialisation for bool
//***************************************************************************
template <>
class atomic<bool, true>
class atomic<bool, true> : public atomic_traits<true>
{
public:

Expand Down Expand Up @@ -1972,8 +1978,6 @@ namespace etl
return true;
}

static ETL_CONSTANT bool is_always_lock_free = true;

private:

atomic& operator =(const atomic&) ETL_DELETE;
Expand All @@ -1987,7 +1991,7 @@ namespace etl
/// Uses a mutex to control access.
//***************************************************************************
template <typename T>
class atomic<T, false>
class atomic<T, false> : public atomic_traits<false>
{
public:

Expand Down Expand Up @@ -2174,8 +2178,6 @@ namespace etl
return compare_exchange_weak(expected, desired);
}

static ETL_CONSTANT bool is_always_lock_free = false;

private:

mutable char flag;
Expand Down Expand Up @@ -2250,3 +2252,4 @@ namespace etl
}

#endif

22 changes: 22 additions & 0 deletions include/etl/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ SOFTWARE.

namespace etl
{
#if ETL_USING_STL && ETL_USING_CPP20
//*****************************************************************************
/// Obtain the address represented by p without forming a reference to the object pointed to by p.
/// Defined when using the STL and C++20
//*****************************************************************************
template <typename TPtr>
constexpr auto to_address(const TPtr& p) noexcept
{
return std::to_address(p);
}

//*****************************************************************************
/// Obtain the address represented by p without forming a reference to the object pointed to by p.
/// Defined when using the STL and C++20
//*****************************************************************************
template <typename T>
constexpr T* to_address(T* p) noexcept
{
return std::to_address(p);
}
#else
//*****************************************************************************
/// Obtain the address represented by p without forming a reference to the object pointed to by p.
/// Defined when not using the STL or C++20
Expand All @@ -74,6 +95,7 @@ namespace etl
{
return itr.operator->();
}
#endif

#if ETL_USING_STL
//*****************************************************************************
Expand Down
Loading

0 comments on commit 574da35

Please sign in to comment.