Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ENABLE_HEAP to #if not defined() #27508

Merged
merged 6 commits into from
Jul 10, 2024
Merged
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
1 change: 0 additions & 1 deletion Tools/ardupilotwaf/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,6 @@ def expand_path(p):

# this makes sure we get the correct subtype
env.DEFINES.update(
ENABLE_HEAP = 0,
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_ESP32_%s' % tt.upper() ,
HAL_HAVE_HARDWARE_DOUBLE = '1',
)
Expand Down
6 changes: 5 additions & 1 deletion libraries/AP_HAL/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "AP_HAL_Namespace.h"
#include <AP_Logger/AP_Logger_config.h>

#ifndef ENABLE_HEAP
#define ENABLE_HEAP 0
#endif

class ExpandingString;

class AP_HAL::Util {
Expand Down Expand Up @@ -154,7 +158,7 @@ class AP_HAL::Util {
virtual void *malloc_type(size_t size, Memory_Type mem_type) { return calloc(1, size); }
virtual void free_type(void *ptr, size_t size, Memory_Type mem_type) { return free(ptr); }

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
// heap functions, note that a heap once alloc'd cannot be dealloc'd
virtual void *allocate_heap_memory(size_t size) = 0;
virtual void *heap_realloc(void *heap, void *ptr, size_t old_size, size_t new_size) = 0;
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_ChibiOS/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void Util::free_type(void *ptr, size_t size, AP_HAL::Util::Memory_Type mem_type)
}


#ifdef ENABLE_HEAP
#if ENABLE_HEAP

void *Util::allocate_heap_memory(size_t size)
{
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_HAL_ChibiOS/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ChibiOS::Util : public AP_HAL::Util {
void *malloc_type(size_t size, AP_HAL::Util::Memory_Type mem_type) override;
void free_type(void *ptr, size_t size, AP_HAL::Util::Memory_Type mem_type) override;

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
// heap functions, note that a heap once alloc'd cannot be dealloc'd
virtual void *allocate_heap_memory(size_t size) override;
virtual void *heap_realloc(void *heap, void *ptr, size_t old_size, size_t new_size) override;
Expand Down Expand Up @@ -143,7 +143,7 @@ class ChibiOS::Util : public AP_HAL::Util {
FlashBootloader flash_bootloader() override;
#endif

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
static memory_heap_t scripting_heap;
#endif // ENABLE_HEAP

Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_ESP32/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void Util::free_type(void *ptr, size_t size, AP_HAL::Util::Memory_Type mem_type)
}


#ifdef ENABLE_HEAP
#if ENABLE_HEAP

void *Util::allocate_heap_memory(size_t size)
{
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_HAL_ESP32/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ESP32::Util : public AP_HAL::Util
void *malloc_type(size_t size, AP_HAL::Util::Memory_Type mem_type) override;
void free_type(void *ptr, size_t size, AP_HAL::Util::Memory_Type mem_type) override;

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
// heap functions, note that a heap once alloc'd cannot be dealloc'd
virtual void *allocate_heap_memory(size_t size) override;
virtual void *heap_realloc(void *heap, void *ptr, size_t old_size, size_t new_size) override;
Expand Down Expand Up @@ -89,7 +89,7 @@ class ESP32::Util : public AP_HAL::Util
FlashBootloader flash_bootloader() override;
#endif

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
// static memory_heap_t scripting_heap;
#endif // ENABLE_HEAP

Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_Linux/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int Util::get_hw_arm32()
return -ENOENT;
}

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
void *Util::allocate_heap_memory(size_t size)
{
struct heap *new_heap = (struct heap*)malloc(sizeof(struct heap));
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_HAL_Linux/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Util : public AP_HAL::Util {
bool get_system_id(char buf[50]) override;
bool get_system_id_unformatted(uint8_t buf[], uint8_t &len) override;

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
// heap functions, note that a heap once alloc'd cannot be dealloc'd
virtual void *allocate_heap_memory(size_t size) override;
virtual void *heap_realloc(void *h, void *ptr, size_t old_size, size_t new_size) override;
Expand Down Expand Up @@ -117,7 +117,7 @@ class Util : public AP_HAL::Util {
const char *custom_defaults = HAL_PARAM_DEFAULTS_PATH;
static const char *_hw_names[UTIL_NUM_HARDWARES];

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
struct heap_allocation_header {
size_t allocation_size; // size of allocated block, not including this header
};
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_HAL_SITL/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool HALSITL::Util::get_system_id(char buf[50])
return get_system_id_unformatted((uint8_t *)buf, len);
}

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
void *HALSITL::Util::allocate_heap_memory(size_t size)
{
struct heap *new_heap = (struct heap*)malloc(sizeof(struct heap));
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_HAL_SITL/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HALSITL::Util : public AP_HAL::Util {
bool get_system_id_unformatted(uint8_t buf[], uint8_t &len) override;
void dump_stack_trace();

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
// heap functions, note that a heap once alloc'd cannot be dealloc'd
void *allocate_heap_memory(size_t size) override;
void *heap_realloc(void *heap, void *ptr, size_t old_size, size_t new_size) override;
Expand Down Expand Up @@ -94,7 +94,7 @@ class HALSITL::Util : public AP_HAL::Util {
static ToneAlarm_SF _toneAlarm;
#endif

#ifdef ENABLE_HEAP
#if ENABLE_HEAP
struct heap_allocation_header {
size_t allocation_size; // size of allocated block, not including this header
};
Expand Down
Loading