|
@@ -42,6 +42,8 @@
|
|
|
#include "core/templates/safe_refcount.h"
|
|
|
#include "core/typedefs.h"
|
|
|
|
|
|
+#include <new>
|
|
|
+
|
|
|
#ifdef MINGW_ENABLED
|
|
|
#define MINGW_STDTHREAD_REDUNDANCY_WARNING
|
|
|
#include "thirdparty/mingw-std-threads/mingw.thread.h"
|
|
@@ -85,6 +87,20 @@ public:
|
|
|
void (*term)() = nullptr;
|
|
|
};
|
|
|
|
|
|
+#if defined(__cpp_lib_hardware_interference_size) && !defined(ANDROID_ENABLED) // This would be OK with NDK >= 26.
|
|
|
+#if defined(__GNUC__) && !defined(__clang__)
|
|
|
+#pragma GCC diagnostic push
|
|
|
+#pragma GCC diagnostic ignored "-Winterference-size"
|
|
|
+#endif
|
|
|
+ static constexpr size_t CACHE_LINE_BYTES = std::hardware_destructive_interference_size;
|
|
|
+#if defined(__GNUC__) && !defined(__clang__)
|
|
|
+#pragma GCC diagnostic pop
|
|
|
+#endif
|
|
|
+#else
|
|
|
+ // At a negligible memory cost, we use a conservatively high value.
|
|
|
+ static constexpr size_t CACHE_LINE_BYTES = 128;
|
|
|
+#endif
|
|
|
+
|
|
|
private:
|
|
|
friend class Main;
|
|
|
|
|
@@ -135,6 +151,8 @@ public:
|
|
|
|
|
|
typedef uint64_t ID;
|
|
|
|
|
|
+ static constexpr size_t CACHE_LINE_BYTES = sizeof(void *);
|
|
|
+
|
|
|
enum : ID {
|
|
|
UNASSIGNED_ID = 0,
|
|
|
MAIN_ID = 1
|