Revert "move US_TO_NT_MULTIPLIER macro definition in Makefile"

This reverts commit 1efbb324f5.
This commit is contained in:
kifir 2024-05-02 22:47:14 +03:00
parent 7b015d79cc
commit 36e86ccdfa
3 changed files with 7 additions and 18 deletions

View File

@ -5,8 +5,6 @@
PROJECT_DIR = . PROJECT_DIR = .
US_TO_NT_MULTIPLIER = 100
# Imported source files and paths # Imported source files and paths
RUSEFI_LIB = . RUSEFI_LIB = .
include $(RUSEFI_LIB)/util/util.mk include $(RUSEFI_LIB)/util/util.mk
@ -59,7 +57,6 @@ ifeq ($(USE_OPT),)
#USE_OPT = $(RFLAGS) -O2 -fgnu89-inline -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers #USE_OPT = $(RFLAGS) -O2 -fgnu89-inline -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers
USE_OPT = -c -Wall -O0 -ggdb -g USE_OPT = -c -Wall -O0 -ggdb -g
USE_OPT += -Werror=missing-field-initializers -Werror=shadow USE_OPT += -Werror=missing-field-initializers -Werror=shadow
USE_OPT += -D US_TO_NT_MULTIPLIER=$(US_TO_NT_MULTIPLIER)
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).

View File

@ -0,0 +1,3 @@
// test value just for unit tests
#define US_TO_NT_MULTIPLIER 100

View File

@ -1,27 +1,16 @@
#pragma once
#include <type_traits>
#include <global.h>
#include <rusefi/rusefi_time_types.h> #include <rusefi/rusefi_time_types.h>
static_assert(
std::is_same_v<decltype(US_TO_NT_MULTIPLIER), int>,
"US_TO_NT_MULTIPLIER macro should be defined as a positive integer value"
);
constexpr int TICKS_IN_US = US_TO_NT_MULTIPLIER;
static_assert(0 < TICKS_IN_US, "US_TO_NT_MULTIPLIER macro should be defined as a positive integer value");
// microseconds to ticks, but floating point // microseconds to ticks, but floating point
// If converting a floating point time period, use this macro to avoid // If converting a floating point time period, use this macro to avoid
// the expensive conversions from int64 <-> float // the expensive conversions from int64 <-> float
#define USF2NT(us_float) ((us_float) * TICKS_IN_US) #define USF2NT(us_float) ((us_float) * US_TO_NT_MULTIPLIER)
#define USF2MS(us_float) (0.001f * (us_float)) #define USF2MS(us_float) (0.001f * (us_float))
// And back // And back
#define NT2US(x) ((x) / TICKS_IN_US) #define NT2US(x) ((x) / US_TO_NT_MULTIPLIER)
#define NT2USF(x) (((float)(x)) / TICKS_IN_US) #define NT2USF(x) (((float)(x)) / US_TO_NT_MULTIPLIER)
#define NT_PER_SECOND (US2NT(US_PER_SECOND_LL)) #define NT_PER_SECOND (US2NT(US_PER_SECOND_LL))