Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
tanneberger committed Dec 16, 2024
1 parent fb0b76b commit ab41edb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
3 changes: 2 additions & 1 deletion include/reactor-uc/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include "reactor-uc/tag.h"
#include <stdbool.h>

#define EVENT_INIT(Tag, Trigger, Payload) {.tag = Tag, .trigger = Trigger, .payload = Payload}
#define EVENT_INIT(Tag, Trigger, Payload) \
{ .tag = Tag, .trigger = Trigger, .payload = Payload }

typedef struct Trigger Trigger;

Expand Down
9 changes: 6 additions & 3 deletions include/reactor-uc/tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@
#define NEVER_TAG \
(tag_t) { .time = NEVER, .microstep = NEVER_MICROSTEP }
// Need a separate initializer expression to comply with some C compilers
#define NEVER_TAG_INITIALIZER {NEVER, NEVER_MICROSTEP}
#define NEVER_TAG_INITIALIZER \
{ NEVER, NEVER_MICROSTEP }
#define FOREVER_TAG \
(tag_t) { .time = FOREVER, .microstep = FOREVER_MICROSTEP }
// Need a separate initializer expression to comply with some C compilers
#define FOREVER_TAG_INITIALIZER {FOREVER, FOREVER_MICROSTEP}
#define ZERO_TAG (tag_t){.time = 0LL, .microstep = 0u}
#define FOREVER_TAG_INITIALIZER \
{ FOREVER, FOREVER_MICROSTEP }
#define ZERO_TAG \
(tag_t) { .time = 0LL, .microstep = 0u }

// Returns true if timeout has elapsed.
#define CHECK_TIMEOUT(start, duration) (lf_time_physical() > ((start) + (duration)))
Expand Down
2 changes: 1 addition & 1 deletion src/federated.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "reactor-uc/logging.h"
#include "reactor-uc/platform.h"

//#pragma GCC diagnostic ignored "-Wstack-usage=" THIS causes some problems with patmos-clang
// #pragma GCC diagnostic ignored "-Wstack-usage=" THIS causes some problems with patmos-clang

// TODO: Refactor so this function is available
void LogicalConnection_trigger_downstreams(Connection *self, const void *value, size_t value_size);
Expand Down
20 changes: 8 additions & 12 deletions src/platform/patmos/patmos.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ static PlatformPatmos platform;
#define USEC_TO_NSEC(usec) (usec * USEC(1))
#define NSEC_TO_USEC(nsec) (nsec / USEC(1))

void Platform_vprintf(const char *fmt, va_list args) {
vprintf(fmt, args);
}
void Platform_vprintf(const char *fmt, va_list args) { vprintf(fmt, args); }

lf_ret_t PlatformPatmos_initialize(Platform *self) {
(void)self;
//TODO:
// TODO:
return LF_OK;
}

instant_t PlatformPatmos_get_physical_time(Platform *self) {
(void)self;

return USEC_TO_NSEC(get_cpu_usecs());
return USEC_TO_NSEC(get_cpu_usecs());
}

lf_ret_t PlatformPatmos_wait_until_interruptible(Platform *untyped_self, instant_t wakeup_time) {
PlatformPatmos* self = (PlatformPatmos*)untyped_self;
PlatformPatmos *self = (PlatformPatmos *)untyped_self;
self->async_event = false;
untyped_self->leave_critical_section(untyped_self); // turing on interrupts

Expand All @@ -38,7 +36,7 @@ lf_ret_t PlatformPatmos_wait_until_interruptible(Platform *untyped_self, instant
do {
now = untyped_self->get_physical_time(untyped_self);
} while ((now < wakeup_time) && !self->async_event);

untyped_self->enter_critical_section(untyped_self);

if (self->async_event) {
Expand All @@ -48,7 +46,6 @@ lf_ret_t PlatformPatmos_wait_until_interruptible(Platform *untyped_self, instant
return LF_OK;
}


interval_t sleep_duration = wakeup_time - untyped_self->get_physical_time(untyped_self);
if (sleep_duration < 0) {
return LF_OK;
Expand All @@ -64,7 +61,8 @@ lf_ret_t PlatformPatmos_wait_until(Platform *untyped_self, instant_t wakeup_time
if (sleep_duration < 0) {
return LF_OK;
}
instant_t now = untyped_self->get_physical_time(untyped_self);

instant_t now = untyped_self->get_physical_time(untyped_self);

// Do busy sleep
do {
Expand Down Expand Up @@ -100,9 +98,7 @@ void PlatformPatmos_enter_critical_section(Platform *self) {
intr_disable();
}

void PlatformPatmos_new_async_event(Platform *self) {
((PlatformPatmos*)self)->async_event = true;
}
void PlatformPatmos_new_async_event(Platform *self) { ((PlatformPatmos *)self)->async_event = true; }

void Platform_ctor(Platform *self) {
self->initialize = PlatformPatmos_initialize;
Expand Down
1 change: 0 additions & 1 deletion src/scheduler.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


#if defined(SCHEDULER_DYNAMIC)
#include "./schedulers/dynamic/scheduler.c"
#elif defined(SCHEDULER_STATIC)
Expand Down

0 comments on commit ab41edb

Please sign in to comment.