Skip to content

Commit

Permalink
Cross-Platform Revision
Browse files Browse the repository at this point in the history
  • Loading branch information
pinwhell committed May 10, 2024
1 parent 79e7e3d commit 6f4c047
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions include/TBS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#else
#define STL_ETL(stl,etl) stl
#define TBS_STL_INC(x) < x >
#define TBS_STL_INC(x) <x>

#include <string.h>
#endif
Expand Down Expand Up @@ -89,7 +89,9 @@
#define CTZ(x) [x]{unsigned long index = 0; _BitScanForward((unsigned long *)&index, x); return index; }()
#include <intrin.h> // For __cpuid
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__i386__) || defined(__x86_64__)
#include <cpuid.h> // For __get_cpuid
#endif
#define CTZ(x) __builtin_ctz(x)
#endif

Expand Down Expand Up @@ -142,12 +144,12 @@ namespace TBS {
/*
Assumed to be 0x1000 for simplicity
*/
constexpr U64 PAGE_SIZE = 0x1000;
constexpr U64 PG_SIZE = 0x1000;

/*
10 Pages per Pattern Slice Scan
*/
constexpr U64 PATTERN_SEARCH_SLICE_SIZE = PAGE_SIZE * 10;
constexpr U64 PATTERN_SEARCH_SLICE_SIZE = PG_SIZE * 10;

#ifdef TBS_MT
namespace Thread {
Expand Down Expand Up @@ -308,7 +310,7 @@ namespace TBS {
int CPUInfo[4];
__cpuid(CPUInfo, 1);
return (CPUInfo[3] & (1 << 26)) != 0; // Check bit 26 of EDX
#elif defined(__GNUC__) || defined(__clang__)
#elif defined(__GNUC__) || defined(__clang__) && defined(__i386__) || defined(__x86_64__)
unsigned int eax, ebx, ecx, edx;
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
return (edx & (1 << 26)) != 0; // Check bit 26 of EDX
Expand Down

0 comments on commit 6f4c047

Please sign in to comment.