mirror of
https://github.com/matrix-construct/construct
synced 2024-11-12 13:01:07 +01:00
ircd::prof::arm: Port rdtsc for aarch64. #132
This commit is contained in:
parent
4292365abf
commit
af0fa4b2e8
3 changed files with 52 additions and 10 deletions
43
include/ircd/prof/arm.h
Normal file
43
include/ircd/prof/arm.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
// The Construct
|
||||
//
|
||||
// Copyright (C) The Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_PROF_ARM_H
|
||||
|
||||
/// ARM platform related
|
||||
namespace ircd::prof::arm
|
||||
{
|
||||
unsigned long long read_virtual_counter() noexcept;
|
||||
}
|
||||
|
||||
#if defined(__aarch64__)
|
||||
extern inline unsigned long long
|
||||
__attribute__((always_inline, gnu_inline, artificial))
|
||||
ircd::prof::arm::read_virtual_counter()
|
||||
noexcept
|
||||
{
|
||||
unsigned long long ret;
|
||||
asm volatile
|
||||
(
|
||||
"mrs %0, cntvct_el0"
|
||||
: "=r" (ret)
|
||||
);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
extern inline unsigned long long
|
||||
__attribute__((always_inline, gnu_inline, artificial))
|
||||
ircd::prof::arm::read_virtual_counter()
|
||||
noexcept
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -21,20 +21,18 @@ namespace ircd
|
|||
using prof::cycles;
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
/// Monotonic reference cycles (since system boot)
|
||||
extern inline uint64_t
|
||||
__attribute__((flatten, always_inline, gnu_inline, artificial))
|
||||
ircd::prof::cycles()
|
||||
noexcept
|
||||
{
|
||||
return x86::rdtsc();
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
return x86::rdtsc();
|
||||
#elif defined(__aarch64__)
|
||||
return arm::read_virtual_counter();
|
||||
#else
|
||||
static_assert(false, "Select reference cycle counter for platform.");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
ircd::prof::cycles()
|
||||
noexcept
|
||||
{
|
||||
static_assert(false, "Select reference cycle counter for platform.");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace ircd::prof
|
|||
}
|
||||
|
||||
#include "x86.h"
|
||||
#include "arm.h"
|
||||
#include "vg.h"
|
||||
#include "type.h"
|
||||
#include "cycles.h"
|
||||
|
|
Loading…
Reference in a new issue