This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new d708edab76 fix compile error
d708edab76 is described below
commit d708edab76aae1962a25e794b0478114e06246a9
Author: hujun5 <[email protected]>
AuthorDate: Fri Jul 19 12:59:58 2024 +0800
fix compile error
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/spinlock.h: In
function 'bool spin_trylock_wo_note(volatile spinlock_t*)':
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/spinlock.h:401:22:
error: 'atomic_ushort' was not declared in this scope; did you mean
'std::__1::atomic_ushort'?
401 | atomic_load((FAR atomic_ushort *)&lock->tickets.next);
| ^~~~~~~~~~~~~
| std::__1::atomic_ushort
/home/hujun5/downloads1/vela_sim/nuttx/include/libcxx/__atomic/aliases.h:33:7:
note: 'std::__1::atomic_ushort' declared here
33 | using atomic_ushort = atomic<unsigned short>;
| ^~~~~~~~~~~~~
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/spinlock.h:401:37:
error: expected primary-expression before ')' token
401 | atomic_load((FAR atomic_ushort *)&lock->tickets.next);
| ^
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/spinlock.h:410:14:
error: expected unqualified-id before 'new'
410 | spinlock_t new =
| ^~~
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/spinlock.h:417:44:
error: 'atomic_uint' was not declared in this scope; did you mean
'std::__1::atomic_uint'?
417 | if (!atomic_compare_exchange_strong((FAR atomic_uint
*)&lock->value,
| ^~~~~~~~~~~
| std::__1::atomic_uint
/home/hujun5/downloads1/vela_sim/nuttx/include/libcxx/__atomic/aliases.h:35:7:
note: 'std::__1::atomic_uint' declared here
35 | using atomic_uint = atomic<unsigned int>;
| ^~~~~~~~~~~
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/spinlock.h:417:57:
error: expected primary-expression before ')' token
417 | if (!atomic_compare_exchange_strong((FAR atomic_uint
*)&lock->value,
| ^
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/spinlock.h:418:54:
error: expected type-specifier before '.' token
418 | &old.value, new.value))
Signed-off-by: hujun5 <[email protected]>
---
include/nuttx/spinlock.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h
index 2e62e43512..2e9103468b 100644
--- a/include/nuttx/spinlock.h
+++ b/include/nuttx/spinlock.h
@@ -42,6 +42,8 @@ extern "C++"
# define CONFIG_HAVE_INLINE_SPINLOCK
using std::atomic_int;
using std::atomic_load;
+ using std::atomic_uint;
+ using std::atomic_ushort;
using std::atomic_fetch_add;
using std::atomic_fetch_sub;
using std::atomic_compare_exchange_strong;
@@ -343,14 +345,14 @@ static inline_function bool spin_trylock(FAR volatile
spinlock_t *lock)
unsigned short ticket =
atomic_load((FAR atomic_ushort *)&lock->tickets.next);
- spinlock_t old =
+ spinlock_t oldval =
{
{
ticket, ticket
}
};
- spinlock_t new =
+ spinlock_t newval =
{
{
ticket, ticket + 1
@@ -358,7 +360,7 @@ static inline_function bool spin_trylock(FAR volatile
spinlock_t *lock)
};
if (!atomic_compare_exchange_strong((FAR atomic_uint *)&lock->value,
- &old.value, new.value))
+ &oldval.value, newval.value))
#else /* CONFIG_TICKET_SPINLOCK */
if (up_testset(lock) == SP_LOCKED)
#endif /* CONFIG_TICKET_SPINLOCK */
@@ -410,14 +412,14 @@ spin_trylock_wo_note(FAR volatile spinlock_t *lock)
unsigned short ticket =
atomic_load((FAR atomic_ushort *)&lock->tickets.next);
- spinlock_t old =
+ spinlock_t oldval =
{
{
ticket, ticket
}
};
- spinlock_t new =
+ spinlock_t newval =
{
{
ticket, ticket + 1
@@ -425,7 +427,7 @@ spin_trylock_wo_note(FAR volatile spinlock_t *lock)
};
if (!atomic_compare_exchange_strong((FAR atomic_uint *)&lock->value,
- &old.value, new.value))
+ &oldval.value, newval.value))
#else /* CONFIG_TICKET_SPINLOCK */
if (up_testset(lock) == SP_LOCKED)
#endif /* CONFIG_TICKET_SPINLOCK */