diff --git a/dse/modelc/model.h b/dse/modelc/model.h index 2e3dc13..0e35ca7 100644 --- a/dse/modelc/model.h +++ b/dse/modelc/model.h @@ -159,7 +159,7 @@ typedef struct ModelDesc { ModelVTable vtable; /* Reserved. */ - uint64_t __reserved__[2]; + uint64_t __reserved__[4]; } ModelDesc; diff --git a/dse/modelc/model/gateway.c b/dse/modelc/model/gateway.c index faed719..8ed5dbd 100644 --- a/dse/modelc/model/gateway.c +++ b/dse/modelc/model/gateway.c @@ -16,14 +16,9 @@ __attribute__((unused)) static void __compile_time_checks(void) { -/* Compile-time type size check. Get actual size with: - * char (*___)[sizeof(ModelGatewayDesc)] = 1; - */ -#if __SIZEOF_POINTER__ == 8 + // Compile-time type size check. Get actual size with: + // char(*___)[sizeof(ModelGatewayDesc)] = 1; _Static_assert(sizeof(ModelGatewayDesc) == 80, "Compatibility FAIL!"); -#else - _Static_assert(sizeof(ModelGatewayDesc) == 64, "Compatibility FAIL!"); -#endif } diff --git a/dse/modelc/model/mcl.c b/dse/modelc/model/mcl.c index 9f4ad2f..7fab4ec 100644 --- a/dse/modelc/model/mcl.c +++ b/dse/modelc/model/mcl.c @@ -12,17 +12,11 @@ __attribute__((unused)) static void __compile_time_checks(void) { - /* Compile-time type size check. Get actual size with: - * char (*___)[sizeof(MclDesc)] = 1; - * char (*___)[sizeof(MarshalSignalMap)] = 1; - */ - #if __SIZEOF_POINTER__ == 8 - _Static_assert(sizeof(MclDesc) == 256, "Compatibility FAIL!"); + // Compile-time type size check. Get actual size with: + // char(*___)[sizeof(MclDesc)] = 1; + // char(*___)[sizeof(MarshalSignalMap)] = 1; + _Static_assert(sizeof(MclDesc) == 272, "Compatibility FAIL!"); _Static_assert(sizeof(MarshalSignalMap) == 56, "Compatibility FAIL!"); - #else - _Static_assert(sizeof(MclDesc) == 160, "Compatibility FAIL!"); - _Static_assert(sizeof(MarshalSignalMap) == 28, "Compatibility FAIL!"); - #endif } @@ -133,7 +127,8 @@ int32_t mcl_load(MclDesc* model) size_t count = hashlist_length(&msm_list); model->msm = calloc(count + 1, sizeof(MarshalSignalMap)); for (uint32_t i = 0; i < count; i++) { - memcpy(&model->msm[i], hashlist_at(&msm_list, i), sizeof(MarshalSignalMap)); + memcpy(&model->msm[i], hashlist_at(&msm_list, i), + sizeof(MarshalSignalMap)); free(hashlist_at(&msm_list, i)); } hashlist_destroy(&msm_list); @@ -204,7 +199,7 @@ int32_t mcl_step(MclDesc* model, double end_time) double model_stop_time; double model_current_time; double mcl_epsilon = 0.0; - int rc; + int rc; if (model && model->vtable.step) { /* Calculate epsilon value (if necessary). */ @@ -233,11 +228,11 @@ int32_t mcl_step(MclDesc* model, double end_time) /* Model stop time past Simulation stop time. */ if (model_stop_time > end_time + mcl_epsilon) return 0; - log_trace("Step the FMU Model: %f %f (%f) %f", - model_current_time, model_stop_time, - (model_stop_time + mcl_epsilon), end_time); + log_trace("Step the FMU Model: %f %f (%f) %f", model_current_time, + model_stop_time, (model_stop_time + mcl_epsilon), end_time); - rc = model->vtable.step(model, &model_current_time, model_stop_time); + rc = + model->vtable.step(model, &model_current_time, model_stop_time); model->model_time = model_current_time; } while (model_stop_time + mcl_epsilon < end_time); diff --git a/dse/modelc/model/model.c b/dse/modelc/model/model.c index 07fbecc..d7cab57 100644 --- a/dse/modelc/model/model.c +++ b/dse/modelc/model/model.c @@ -17,17 +17,17 @@ __attribute__((unused)) static void __compile_time_checks(void) { -/* Compile-time type size check. Get actual size with: - * char (*___)[sizeof(ModelInstanceSpec)] = 1; - * char (*___)[sizeof(ModelDesc)] = 1; - */ -#if __SIZEOF_POINTER__ == 8 - _Static_assert(sizeof(ModelInstanceSpec) == 128, "Compatibility FAIL!"); - _Static_assert(sizeof(ModelDesc) == 96, "Compatibility FAIL!"); -#else - _Static_assert(sizeof(ModelInstanceSpec) == 80, "Compatibility FAIL!"); - _Static_assert(sizeof(ModelDesc) == 56, "Compatibility FAIL!"); -#endif + // Compile-time type size check. Get actual size with: + // char(*___)[sizeof(SimulationSpec)] = 1; + // char(*___)[sizeof(ModelInstanceSpec)] = 1; + // char(*___)[sizeof(ModelDesc)] = 1; + // char(*___)[sizeof(ModelCArguments)] = 1; + // char(*___)[sizeof(RuntimeModelDesc)] = 1; + _Static_assert(sizeof(SimulationSpec) == 104, "Compatibility FAIL!"); + _Static_assert(sizeof(ModelInstanceSpec) == 160, "Compatibility FAIL!"); + _Static_assert(sizeof(ModelDesc) == 112, "Compatibility FAIL!"); + _Static_assert(sizeof(ModelCArguments) == 160, "Compatibility FAIL!"); + _Static_assert(sizeof(RuntimeModelDesc) == 272, "Compatibility FAIL!"); } diff --git a/dse/modelc/model/signal.c b/dse/modelc/model/signal.c index bf15730..92b1f9d 100644 --- a/dse/modelc/model/signal.c +++ b/dse/modelc/model/signal.c @@ -25,14 +25,9 @@ extern void ncodec_trace_destroy(NCodecInstance* nc); __attribute__((unused)) static void __compile_time_checks(void) { -/* Compile-time type size check. Get actual size with: - * char (*___)[sizeof(SignalVector)] = 1; - */ -#if __SIZEOF_POINTER__ == 8 + // Compile-time type size check. Get actual size with: + // char (*___)[sizeof(SignalVector)] = 1; _Static_assert(sizeof(SignalVector) == 256, "Compatibility FAIL!"); -#else - _Static_assert(sizeof(SignalVector) == 168, "Compatibility FAIL!"); -#endif } diff --git a/dse/modelc/runtime.h b/dse/modelc/runtime.h index 4620fd1..21f18f4 100644 --- a/dse/modelc/runtime.h +++ b/dse/modelc/runtime.h @@ -51,7 +51,7 @@ typedef struct ModelInstanceSpec { void* private; /* Reserved. */ - uint64_t __reserved__[4]; + uint64_t __reserved__[8]; } ModelInstanceSpec; @@ -70,6 +70,9 @@ typedef struct SimulationSpec { const char* sim_path; /* Operational properties needed for loopback operation. */ bool mode_loopback; + + /* Reserved. */ + uint64_t __reserved__[4]; } SimulationSpec; @@ -96,6 +99,9 @@ typedef struct ModelCArguments { uint32_t steps; /* The simulation is in a different location (i.e. not the CWD). */ const char* sim_path; + + /* Reserved. */ + uint64_t __reserved__[4]; } ModelCArguments; @@ -145,7 +151,7 @@ DLL_PRIVATE int model_configure_channel(ModelInstanceSpec* model_instance, #define MODEL_RUNTIME_STEP_FUNC_NAME "model_runtime_step" #define MODEL_RUNTIME_DESTROY_FUNC_NAME "model_runtime_destroy" -typedef struct { +typedef struct RuntimeModelDesc { ModelDesc model; /* Runtime properties. */ @@ -168,6 +174,9 @@ typedef struct { double step_time_correction; bool binary_signals_reset; } runtime; + + /* Reserved. */ + uint64_t __reserved__[8]; } RuntimeModelDesc; DLL_PUBLIC RuntimeModelDesc* model_runtime_create(RuntimeModelDesc* model);