aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-05-27 22:07:38 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:58 +0200
commit1c1b372decaa2fb7f9761c376f8b44d2e6e33c35 (patch)
treeddc3cd8b8f77115374cb6e7a6e61b0264ca4b265
parentf6caac38117a99782513db0b62bfd29b921f873c (diff)
Fix platform family checks (fixed pthreads on linux)
-rw-r--r--src/Platform.cpp12
-rw-r--r--tests/src/platformTest.cpp14
2 files changed, 15 insertions, 11 deletions
diff --git a/src/Platform.cpp b/src/Platform.cpp
index 55c2188..5f9f9af 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -6,16 +6,6 @@ namespace sibs
{
static std::unordered_map<Platform, const char*> platformNames;
static bool platformNamesSet = false;
- static int countSetBits(u64 value)
- {
- int count = 0;
- while(value)
- {
- count += (value & 1ULL);
- value >>= 1ULL;
- }
- return count;
- }
// Returns -1 if no bit is set
static u64 getLeastSignificantBitSetPosition(u64 value)
@@ -94,7 +84,7 @@ namespace sibs
bool isSamePlatformFamily(Platform a, Platform b)
{
- return (a & b) == a;
+ return (a & b) == a || (b & a) == b;
}
bool isBaseForPlatform(Platform base, Platform platform)
diff --git a/tests/src/platformTest.cpp b/tests/src/platformTest.cpp
new file mode 100644
index 0000000..aecc3e4
--- /dev/null
+++ b/tests/src/platformTest.cpp
@@ -0,0 +1,14 @@
+#include <catch.hpp>
+#include "../../include/Platform.hpp"
+
+using namespace sibs;
+
+TEST_CASE("platform same family")
+{
+ REQUIRE(isSamePlatformFamily(PLATFORM_LINUX, PLATFORM_LINUX_X86_64));
+ REQUIRE(isSamePlatformFamily(PLATFORM_LINUX_X86_64, PLATFORM_LINUX));
+ REQUIRE(!isSamePlatformFamily(PLATFORM_LINUX_X86_64, PLATFORM_MACOS));
+ REQUIRE(!isSamePlatformFamily(PLATFORM_MACOS, PLATFORM_LINUX_X86_64));
+ REQUIRE(!isSamePlatformFamily(PLATFORM_MACOS, PLATFORM_LINUX));
+ REQUIRE(!isSamePlatformFamily(PLATFORM_LINUX, PLATFORM_MACOS));
+}