mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-30 00:57:37 +13:00
Move #include
to top level and exclude Clang from compiler version
check. Clang cannot handle <semaphore> being included in a namespace, which is also unadvised see: https://softwareengineering.stackexchange.com/a/335261. Using the fallback <semaphore.h> is only meant for GCC 10, but Clang defines `__GNUC__ = 4` so exclude Clang.
This commit is contained in:
parent
922b6475ae
commit
34ae6d96d5
1 changed files with 6 additions and 3 deletions
|
@ -37,6 +37,11 @@ tab-size = 4
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(__clang__) && __GNUC__ < 11
|
||||||
|
#include <semaphore.h>
|
||||||
|
#else
|
||||||
|
#include <semaphore>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <btop_shared.hpp>
|
#include <btop_shared.hpp>
|
||||||
#include <btop_tools.hpp>
|
#include <btop_tools.hpp>
|
||||||
|
@ -336,14 +341,12 @@ namespace Runner {
|
||||||
atomic<bool> coreNum_reset (false);
|
atomic<bool> coreNum_reset (false);
|
||||||
|
|
||||||
//* Setup semaphore for triggering thread to do work
|
//* Setup semaphore for triggering thread to do work
|
||||||
#if __GNUC__ < 11
|
#if !defined(__clang__) && __GNUC__ < 11
|
||||||
#include <semaphore.h>
|
|
||||||
sem_t do_work;
|
sem_t do_work;
|
||||||
inline void thread_sem_init() { sem_init(&do_work, 0, 0); }
|
inline void thread_sem_init() { sem_init(&do_work, 0, 0); }
|
||||||
inline void thread_wait() { sem_wait(&do_work); }
|
inline void thread_wait() { sem_wait(&do_work); }
|
||||||
inline void thread_trigger() { sem_post(&do_work); }
|
inline void thread_trigger() { sem_post(&do_work); }
|
||||||
#else
|
#else
|
||||||
#include <semaphore>
|
|
||||||
std::binary_semaphore do_work(0);
|
std::binary_semaphore do_work(0);
|
||||||
inline void thread_sem_init() { ; }
|
inline void thread_sem_init() { ; }
|
||||||
inline void thread_wait() { do_work.acquire(); }
|
inline void thread_wait() { do_work.acquire(); }
|
||||||
|
|
Loading…
Reference in a new issue