Skip to content

Commit

Permalink
fix: heap4 include error
Browse files Browse the repository at this point in the history
  • Loading branch information
hacperme committed Apr 24, 2024
1 parent 9c73aaa commit 913d000
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
12 changes: 7 additions & 5 deletions components/network/inc/esp_mbedtls_dynamic_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@

#include <sys/cdefs.h> //

// #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (const typeof( ((type *)0)->member ) *)(ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

#define __containerof(ptr, type, member) container_of(ptr, type, member)
/* TODO: Remove this once the appropriate solution is found
*
* ssl_misc.h header uses private elements from
Expand All @@ -36,6 +31,13 @@
// #include "esp_log.h"
#include "dlg/dlg.h"

// #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (const typeof( ((type *)0)->member ) *)(ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

#define __containerof(ptr, type, member) container_of(ptr, type, member)

#define TRACE_CHECK(_fn, _state) \
({ \
dlg_info("%d " _state " to do \"%s\"", __LINE__, # _fn); \
Expand Down
2 changes: 2 additions & 0 deletions components/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ file(GLOB_RECURSE SOURCES src/*.c)
sdk_library_add_sources(${SOURCES})
sdk_add_include_directories(inc)

if(CONFIG_USE_HEAP_4)
sdk_add_link_options(
-Wl,--wrap=malloc
-Wl,--wrap=_malloc_r
Expand All @@ -14,3 +15,4 @@ sdk_add_link_options(
-Wl,--wrap=_free_r
-Wl,--wrap=_realloc_r
)
endif()
4 changes: 3 additions & 1 deletion components/utils/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ menuconfig UTILS
default y

if UTILS

config USE_HEAP_4
bool "Use freertos heap_4.c dynamic memory"
default y
endif
2 changes: 1 addition & 1 deletion components/utils/inc/heap4.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __HEAP_4_H__
#define __HEAP_4_H__
#include "config.h"
// #include "config.h"

#include <stdint.h>
#include <stdio.h>
Expand Down

0 comments on commit 913d000

Please sign in to comment.