src/core/timing.h (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef M_CORE_TIMING
7#define M_CORE_TIMING
8
9#include "util/common.h"
10
11struct mTiming;
12struct mTimingEvent {
13 void* context;
14 void (*callback)(struct mTiming*, void* context, uint32_t);
15 const char* name;
16 uint32_t when;
17
18 struct mTimingEvent* next;
19};
20
21struct mTiming {
22 struct mTimingEvent* root;
23
24 uint32_t masterCycles;
25 int32_t* relativeCycles;
26 int32_t* nextEvent;
27};
28
29void mTimingInit(struct mTiming* timing, int32_t* relativeCycles, int32_t* nextEvent);
30void mTimingDeinit(struct mTiming* timing);
31void mTimingClear(struct mTiming* timing);
32void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
33void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent*);
34int32_t mTimingTick(struct mTiming* timing, int32_t cycles);
35int32_t mTimingNextEvent(struct mTiming* timing);
36
37#endif