fix(nvs): Fix possible collision with app trace sysview defines

Global.h defines U8, I8, U16, etc. symbols, which are also used in NVS
as a part of custom enum class and this can cause a compilation error
during macro expansion, when sysview is enabled and FreeRTOS.h is included in NVS
pull/13651/head
Adam Múdry 2024-04-10 16:51:31 +02:00
rodzic 94580bb14a
commit 8e43afef3b
5 zmienionych plików z 85 dodań i 2 usunięć

Wyświetl plik

@ -26,6 +26,18 @@
#define WD_PREFIX "./components/nvs_flash/host_test/nvs_host_test/" // path from ci cwd to the location of host test
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_PUSH();
#undef U8
#undef I8
#undef U16
#undef I16
#undef U32
#undef I32
#undef U64
#undef I64
#endif
stringstream s_perf;
TEST_CASE("crc32 behaves as expected", "[nvs]")
@ -3405,3 +3417,7 @@ TEST_CASE("dump all performance data", "[nvs]")
std::cout << s_perf.str() << std::endl;
std::cout << "====================" << std::endl;
}
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_POP();
#endif

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -10,6 +10,18 @@ static const char* TAG = "nvs_page_host_test";
#include "test_fixtures.hpp"
#include "esp_log.h"
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_PUSH();
#undef U8
#undef I8
#undef U16
#undef I16
#undef U32
#undef I32
#undef U64
#undef I64
#endif
using namespace std;
using namespace nvs;
@ -968,3 +980,7 @@ int main(int argc, char **argv)
int failures = UNITY_END();
return failures;
}
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_POP();
#endif

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -61,6 +61,26 @@ typedef nvs_handle_t nvs_handle IDF_DEPRECATED("Replace with nvs_handle_t");
#define NVS_KEY_NAME_MAX_SIZE 16 /*!< Maximum length of NVS key name (including null terminator) */
#define NVS_NS_NAME_MAX_SIZE NVS_KEY_NAME_MAX_SIZE /*!< Maximum length of NVS namespace name (including null terminator) */
#define NVS_GUARD_SYSVIEW_MACRO_EXPANSION_PUSH() \
_Pragma("push_macro(\"U8\")") \
_Pragma("push_macro(\"I8\")") \
_Pragma("push_macro(\"U16\")") \
_Pragma("push_macro(\"I16\")") \
_Pragma("push_macro(\"U32\")") \
_Pragma("push_macro(\"I32\")") \
_Pragma("push_macro(\"U64\")") \
_Pragma("push_macro(\"I64\")")
#define NVS_GUARD_SYSVIEW_MACRO_EXPANSION_POP() \
_Pragma("pop_macro(\"U8\")") \
_Pragma("pop_macro(\"I8\")") \
_Pragma("pop_macro(\"U16\")") \
_Pragma("pop_macro(\"I16\")") \
_Pragma("pop_macro(\"U32\")") \
_Pragma("pop_macro(\"I32\")") \
_Pragma("pop_macro(\"U64\")") \
_Pragma("pop_macro(\"I64\")")
/**
* @brief Mode of opening the non-volatile storage
*/

Wyświetl plik

@ -9,6 +9,18 @@
namespace nvs {
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_PUSH();
#undef U8
#undef I8
#undef U16
#undef I16
#undef U32
#undef I32
#undef U64
#undef I64
#endif
/**
* The possible blob types. This is a helper definition for template functions.
*/
@ -28,6 +40,9 @@ enum class ItemType : uint8_t {
ANY = NVS_TYPE_ANY
};
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_POP();
#endif
/**
* @brief A handle allowing nvs-entry related operations on the NVS.

Wyświetl plik

@ -23,6 +23,18 @@
#include "esp_log.h"
#define TAG "nvs_storage"
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_PUSH();
#undef U8
#undef I8
#undef U16
#undef I16
#undef U32
#undef I32
#undef U64
#undef I64
#endif
namespace nvs
{
@ -983,3 +995,7 @@ bool Storage::nextEntry(nvs_opaque_iterator_t* it)
}
#if defined(SEGGER_H) && defined(GLOBAL_H)
NVS_GUARD_SYSVIEW_MACRO_EXPANSION_POP();
#endif