reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1
9
10#ifndef UTIL_H
11#define UTIL_H
12
13#include <stdarg.h> // Defines va_list
14#include <stdbool.h>
15#include <stdint.h> // Defines int64_t
16
17#include "logging_macros.h"
18
27#define CONCATENATE_THREE_STRINGS(__string1, __string2, __string3) __string1 __string2 __string3
28
40#define LF_LEVEL(index) (index & 0xffffLL)
41
46#ifndef LF_MAX
47#define LF_MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
48#endif
49
54#ifndef LF_MIN
55#define LF_MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
56#endif
57
66extern uint16_t _lf_my_fed_id;
67
72uint16_t lf_fed_id(void);
73
78void lf_vprint(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
79
84void lf_vprint_log(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
85
90void lf_vprint_debug(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
91
98void error(const char* msg);
99
104void lf_vprint_error(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
105
110void lf_vprint_warning(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
111
116void lf_vprint_error_and_exit(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
117
124#define LF_MUTEX_INIT(mutex) LF_ASSERTN(lf_mutex_init(mutex), "Mutex init failed.")
125
132#define LF_MUTEX_LOCK(mutex) LF_ASSERTN(lf_mutex_lock(mutex), "Mutex lock failed.")
133
140#define LF_MUTEX_UNLOCK(mutex) LF_ASSERTN(lf_mutex_unlock(mutex), "Mutex unlock failed.")
141
149#define LF_COND_INIT(cond, mutex) LF_ASSERTN(lf_cond_init(cond, mutex), "Condition variable init failed.")
150
157#define LF_COND_SIGNAL(cond) LF_ASSERTN(lf_cond_signal(cond), "Condition variable signal failed.")
158
165#define LF_COND_BROADCAST(cond) LF_ASSERTN(lf_cond_broadcast(cond), "Condition variable broadcast failed.")
166
173#define LF_COND_WAIT(cond) LF_ASSERTN(lf_cond_wait(cond), "Condition variable wait failed.")
174
181#define LF_CRITICAL_SECTION_ENTER(env) LF_ASSERT(!lf_critical_section_enter(env), "Could not enter critical section")
182
189#define LF_CRITICAL_SECTION_EXIT(env) LF_ASSERT(!lf_critical_section_exit(env), "Could not exit critical section")
190
191#endif /* UTIL_H */
void lf_vprint(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
varargs alternative of "lf_print"
void void void lf_vprint_debug(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
varargs alternative of "lf_print_debug"
uint16_t _lf_my_fed_id
The ID of this federate.
void lf_vprint_error(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
varargs alternative of "lf_print_error"
void void lf_vprint_warning(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
varargs alternative of "lf_print_warning"
void void void lf_vprint_error_and_exit(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
varargs alternative of "lf_print_error_and_exit"
uint16_t lf_fed_id(void)
Return the federate ID or -1 if this program is not part of a federation.
void void lf_vprint_log(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
varargs alternative of "lf_print_log"
void void void void error(const char *msg)
Print the error defined by the errno variable with the specified message as a prefix,...
Logging macros for the logging API.