2020-10-14 11:45:08 +02:00
|
|
|
#ifdef __SUPPORT_VHEX_KERNEL
|
2021-05-09 17:34:00 +02:00
|
|
|
#include <bits/asm/unistd_32.h>
|
2020-10-14 11:45:08 +02:00
|
|
|
.text
|
|
|
|
.global _realloc
|
|
|
|
.type _realloc, @function
|
|
|
|
|
|
|
|
|
|
|
|
.align 2
|
|
|
|
/*
|
|
|
|
** extern void *realloc(void ptr, size_t size)
|
|
|
|
**
|
|
|
|
** @note:
|
|
|
|
** The MMU is used by Casio so we cannot implement brk or skr for technical
|
|
|
|
** reason (non-continius heap, no shared page, ...), so all memory management
|
|
|
|
** is performed by the Vhex kernel.
|
|
|
|
*/
|
|
|
|
_realloc:
|
|
|
|
! Check if the PTR is NULL
|
|
|
|
! In this case, realloc() work like malloc(), so lets call it
|
|
|
|
tst r4, r4
|
|
|
|
bf check_free
|
|
|
|
mov r5, r4
|
2020-10-14 12:18:34 +02:00
|
|
|
trapa #__NR_proc_heap_alloc
|
2020-10-14 11:45:08 +02:00
|
|
|
rts
|
|
|
|
nop
|
|
|
|
|
|
|
|
! Check is the size is NULL
|
|
|
|
! In this case, realloc() work like free(), so lets call it
|
|
|
|
! then return NULL pointer
|
|
|
|
check_free:
|
|
|
|
tst r5, r5
|
|
|
|
bf call_realloc
|
|
|
|
trapa #__NR_proc_heap_free
|
|
|
|
rts
|
|
|
|
xor r0, r0
|
|
|
|
|
|
|
|
! Call realloc
|
|
|
|
call_realloc:
|
|
|
|
trapa #__NR_proc_heap_realloc
|
|
|
|
rts
|
|
|
|
nop
|
|
|
|
.end
|
|
|
|
#endif
|