implementations moved on the composer class.

This commit is contained in:
David Carlier
2020-03-13 15:39:49 +00:00
parent 2d4f2c3867
commit e7f020cf76
3 changed files with 16 additions and 12 deletions

View File

@@ -94,7 +94,9 @@ if (WIN32)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(snmalloc_lib INTERFACE -mcx16)
if (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
target_compile_options(snmalloc_lib INTERFACE -mcx16)
endif()
endif ()
# Have to set this globally, as can't be set on an interface target.

View File

@@ -2,6 +2,7 @@
#include "../ds/defines.h"
#include <cstdint>
#include <ctime>
#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \
defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || \
@@ -11,6 +12,10 @@
#if defined(__arm__) || defined(__aarch64__)
# define PLATFORM_IS_ARM
/**
* on ARM cpu counters are accessible only in privileged mode
*/
# define SNMALLOC_NO_ALL_CPUCOUNTERS
#endif
namespace snmalloc
@@ -63,7 +68,12 @@ namespace snmalloc
*/
static inline uint64_t tick()
{
#if __has_builtin(__builtin_readcyclecounter) && \
#if defined(SNMALLOC_NO_ALL_CPUCOUNTERS)
struct timespec n = {0, 0ul};
clock_gettime(CLOCK_MONOTONIC, &n);
return static_cast<uint64_t>((n.tv_sec) * (1000000000 * n.tv_nsec));
#elif __has_builtin(__builtin_readcyclecounter) && \
!defined(SNMALLOC_NO_AAL_BUILTINS)
return __builtin_readcyclecounter();
#else

View File

@@ -31,21 +31,13 @@ namespace snmalloc
/**
* Issue a prefetch hint at the specified address.
*/
static inline void prefetch(void* ptr)
static inline void prefetch(void*)
{
__builtin_prefetch(ptr, 0, 1);
}
/**
* Return a cycle counter value.
* on ARM cpu counters are accessible only in privileged mode
*/
static inline uint64_t tick()
{
struct timespec n = {0, 0ul};
clock_gettime(CLOCK_MONOTONIC, &n);
return static_cast<uint64_t>((n.tv_sec) * (1000000000ul * n.tv_nsec));
return 0ull;
}
};