reactor-c
C Runtime for Lingua Franca
|
Go to the source code of this file.
Macros | |
#define | lf_set(out, val) _LF_SET(out, val) |
#define | SET(out, val) |
#define | SET_ARRAY(out, val, elem_size, length) |
#define | SET_NEW(out) |
#define | SET_NEW_ARRAY(out, len) |
#define | SET_PRESENT(out) |
#define | lf_set_token(out, newtoken) _LF_SET_TOKEN(out, newtoken) |
#define | SET_TOKEN(out, newtoken) |
#define | lf_set_destructor(out, dtor) _LF_SET_DESTRUCTOR(out, dtor) |
#define | lf_set_copy_constructor(out, cpy_ctor) _LF_SET_COPY_CONSTRUCTOR(out, cpy_ctor) |
#define | lf_tag() lf_tag(self->base.environment) |
#define | get_current_tag() get_current_tag(self->base.environment) |
#define | get_microstep() get_microstep(self->base.environment) |
#define | lf_time_logical() lf_time_logical(self->base.environment) |
#define | lf_time_logical_elapsed() lf_time_logical_elapsed(self->base.environment) |
#define | get_elapsed_logical_time() get_elapsed_logical_time(self->base.environment) |
#define | get_logical_time() get_logical_time(self->base.environment) |
Copyright (c) 2020, The University of California at Berkeley.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Target-specific runtime functions for the C target language. This API layer can be used in conjunction with: target C;
Note for target language developers. This is one way of developing a target language where the C core runtime is adopted. This file is a translation layer that implements Lingua Franca APIs which interact with the internal _lf_SET and _lf_schedule APIs. This file can act as a template for future runtime developement for target languages. For source generation, see xtext/org.icyphy.linguafranca/src/org/icyphy/generator/CCppGenerator.xtend.
#define get_current_tag | ( | ) | get_current_tag(self->base.environment) |
#define get_elapsed_logical_time | ( | ) | get_elapsed_logical_time(self->base.environment) |
#define get_logical_time | ( | ) | get_logical_time(self->base.environment) |
#define get_microstep | ( | ) | get_microstep(self->base.environment) |
Set the specified output (or input of a contained reactor) to the specified value.
If the value argument is a primitive type such as int, double, etc. as well as the built-in types bool and string, the value is copied and therefore the variable carrying the value can be subsequently modified without changing the output. This also applies to structs with a type defined by a typedef so that the type designating string does not end in '*'.
If the value argument is a pointer to memory that the calling reaction has dynamically allocated, the memory will be automatically freed once all downstream reactions no longer need the value. If 'lf_set_destructor' is called on 'out', then that destructor will be used to free 'value'. Otherwise, the default void free(void*) function is used.
out | The output port (by name) or input of a contained reactor in form input_name.port_name. |
value | The value to insert into the self struct. |
Set the destructor used to copy construct "token->value" received by "in" if "in" is mutable.
out | The output port (by name) or input of a contained reactor in form input_name.port_name. |
cpy_ctor | A pointer to a void* function that takes a pointer argument or NULL to use the memcpy operator. |
Set the destructor used to free "token->value" set on "out". That memory will be automatically freed once all downstream reactions no longer need the value.
out | The output port (by name) or input of a contained reactor in form input_name.port_name. |
dtor | A pointer to a void function that takes a pointer argument or NULL to use the default void free(void*) function. |
Version of lf_set() for output types given as 'type*' or 'type[]' where you want to forward an input or action without copying it.
The deallocation of memory is delegated to downstream reactors, which automatically deallocate when the reference count drops to zero.
out | The output port (by name). |
token | A pointer to token obtained from an input or action. |
#define lf_tag | ( | ) | lf_tag(self->base.environment) |
Sets the next mode of a modal reactor. Same as SET for outputs, only the last value will have effect if invoked multiple times. Works only in reactions with the target mode declared as effect.
mode | The target mode to set for activation. |
#define lf_time_logical | ( | ) | lf_time_logical(self->base.environment) |
#define lf_time_logical_elapsed | ( | ) | lf_time_logical_elapsed(self->base.environment) |
Version of lf_set for output types given as type[]
or type*
where you want to send a previously dynamically allocated array.
The deallocation is delegated to downstream reactors, which automatically deallocate when the reference count drops to zero. It also sets the corresponding _is_present variable in the self struct to true (which causes the object message to be sent).
out | The output port (by name). |
val | The array to send (a pointer to the first element). |
length | The length of the array to send. |
Version of lf_set() for output types given as 'type*' that allocates a new object of the type of the specified output port.
This macro dynamically allocates enough memory to contain one instance of the output datatype and sets the variable named by the argument to point to the newly allocated memory. The user code can then populate it with whatever value it wishes to send.
This macro also sets the corresponding _is_present variable in the self struct to true (which causes the object message to be sent),
out | The output port (by name). |
Version of lf_set() for output types given as 'type[]'.
This allocates a new array of the specified length, sets the corresponding _is_present variable in the self struct to true (which causes the array message to be sent), and sets the variable given by the first argument to point to the new array so that the user code can populate the array. The freeing of the dynamically allocated array will be handled automatically when the last downstream reader of the message has finished.
out | The output port (by name). |
len | The length of the array to be sent. |
Version of lf_set() for output types given as 'type[number]'.
This sets the _is_present variable corresponding to the specified output to true (which causes the array message to be sent). The values in the output are normally written directly to the array or struct before or after this is called.
out | The output port (by name). |