@@ -146,8 +146,8 @@ extern "C" {
146
146
*
147
147
* Support debug wrappers that need to include handling poison
148
148
*/
149
- #define UMM_MALLOC_FL ( s,f,l,c ) umm_poison_malloc(s)
150
- #define UMM_CALLOC_FL (n,s,f,l,c ) umm_poison_calloc(n,s)
149
+ #define UMM_MALLOC ( s ) umm_poison_malloc(s)
150
+ #define UMM_CALLOC (n,s ) umm_poison_calloc(n,s)
151
151
#define UMM_REALLOC_FL (p,s,f,l,c ) umm_poison_realloc_flc(p,s,f,l,c)
152
152
#define UMM_FREE_FL (p,f,l,c ) umm_poison_free_flc(p,f,l,c)
153
153
#define ENABLE_THICK_DEBUG_WRAPPERS
@@ -161,19 +161,19 @@ extern "C" {
161
161
*
162
162
* Support debug wrappers that need to include handling poison
163
163
*/
164
- #define UMM_MALLOC_FL ( s,f,l,c ) umm_poison_malloc(s)
165
- #define UMM_CALLOC_FL (n,s,f,l,c ) umm_poison_calloc(n,s)
164
+ #define UMM_MALLOC ( s ) umm_poison_malloc(s)
165
+ #define UMM_CALLOC (n,s ) umm_poison_calloc(n,s)
166
166
#define UMM_REALLOC_FL (p,s,f,l,c ) umm_poison_realloc(p,s)
167
167
#define UMM_FREE_FL (p,f,l,c ) umm_poison_free(p)
168
168
#define ENABLE_THICK_DEBUG_WRAPPERS
169
169
170
170
#undef realloc
171
171
#undef free
172
172
173
- #elif defined(DEBUG_ESP_OOM) || defined(UMM_INTEGRITY_CHECK) || defined(DEBUG_ESP_WITHINISR) || defined(HEAP_DEBUG_PROBE_PSFLC_CB)
173
+ #elif defined(DEBUG_ESP_OOM) || defined(UMM_INTEGRITY_CHECK) || defined(DEBUG_ESP_WITHINISR)
174
174
// All other debug wrappers that do not require handling poison
175
- #define UMM_MALLOC_FL ( s,f,l,c ) umm_malloc(s)
176
- #define UMM_CALLOC_FL (n,s,f,l,c ) umm_calloc(n,s)
175
+ #define UMM_MALLOC ( s ) umm_malloc(s)
176
+ #define UMM_CALLOC (n,s ) umm_calloc(n,s)
177
177
#define UMM_REALLOC_FL (p,s,f,l,c ) umm_realloc(p,s)
178
178
#define UMM_FREE_FL (p,f,l,c ) umm_free(p)
179
179
#define ENABLE_THICK_DEBUG_WRAPPERS
@@ -241,19 +241,19 @@ extern "C" {
241
241
// always track last failed caller and size requested
242
242
#if defined(DEBUG_ESP_OOM)
243
243
struct umm_last_fail_alloc {
244
- const void *addr;
245
- size_t size;
246
- const char *file;
247
- int line;
248
- } _umm_last_fail_alloc = { NULL , 0 , NULL , 0 } ;
244
+ const void *addr = { nullptr } ;
245
+ size_t size = { 0 } ;
246
+ const char *file = { nullptr } ;
247
+ int line = { 0 } ;
248
+ } _umm_last_fail_alloc;
249
249
250
250
#else
251
251
// Note for the least used case "(defined(__cpp_exceptions) &&
252
252
// !defined(DEBUG_ESP_OOM))", we only capture details for LIBC calls.
253
253
struct umm_last_fail_alloc {
254
- const void *addr;
255
- size_t size;
256
- } _umm_last_fail_alloc = { NULL , 0 } ;
254
+ const void *addr = { nullptr } ;
255
+ size_t size = { 0 } ;
256
+ } _umm_last_fail_alloc;
257
257
#endif
258
258
259
259
@@ -314,7 +314,7 @@ static bool IRAM_ATTR oom_check__log_last_fail_atomic_psflc(void *ptr, size_t si
314
314
return true ;
315
315
}
316
316
#define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, f, l, c ) oom_check__log_last_fail_atomic_psflc(p, s, f, l, c)
317
- #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, f, l, c ) ({ (void )p, ( void )s, ( void )f ; (void )l ; (void )c; true ; })
317
+ #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, c ) ({ (void )p; (void )s ; (void )c; true ; })
318
318
319
319
#elif defined(ENABLE_THICK_DEBUG_WRAPPERS)
320
320
static bool IRAM_ATTR oom_check__log_last_fail_atomic_psc (void *ptr, size_t size, const void * caller) {
@@ -329,7 +329,7 @@ static bool IRAM_ATTR oom_check__log_last_fail_atomic_psc(void *ptr, size_t size
329
329
return true ;
330
330
}
331
331
#define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, f, l, c ) oom_check__log_last_fail_atomic_psc(p, s, c)
332
- #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, f, l, c ) ({ (void )p, ( void )s, ( void )f ; (void )l ; (void )c; true ; })
332
+ #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, c ) ({ (void )p; (void )s ; (void )c; true ; })
333
333
334
334
#else
335
335
// At this location, the macro is only used by Heap API families "new" and
@@ -344,8 +344,8 @@ static bool oom_check__log_last_fail_psc(void *ptr, size_t size, const void* cal
344
344
return true ;
345
345
}
346
346
// Used to capture minumum OOM info for "new" and LIBC
347
- #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, f, l, c ) oom_check__log_last_fail_psc(p, s, c)
348
- #define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, f, l, c ) ({ (void )p, ( void )s, ( void )f ; (void )l ; (void )c; true ; })
347
+ #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, c ) oom_check__log_last_fail_psc(p, s, c)
348
+ #define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, c ) ({ (void )p; (void )s ; (void )c; true ; })
349
349
#endif
350
350
351
351
@@ -398,26 +398,26 @@ static void isr_check__flash_not_safe(const void *caller) {
398
398
// * "fancy macros" that call heap_pvPortMalloc, ...
399
399
// * Fallback for uncapture malloc API calls, malloc, ...
400
400
//
401
- void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
401
+ void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
402
402
{
403
403
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
404
404
POISON_CHECK__PANIC_FL (file, line, caller);
405
- void * ret = UMM_MALLOC_FL (size, file, line, caller );
405
+ void * ret = UMM_MALLOC (size);
406
406
OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, file, line, caller);
407
407
return ret;
408
408
}
409
409
410
- void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
410
+ void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
411
411
{
412
412
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
413
413
POISON_CHECK__PANIC_FL (file, line, caller);
414
414
size_t total_size = umm_umul_sat (count, size);
415
- void * ret = UMM_CALLOC_FL (1 , total_size, file, line, caller );
415
+ void * ret = UMM_CALLOC (1 , total_size);
416
416
OOM_CHECK__LOG_LAST_FAIL_FL (ret, total_size, file, line, caller);
417
417
return ret;
418
418
}
419
419
420
- void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
420
+ void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
421
421
{
422
422
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
423
423
POISON_CHECK__PANIC_FL (file, line, caller);
@@ -426,7 +426,7 @@ void* IRAM_ATTR _heap_pvPortRealloc(void *ptr, size_t size, const char* file, in
426
426
return ret;
427
427
}
428
428
429
- void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, [[maybe_unused]] const void * caller)
429
+ void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, [[maybe_unused]] const void * caller)
430
430
{
431
431
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
432
432
POISON_CHECK__PANIC_FL (file, line, caller);
@@ -448,12 +448,12 @@ void* IRAM_ATTR heap_pvPortCalloc(size_t count, size_t size, const char* file, i
448
448
return _heap_pvPortCalloc (count, size, file, line, __builtin_return_address (0 ));
449
449
}
450
450
451
- void * IRAM_ATTR heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line)
451
+ void * IRAM_ATTR heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line)
452
452
{
453
453
return _heap_pvPortRealloc (ptr, size, file, line, __builtin_return_address (0 ));
454
454
}
455
455
456
- void IRAM_ATTR heap_vPortFree (void * ptr, const char * file, int line)
456
+ void IRAM_ATTR heap_vPortFree (void * ptr, const char * file, int line)
457
457
{
458
458
return _heap_vPortFree (ptr, file, line, __builtin_return_address (0 ));
459
459
}
@@ -489,7 +489,7 @@ void IRAM_ATTR free(void* ptr)
489
489
#define STATIC_ALWAYS_INLINE static ALWAYS_INLINE
490
490
491
491
STATIC_ALWAYS_INLINE
492
- void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
492
+ void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
493
493
{
494
494
(void )file;
495
495
(void )line;
@@ -498,7 +498,7 @@ void* IRAM_ATTR _heap_pvPortMalloc(size_t size, const char* file, int line, cons
498
498
}
499
499
500
500
STATIC_ALWAYS_INLINE
501
- void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
501
+ void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
502
502
{
503
503
(void )file;
504
504
(void )line;
@@ -507,7 +507,7 @@ void* IRAM_ATTR _heap_pvPortCalloc(size_t count, size_t size, const char* file,
507
507
}
508
508
509
509
STATIC_ALWAYS_INLINE
510
- void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
510
+ void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
511
511
{
512
512
(void )file;
513
513
(void )line;
@@ -516,7 +516,7 @@ void* IRAM_ATTR _heap_pvPortRealloc(void *ptr, size_t size, const char* file, in
516
516
}
517
517
518
518
STATIC_ALWAYS_INLINE
519
- void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, const void * caller)
519
+ void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, const void * caller)
520
520
{
521
521
(void )file;
522
522
(void )line;
@@ -532,37 +532,37 @@ void IRAM_ATTR _heap_vPortFree(void *ptr, const char* file, int line, const void
532
532
void * _malloc_r (struct _reent * unused, size_t size)
533
533
{
534
534
(void ) unused;
535
- void * caller = __builtin_return_address (0 );
535
+ void * caller = __builtin_return_address (0 );
536
536
ISR_CHECK__LOG_NOT_SAFE (caller);
537
537
void * ret = _heap_pvPortMalloc (size, NULL , 0 , caller);
538
- OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, NULL , 0 , caller);
538
+ OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
539
539
return ret;
540
540
}
541
541
542
542
void * _calloc_r (struct _reent * unused, size_t count, size_t size)
543
543
{
544
544
(void ) unused;
545
- void * caller = __builtin_return_address (0 );
545
+ void * caller = __builtin_return_address (0 );
546
546
ISR_CHECK__LOG_NOT_SAFE (caller);
547
547
void * ret = _heap_pvPortCalloc (count, size, NULL , 0 , caller);
548
- OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, NULL , 0 , caller);
548
+ OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
549
549
return ret;
550
550
}
551
551
552
552
void * _realloc_r (struct _reent * unused, void * ptr, size_t size)
553
553
{
554
554
(void ) unused;
555
- void * caller = __builtin_return_address (0 );
555
+ void * caller = __builtin_return_address (0 );
556
556
ISR_CHECK__LOG_NOT_SAFE (caller);
557
557
void * ret = _heap_pvPortRealloc (ptr, size, NULL , 0 , caller);
558
- OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, NULL , 0 , caller);
558
+ OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
559
559
return ret;
560
560
}
561
561
562
562
void _free_r (struct _reent * unused, void * ptr)
563
563
{
564
564
(void ) unused;
565
- void * caller = __builtin_return_address (0 );
565
+ void * caller = __builtin_return_address (0 );
566
566
ISR_CHECK__LOG_NOT_SAFE (caller);
567
567
_heap_vPortFree (ptr, NULL , 0 , caller);
568
568
}
@@ -590,7 +590,7 @@ void* IRAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int li
590
590
return _heap_pvPortCalloc (count, size, file, line, __builtin_return_address (0 ));
591
591
}
592
592
593
- void * IRAM_ATTR pvPortRealloc (void * ptr, size_t size, const char * file, int line)
593
+ void * IRAM_ATTR pvPortRealloc (void * ptr, size_t size, const char * file, int line)
594
594
{
595
595
HeapSelectDram ephemeral;
596
596
return _heap_pvPortRealloc (ptr, size, file, line, __builtin_return_address (0 ));
@@ -602,7 +602,7 @@ void* IRAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
602
602
return _heap_pvPortCalloc (1 , size, file, line, __builtin_return_address (0 ));
603
603
}
604
604
605
- void IRAM_ATTR vPortFree (void * ptr, const char * file, int line)
605
+ void IRAM_ATTR vPortFree (void * ptr, const char * file, int line)
606
606
{
607
607
#if defined(UMM_POISON_CHECK) || defined(UMM_INTEGRITY_CHECK)
608
608
// While umm_free internally determines the correct heap, UMM_POISON_CHECK
@@ -639,19 +639,16 @@ void system_show_malloc(void)
639
639
// heap allocator for "new" (ABI) - To support collecting OOM info, always defined
640
640
void * _heap_abi_malloc (size_t size, bool unhandled, const void * caller)
641
641
{
642
- [[maybe_unused]] const char *file = NULL ;
643
- [[maybe_unused]] const int line = 0 ;
644
-
645
642
#ifdef ENABLE_THICK_DEBUG_WRAPPERS
646
643
ISR_CHECK__LOG_NOT_SAFE (caller);
647
- INTEGRITY_CHECK__PANIC_FL (file, line , caller);
648
- POISON_CHECK__PANIC_FL (file, line , caller);
649
- void * ret = UMM_MALLOC_FL (size, file, line, caller );
650
- bool ok = OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, file, line , caller);
644
+ INTEGRITY_CHECK__PANIC_FL (NULL , 0 , caller);
645
+ POISON_CHECK__PANIC_FL (NULL , 0 , caller);
646
+ void * ret = UMM_MALLOC (size);
647
+ bool ok = OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, NULL , 0 , caller);
651
648
#else
652
649
void * ret = UMM_MALLOC (size);
653
650
// minimum OOM check
654
- bool ok = OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, file, line, caller);
651
+ bool ok = OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
655
652
#endif
656
653
if (!ok && unhandled) {
657
654
__unhandled_exception (PSTR (" OOM" ));
@@ -767,22 +764,22 @@ uint32 IRAM_ATTR user_iram_memory_is_enabled(void)
767
764
//
768
765
#include < bits/c++config.h>
769
766
#include < cstdlib>
770
- #include " new"
767
+ #include < new>
771
768
772
769
// The sized deletes are defined in other files.
773
770
#pragma GCC diagnostic ignored "-Wsized-deallocation"
774
771
775
772
// These function replace their weak counterparts tagged with _GLIBCXX_WEAK_DEFINITION
776
773
void operator delete (void * ptr) noexcept
777
774
{
778
- void * caller = __builtin_return_address (0 );
775
+ void * caller = __builtin_return_address (0 );
779
776
ISR_CHECK__LOG_NOT_SAFE (caller);
780
777
_heap_vPortFree (ptr, NULL , 0 , caller);
781
778
}
782
779
783
780
void operator delete (void * ptr, std::size_t ) noexcept
784
781
{
785
- void * caller = __builtin_return_address (0 );
782
+ void * caller = __builtin_return_address (0 );
786
783
ISR_CHECK__LOG_NOT_SAFE (caller);
787
784
_heap_vPortFree (ptr, NULL , 0 , caller);
788
785
}
0 commit comments