mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
commit
70c00c7c83
@ -75,6 +75,11 @@ ifeq ($(STACK_PROTECTOR), 1)
|
|||||||
CFLAGS += -fstack-protector-all -DSTACK_PROTECTOR
|
CFLAGS += -fstack-protector-all -DSTACK_PROTECTOR
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Enable debug printf
|
||||||
|
ifeq ($(FB_ALLOC_STATS), 1)
|
||||||
|
CFLAGS += -DFB_ALLOC_STATS
|
||||||
|
endif
|
||||||
|
|
||||||
# Compiler Flags
|
# Compiler Flags
|
||||||
include $(OMV_BOARD_CONFIG_DIR)/omv_boardconfig.mk
|
include $(OMV_BOARD_CONFIG_DIR)/omv_boardconfig.mk
|
||||||
CFLAGS += -std=gnu99 -Wall -Werror -Warray-bounds -mthumb -nostartfiles -fdata-sections -ffunction-sections
|
CFLAGS += -std=gnu99 -Wall -Werror -Warray-bounds -mthumb -nostartfiles -fdata-sections -ffunction-sections
|
||||||
|
|||||||
@ -13,6 +13,9 @@
|
|||||||
extern char _fballoc;
|
extern char _fballoc;
|
||||||
static char *pointer = &_fballoc;
|
static char *pointer = &_fballoc;
|
||||||
static int marks = 0;
|
static int marks = 0;
|
||||||
|
#if defined(FB_ALLOC_STATS)
|
||||||
|
static uint32_t alloc_bytes;
|
||||||
|
#endif
|
||||||
|
|
||||||
__weak NORETURN void fb_alloc_fail()
|
__weak NORETURN void fb_alloc_fail()
|
||||||
{
|
{
|
||||||
@ -51,6 +54,9 @@ void fb_alloc_mark()
|
|||||||
*((uint32_t *) new_pointer) = sizeof(uint32_t); // Save size.
|
*((uint32_t *) new_pointer) = sizeof(uint32_t); // Save size.
|
||||||
pointer = new_pointer;
|
pointer = new_pointer;
|
||||||
marks += 1;
|
marks += 1;
|
||||||
|
#if defined(FB_ALLOC_STATS)
|
||||||
|
alloc_bytes = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void fb_alloc_free_till_mark()
|
void fb_alloc_free_till_mark()
|
||||||
@ -62,6 +68,9 @@ void fb_alloc_free_till_mark()
|
|||||||
if (size == sizeof(uint32_t)) break; // Break on first marker.
|
if (size == sizeof(uint32_t)) break; // Break on first marker.
|
||||||
}
|
}
|
||||||
marks -= 1;
|
marks -= 1;
|
||||||
|
#if defined(FB_ALLOC_STATS)
|
||||||
|
printf("Total allocated FB memory: %lu bytes\n", alloc_bytes);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns null pointer without error if size==0
|
// returns null pointer without error if size==0
|
||||||
@ -83,6 +92,10 @@ void *fb_alloc(uint32_t size)
|
|||||||
// size is always 4/8/12/etc. so the value below must be 8 or more.
|
// size is always 4/8/12/etc. so the value below must be 8 or more.
|
||||||
*((uint32_t *) new_pointer) = size + sizeof(uint32_t); // Save size.
|
*((uint32_t *) new_pointer) = size + sizeof(uint32_t); // Save size.
|
||||||
pointer = new_pointer;
|
pointer = new_pointer;
|
||||||
|
#if defined(FB_ALLOC_STATS)
|
||||||
|
alloc_bytes += size;
|
||||||
|
printf("fb_alloc %lu bytes\n", size);
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +123,10 @@ void *fb_alloc_all(uint32_t *size)
|
|||||||
// size is always 4/8/12/etc. so the value below must be 8 or more.
|
// size is always 4/8/12/etc. so the value below must be 8 or more.
|
||||||
*((uint32_t *) new_pointer) = *size + sizeof(uint32_t); // Save size.
|
*((uint32_t *) new_pointer) = *size + sizeof(uint32_t); // Save size.
|
||||||
pointer = new_pointer;
|
pointer = new_pointer;
|
||||||
|
#if defined(FB_ALLOC_STATS)
|
||||||
|
alloc_bytes += *size;
|
||||||
|
printf("fb_alloc_all %lu bytes\n", *size);
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user