Skip to content

Commit 022447b

Browse files
Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC: optimize _sbrk() (FreeRTOS#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 <[email protected]> Co-authored-by: Rahul Kar <[email protected]>
1 parent 17eeb79 commit 022447b

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
extern void vPortSVCHandler( void );
3535
extern void xPortPendSVHandler( void );
3636
extern void xPortSysTickHandler( void );
37-
extern void uart_init();
37+
extern void uart_init( void );
3838
extern int main();
3939

4040
extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss;

FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern unsigned long g_ulBase;
5353
/**
5454
* @brief initializes the UART emulated hardware
5555
*/
56-
void uart_init()
56+
void uart_init(void)
5757
{
5858
UART0_ADDR->BAUDDIV = 16;
5959
UART0_ADDR->CTRL = UART_CTRL_TX_EN;
@@ -85,7 +85,7 @@ FILE *const stdout = &__stdio;
8585

8686
#else
8787

88-
static void * heap_end = 0;
88+
static char * heap_end = ( char * ) &_heap_bottom;
8989

9090
/**
9191
* @brief not used anywhere in the code
@@ -139,16 +139,9 @@ int _write( __attribute__( ( unused ) ) int file,
139139
*/
140140
void * _sbrk( int incr )
141141
{
142-
char * prev_heap_end;
142+
void * prev_heap_end = heap_end;
143143

144-
if( heap_end == 0 )
145-
{
146-
heap_end = ( void * ) &_heap_bottom;
147-
}
148-
149-
prev_heap_end = heap_end;
150-
151-
if( ( heap_end + incr ) > ( void * ) &_heap_top )
144+
if( ( heap_end + incr ) > ( char * ) &_heap_top )
152145
{
153146
return ( void * ) -1;
154147
}
@@ -202,7 +195,7 @@ void _kill( pid_t pid,
202195
( void ) sig;
203196
}
204197

205-
int _getpid()
198+
int _getpid( void )
206199
{
207200
return 1;
208201
}

0 commit comments

Comments
 (0)