Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminary support for enclaves in the C target #308

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
13 changes: 8 additions & 5 deletions core/environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,18 @@ void environment_free(environment_t* env) {
}

void environment_init_tags(environment_t* env, instant_t start_time, interval_t duration) {
env->current_tag = (tag_t){.time = start_time, .microstep = 0u};
// Current tag and start tag of the environment is initialized.
env->current_tag = (tag_t){.time = start_time, .microstep = 0};
env->start_tag = (tag_t){.time = start_time, .microstep = 0};
env->duration = duration;

tag_t stop_tag = FOREVER_TAG_INITIALIZER;
if (duration >= 0LL) {
// A duration has been specified. Calculate the stop time.
stop_tag.time = env->current_tag.time + duration;
stop_tag.microstep = 0;
env->stop_tag.time = env->start_tag.time + env->duration;
env->stop_tag.microstep = 0;
} else {
env->stop_tag = (tag_t)FOREVER_TAG_INITIALIZER;
}
env->stop_tag = stop_tag;
}

int environment_init(environment_t* env, const char* name, int id, int num_workers, int num_timers,
Expand Down
14 changes: 14 additions & 0 deletions core/reactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,25 @@ int lf_reactor_c_main(int argc, const char* argv[]) {
#ifndef FEDERATED
lf_tracing_set_start_time(start_time);
#endif
// Create and initialize the environment
_lf_create_environments(); // code-generated function
environment_t* env;
int num_environments = _lf_get_environments(&env);
LF_ASSERT(num_environments == 1, "Found %d environments. Only 1 can be used with the single-threaded runtime",
num_environments);

LF_PRINT_DEBUG("Initializing.");
initialize_global();
// Set start time
start_time = lf_time_physical();

LF_PRINT_DEBUG("NOTE: FOREVER is displayed as " PRINTF_TAG " and NEVER as " PRINTF_TAG,
FOREVER_TAG.time - start_time, FOREVER_TAG.microstep, NEVER_TAG.time - start_time, 0);

environment_init_tags(env, start_time, duration);
env->current_tag = env->start_tag;
// Start tracing if enalbed
start_trace(env->trace);
#ifdef MODAL_REACTORS
// Set up modal infrastructure
_lf_initialize_modes(env);
Expand Down
Loading
Loading