Skip to content

Commit f0d15a5

Browse files
committed
new clang-format
1 parent 3c38945 commit f0d15a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1144
-1216
lines changed

.clang-format

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
BasedOnStyle: LLVM
33
Language: Cpp
44
IndentWidth: 2
5+
BreakConstructorInitializersBeforeComma: 'true'
6+
PointerAlignment: Left
7+
IncludeBlocks: Preserve
8+
SortIncludes: false
59
ColumnLimit: 120
6-
AllowShortIfStatementsOnASingleLine: false
7-
AllowShortFunctionsOnASingleLine: false
8-
SortIncludes: false

include/reactor-uc/action.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct Action {
1818
interval_t min_offset; // The minimum offset from the current time that an event can be scheduled on this action.
1919
interval_t min_spacing; // The minimum spacing between two events scheduled on this action.
2020
instant_t last_event_time; // Logical time of most recent event scheduled on this action.
21-
void *value_ptr; // Pointer to the value associated with this action at the current logical tag.
21+
void* value_ptr; // Pointer to the value associated with this action at the current logical tag.
2222
TriggerEffects effects; // The reactions triggered by this Action.
2323
TriggerSources sources; // The reactions that can write to this Action.
2424
TriggerObservers observers; // The reactions that can observe this Action.
@@ -33,30 +33,30 @@ struct Action {
3333
* @param offset The tag of the scheduled event will be the current tag plus the min_offset plus this offset.
3434
* @param value A pointer to the value which should be scheduled with the event.
3535
*/
36-
lf_ret_t (*schedule)(Action *self, interval_t offset, const void *value);
36+
lf_ret_t (*schedule)(Action* self, interval_t offset, const void* value);
3737
};
3838

39-
void Action_ctor(Action *self, ActionType type, interval_t min_offset, interval_t min_spacing, Reactor *parent,
40-
Reaction **sources, size_t sources_size, Reaction **effects, size_t effects_size, Reaction **observers,
41-
size_t observers_size, void *value_ptr, size_t value_size, void *payload_buf, bool *payload_used_buf,
39+
void Action_ctor(Action* self, ActionType type, interval_t min_offset, interval_t min_spacing, Reactor* parent,
40+
Reaction** sources, size_t sources_size, Reaction** effects, size_t effects_size, Reaction** observers,
41+
size_t observers_size, void* value_ptr, size_t value_size, void* payload_buf, bool* payload_used_buf,
4242
size_t event_bound);
4343

4444
struct LogicalAction {
4545
Action super;
4646
};
4747

48-
void LogicalAction_ctor(LogicalAction *self, interval_t min_offset, interval_t min_spacing, Reactor *parent,
49-
Reaction **sources, size_t sources_size, Reaction **effects, size_t effects_size,
50-
Reaction **observers, size_t observers_size, void *value_ptr, size_t value_size,
51-
void *payload_buf, bool *payload_used_buf, size_t event_bound);
48+
void LogicalAction_ctor(LogicalAction* self, interval_t min_offset, interval_t min_spacing, Reactor* parent,
49+
Reaction** sources, size_t sources_size, Reaction** effects, size_t effects_size,
50+
Reaction** observers, size_t observers_size, void* value_ptr, size_t value_size,
51+
void* payload_buf, bool* payload_used_buf, size_t event_bound);
5252

5353
struct PhysicalAction {
5454
Action super;
5555
MUTEX_T mutex;
5656
};
5757

58-
void PhysicalAction_ctor(PhysicalAction *self, interval_t min_offset, interval_t min_spacing, Reactor *parent,
59-
Reaction **sources, size_t sources_size, Reaction **effects, size_t effects_size,
60-
Reaction **observers, size_t observers_size, void *value_ptr, size_t value_size,
61-
void *payload_buf, bool *payload_used_buf, size_t event_bound);
58+
void PhysicalAction_ctor(PhysicalAction* self, interval_t min_offset, interval_t min_spacing, Reactor* parent,
59+
Reaction** sources, size_t sources_size, Reaction** effects, size_t effects_size,
60+
Reaction** observers, size_t observers_size, void* value_ptr, size_t value_size,
61+
void* payload_buf, bool* payload_used_buf, size_t event_bound);
6262
#endif

include/reactor-uc/builtin_triggers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ struct BuiltinTrigger {
1111
Trigger super;
1212
TriggerEffects effects;
1313
TriggerObservers observers;
14-
BuiltinTrigger *next;
14+
BuiltinTrigger* next;
1515
};
1616

17-
void BuiltinTrigger_ctor(BuiltinTrigger *self, TriggerType type, Reactor *parent, Reaction **effects,
18-
size_t effects_size, Reaction **observers, size_t observers_size);
17+
void BuiltinTrigger_ctor(BuiltinTrigger* self, TriggerType type, Reactor* parent, Reaction** effects,
18+
size_t effects_size, Reaction** observers, size_t observers_size);
1919

2020
#endif

include/reactor-uc/clock_synchronization.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ typedef struct {
4444

4545
struct ClockSynchronization {
4646
SystemEventHandler super; // ClockSynchronization is a subclass of SystemEventHandler
47-
Environment *env;
48-
NeighborClock *neighbor_clock; // Pointer to an array of neighbor clocks, one for each neighbor.
47+
Environment* env;
48+
NeighborClock* neighbor_clock; // Pointer to an array of neighbor clocks, one for each neighbor.
4949
size_t num_neighbours; // Number of neighbors, length of the neighbor_clock array.
5050
bool is_grandmaster; // Whether this node is the grandmaster.
5151
bool has_initial_sync; // Whether the initial sync has been completed.
@@ -55,12 +55,12 @@ struct ClockSynchronization {
5555
interval_t period; // The period between sync request messages are sent to the neighbor master.
5656
ClockSyncTimestamps timestamps; // The timestamps used to compute clock offset.
5757
ClockServo servo; // The PID controller
58-
void (*handle_message_callback)(ClockSynchronization *self, const ClockSyncMessage *msg, size_t bundle_idx);
58+
void (*handle_message_callback)(ClockSynchronization* self, const ClockSyncMessage* msg, size_t bundle_idx);
5959
};
6060

61-
void ClockSynchronization_ctor(ClockSynchronization *self, Environment *env, NeighborClock *neighbor_clock,
62-
size_t num_neighbors, bool is_grandmaster, size_t payload_size, void *payload_buf,
63-
bool *payload_used_buf, size_t payload_buf_capacity, interval_t period,
61+
void ClockSynchronization_ctor(ClockSynchronization* self, Environment* env, NeighborClock* neighbor_clock,
62+
size_t num_neighbors, bool is_grandmaster, size_t payload_size, void* payload_buf,
63+
bool* payload_used_buf, size_t payload_buf_capacity, interval_t period,
6464
interval_t max_adj, float servo_kp, float servo_ki);
6565

6666
#endif // REACTOR_UC_CLOCK_SYNCHRONIZATION_H

include/reactor-uc/connection.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@ typedef enum { LOGICAL_CONNECTION, PHYSICAL_CONNECTION } ConnectionType;
1919

2020
struct Connection {
2121
Trigger super;
22-
Port *upstream; // Single upstream port
23-
Port **downstreams; // Pointer to array of pointers of downstream ports
22+
Port* upstream; // Single upstream port
23+
Port** downstreams; // Pointer to array of pointers of downstream ports
2424
size_t downstreams_size; // Size of downstreams array
2525
size_t downstreams_registered; // Number of downstreams currently registered
26-
void (*register_downstream)(Connection *, Port *);
27-
Port *(*get_final_upstream)(Connection *);
28-
void (*trigger_downstreams)(Connection *, const void *value_ptr, size_t value_size);
26+
void (*register_downstream)(Connection*, Port*);
27+
Port* (*get_final_upstream)(Connection*);
28+
void (*trigger_downstreams)(Connection*, const void* value_ptr, size_t value_size);
2929
};
3030

31-
void Connection_ctor(Connection *self, TriggerType type, Reactor *parent, Port **downstreams, size_t num_downstreams,
32-
EventPayloadPool *payload_pool, void (*prepare)(Trigger *, Event *), void (*cleanup)(Trigger *),
33-
void (*trigger_downstreams)(Connection *, const void *, size_t));
31+
void Connection_ctor(Connection* self, TriggerType type, Reactor* parent, Port** downstreams, size_t num_downstreams,
32+
EventPayloadPool* payload_pool, void (*prepare)(Trigger*, Event*), void (*cleanup)(Trigger*),
33+
void (*trigger_downstreams)(Connection*, const void*, size_t));
3434

3535
struct LogicalConnection {
3636
Connection super;
3737
};
3838

39-
void LogicalConnection_ctor(LogicalConnection *self, Reactor *parent, Port **downstreams, size_t num_downstreams);
39+
void LogicalConnection_ctor(LogicalConnection* self, Reactor* parent, Port** downstreams, size_t num_downstreams);
4040

4141
struct DelayedConnection {
4242
Connection super;
4343
interval_t delay;
4444
ConnectionType type;
4545
EventPayloadPool payload_pool;
46-
void *staged_payload_ptr;
46+
void* staged_payload_ptr;
4747
};
4848

49-
void DelayedConnection_ctor(DelayedConnection *self, Reactor *parent, Port **downstreams, size_t num_downstreams,
50-
interval_t delay, ConnectionType type, size_t payload_size, void *payload_buf,
51-
bool *payload_used_buf, size_t payload_buf_capacity);
49+
void DelayedConnection_ctor(DelayedConnection* self, Reactor* parent, Port** downstreams, size_t num_downstreams,
50+
interval_t delay, ConnectionType type, size_t payload_size, void* payload_buf,
51+
bool* payload_used_buf, size_t payload_buf_capacity);
5252

5353
#endif

include/reactor-uc/coordinator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ typedef struct Coordinator Coordinator;
99

1010
struct Coordinator {
1111
SystemEventHandler super;
12-
Environment *env;
12+
Environment* env;
1313

14-
void (*logical_tag_complete)(Coordinator *self, tag_t next_local_event_tag);
15-
void (*handle_message_callback)(Coordinator *self, const void *msg, size_t bundle_idx);
14+
void (*logical_tag_complete)(Coordinator* self, tag_t next_local_event_tag);
15+
void (*handle_message_callback)(Coordinator* self, const void* msg, size_t bundle_idx);
1616
};
1717

1818
#endif // REACTOR_UC_COORDINATOR_H

include/reactor-uc/environment.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,29 @@
1616

1717
typedef struct Platform Platform;
1818
typedef struct Environment Environment;
19-
extern Environment *_lf_environment; // NOLINT
19+
extern Environment* _lf_environment; // NOLINT
2020

2121
struct Environment {
22-
Reactor *main; // The top-level reactor of the program.
23-
Scheduler *scheduler; // The scheduler in charge of executing the reactions.
24-
Platform *platform;
22+
Reactor* main; // The top-level reactor of the program.
23+
Scheduler* scheduler; // The scheduler in charge of executing the reactions.
24+
Platform* platform;
2525
bool has_async_events; // Whether the program has multiple execution contexts and can receive async events and thus
2626
// need critical sections.
2727
bool fast_mode; // Whether the program is executing in fast mode where we do not wait for physical time to elapse
2828
// before handling events.
29-
BuiltinTrigger *startup; // A pointer to a startup trigger, if the program has one.
30-
BuiltinTrigger *shutdown; // A pointer to a chain of shutdown triggers, if the program has one.
29+
BuiltinTrigger* startup; // A pointer to a startup trigger, if the program has one.
30+
BuiltinTrigger* shutdown; // A pointer to a chain of shutdown triggers, if the program has one.
3131
/**
3232
* @private
3333
* @brief Assemble the program by computing levels for each reaction and setting up the scheduler.
3434
*/
35-
void (*assemble)(Environment *self);
35+
void (*assemble)(Environment* self);
3636

3737
/**
3838
* @private
3939
* @brief Start the program.
4040
*/
41-
void (*start)(Environment *self);
41+
void (*start)(Environment* self);
4242

4343
/**
4444
* @private
@@ -50,15 +50,15 @@ struct Environment {
5050
* This function must be called from a critical section.
5151
*
5252
*/
53-
lf_ret_t (*wait_until)(Environment *self, instant_t wakeup_time);
53+
lf_ret_t (*wait_until)(Environment* self, instant_t wakeup_time);
5454

5555
/**
5656
* @brief Sleep for a duration.
5757
* @param self The environment.
5858
* @param wait_time The time duration to wait
5959
*
6060
*/
61-
lf_ret_t (*wait_for)(Environment *self, interval_t wait_time);
61+
lf_ret_t (*wait_for)(Environment* self, interval_t wait_time);
6262

6363
/**
6464
* @brief Get the elapsed logical time since the start of the program.
@@ -69,7 +69,7 @@ struct Environment {
6969
7070
* @returns The elapsed logical time.
7171
*/
72-
interval_t (*get_elapsed_logical_time)(Environment *self);
72+
interval_t (*get_elapsed_logical_time)(Environment* self);
7373

7474
/**
7575
* @brief Get the current logical time of the program.AbstractEvent
@@ -79,7 +79,7 @@ struct Environment {
7979
*
8080
* @returns The current logical time.
8181
*/
82-
instant_t (*get_logical_time)(Environment *self);
82+
instant_t (*get_logical_time)(Environment* self);
8383

8484
/**
8585
* @brief Get the elapsed physical time since the start of the program.
@@ -90,7 +90,7 @@ struct Environment {
9090
*
9191
* @returns The elapsed physical time.
9292
*/
93-
interval_t (*get_elapsed_physical_time)(Environment *self);
93+
interval_t (*get_elapsed_physical_time)(Environment* self);
9494

9595
/**
9696
* @brief Get the current physical time.
@@ -101,7 +101,7 @@ struct Environment {
101101
*
102102
* @returns The current physical time.
103103
*/
104-
instant_t (*get_physical_time)(Environment *self);
104+
instant_t (*get_physical_time)(Environment* self);
105105

106106
/**
107107
* @brief Get the current lag.
@@ -111,7 +111,7 @@ struct Environment {
111111
* current logical time. Deadlines are bounds on the release lag of a reaction.
112112
*
113113
*/
114-
interval_t (*get_lag)(Environment *self);
114+
interval_t (*get_lag)(Environment* self);
115115

116116
/**
117117
* @brief Request the termination of the program.
@@ -122,7 +122,7 @@ struct Environment {
122122
* If the program is not federated, then the shutdown will occur at the next microstep.
123123
* If the program is federated, then the shutdown tag will be negotiated with the other federates.
124124
*/
125-
void (*request_shutdown)(Environment *self);
125+
void (*request_shutdown)(Environment* self);
126126

127127
/**
128128
* @private
@@ -134,7 +134,7 @@ struct Environment {
134134
* In a federated setting, we might have to wait before doing this. We might
135135
* wait for a STA offset or send out a coordination message to the upstream.
136136
*/
137-
lf_ret_t (*acquire_tag)(Environment *self, tag_t tag);
137+
lf_ret_t (*acquire_tag)(Environment* self, tag_t tag);
138138

139139
/**
140140
* @private
@@ -144,13 +144,13 @@ struct Environment {
144144
* This function should only be supplied in a federated environment. It should
145145
* poll all the PolledNetworkChannels that the federate has.
146146
*/
147-
lf_ret_t (*poll_network_channels)(Environment *self);
147+
lf_ret_t (*poll_network_channels)(Environment* self);
148148
};
149149

150-
void Environment_ctor(Environment *self, Reactor *main, Scheduler *scheduler, bool fast_mode);
151-
void Environment_free(Environment *self);
150+
void Environment_ctor(Environment* self, Reactor* main, Scheduler* scheduler, bool fast_mode);
151+
void Environment_free(Environment* self);
152152

153-
void Environment_schedule_startups(const Environment *self, tag_t start_tag);
154-
void Environment_schedule_timers(Environment *self, const Reactor *reactor, tag_t start_tag);
153+
void Environment_schedule_startups(const Environment* self, tag_t start_tag);
154+
void Environment_schedule_timers(Environment* self, const Reactor* reactor, tag_t start_tag);
155155

156156
#endif

include/reactor-uc/environments/federated_environment.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
#include "reactor-uc/physical_clock.h"
99

1010
typedef struct FederatedEnvironment FederatedEnvironment;
11-
extern Environment *_lf_environment; // NOLINT
11+
extern Environment* _lf_environment; // NOLINT
1212

1313
struct FederatedEnvironment {
1414
Environment super;
1515
PhysicalClock clock; // The physical clock that provides the physical time.
1616
bool do_clock_sync;
17-
FederatedConnectionBundle **net_bundles; // A pointer to an array of NetworkChannel pointers that are used to
17+
FederatedConnectionBundle** net_bundles; // A pointer to an array of NetworkChannel pointers that are used to
1818
// communicate with other federates running in different environments.
1919
size_t net_bundles_size; // The number of NetworkChannels in the net_channels array.
2020
size_t federation_longest_path; // The longest path in the federation.
21-
StartupCoordinator *startup_coordinator; // A pointer to the startup coordinator, if the program has one.
22-
ClockSynchronization *clock_sync; // A pointer to the clock synchronization module, if the program has one.
21+
StartupCoordinator* startup_coordinator; // A pointer to the startup coordinator, if the program has one.
22+
ClockSynchronization* clock_sync; // A pointer to the clock synchronization module, if the program has one.
2323
};
2424

25-
void FederatedEnvironment_ctor(FederatedEnvironment *self, Reactor *main, Scheduler *scheduler, bool fast_mode,
26-
FederatedConnectionBundle **net_bundles, size_t net_bundles_size,
27-
StartupCoordinator *startup_coordinator, ClockSynchronization *clock_sync);
28-
void FederatedEnvironment_free(FederatedEnvironment *self);
25+
void FederatedEnvironment_ctor(FederatedEnvironment* self, Reactor* main, Scheduler* scheduler, bool fast_mode,
26+
FederatedConnectionBundle** net_bundles, size_t net_bundles_size,
27+
StartupCoordinator* startup_coordinator, ClockSynchronization* clock_sync);
28+
void FederatedEnvironment_free(FederatedEnvironment* self);
2929

3030
#endif

0 commit comments

Comments
 (0)