reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1
33#ifndef UTIL_H
34#define UTIL_H
35
36#include <stdarg.h> // Defines va_list
37#include <stdbool.h>
38#include <stdint.h> // Defines int64_t
39
40#include "logging_macros.h"
41
45typedef struct lf_stat_ll {
46 int64_t average;
48 int64_t variance;
49 int64_t max;
51
59#define CONCATENATE_THREE_STRINGS(__string1, __string2, __string3) __string1 __string2 __string3
60
71#define LF_LEVEL(index) (index & 0xffffLL)
72
74#ifndef LF_MAX
75#define LF_MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
76#endif
77
79#ifndef LF_MIN
80#define LF_MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
81#endif
82
89extern uint16_t _lf_my_fed_id;
90
94uint16_t lf_fed_id(void);
95
99void lf_vprint(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
100
104void lf_vprint_log(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
105
109void lf_vprint_debug(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
110
116void error(const char* msg);
117
121void lf_vprint_error(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
122
126void lf_vprint_warning(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
127
131void lf_vprint_error_and_exit(const char* format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1, 0);
132
138#define LF_MUTEX_INIT(mutex) LF_ASSERTN(lf_mutex_init(mutex), "Mutex init failed.")
139
145#define LF_MUTEX_LOCK(mutex) LF_ASSERTN(lf_mutex_lock(mutex), "Mutex lock failed.")
146
152#define LF_MUTEX_UNLOCK(mutex) LF_ASSERTN(lf_mutex_unlock(mutex), "Mutex unlock failed.")
153
160#define LF_COND_INIT(cond, mutex) LF_ASSERTN(lf_cond_init(cond, mutex), "Condition variable init failed.")
161
167#define LF_COND_SIGNAL(cond) LF_ASSERTN(lf_cond_signal(cond), "Condition variable signal failed.")
168
174#define LF_COND_BROADCAST(cond) LF_ASSERTN(lf_cond_broadcast(cond), "Condition variable broadcast failed.")
175
181#define LF_COND_WAIT(cond) LF_ASSERTN(lf_cond_wait(cond), "Condition variable wait failed.")
182
188#define LF_CRITICAL_SECTION_ENTER(env) LF_ASSERT(!lf_critical_section_enter(env), "Could not enter critical section")
189
195#define LF_CRITICAL_SECTION_EXIT(env) LF_ASSERT(!lf_critical_section_exit(env), "Could not exit critical section")
196
197#endif /* UTIL_H */
#define ATTRIBUTE_FORMAT_PRINTF(f, s)
Definition logging.h:10
Definition util.h:45
int64_t standard_deviation
Definition util.h:47
int64_t variance
Definition util.h:48
int64_t max
Definition util.h:49
int64_t average
Definition util.h:46
void lf_vprint(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
void void void lf_vprint_debug(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
uint16_t _lf_my_fed_id
Definition util.c:61
void lf_vprint_error(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
void void lf_vprint_warning(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
void void void lf_vprint_error_and_exit(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
uint16_t lf_fed_id(void)
Definition util.c:72
void void lf_vprint_log(const char *format, va_list args) ATTRIBUTE_FORMAT_PRINTF(1
void void void void error(const char *msg)
struct lf_stat_ll lf_stat_ll