diff --git a/org.lflang/src/lib/c/reactor-c b/org.lflang/src/lib/c/reactor-c index 0cfbcd7e77..d97620bb54 160000 --- a/org.lflang/src/lib/c/reactor-c +++ b/org.lflang/src/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 0cfbcd7e7716116ff5bdf2daaafa6a4d504130df +Subproject commit d97620bb54734a25521271169dadae68b6b3ad9b diff --git a/org.lflang/src/org/lflang/TargetProperty.java b/org.lflang/src/org/lflang/TargetProperty.java index 6b8977d11d..14cc3bb4c8 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -1410,6 +1410,7 @@ public String toString() { public enum Platform { AUTO, ARDUINO("Arduino"), + NRF52("Nrf52"), LINUX("Linux"), MAC("Darwin"), WINDOWS("Windows"); diff --git a/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java b/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java index 37179fcf02..f63c9e1c2b 100644 --- a/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java +++ b/org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java @@ -226,10 +226,10 @@ CodeBuilder generateCMakeCode( // Add additional flags so runtime can distinguish between multi-threaded and single-threaded mode if (targetConfig.threading) { cMakeCode.pr("# Set flag to indicate a multi-threaded runtime"); - cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_MULTI_THREADED)"); + cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_THREADED=1)"); } else { cMakeCode.pr("# Set flag to indicate a single-threaded runtime"); - cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_SINGLE_THREADED)"); + cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_UNTHREADED=1)"); } cMakeCode.newLine(); diff --git a/org.lflang/src/org/lflang/generator/c/CGenerator.java b/org.lflang/src/org/lflang/generator/c/CGenerator.java index 9c9590b1e0..1d96ee84eb 100644 --- a/org.lflang/src/org/lflang/generator/c/CGenerator.java +++ b/org.lflang/src/org/lflang/generator/c/CGenerator.java @@ -1104,8 +1104,7 @@ private void pickCompilePlatform() { // if platform target was set, use given platform instead if (targetConfig.platformOptions.platform != Platform.AUTO) { osName = targetConfig.platformOptions.platform.toString(); - } - if (Stream.of("mac", "darwin", "win", "nux", "arduino").noneMatch(osName::contains)) { + } else if (Stream.of("mac", "darwin", "win", "nux").noneMatch(osName::contains)) { errorReporter.reportError("Platform " + osName + " is not supported"); } } @@ -1831,7 +1830,7 @@ public void processProtoFile(String filename, CancelIndicator cancelIndicator) { List.of("--c_out="+this.fileConfig.getSrcGenPath(), filename), fileConfig.srcPath); if (protoc == null) { - errorReporter.reportError("Processing .proto files requires proto-c >= 1.3.3."); + errorReporter.reportError("Processing .proto files requires protoc-c >= 1.3.3."); return; } var returnCode = protoc.run(cancelIndicator); diff --git a/org.lflang/src/org/lflang/generator/c/CPreambleGenerator.java b/org.lflang/src/org/lflang/generator/c/CPreambleGenerator.java index 7bf079f515..d508306c8b 100644 --- a/org.lflang/src/org/lflang/generator/c/CPreambleGenerator.java +++ b/org.lflang/src/org/lflang/generator/c/CPreambleGenerator.java @@ -87,10 +87,6 @@ public static String generateDefineDirectives( code.pr("#define LOG_LEVEL " + logLevel); code.pr("#define TARGET_FILES_DIRECTORY " + addDoubleQuotes(srcGenPath.toString())); - if (targetConfig.platformOptions.platform == Platform.ARDUINO) { - code.pr("#define MICROSECOND_TIME"); - code.pr("#define BIT_32"); - } if (isFederated) { code.pr("#define NUMBER_OF_FEDERATES " + numFederates); code.pr(generateFederatedDefineDirective(coordinationType)); @@ -100,7 +96,7 @@ public static String generateDefineDirectives( } } if (tracing != null) { - targetConfig.compileDefinitions.put("LINGUA_FRANCA_TRACE", tracing.traceFileName); + targetConfig.compileDefinitions.put("LF_TRACE", tracing.traceFileName); } if (clockSyncIsOn) { code.pr(generateClockSyncDefineDirective( @@ -108,6 +104,11 @@ public static String generateDefineDirectives( targetConfig.clockSyncOptions )); } + if (targetConfig.threading) { + targetConfig.compileDefinitions.put("LF_THREADED", "1"); + } else { + targetConfig.compileDefinitions.put("LF_UNTHREADED", "1"); + } code.newLine(); return code.toString(); } diff --git a/test/C/src/ManualDelayedReaction.lf b/test/C/src/ManualDelayedReaction.lf index 0ed0ab555f..1402e00c62 100644 --- a/test/C/src/ManualDelayedReaction.lf +++ b/test/C/src/ManualDelayedReaction.lf @@ -25,7 +25,7 @@ reactor Source { output out: int timer t - // reaction(t) -> out after 100 msec {= + // reaction(t) -> out after 100 msec reaction(t) -> out {= lf_set(out, 1); =} } diff --git a/test/C/src/SimpleDeadline.lf b/test/C/src/SimpleDeadline.lf index b586e8189c..a59a6728e9 100644 --- a/test/C/src/SimpleDeadline.lf +++ b/test/C/src/SimpleDeadline.lf @@ -34,7 +34,7 @@ main reactor SimpleDeadline { reaction(start) -> d.x {= instant_t sleep_time_ns = 20000000; - lf_nanosleep(sleep_time_ns); + lf_sleep(sleep_time_ns); lf_set(d.x, 42); =} } diff --git a/test/C/src/concurrent/AsyncCallback.lf b/test/C/src/concurrent/AsyncCallback.lf index 8fdb0d943a..90c300a8b2 100644 --- a/test/C/src/concurrent/AsyncCallback.lf +++ b/test/C/src/concurrent/AsyncCallback.lf @@ -26,7 +26,7 @@ main reactor AsyncCallback { // Simulate time passing before a callback occurs. void* take_time(void* a) { instant_t sleep_time = 100000000; - lf_nanosleep(sleep_time); + lf_sleep(sleep_time); callback(a); return NULL; } diff --git a/test/C/src/concurrent/AsyncCallbackDrop.lf b/test/C/src/concurrent/AsyncCallbackDrop.lf index 774e4b704f..b3f857333a 100644 --- a/test/C/src/concurrent/AsyncCallbackDrop.lf +++ b/test/C/src/concurrent/AsyncCallbackDrop.lf @@ -20,7 +20,7 @@ main reactor { // Simulate time passing before a callback occurs. void* take_time(void* a) { instant_t sleep_time = 100000000; - lf_nanosleep(sleep_time); + lf_sleep(sleep_time); callback(a); return NULL; } diff --git a/test/C/src/concurrent/AsyncCallbackReplace.lf b/test/C/src/concurrent/AsyncCallbackReplace.lf index a3758a6953..92e4e5f2af 100644 --- a/test/C/src/concurrent/AsyncCallbackReplace.lf +++ b/test/C/src/concurrent/AsyncCallbackReplace.lf @@ -20,7 +20,7 @@ main reactor { // Simulate time passing before a callback occurs. void* take_time(void* a) { instant_t sleep_time = 100000000; - lf_nanosleep(sleep_time); + lf_sleep(sleep_time); callback(a); return NULL; } diff --git a/test/C/src/federated/DistributedPhysicalActionUpstream.lf b/test/C/src/federated/DistributedPhysicalActionUpstream.lf index 7b3e20e456..7e7318726e 100644 --- a/test/C/src/federated/DistributedPhysicalActionUpstream.lf +++ b/test/C/src/federated/DistributedPhysicalActionUpstream.lf @@ -21,7 +21,7 @@ preamble {= void* take_time(void* a) { while (_counter < 15) { instant_t sleep_time = MSEC(10); - lf_nanosleep(sleep_time); + lf_sleep(sleep_time); callback(a); } return NULL; diff --git a/test/C/src/federated/DistributedPhysicalActionUpstreamLong.lf b/test/C/src/federated/DistributedPhysicalActionUpstreamLong.lf index 3830a3e53b..33d6c62999 100644 --- a/test/C/src/federated/DistributedPhysicalActionUpstreamLong.lf +++ b/test/C/src/federated/DistributedPhysicalActionUpstreamLong.lf @@ -21,7 +21,7 @@ preamble {= void* take_time(void* a) { while (_counter < 20) { instant_t sleep_time = USEC(50); - lf_nanosleep(sleep_time); + lf_sleep(sleep_time); callback(a); } return NULL; diff --git a/test/C/src/federated/FeedbackDelay.lf b/test/C/src/federated/FeedbackDelay.lf index 4bfad01615..e369e90df4 100644 --- a/test/C/src/federated/FeedbackDelay.lf +++ b/test/C/src/federated/FeedbackDelay.lf @@ -49,7 +49,7 @@ reactor Planner { output response: double reaction(request) -> response {= - lf_nanosleep(MSEC(10)); + lf_sleep(MSEC(10)); SET(response, request->value); =} } diff --git a/test/Python/src/ManualDelayedReaction.lf b/test/Python/src/ManualDelayedReaction.lf index 773c106b5f..0d142405cd 100644 --- a/test/Python/src/ManualDelayedReaction.lf +++ b/test/Python/src/ManualDelayedReaction.lf @@ -25,7 +25,7 @@ reactor Source { output out timer t - reaction(t) -> out {= out.set(1) =} # reaction(t) -> out after 100 msec {= + reaction(t) -> out {= out.set(1) =} # reaction(t) -> out after 100 msec } reactor Sink { diff --git a/util/tracing/trace_to_chrome.c b/util/tracing/trace_to_chrome.c index a394a194ee..d39f53171e 100644 --- a/util/tracing/trace_to_chrome.c +++ b/util/tracing/trace_to_chrome.c @@ -30,7 +30,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * for viewing in Chrome's event visualizer. To visualize the resulting file, * point your chrome browser to chrome://tracing/ and the load the .json file. */ -#define LINGUA_FRANCA_TRACE +#define LF_TRACE #include "reactor.h" #include "trace.h" #include "trace_util.h" diff --git a/util/tracing/trace_to_csv.c b/util/tracing/trace_to_csv.c index 4f12f7f4bf..a2bcfd91a2 100644 --- a/util/tracing/trace_to_csv.c +++ b/util/tracing/trace_to_csv.c @@ -29,7 +29,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Standalone program to convert a Lingua Franca trace file to a comma-separated values * text file. */ -#define LINGUA_FRANCA_TRACE +#define LF_TRACE #include "reactor.h" #include "trace.h" #include "trace_util.h" diff --git a/util/tracing/trace_to_influxdb.c b/util/tracing/trace_to_influxdb.c index 2b84d47ebe..d8281abd01 100644 --- a/util/tracing/trace_to_influxdb.c +++ b/util/tracing/trace_to_influxdb.c @@ -108,7 +108,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * The data can then be viewed in the InfluxDB browser, or you can configure an external * tool such as Grafana to visualize it (see https://grafana.com/docs/grafana/latest/datasources/influxdb/). */ -#define LINGUA_FRANCA_TRACE +#define LF_TRACE #include "reactor.h" #include "trace.h" #include "trace_util.h" diff --git a/util/tracing/trace_util.c b/util/tracing/trace_util.c index 90f6935291..f688b560d4 100644 --- a/util/tracing/trace_util.c +++ b/util/tracing/trace_util.c @@ -29,7 +29,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Standalone program to convert a Lingua Franca trace file to a comma-separated values * text file. */ -#define LINGUA_FRANCA_TRACE +#define LF_TRACE #include "reactor.h" #include "trace.h" #include "trace_util.h" diff --git a/util/tracing/trace_util.h b/util/tracing/trace_util.h index 52aa76fb0b..56eb9fe3e8 100644 --- a/util/tracing/trace_util.h +++ b/util/tracing/trace_util.h @@ -29,7 +29,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Header file for common utilities used in converting Lingua Franca trace files * into other formats. */ -#define LINGUA_FRANCA_TRACE +#define LF_TRACE #include "reactor.h" #include "trace.h"