Skip to content

Commit 5653249

Browse files
committed
Updated changes to match upstream style using uncrustify.
Removed '//D' block comments Removed redundant title sub-string from DEV_DEBUG_ABI_CPP. Moved some operation delete's with respect to build macros such that they were built when needed.
1 parent e948329 commit 5653249

File tree

5 files changed

+42
-59
lines changed

5 files changed

+42
-59
lines changed

cores/esp8266/abi.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
3636

3737

3838
#if DEV_DEBUG_ABI_CPP
39-
extern "C" void _dbg_abi_print_pstr(const char* op, const char *function_name);
40-
#define DEBUG_NEW_OP_PRINTF() _dbg_abi_print_pstr("new_op", __PRETTY_FUNCTION__)
39+
extern "C" void _dbg_abi_print_pstr(const char *function_name);
40+
#define DEBUG_NEW_OP_PRINTF() _dbg_abi_print_pstr(__PRETTY_FUNCTION__)
4141
#else
4242
#define DEBUG_NEW_OP_PRINTF() do { } while (false)
4343
#endif
@@ -148,6 +148,8 @@ void* operator new[] (std::size_t size, std::align_val_t alignment, const std::n
148148
}
149149
}
150150

151+
// default alignment
152+
151153
// new_op
152154
void* operator new (std::size_t size)
153155
{
@@ -288,6 +290,8 @@ void* operator new[] (size_t size, std::align_val_t alignment, const std::nothro
288290
return _heap_abi_memalign(std::size_t(alignment), size, false, __builtin_return_address(0));
289291
}
290292

293+
// default alignment
294+
291295
void* operator new (size_t size)
292296
{
293297
DEBUG_NEW_OP_PRINTF();
@@ -361,16 +365,7 @@ void* operator new[] (size_t size, const std::nothrow_t&)
361365
362366
This saves about 20 bytes in the UMM_ENABLE_MEMALIGN=1 case and 32 bytes when
363367
UMM_ENABLE_MEMALIGN=0.
364-
365368
*/
366-
//D <<
367-
//C temporary pragmas remove before merge
368-
#pragma message("Using weaklink C++ Exception handlers in libstdc")
369-
#if UMM_ENABLE_MEMALIGN
370-
#pragma message("The \"new\" operators that express alignment should work through libstdc via memalign() in the umm_malloc library.")
371-
#endif
372-
//D >>
373-
374369
#endif // #if defined(__cpp_exceptions)
375370

376371

cores/esp8266/heap.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,10 @@ bool abi_new_print = false;
805805
#define DEBUG_ABI_CPP_PRINTF ets_uart_printf
806806

807807
// _dbg_abi_print_pstr is shared (private) between abi.cpp and heap.cpp
808-
extern "C" void _dbg_abi_print_pstr(const char* op, const char *function_name) {
808+
extern "C" void _dbg_abi_print_pstr(const char *function_name) {
809809
if (abi_new_print) {
810810
uint32_t saved_ps = xt_rsil(DEFAULT_CRITICAL_SECTION_INTLEVEL);
811-
DEBUG_HEAP_PRINTF("\nTrace %s: ", op);
811+
DEBUG_HEAP_PRINTF("\nTrace: ");
812812
if (withinISR(saved_ps)) {
813813
DEBUG_HEAP_PRINTF("FN(%p)", function_name);
814814
} else {
@@ -821,7 +821,7 @@ extern "C" void _dbg_abi_print_pstr(const char* op, const char *function_name) {
821821
}
822822
}
823823
// #define DEBUG_DELETE_OP_PRINT_FN() do { _dbg_abi_print_pstr("delete_op", __PRETTY_FUNCTION__, __builtin_return_address(0)); } while (false)
824-
#define DEBUG_DELETE_OP_PRINT_FN() do { _dbg_abi_print_pstr("delete_op", __PRETTY_FUNCTION__); } while (false)
824+
#define DEBUG_DELETE_OP_PRINT_FN() do { _dbg_abi_print_pstr(__PRETTY_FUNCTION__); } while (false)
825825

826826
#else
827827
#define DEBUG_DELETE_OP_PRINT_FN(...) do { } while (false)
@@ -972,57 +972,58 @@ void operator delete[] (void *ptr, const std::nothrow_t&) noexcept
972972
}
973973

974974
// del_opvs
975-
void operator delete[] (void *ptr,[[maybe_unused]]std::size_t size) noexcept
975+
void operator delete[] (void *ptr, [[maybe_unused]]std::size_t size) noexcept
976976
{
977977
DEBUG_DELETE_OP_PRINT_FN();
978978
DEBUG_ABI_CPP_PRINTF(", ptr(%p), size(%u), caller(%p)\n", ptr, size, __builtin_return_address(0));
979979

980980
_heap_delete(ptr, __builtin_return_address(0));
981981
}
982982

983-
#if defined(__cpp_exceptions)
984983
#if defined(UMM_ENABLE_MEMALIGN)
985-
// del_opa
986-
void operator delete (void* ptr, [[maybe_unused]]std::align_val_t alignment) noexcept
984+
985+
// del_opant
986+
void operator delete (void *ptr, [[maybe_unused]]std::align_val_t alignment, const std::nothrow_t&) noexcept
987987
{
988988
DEBUG_DELETE_OP_PRINT_FN();
989-
DEBUG_ABI_CPP_PRINTF(", ptr(%p), alignment(%u), caller(%p)\n", ptr, std::size_t(alignment), __builtin_return_address(0));
989+
DEBUG_ABI_CPP_PRINTF(", ptr(%p), alignment(%u), std::nothrow_t, caller(%p)\n", ptr, std::size_t(alignment), __builtin_return_address(0));
990990

991991
_heap_delete(ptr, __builtin_return_address(0));
992992
}
993993

994-
// del_opant
995-
void operator delete (void *ptr, [[maybe_unused]]std::align_val_t alignment, const std::nothrow_t&) noexcept
994+
// del_opvant
995+
void operator delete[] (void *ptr, [[maybe_unused]]std::align_val_t alignment, const std::nothrow_t&) noexcept
996996
{
997997
DEBUG_DELETE_OP_PRINT_FN();
998998
DEBUG_ABI_CPP_PRINTF(", ptr(%p), alignment(%u), std::nothrow_t, caller(%p)\n", ptr, std::size_t(alignment), __builtin_return_address(0));
999999

10001000
_heap_delete(ptr, __builtin_return_address(0));
10011001
}
1002+
///////////////////////////////////////////////////////////////////////////////
10021003

1003-
// del_opsa
1004-
void operator delete (void* ptr, [[maybe_unused]]std::size_t size, [[maybe_unused]]std::align_val_t alignment) noexcept
1004+
// del_opa
1005+
void operator delete (void* ptr, [[maybe_unused]]std::align_val_t alignment) noexcept
10051006
{
10061007
DEBUG_DELETE_OP_PRINT_FN();
1007-
DEBUG_ABI_CPP_PRINTF(", ptr(%p), size(%u), alignment(%u), caller(%p)\n", ptr, size, std::size_t(alignment), __builtin_return_address(0));
1008+
DEBUG_ABI_CPP_PRINTF(", ptr(%p), alignment(%u), caller(%p)\n", ptr, std::size_t(alignment), __builtin_return_address(0));
10081009

10091010
_heap_delete(ptr, __builtin_return_address(0));
10101011
}
10111012

1012-
// del_opva
1013-
void operator delete[] (void *ptr, [[maybe_unused]]std::align_val_t alignment) noexcept
1013+
// del_opsa
1014+
void operator delete (void* ptr, [[maybe_unused]]std::size_t size, [[maybe_unused]]std::align_val_t alignment) noexcept
10141015
{
10151016
DEBUG_DELETE_OP_PRINT_FN();
1016-
DEBUG_ABI_CPP_PRINTF(", ptr(%p), alignment(%u), caller(%p)\n", ptr, std::size_t(alignment), __builtin_return_address(0));
1017+
DEBUG_ABI_CPP_PRINTF(", ptr(%p), size(%u), alignment(%u), caller(%p)\n", ptr, size, std::size_t(alignment), __builtin_return_address(0));
10171018

10181019
_heap_delete(ptr, __builtin_return_address(0));
10191020
}
10201021

1021-
// del_opvant
1022-
void operator delete[] (void *ptr, [[maybe_unused]]std::align_val_t alignment, const std::nothrow_t&) noexcept
1022+
// del_opva
1023+
void operator delete[] (void *ptr, [[maybe_unused]]std::align_val_t alignment) noexcept
10231024
{
10241025
DEBUG_DELETE_OP_PRINT_FN();
1025-
DEBUG_ABI_CPP_PRINTF(", ptr(%p), alignment(%u), std::nothrow_t, caller(%p)\n", ptr, std::size_t(alignment), __builtin_return_address(0));
1026+
DEBUG_ABI_CPP_PRINTF(", ptr(%p), alignment(%u), caller(%p)\n", ptr, std::size_t(alignment), __builtin_return_address(0));
10261027

10271028
_heap_delete(ptr, __builtin_return_address(0));
10281029
}
@@ -1035,7 +1036,6 @@ void operator delete[] (void *ptr, [[maybe_unused]]std::size_t size, [[maybe_unu
10351036

10361037
_heap_delete(ptr, __builtin_return_address(0));
10371038
}
1038-
#endif // #if defined(UMM_ENABLE_MEMALIGN)
1039-
#endif // #if defined(__cpp_exceptions)
10401039

1041-
#endif
1040+
#endif // #if defined(UMM_ENABLE_MEMALIGN)
1041+
#endif // #if defined(ENABLE_THICK_DEBUG_WRAPPERS)

cores/esp8266/umm_malloc/umm_local.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ static size_t umm_uadd_sat(const size_t a, const size_t b);
3535

3636

3737
#if defined(DEBUG_ESP_OOM) || defined(UMM_POISON_CHECK) \
38-
|| defined(UMM_POISON_CHECK_LITE) || defined(UMM_INTEGRITY_CHECK) \
39-
|| defined(DEBUG_ESP_WITHINISR)
38+
|| defined(UMM_POISON_CHECK_LITE) || defined(UMM_INTEGRITY_CHECK) \
39+
|| defined(DEBUG_ESP_WITHINISR)
4040
#else
4141
#define umm_malloc(s) malloc(s)
4242
#define umm_memalign(a,s) memalign(a,s)

cores/esp8266/umm_malloc/umm_malloc.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,14 @@ void ICACHE_MAYBE umm_init_heap(size_t id, void *start_addr, size_t size, bool f
536536
// Our default target alignment is __STDCPP_DEFAULT_NEW_ALIGNMENT__ == 8
537537
// To return malloc memory 8-byte aligned, we have to sacrifice 4-bytes at
538538
// beginning and end of the heap address space.
539-
#if defined(UMM_LEGACY_ALIGN_4BYTE) && defined(UMM_ENABLE_MEMALIGN)
539+
#if defined(UMM_LEGACY_ALIGN_4BYTE) && defined(UMM_ENABLE_MEMALIGN)
540540
#error "Build option conflict - cannot support both UMM_LEGACY_ALIGN_4BYTE and UMM_ENABLE_MEMALIGN"
541-
#elif defined(UMM_LEGACY_ALIGN_4BYTE)
541+
#elif defined(UMM_LEGACY_ALIGN_4BYTE)
542542
_context->heap = (umm_block *)((uintptr_t)start_addr);
543-
#else
543+
#else
544544
_context->heap = (umm_block *)((uintptr_t)start_addr + 4u);
545545
size -= 4u;
546-
#endif
546+
#endif
547547
_context->numblocks = (size / sizeof(umm_block));
548548
_context->heap_end = (void *)((uintptr_t)_context->heap + _context->numblocks * sizeof(umm_block));
549549

@@ -725,12 +725,12 @@ static void *umm_malloc_core(umm_heap_context_t *_context, size_t size)
725725

726726
STATS__ALLOC_REQUEST(id_malloc, size);
727727

728-
#if UMM_ENABLE_MEMALIGN
728+
#if UMM_ENABLE_MEMALIGN
729729
if (alignment) {
730730
// Pad size to cover alignment adjustments
731731
size += alignment;
732732
}
733-
#endif
733+
#endif
734734

735735
blocks = umm_blocks(size);
736736

@@ -780,7 +780,7 @@ static void *umm_malloc_core(umm_heap_context_t *_context, size_t size)
780780

781781
UMM_FRAGMENTATION_METRIC_REMOVE(cf);
782782

783-
#if UMM_ENABLE_MEMALIGN
783+
#if UMM_ENABLE_MEMALIGN
784784
if (__builtin_expect(alignment, 0u)) {
785785
size_t alignMask = (alignment - 1u);
786786
uintptr_t aptr = (uintptr_t)&UMM_DATA(cf);
@@ -816,7 +816,7 @@ static void *umm_malloc_core(umm_heap_context_t *_context, size_t size)
816816
blocks -= frag;
817817
}
818818
}
819-
#endif
819+
#endif
820820

821821
/*
822822
* This is an existing block in the memory heap, we just need to split off
@@ -957,15 +957,15 @@ void *umm_malloc(size_t size)
957957
return ptr;
958958
}
959959

960-
#if UMM_ENABLE_MEMALIGN
960+
#if UMM_ENABLE_MEMALIGN
961961

962962
/*
963963
* Ensure alignment is power of 2; however, we allow zero.
964964
*/
965965

966966
if (0u != (alignment & (alignment - 1u))) {
967-
STATS__ALIGNMENT_ERROR(id_malloc, alignment);
968-
return ptr;
967+
STATS__ALIGNMENT_ERROR(id_malloc, alignment);
968+
return ptr;
969969
}
970970

971971
/*
@@ -979,7 +979,7 @@ void *umm_malloc(size_t size)
979979
if (alignment <= sizeof(umm_block)) {
980980
alignment = 0u; // Use implementation default/minimum, 8.
981981
}
982-
#endif
982+
#endif
983983

984984
/* Allocate the memory within a protected critical section */
985985

cores/esp8266/umm_malloc/umm_malloc_cfgport.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,6 @@ extern char _heap_start[];
134134
#undef UMM_ENABLE_MEMALIGN
135135
#endif
136136

137-
//D
138-
//D #ifndef __STRINGIFY
139-
//D #define __STRINGIFY(a) #a
140-
//D #endif
141-
//D #define QUOTE(a) __STRINGIFY(a)
142-
//D #pragma message("UMM_ENABLE_MEMALIGN: \"" QUOTE(UMM_ENABLE_MEMALIGN) "\"")
143-
//D #ifdef UMM_ENABLE_MEMALIGN
144-
//D #pragma message("UMM_ENABLE_MEMALIGN defined")
145-
//D #else
146-
//D #pragma message("UMM_ENABLE_MEMALIGN not defined")
147-
//D #endif
148-
149137
/*
150138
* The NONOS SDK API requires function `umm_info()` for implementing
151139
* `system_show_malloc()`. Build option `-DUMM_INFO` enables this support.

0 commit comments

Comments
 (0)