diff --git a/core/federated/RTI/message_record/message_record.c b/core/federated/RTI/message_record/message_record.c index b2086e567..697b9ee86 100644 --- a/core/federated/RTI/message_record/message_record.c +++ b/core/federated/RTI/message_record/message_record.c @@ -29,6 +29,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***************/ #include "message_record.h" +#include "platform.h" #include /** diff --git a/core/federated/RTI/message_record/rti_pqueue_support.h b/core/federated/RTI/message_record/rti_pqueue_support.h index bf692d4c5..6265f1f99 100644 --- a/core/federated/RTI/message_record/rti_pqueue_support.h +++ b/core/federated/RTI/message_record/rti_pqueue_support.h @@ -34,6 +34,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tag.h" #include "utils/pqueue.h" #include "utils/util.h" +#include "platform.h" // ********** Priority Queue Support Start /** diff --git a/core/federated/RTI/rti_lib.c b/core/federated/RTI/rti_lib.c index b456c4f8f..f0e3f2c1d 100644 --- a/core/federated/RTI/rti_lib.c +++ b/core/federated/RTI/rti_lib.c @@ -47,6 +47,8 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rti_lib.h" +#include "string.h" + /** * The state of this RTI instance. */ @@ -2032,4 +2034,4 @@ int process_args(int argc, const char* argv[]) { return 0; } return 1; -} \ No newline at end of file +} diff --git a/core/federated/clock-sync.c b/core/federated/clock-sync.c index feeb2f070..dd6bd8fcd 100644 --- a/core/federated/clock-sync.c +++ b/core/federated/clock-sync.c @@ -38,6 +38,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include "platform.h" #include "clock-sync.h" #include "net_common.h" #include "net_util.h" diff --git a/core/federated/federate.c b/core/federated/federate.c index 820269a6b..c0964e2d3 100644 --- a/core/federated/federate.c +++ b/core/federated/federate.c @@ -48,6 +48,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include // Defines read(), write(), and close() +#include #include "clock-sync.h" #include "federate.h" @@ -2940,4 +2941,4 @@ parse_rti_code_t parse_rti_addr(const char* rti_addr) { void set_federation_id(const char* fid) { federation_metadata.federation_id = fid; } -#endif \ No newline at end of file +#endif diff --git a/core/modal_models/modes.c b/core/modal_models/modes.c index 2d5a33bcb..35e10718c 100644 --- a/core/modal_models/modes.c +++ b/core/modal_models/modes.c @@ -39,6 +39,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include "platform.h" #include "lf_types.h" #include "modes.h" #include "reactor_common.h" diff --git a/core/platform/lf_unix_clock_support.c b/core/platform/lf_unix_clock_support.c index a936d8a15..65d5e31be 100644 --- a/core/platform/lf_unix_clock_support.c +++ b/core/platform/lf_unix_clock_support.c @@ -2,6 +2,7 @@ #include #include +#include "platform.h" #include "lf_unix_clock_support.h" /** diff --git a/core/platform/lf_windows_support.c b/core/platform/lf_windows_support.c index 4e563d0d9..382870107 100644 --- a/core/platform/lf_windows_support.c +++ b/core/platform/lf_windows_support.c @@ -34,15 +34,16 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @see https://gist.github.com/Soroosh129/127d1893fa4c1da6d3e1db33381bb273 */ -#include +#include // Order in which windows.h is included does matter! +#include #include #include -#include +#include + #include "lf_windows_support.h" #include "platform.h" -#include "util.h" #include "tag.h" -#include +#include "util.h" /** * Indicate whether or not the underlying hardware @@ -59,8 +60,6 @@ double _lf_frequency_to_ns = 1.0; #define LF_MIN_SLEEP_NS USEC(10) -#define BILLION 1000000000 - #if defined LF_THREADED || defined _LF_TRACE /** diff --git a/core/reactor_common.c b/core/reactor_common.c index 9617fd235..5be23ff9c 100644 --- a/core/reactor_common.c +++ b/core/reactor_common.c @@ -38,6 +38,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "platform.h" #include "lf_types.h" diff --git a/core/tag.c b/core/tag.c index f10bed4cf..a38caa5fb 100644 --- a/core/tag.c +++ b/core/tag.c @@ -37,6 +37,8 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tag.h" #include "util.h" +#include "platform.h" +#include "util.h" // Global variables :( diff --git a/core/threaded/reactor_threaded.c b/core/threaded/reactor_threaded.c index 3e0a67fb5..2697c2782 100644 --- a/core/threaded/reactor_threaded.c +++ b/core/threaded/reactor_threaded.c @@ -1192,4 +1192,4 @@ int lf_critical_section_enter() { int lf_critical_section_exit() { return lf_mutex_unlock(&mutex); } -#endif \ No newline at end of file +#endif diff --git a/core/utils/pqueue.c b/core/utils/pqueue.c index 6977a958f..aa1f1bd15 100644 --- a/core/utils/pqueue.c +++ b/core/utils/pqueue.c @@ -37,6 +37,7 @@ #include #include +#include "platform.h" #include "pqueue.h" #include "util.h" #include "lf_types.h" diff --git a/include/api/api.h b/include/api/api.h index b4b4274c6..85e06ff9f 100644 --- a/include/api/api.h +++ b/include/api/api.h @@ -35,6 +35,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef API_H #define API_H +#include // Included for backwards compatibility so that users do not need to explicitly include this #include "lf_types.h" #include "tag.h" diff --git a/include/core/federated/federate.h b/include/core/federated/federate.h index d15a0e920..2cfb6f5c1 100644 --- a/include/core/federated/federate.h +++ b/include/core/federated/federate.h @@ -32,9 +32,11 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef FEDERATE_H #define FEDERATE_H +#include + #include "tag.h" #include "lf_types.h" -#include +#include "platform.h" #ifndef ADVANCE_MESSAGE_INTERVAL #define ADVANCE_MESSAGE_INTERVAL MSEC(10) diff --git a/include/core/lf_types.h b/include/core/lf_types.h index 4698f8abd..5a0bde4bf 100644 --- a/include/core/lf_types.h +++ b/include/core/lf_types.h @@ -40,7 +40,6 @@ #include "modal_models/modes.h" // Modal model support #include "utils/pqueue.h" -#include "platform.h" #include "tag.h" #include "lf_token.h" diff --git a/include/core/modal_models/modes.h b/include/core/modal_models/modes.h index 334df011e..7a3b82667 100644 --- a/include/core/modal_models/modes.h +++ b/include/core/modal_models/modes.h @@ -47,8 +47,8 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "platform.h" #include "lf_types.h" +#include "tag.h" typedef struct event_t event_t; typedef struct reaction_t reaction_t; diff --git a/include/core/platform.h b/include/core/platform.h index c0ea35ce8..30fa251ce 100644 --- a/include/core/platform.h +++ b/include/core/platform.h @@ -29,12 +29,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * This file detects the platform on which the C compiler is being run * (e.g. Windows, Linux, Mac) and conditionally includes platform-specific * files that define core datatypes and function signatures for Lingua Franca. - * For example, the type instant_t represents a time value (long long on - * most of the platforms). The conditionally included files define a type - * _instant_t, and this file defines the type instant_t to be whatever - * the included defines _instant_t to be. All platform-independent code - * in Lingua Franca, therefore, should use the type instant_t for time - * values. * * @author{Soroush Bateni } */ @@ -42,6 +36,8 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef PLATFORM_H #define PLATFORM_H +#include "lf_types.h" + #if defined(LF_THREADED) && defined(LF_UNTHREADED) #error LF_UNTHREADED and LF_THREADED runtime requested #endif @@ -85,23 +81,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define LF_TIMEOUT _LF_TIMEOUT - -/** - * Time instant. Both physical and logical times are represented - * using this typedef. - */ -typedef _instant_t instant_t; - -/** - * Interval of time. - */ -typedef _interval_t interval_t; - -/** - * Microstep instant. - */ -typedef _microstep_t microstep_t; - /** * Enter a critical section where logical time and the event queue are guaranteed * to not change unless they are changed within the critical section. diff --git a/include/core/platform/lf_arduino_support.h b/include/core/platform/lf_arduino_support.h index 310731015..8db4c84c1 100644 --- a/include/core/platform/lf_arduino_support.h +++ b/include/core/platform/lf_arduino_support.h @@ -135,20 +135,4 @@ extern lf_cond_t event_q_changed; // Arduinos are embedded platforms with no tty #define NO_TTY -/** - * Time instant. Both physical and logical times are represented - * using this typedef. - */ -typedef int64_t _instant_t; - -/** - * Interval of time. - */ -typedef int64_t _interval_t; - -/** - * Microstep instant. - */ -typedef uint32_t _microstep_t; - #endif // LF_ARDUINO_SUPPORT_H diff --git a/include/core/platform/lf_nrf52_support.h b/include/core/platform/lf_nrf52_support.h index cca307e17..a0a10d278 100644 --- a/include/core/platform/lf_nrf52_support.h +++ b/include/core/platform/lf_nrf52_support.h @@ -46,18 +46,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PRINTF_MICROSTEP "%" PRIu32 #define PRINTF_TAG "(%" PRId64 ", %" PRIu32 ")" -typedef int64_t _instant_t; - -/** - * Interval of time. - */ -typedef int64_t _interval_t; - -/** - * Microstep instant. - */ -typedef uint32_t _microstep_t; - /** * No mutex or condition variable needed for single threaded NRF platforms */ diff --git a/include/core/platform/lf_tag_64_32.h b/include/core/platform/lf_tag_64_32.h index 74c2b07cd..49f9e38c0 100644 --- a/include/core/platform/lf_tag_64_32.h +++ b/include/core/platform/lf_tag_64_32.h @@ -38,7 +38,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // If you are targeting a platform that uses some other type // for time and microsteps, you can simply define // PRINTF_TIME and PRINTF_MICROSTEP directly in the same file that -// defines the types _instant_t, _interval_t, and _microstep_t. +// defines the types instant_t, interval_t, and microstep_t. #include #define PRINTF_TIME "%" PRId64 #define PRINTF_MICROSTEP "%" PRIu32 @@ -48,24 +48,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // printf("Tag is " PRINTF_TAG "\n", time_value, microstep); #define PRINTF_TAG "(" PRINTF_TIME ", " PRINTF_MICROSTEP ")" -/** - * Time instant. Both physical and logical times are represented - * using this typedef. - * WARNING: If this code is used after about the year 2262, - * then representing time as a 64-bit long long will be insufficient. - */ -typedef int64_t _instant_t; - -/** - * Interval of time. - */ -typedef int64_t _interval_t; - -/** - * Microstep instant. - */ -typedef uint32_t _microstep_t; - /** * For user-friendly reporting of time values, the buffer length required. * This is calculated as follows, based on 64-bit time in nanoseconds: diff --git a/include/core/platform/lf_windows_support.h b/include/core/platform/lf_windows_support.h index 3979290d7..e573be277 100644 --- a/include/core/platform/lf_windows_support.h +++ b/include/core/platform/lf_windows_support.h @@ -50,9 +50,10 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define _LF_TIMEOUT ETIMEDOUT // Use 64-bit times and 32-bit unsigned microsteps #include "lf_tag_64_32.h" +#include "tag.h" // Forward declare lf_clock_gettime which is needed by lf_cond_timedwait -extern int lf_clock_gettime(_instant_t* t); +extern int lf_clock_gettime(instant_t* t); #if defined LF_THREADED || defined _LF_TRACE #if __STDC_VERSION__ < 201112L || defined (__STDC_NO_THREADS__) // (Not C++11 or later) or no threads support @@ -218,11 +219,11 @@ static int lf_cond_wait(lf_cond_t* cond) { * * @return 0 on success and LF_TIMEOUT on timeout, 1 otherwise. */ -static int lf_cond_timedwait(lf_cond_t* cond, _instant_t absolute_time_ns) { +static int lf_cond_timedwait(lf_cond_t* cond, instant_t absolute_time_ns) { // Convert the absolute time to a relative time - _instant_t current_time_ns; + instant_t current_time_ns; lf_clock_gettime(¤t_time_ns); - _interval_t relative_time_ns = (absolute_time_ns - current_time_ns); + interval_t relative_time_ns = (absolute_time_ns - current_time_ns); if (relative_time_ns <= 0) { // physical time has already caught up sufficiently and we do not need to wait anymore return 0; diff --git a/include/core/platform/lf_zephyr_support.h b/include/core/platform/lf_zephyr_support.h index 010eee599..68bd6ab0f 100644 --- a/include/core/platform/lf_zephyr_support.h +++ b/include/core/platform/lf_zephyr_support.h @@ -45,22 +45,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PRINTF_TAG "(" PRINTF_TIME ", " PRINTF_MICROSTEP ")" #define _LF_TIMEOUT 1 -/** - * Time instant. Both physical and logical times are represented - * using this typedef. - */ -typedef int64_t _instant_t; - -/** - * Interval of time. - */ -typedef int64_t _interval_t; - -/** - * Microstep instant. - */ -typedef uint32_t _microstep_t; - #ifdef LF_THREADED typedef struct k_mutex lf_mutex_t; diff --git a/include/core/port.h b/include/core/port.h index 3544b26ae..a8888c8bc 100644 --- a/include/core/port.h +++ b/include/core/port.h @@ -68,7 +68,6 @@ #include #include #include "lf_token.h" // Defines token types and lf_port_base_t, lf_sparse_io_record -#include "utils/vector.h" /** Threshold for width of multiport s.t. sparse reading is supported. */ #define LF_SPARSE_WIDTH_THRESHOLD 10 diff --git a/include/core/reactor.h b/include/core/reactor.h index a70084820..39ef96e9e 100644 --- a/include/core/reactor.h +++ b/include/core/reactor.h @@ -49,19 +49,9 @@ #ifndef REACTOR_H #define REACTOR_H -#include -#include -#include -#include -#include -#include - #include "lf_types.h" -#include "lf_token.h" #include "modes.h" // Modal model support -#include "platform.h" // Platform-specific times and APIs #include "port.h" -#include "pqueue.h" #include "tag.h" // Time-related functions. #include "trace.h" #include "util.h" diff --git a/include/core/tag.h b/include/core/tag.h index 356ea8d8c..86776983f 100644 --- a/include/core/tag.h +++ b/include/core/tag.h @@ -34,10 +34,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef TAG_H #define TAG_H -#include - -#include "platform.h" - #define NSEC(t) (t * 1LL) #define NSECS(t) (t * 1LL) #define USEC(t) (t * 1000LL) @@ -69,6 +65,26 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Convenience for converting times #define BILLION 1000000000LL +#include +#include +#include + +/** + * Time instant. Both physical and logical times are represented + * using this typedef. + */ +typedef int64_t instant_t; + +/** + * Interval of time. + */ +typedef int64_t interval_t; + +/** + * Microstep instant. + */ +typedef uint32_t microstep_t; + /** * Global physical clock offset. * Initially set according to the RTI's clock in federated diff --git a/include/core/threaded/worker_assignments.h b/include/core/threaded/worker_assignments.h index 5bd5d1589..163f1bddc 100644 --- a/include/core/threaded/worker_assignments.h +++ b/include/core/threaded/worker_assignments.h @@ -39,6 +39,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "scheduler.h" #include "util.h" +#include "platform.h" /** The queued reactions. */ static reaction_t**** reactions_by_worker_by_level; diff --git a/lingua-franca-ref.txt b/lingua-franca-ref.txt index 1f7391f92..7f1686ea5 100644 --- a/lingua-franca-ref.txt +++ b/lingua-franca-ref.txt @@ -1 +1 @@ -master +bodyless-reactions