You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
944 B
C

#ifndef TIMER_H
#define TIMER_H
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#define NSEC_PER_SEC 1000000000
struct timespec subts(struct timespec t1, struct timespec t2);
struct timespec addts(struct timespec t1, struct timespec t2);
double timespec_to_double(struct timespec ts);
//appended GH just incase theres a conflict with anything
//else named "Timer"
typedef struct GHTimer {
struct timespec start;
struct timespec current;
struct timespec pause_start;
struct timespec pause_current;
struct timespec diff;
int running;
int paused;
} GHTimer;
void ghtimer_start(GHTimer *timer);
void ghtimer_pause(GHTimer *timer);
void ghtimer_resume(GHTimer *timer);
void ghtimer_stop(GHTimer *timer);
void ghtimer_reset(GHTimer *timer);
void ghtimer_tick(GHTimer *timer);
struct timespec ghtimer_time(GHTimer *timer);
void ghtimer_timestring(GHTimer *timer, char *buffer);
#endif