summaryrefslogtreecommitdiff
path: root/include/ticker.h
blob: f6387c474887ae222a0021a8ccad580c85828823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-FileCopyrightText: 2024 Lizzy Fleckenstein <lizzy@vlhl.dev>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

#ifndef TICKER_H
#define TICKER_H

#include <time.h>
#include <stdint.h>
#include <stdbool.h>

#define NANOS 1000000000

typedef struct {
	struct timespec timestamp;
	uint64_t freq_nanos;
} ticker;

void ticker_init(ticker *t, uint64_t f);
bool ticker_tick(ticker *t, uint64_t *dtime);
int ticker_timeout(ticker *t);

#endif