summaryrefslogtreecommitdiffhomepage
path: root/dev/misc
diff options
context:
space:
mode:
author0xf00sec <159052166+0xf00sec@users.noreply.github.com>2025-08-09 20:14:37 +0000
committerGitHub <noreply@github.com>2025-08-09 20:14:37 +0000
commitcfd80c4212d449c9b33cc9d18b05da6b3d2c52bc (patch)
tree77d15a66a6d600b72ddf69ff257a7692ed485ae5 /dev/misc
parentd9f1a4f656ced76df3f23eeec678e1a3be1fd432 (diff)
parent7ada9006860084ba5d72b517649d1b2d51e4484a (diff)
Merge branch 'nekernel-org:dev' into dev
Diffstat (limited to 'dev/misc')
-rw-r--r--dev/misc/BenchKit/Chrono.h17
-rw-r--r--dev/misc/BenchKit/X64Chrono.h16
2 files changed, 22 insertions, 11 deletions
diff --git a/dev/misc/BenchKit/Chrono.h b/dev/misc/BenchKit/Chrono.h
index 394f16fd..3a82a94e 100644
--- a/dev/misc/BenchKit/Chrono.h
+++ b/dev/misc/BenchKit/Chrono.h
@@ -10,6 +10,11 @@ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
#include <CompilerKit/CompilerKit.h>
#include <NeKit/Defines.h>
+/// @author Amlal El Mahrouss
+/// @brief BenchKit Chrono contract.
+
+#define BENCHKIT_INTERFACE : public ::Kernel::ChronoInterface
+
namespace Kernel {
class ChronoInterface;
@@ -19,13 +24,17 @@ class ChronoInterface {
ChronoInterface() = default;
virtual ~ChronoInterface() = default;
- NE_COPY_DEFAULT(ChronoInterface);
+ NE_COPY_DEFAULT(ChronoInterface)
- virtual void Start() = 0;
- virtual void Stop() = 0;
- virtual void Reset() = 0;
+ virtual Void Start() = 0;
+ virtual Void Stop() = 0;
+ virtual Void Reset() = 0;
virtual UInt64 GetElapsedTime() const = 0;
};
} // namespace Kernel
+namespace BenchKit {
+using namespace Kernel;
+}
+
#endif // BENCHKIT_CHRONO_H
diff --git a/dev/misc/BenchKit/X64Chrono.h b/dev/misc/BenchKit/X64Chrono.h
index 706ce883..ac92ebb1 100644
--- a/dev/misc/BenchKit/X64Chrono.h
+++ b/dev/misc/BenchKit/X64Chrono.h
@@ -14,11 +14,13 @@ namespace Kernel {
class X64Chrono;
struct X64ChronoTraits;
+/// @brief BenchKit chrono logic for x64.
struct X64ChronoTraits {
private:
STATIC UInt64 TickImpl_(void) {
UInt64 a = 0, d = 0;
- __asm__ volatile("rdtsc" : "=a"(a), "=d"(d));
+
+ asm volatile("rdtsc" : "=a"(a), "=d"(d));
return (d << 32) | a;
}
@@ -26,7 +28,7 @@ struct X64ChronoTraits {
};
/// @brief X86_64 hardware chrono implementation using the `rdtsc` instruction.
-class X64Chrono : public ChronoInterface {
+class X64Chrono BENCHKIT_INTERFACE {
public:
X64Chrono() = default;
~X64Chrono() override = default;
@@ -34,11 +36,11 @@ class X64Chrono : public ChronoInterface {
NE_COPY_DEFAULT(X64Chrono);
public:
- void Start() override { fStart = X64ChronoTraits::TickImpl_(); }
+ Void Start() override { fStart = X64ChronoTraits::TickImpl_(); }
- void Stop() override { fStop = X64ChronoTraits::TickImpl_(); }
+ Void Stop() override { fStop = X64ChronoTraits::TickImpl_(); }
- void Reset() override {
+ Void Reset() override {
fStart = 0;
fStop = 0;
}
@@ -46,8 +48,8 @@ class X64Chrono : public ChronoInterface {
UInt64 GetElapsedTime() const override { return fStop - fStart; }
private:
- UInt64 fStart = 0;
- UInt64 fStop = 0;
+ UInt64 fStart{};
+ UInt64 fStop{};
};
} // namespace Kernel