time is now a thing

This commit is contained in:
IonutParau 2025-05-22 17:02:08 +02:00
parent dac305a1a1
commit 708d090ba2
2 changed files with 7 additions and 0 deletions

View File

@ -145,6 +145,7 @@ void nn_unsafeDeleteUniverse(nn_universe *universe);
void *nn_queryUserdata(nn_universe *universe, const char *name);
void nn_storeUserdata(nn_universe *universe, const char *name, void *data);
void nn_setClock(nn_universe *universe, nn_clock_t *clock, void *userdata);
double nn_getTime(nn_universe *universe);
nn_computer *nn_newComputer(nn_universe *universe, nn_address address, nn_architecture *arch, void *userdata, size_t memoryLimit, size_t componentLimit);
void nn_tickComputer(nn_computer *computer);

View File

@ -7,6 +7,8 @@ nn_universe *nn_newUniverse() {
if(u == NULL) return u;
// we leave udata uninitialized because it does not matter
u->udataLen = 0;
u->clockUserdata = NULL;
u->currentClock = nn_realTimeClock;
return u;
}
@ -36,3 +38,7 @@ void nn_storeUserdata(nn_universe *universe, const char *name, void *data) {
universe->udata[idx].userdata = data;
universe->udataLen++;
}
double nn_getTime(nn_universe *universe) {
return universe->currentClock(universe->clockUserdata);
}