Skip to content

Commit

Permalink
Merge pull request #143 from joelriendeau/feature/arm-support
Browse files Browse the repository at this point in the history
Basic arm / 32-bit cpu support
  • Loading branch information
bombomby authored Jan 8, 2022
2 parents c400a7f + 3cd36ca commit 2ee1888
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/optick.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,24 @@
# define OPTICK_GCC (1)
# if defined(__APPLE_CC__)
# define OPTICK_OSX (1)
# define OPTICK_64BIT (1)
# elif defined(__linux__)
# define OPTICK_LINUX (1)
# define OPTICK_64BIT (1)
# elif defined(__FreeBSD__)
# define OPTICK_FREEBSD (1)
# define OPTICK_64BIT (1)
# endif
# if defined(__aarch64__) || defined(_M_ARM64)
# define OPTICK_ARM (1)
# define OPTICK_64BIT (1)
# elif defined(__arm__) || defined(_M_ARM)
# define OPTICK_ARM (1)
# define OPTICK_32BIT (1)
# endif
#elif defined(_MSC_VER)
# define OPTICK_MSVC (1)
# define OPTICK_64BIT (1)
# if defined(_DURANGO)
# define OPTICK_PC (0)
# else
Expand Down
15 changes: 13 additions & 2 deletions src/optick_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#if USE_OPTICK

#include "optick.h"
#include "optick_server.h"

#include <algorithm>
Expand Down Expand Up @@ -64,7 +65,11 @@ namespace Optick
void* (*Memory::allocate)(size_t) = [](size_t size)->void* { return operator new(size); };
void (*Memory::deallocate)(void* p) = [](void* p) { operator delete(p); };
void (*Memory::initThread)(void) = nullptr;
std::atomic<uint64_t> Memory::memAllocated;
#if defined(OPTICK_32BIT)
std::atomic<uint32_t> Memory::memAllocated;
#else
std::atomic<uint64_t> Memory::memAllocated;
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
uint64_t MurmurHash64A(const void * key, int len, uint64_t seed)
{
Expand Down Expand Up @@ -738,7 +743,7 @@ bool SwitchContextCollector::Serialize(OutputDataStream& stream)
#if defined(OPTICK_MSVC)
#include <intrin.h>
#define CPUID(INFO, ID) __cpuid(INFO, ID)
#elif defined(__ANDROID__)
#elif (defined(__ANDROID__) || defined(OPTICK_ARM))
// Nothing
#elif defined(OPTICK_GCC)
#include <cpuid.h>
Expand All @@ -762,6 +767,12 @@ string GetCPUName()
return s;
}
return "Undefined CPU";
#elif defined(OPTICK_ARM)
#if defined(OPTICK_ARM32)
return "ARM 32-bit";
#else
return "ARM 64-bit";
#endif
#else
int cpuInfo[4] = { -1 };
char cpuBrandString[0x40] = { 0 };
Expand Down
4 changes: 4 additions & 0 deletions src/optick_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ namespace Optick
uint64_t size;
};

#if defined(OPTICK_32BIT)
static std::atomic<uint32_t> memAllocated;
#else
static std::atomic<uint64_t> memAllocated;
#endif

static void* (*allocate)(size_t);
static void (*deallocate)(void*);
Expand Down

0 comments on commit 2ee1888

Please sign in to comment.