27 lines
464 B
C
27 lines
464 B
C
#pragma once
|
|
|
|
#include <time.h>
|
|
|
|
enum timer_status {
|
|
TIMER_STOPPED,
|
|
TIMER_RUNNING,
|
|
};
|
|
|
|
struct stopwatch_time {
|
|
int integer_value;
|
|
int integer_digits;
|
|
int fraction_value;
|
|
int fraction_digits;
|
|
};
|
|
|
|
struct running_counter {
|
|
struct timespec start; // CLOCK_MONOTONIC (relative)
|
|
struct timespec offset; // CLOCK_MONOTONIC (relative)
|
|
};
|
|
|
|
struct timer_state {
|
|
enum timer_status status;
|
|
struct running_counter counter;
|
|
struct stopwatch_time time;
|
|
};
|