Skip to content

Commit

Permalink
Merge pull request #3129 from barracuda156/darwin
Browse files Browse the repository at this point in the history
spin_delay.hpp: fix for Darwin PPC
  • Loading branch information
eseiler committed Jan 30, 2023
2 parents 329e5a3 + 619db34 commit c62f2cb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions include/seqan3/utility/parallel/detail/spin_delay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

#include <thread>

#include <seqan3/core/platform.hpp>

//!\cond
#ifndef SEQAN3_HAS_MM_PAUSE
# if defined(__SSE2__) && __has_include(<xmmintrin.h>)
# include <xmmintrin.h> // _mm_pause()
# define SEQAN3_HAS_MM_PAUSE 1
# else
# define SEQAN3_HAS_MM_PAUSE 0
# endif // defined(__SSE2__) && __has_include(<xmmintrin.h>)
#endif // SEQAN3_HAS_MM_PAUSE
//!\endcond

#include <seqan3/core/platform.hpp>

namespace seqan3::detail
{
/*!\brief A delay for threads waiting for a shared resource.
Expand Down Expand Up @@ -80,16 +82,19 @@ class spin_delay
{
#if SEQAN3_HAS_MM_PAUSE // AMD and Intel
_mm_pause();
#elif defined(__armel__) \
|| defined(__ARMEL__) // arm, but broken? ; repeat of default case as armel also defines __arm__
#elif defined(__armel__) || defined(__ARMEL__) // ARM, but broken? repeat of default case as ARMEL also defines __arm__
asm volatile("nop" ::: "memory"); // default operation - does nothing => Might lead to passive spinning.
#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64
#elif defined(__arm__) || defined(__aarch64__) // ARM big endian / ARM64
__asm__ __volatile__("yield" ::: "memory");
#elif defined(__ia64__) // IA64
#elif defined(__ia64__) // IA64
__asm__ __volatile__("hint @pause");
#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) // PowerPC
#elif defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) || defined(__ppc64__) // PowerPC
# if defined(__APPLE__)
__asm__ volatile("or r27,r27,r27" ::: "memory");
# else
__asm__ __volatile__("or 27,27,27" ::: "memory");
#else // everything else.
# endif
#else // everything else
asm volatile("nop" ::: "memory"); // default operation - does nothing => Might lead to passive spinning.
#endif
}
Expand Down

1 comment on commit c62f2cb

@vercel
Copy link

@vercel vercel bot commented on c62f2cb Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

seqan3 – ./

seqan3-seqan.vercel.app
seqan3-git-master-seqan.vercel.app
seqan3.vercel.app

Please sign in to comment.