mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-06 07:33:17 +00:00
2003-11-26 Joel Sherrill <joel@OARcorp.com>
PR 523/filesystem * src/malloc.c: Make malloc family safer for use from ISRs and dispatching critical sections. If in a critical section while doing a free(), then the free is deferred until the next malloc() attempt.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2003-11-26 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
|
PR 523/filesystem
|
||||||
|
* src/malloc.c: Make malloc family safer for use from ISRs and
|
||||||
|
dispatching critical sections. If in a critical section while doing
|
||||||
|
a free(), then the free is deferred until the next malloc() attempt.
|
||||||
|
|
||||||
2003-11-25 Jennifer Averett <jennifer@OARcorp.com>
|
2003-11-25 Jennifer Averett <jennifer@OARcorp.com>
|
||||||
|
|
||||||
PR 519/filesystem
|
PR 519/filesystem
|
||||||
|
|||||||
@@ -170,11 +170,13 @@ void *malloc(
|
|||||||
* Do not attempt to allocate memory if in a critical section or ISR.
|
* Do not attempt to allocate memory if in a critical section or ISR.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (_System_state_Is_up(_System_state_Get())) {
|
||||||
if (_Thread_Dispatch_disable_level > 0)
|
if (_Thread_Dispatch_disable_level > 0)
|
||||||
return (void *) 0;
|
return (void *) 0;
|
||||||
|
|
||||||
if (_ISR_Nest_level > 0)
|
if (_ISR_Nest_level > 0)
|
||||||
return (void *) 0;
|
return (void *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If some free's have been deferred, then do them now.
|
* If some free's have been deferred, then do them now.
|
||||||
@@ -297,11 +299,13 @@ void *realloc(
|
|||||||
* Do not attempt to allocate memory if in a critical section or ISR.
|
* Do not attempt to allocate memory if in a critical section or ISR.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (_System_state_Is_up(_System_state_Get())) {
|
||||||
if (_Thread_Dispatch_disable_level > 0)
|
if (_Thread_Dispatch_disable_level > 0)
|
||||||
return (void *) 0;
|
return (void *) 0;
|
||||||
|
|
||||||
if (_ISR_Nest_level > 0)
|
if (_ISR_Nest_level > 0)
|
||||||
return (void *) 0;
|
return (void *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Continue with calloc().
|
* Continue with calloc().
|
||||||
@@ -356,10 +360,12 @@ void free(
|
|||||||
* Do not attempt to free memory if in a critical section or ISR.
|
* Do not attempt to free memory if in a critical section or ISR.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (_System_state_Is_up(_System_state_Get())) {
|
||||||
if ((_Thread_Dispatch_disable_level > 0) || (_ISR_Nest_level > 0)) {
|
if ((_Thread_Dispatch_disable_level > 0) || (_ISR_Nest_level > 0)) {
|
||||||
Chain_Append(&RTEMS_Malloc_GC_list, (Chain_Node *)ptr);
|
Chain_Append(&RTEMS_Malloc_GC_list, (Chain_Node *)ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MALLOC_STATS
|
#ifdef MALLOC_STATS
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user