summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-24 15:20:25 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-25 16:08:16 +0100
commit0273349594cd2f87a839bdaf2c33ad7fd26c81f5 (patch)
treec7ed39c984a104aa72024a145c889573d00ed7e9 /cpukit/libcsupport
parentarm: Use CPU_TIMESTAMP_USE_STRUCT_TIMESPEC (diff)
downloadrtems-0273349594cd2f87a839bdaf2c33ad7fd26c81f5.tar.bz2
libcsupport: malloc_is_system_state_OK()
Move system state check to malloc_is_system_state_OK().
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/free.c3
-rw-r--r--cpukit/libcsupport/src/malloc.c5
-rw-r--r--cpukit/libcsupport/src/malloc_deferred.c7
-rw-r--r--cpukit/libcsupport/src/rtems_malloc.c7
-rw-r--r--cpukit/libcsupport/src/rtems_memalign.c5
5 files changed, 7 insertions, 20 deletions
diff --git a/cpukit/libcsupport/src/free.c b/cpukit/libcsupport/src/free.c
index 7bc8e47825..2a7e3d931d 100644
--- a/cpukit/libcsupport/src/free.c
+++ b/cpukit/libcsupport/src/free.c
@@ -36,8 +36,7 @@ void free(
/*
* Do not attempt to free memory if in a critical section or ISR.
*/
- if ( _System_state_Is_up(_System_state_Get()) &&
- !malloc_is_system_state_OK() ) {
+ if ( !malloc_is_system_state_OK() ) {
malloc_deferred_free(ptr);
return;
}
diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c
index 566cfa67e9..4645fdbbcb 100644
--- a/cpukit/libcsupport/src/malloc.c
+++ b/cpukit/libcsupport/src/malloc.c
@@ -24,8 +24,6 @@
#include "malloc_p.h"
-#include <rtems/score/sysstate.h>
-
void *malloc(
size_t size
)
@@ -48,8 +46,7 @@ void *malloc(
/*
* Do not attempt to allocate memory if not in correct system state.
*/
- if ( _System_state_Is_up(_System_state_Get()) &&
- !malloc_is_system_state_OK() )
+ if ( !malloc_is_system_state_OK() )
return NULL;
/*
diff --git a/cpukit/libcsupport/src/malloc_deferred.c b/cpukit/libcsupport/src/malloc_deferred.c
index f15e71153f..81559c4c39 100644
--- a/cpukit/libcsupport/src/malloc_deferred.c
+++ b/cpukit/libcsupport/src/malloc_deferred.c
@@ -27,16 +27,15 @@
#include "malloc_p.h"
+#include <rtems/score/sysstate.h>
#include <rtems/score/threaddispatch.h>
RTEMS_CHAIN_DEFINE_EMPTY(RTEMS_Malloc_GC_list);
bool malloc_is_system_state_OK(void)
{
- if ( !_Thread_Dispatch_is_enabled() )
- return false;
-
- return true;
+ return !_System_state_Is_up( _System_state_Get() )
+ || _Thread_Dispatch_is_enabled();
}
void malloc_deferred_frees_process(void)
diff --git a/cpukit/libcsupport/src/rtems_malloc.c b/cpukit/libcsupport/src/rtems_malloc.c
index 0ba91c1ebc..9eaa1df60e 100644
--- a/cpukit/libcsupport/src/rtems_malloc.c
+++ b/cpukit/libcsupport/src/rtems_malloc.c
@@ -26,18 +26,13 @@
#ifdef RTEMS_NEWLIB
#include "malloc_p.h"
-#include <rtems/score/sysstate.h>
-
void *rtems_heap_allocate_aligned_with_boundary(
size_t size,
uintptr_t alignment,
uintptr_t boundary
)
{
- if (
- _System_state_Is_up( _System_state_Get() )
- && !malloc_is_system_state_OK()
- ) {
+ if ( !malloc_is_system_state_OK() ) {
return NULL;
}
diff --git a/cpukit/libcsupport/src/rtems_memalign.c b/cpukit/libcsupport/src/rtems_memalign.c
index d991f57615..1b9c6bc4b3 100644
--- a/cpukit/libcsupport/src/rtems_memalign.c
+++ b/cpukit/libcsupport/src/rtems_memalign.c
@@ -24,8 +24,6 @@
#include <stdlib.h>
#include <errno.h>
-#include <rtems/score/sysstate.h>
-
int rtems_memalign(
void **pointer,
size_t alignment,
@@ -45,8 +43,7 @@ int rtems_memalign(
/*
* Do not attempt to allocate memory if not in correct system state.
*/
- if ( _System_state_Is_up(_System_state_Get()) &&
- !malloc_is_system_state_OK() )
+ if ( !malloc_is_system_state_OK() )
return EINVAL;
/*