Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC: optimize _sbrk() (#1211)

Optimize _sbrk() from runtime to compiletime initialization.
Fix compiler warnings by adjusting (void *) and (char *) types.

Complete function declarations for uart_init() and _getpid().

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
pull/1213/head^2
Florian La Roche 10 months ago committed by GitHub
parent 17eeb79698
commit 022447b855
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -34,7 +34,7 @@
extern void vPortSVCHandler( void );
extern void xPortPendSVHandler( void );
extern void xPortSysTickHandler( void );
extern void uart_init();
extern void uart_init( void );
extern int main();
extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss;

@ -53,7 +53,7 @@ extern unsigned long g_ulBase;
/**
* @brief initializes the UART emulated hardware
*/
void uart_init()
void uart_init(void)
{
UART0_ADDR->BAUDDIV = 16;
UART0_ADDR->CTRL = UART_CTRL_TX_EN;
@ -85,7 +85,7 @@ FILE *const stdout = &__stdio;
#else
static void * heap_end = 0;
static char * heap_end = ( char * ) &_heap_bottom;
/**
* @brief not used anywhere in the code
@ -139,16 +139,9 @@ int _write( __attribute__( ( unused ) ) int file,
*/
void * _sbrk( int incr )
{
char * prev_heap_end;
void * prev_heap_end = heap_end;
if( heap_end == 0 )
{
heap_end = ( void * ) &_heap_bottom;
}
prev_heap_end = heap_end;
if( ( heap_end + incr ) > ( void * ) &_heap_top )
if( ( heap_end + incr ) > ( char * ) &_heap_top )
{
return ( void * ) -1;
}
@ -202,7 +195,7 @@ void _kill( pid_t pid,
( void ) sig;
}
int _getpid()
int _getpid( void )
{
return 1;
}

Loading…
Cancel
Save