From a231fd1c8afedbeb14b0bc77d76bad61db986059 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 2 May 2024 17:06:25 +1000 Subject: Replace cpp::span shim with std::span --- src/tasks/CMakeLists.txt | 2 +- src/tasks/tasks.cpp | 10 +++++----- src/tasks/tasks.hpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/tasks') diff --git a/src/tasks/CMakeLists.txt b/src/tasks/CMakeLists.txt index 0fdacf78..814c9943 100644 --- a/src/tasks/CMakeLists.txt +++ b/src/tasks/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright 2023 jacqueline # # SPDX-License-Identifier: GPL-3.0-only -idf_component_register(SRCS "tasks.cpp" INCLUDE_DIRS "." REQUIRES "span" "memory") +idf_component_register(SRCS "tasks.cpp" INCLUDE_DIRS "." REQUIRES "memory") target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS}) diff --git a/src/tasks/tasks.cpp b/src/tasks/tasks.cpp index aa382655..d3937c68 100644 --- a/src/tasks/tasks.cpp +++ b/src/tasks/tasks.cpp @@ -33,12 +33,12 @@ auto Name() -> std::pmr::string { } template -auto AllocateStack() -> cpp::span; +auto AllocateStack() -> std::span; // Decoders often require a very large amount of stack space, since they aren't // usually written with embedded use cases in mind. template <> -auto AllocateStack() -> cpp::span { +auto AllocateStack() -> std::span { constexpr std::size_t size = 20 * 1024; static StackType_t sStack[size]; return {sStack, size}; @@ -46,14 +46,14 @@ auto AllocateStack() -> cpp::span { // LVGL requires only a relatively small stack. Lua's stack is allocated // separately. template <> -auto AllocateStack() -> cpp::span { +auto AllocateStack() -> std::span { constexpr std::size_t size = 14 * 1024; static StackType_t sStack[size]; return {sStack, size}; } template <> // PCM conversion and resampling uses a very small amount of stack. -auto AllocateStack() -> cpp::span { +auto AllocateStack() -> std::span { constexpr std::size_t size = 4 * 1024; static StackType_t sStack[size]; return {sStack, size}; @@ -63,7 +63,7 @@ auto AllocateStack() -> cpp::span { // cases, where large stack usage isn't so much of a concern. It therefore uses // an eye-wateringly large amount of stack. template <> -auto AllocateStack() -> cpp::span { +auto AllocateStack() -> std::span { std::size_t size = 64 * 1024; return {static_cast(heap_caps_malloc(size, MALLOC_CAP_SPIRAM)), size}; diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index 47f26837..566b5706 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "esp_heap_caps.h" @@ -19,7 +20,6 @@ #include "freertos/projdefs.h" #include "freertos/queue.h" #include "freertos/task.h" -#include "span.hpp" namespace tasks { @@ -46,7 +46,7 @@ enum class Type { template auto Name() -> std::pmr::string; template -auto AllocateStack() -> cpp::span; +auto AllocateStack() -> std::span; template auto Priority() -> UBaseType_t; @@ -56,7 +56,7 @@ template auto StartPersistent(const std::function& fn) -> void { StaticTask_t* task_buffer = static_cast(heap_caps_malloc( sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); - cpp::span stack = AllocateStack(); + std::span stack = AllocateStack(); xTaskCreateStatic(&PersistentMain, Name().c_str(), stack.size(), new std::function(fn), Priority(), stack.data(), task_buffer); @@ -67,7 +67,7 @@ auto StartPersistent(BaseType_t core, const std::function& fn) -> void { StaticTask_t* task_buffer = static_cast(heap_caps_malloc( sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); - cpp::span stack = AllocateStack(); + std::span stack = AllocateStack(); xTaskCreateStaticPinnedToCore(&PersistentMain, Name().c_str(), stack.size(), new std::function(fn), Priority(), stack.data(), task_buffer, core); -- cgit v1.2.3