Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/core/compiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @file core/compiler.h
*
* @brief Compiler version detection variable
*
* Compiler version detection variable
*
* The variable rootsim_compiler_version is used to detect the compiler version.
* It is set to 0 by default, but it is overridden by the compiler when a model is compiled.
* The macro ROOTSIM_COMPILER_VERSION is used to check the compiler version.
*
* SPDX-FileCopyrightText: 2008-2023 HPDCS Group <rootsim@googlegroups.com>
* SPDX-License-Identifier: GPL-3.0-only
*/
#pragma once

#include <stdint.h>

Check warning

Code scanning / Cppcheck (reported by Codacy)

Include file: <stdint.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Include file: <stdint.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

/// The version of the compiler used to generate a model
uint32_t __attribute__((weak)) rootsim_compiler_version = 0;

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file

misra violation 804 with no text in the supplied rule-texts-file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could declare this variable here rather than defining it inside this header, and define it as a weak symbol inside core.c


/// This macro allows to convert a major, minor and patch version into a single uint32_t
#define ROOTSIM_COMPILER_VERSION(a,b,c) (uint32_t)(((a) << 16) + ((b) << 8) + (c))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we used an array of three unsigned chars to represent the version, we wouldn't need a macro to set it (or to read it, even if the corresponding macros haven't been defined)

1 change: 1 addition & 0 deletions src/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
#include <core/core.h>
#include <core/compiler.h>

Check warning

Code scanning / Cppcheck (reported by Codacy)

Include file: <core/compiler.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Include file: <core/compiler.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

__thread rid_t rid;
nid_t n_nodes = 1;
Expand Down