Skip to content

Commit

Permalink
Merge pull request #428 from lf-lang/trace-plugin-c-linkage-warn
Browse files Browse the repository at this point in the history
Update trace-plugin API
  • Loading branch information
lhstrh authored May 15, 2024
2 parents 2318dad + 9c18b70 commit 3c1fffa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
20 changes: 10 additions & 10 deletions core/reactor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,26 +1038,26 @@ int process_args(int argc, const char* argv[]) {
* core runtime.
*/
#ifdef LF_TRACE
static void check_version(version_t version) {
static void check_version(const version_t* version) {
#ifdef LF_SINGLE_THREADED
LF_ASSERT(version.build_config.single_threaded == TRIBOOL_TRUE ||
version.build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.single_threaded == TRIBOOL_TRUE ||
version->build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
"expected single-threaded version");
#else
LF_ASSERT(version.build_config.single_threaded == TRIBOOL_FALSE ||
version.build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.single_threaded == TRIBOOL_FALSE ||
version->build_config.single_threaded == TRIBOOL_DOES_NOT_MATTER,
"expected multi-threaded version");
#endif
#ifdef NDEBUG
LF_ASSERT(version.build_config.build_type_is_debug == TRIBOOL_FALSE ||
version.build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.build_type_is_debug == TRIBOOL_FALSE ||
version->build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
"expected release version");
#else
LF_ASSERT(version.build_config.build_type_is_debug == TRIBOOL_TRUE ||
version.build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
LF_ASSERT(version->build_config.build_type_is_debug == TRIBOOL_TRUE ||
version->build_config.build_type_is_debug == TRIBOOL_DOES_NOT_MATTER,
"expected debug version");
#endif
LF_ASSERT(version.build_config.log_level == LOG_LEVEL || version.build_config.log_level == INT_MAX,
LF_ASSERT(version->build_config.log_level == LOG_LEVEL || version->build_config.log_level == INT_MAX,
"expected log level %d", LOG_LEVEL);
// assert(!version.core_version_name || strcmp(version.core_version_name, CORE_SHA) == 0); // TODO: provide CORE_SHA
}
Expand Down
10 changes: 9 additions & 1 deletion trace/api/trace.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef TRACE_H
#define TRACE_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>

Expand All @@ -10,7 +14,7 @@
* @brief Return a description of the compile-time properties of the current
* plugin.
*/
version_t lf_version_tracing();
const version_t* lf_version_tracing();

/**
* Identifier for what is in the object table.
Expand Down Expand Up @@ -82,4 +86,8 @@ void lf_tracing_tracepoint(int worker, trace_record_nodeps_t* tr);
*/
void lf_tracing_global_shutdown();

#ifdef __cplusplus
}
#endif

#endif // TRACE_H
27 changes: 12 additions & 15 deletions trace/impl/src/trace_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ static lf_platform_mutex_ptr_t trace_mutex;
static trace_t trace;
static int process_id;
static int64_t start_time;
static version_t version = {.build_config =
{
.single_threaded = TRIBOOL_DOES_NOT_MATTER,
#ifdef NDEBUG
.build_type_is_debug = TRIBOOL_FALSE,
#else
.build_type_is_debug = TRIBOOL_TRUE,
#endif
.log_level = LOG_LEVEL,
},
.core_version_name = NULL};

// PRIVATE HELPERS ***********************************************************

Expand Down Expand Up @@ -192,21 +203,7 @@ static void stop_trace(trace_t* trace) {

// IMPLEMENTATION OF VERSION API *********************************************

version_t lf_version_tracing() {
return (version_t){
.build_config =
(build_config_t){
.single_threaded = TRIBOOL_DOES_NOT_MATTER,
#ifdef NDEBUG
.build_type_is_debug = TRIBOOL_FALSE,
#else
.build_type_is_debug = TRIBOOL_TRUE,
#endif
.log_level = LOG_LEVEL,
},
.core_version_name = NULL,
};
}
const version_t* lf_version_tracing() { return &version; }

// IMPLEMENTATION OF TRACE API ***********************************************

Expand Down

0 comments on commit 3c1fffa

Please sign in to comment.