diff --git a/core/src/main/java/org/lflang/generator/c/CGenerator.java b/core/src/main/java/org/lflang/generator/c/CGenerator.java index 4d77463c4f..567b04ba4f 100644 --- a/core/src/main/java/org/lflang/generator/c/CGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CGenerator.java @@ -973,6 +973,7 @@ protected void generateReactorClassHeaders( } header.pr("#include \"include/core/reactor.h\""); src.pr("#include \"include/api/api.h\""); + src.pr("#include \"include/core/platform.h\""); generateIncludes(tpr); if (cppMode) { src.pr("}"); diff --git a/core/src/main/java/org/lflang/generator/c/CReactionGenerator.java b/core/src/main/java/org/lflang/generator/c/CReactionGenerator.java index b5db35ce92..e1123e8312 100644 --- a/core/src/main/java/org/lflang/generator/c/CReactionGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CReactionGenerator.java @@ -336,6 +336,7 @@ public static String generateForwardBody( ? String.join( "\n", DISABLE_REACTION_INITIALIZATION_MARKER, + "lf_critical_section_enter(self->base.environment);", "self->_lf_" + outputName + ".value = (" @@ -348,7 +349,8 @@ public static String generateForwardBody( + ", (lf_token_t*)self->_lf__" + actionName + ".tmplt.token);", - "self->_lf_" + outputName + ".is_present = true;") + "self->_lf_" + outputName + ".is_present = true;", + "lf_critical_section_exit(self->base.environment);") : "lf_set(" + outputName + ", " + actionName + "->value);"; } @@ -551,6 +553,7 @@ private static String generateActionVariablesInReaction( builder.pr( String.join( "\n", + "lf_critical_section_enter(self->base.environment);", "// Expose the action struct as a local variable whose name matches the action name.", structType + "* " + action.getName() + " = &self->_lf_" + action.getName() + ";", "// Set the fields of the action struct to match the current trigger.", @@ -565,7 +568,8 @@ private static String generateActionVariablesInReaction( + action.getName() + ", " + tokenPointer - + ");")); + + ");", + "lf_critical_section_exit(self->base.environment);")); // Set the value field only if there is a type. if (!type.isUndefined()) { // The value field will either be a copy (for primitive types)