serenity.h 788 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #ifdef __cplusplus
  5. struct Stopwatch {
  6. union SplitQword {
  7. struct {
  8. uint32_t lsw;
  9. uint32_t msw;
  10. };
  11. uint64_t qw { 0 };
  12. };
  13. public:
  14. Stopwatch(const char* name)
  15. : m_name(name)
  16. {
  17. read_tsc(&m_start.lsw, &m_start.msw);
  18. }
  19. ~Stopwatch()
  20. {
  21. SplitQword end;
  22. read_tsc(&end.lsw, &end.msw);
  23. uint64_t diff = end.qw - m_start.qw;
  24. dbgprintf("Stopwatch(%s): %Q ticks\n", m_name, diff);
  25. }
  26. private:
  27. const char* m_name { nullptr };
  28. SplitQword m_start;
  29. };
  30. #endif // __cplusplus
  31. __BEGIN_DECLS
  32. int module_load(const char* path, size_t path_length);
  33. int module_unload(const char* name, size_t name_length);
  34. __END_DECLS