0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::prof: Split cycles into header.

This commit is contained in:
Jason Volk 2020-02-27 19:08:09 -08:00
parent e27dd573ad
commit 92b7ae5c17
2 changed files with 41 additions and 24 deletions

View file

@ -0,0 +1,40 @@
// The Construct
//
// Copyright (C) Matrix 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_CYCLES_H
namespace ircd::prof
{
uint64_t cycles() noexcept;
}
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();
}
#else
ircd::prof::cycles()
noexcept
{
static_assert(false, "Select reference cycle counter for platform.");
return 0;
}
#endif

View file

@ -19,7 +19,6 @@ namespace ircd::prof
IRCD_OVERLOAD(sample)
// Samples
uint64_t cycles() noexcept; ///< Monotonic reference cycles (since system boot)
uint64_t time_user() noexcept; ///< Nanoseconds of CPU time in userspace.
uint64_t time_kern() noexcept; ///< Nanoseconds of CPU time in kernelland.
uint64_t time_real() noexcept; ///< Nanoseconds of CPU time real.
@ -35,6 +34,7 @@ namespace ircd::prof
#include "x86.h"
#include "vg.h"
#include "type.h"
#include "cycles.h"
#include "scope_cycles.h"
#include "syscall_timer.h"
#include "instructions.h"
@ -42,26 +42,3 @@ namespace ircd::prof
#include "times.h"
#include "system.h"
#include "psi.h"
// Exports to ircd::
namespace ircd
{
using prof::cycles;
}
#if defined(__x86_64__) || defined(__i386__)
extern inline uint64_t
__attribute__((flatten, always_inline, gnu_inline, artificial))
ircd::prof::cycles()
noexcept
{
return x86::rdtsc();
}
#else
ircd::prof::cycles()
noexcept
{
static_assert(false, "Select reference cycle counter for platform.");
return 0;
}
#endif