summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/posix_memalign.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-29 17:28:27 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-01-29 17:28:27 +0000
commite0a66c157439fc5512e3406542a5a96667f2e452 (patch)
treedc2d7ae38579af1757a1a0f40dfe31a0450d8b4f /cpukit/libcsupport/src/posix_memalign.c
parent2008-01-29 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-e0a66c157439fc5512e3406542a5a96667f2e452.tar.bz2
2008-01-29 Joel Sherrill <joel.sherrill@OARcorp.com>
* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h, libcsupport/src/malloc_walk.c, libcsupport/src/posix_memalign.c, libcsupport/src/realloc.c, score/src/heapwalk.c: Add rtems_memalign as helper and as exposed nmemalign variant with few restrictions. Also turn on compilation of _Heap_Walk but make forced calls to it conditionally compiled. This should allow more flexibility to the user as to run-time checking of the heap. * libcsupport/src/rtems_memalign.c: New file.
Diffstat (limited to 'cpukit/libcsupport/src/posix_memalign.c')
-rw-r--r--cpukit/libcsupport/src/posix_memalign.c64
1 files changed, 4 insertions, 60 deletions
diff --git a/cpukit/libcsupport/src/posix_memalign.c b/cpukit/libcsupport/src/posix_memalign.c
index 34b6b627e6..19d469e0c1 100644
--- a/cpukit/libcsupport/src/posix_memalign.c
+++ b/cpukit/libcsupport/src/posix_memalign.c
@@ -1,7 +1,7 @@
/*
* posix_memalign()
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -34,69 +34,13 @@ int posix_memalign(
*/
MSBUMP(memalign_calls, 1);
- /*
- * Parameter error checks
- */
- if ( !pointer )
- return EINVAL;
-
- *pointer = NULL;
-
if (((alignment - 1) & alignment) != 0 || (alignment < sizeof(void *)))
return EINVAL;
- if ( !size )
- return EINVAL;
-
- /*
- * 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() )
- return EINVAL;
-
/*
- *
- * If some free's have been deferred, then do them now.
+ * rtems_memalign does all of the error checking work EXCEPT
+ * for adding restrictionso on the alignment.
*/
- malloc_deferred_frees_process();
-
- #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS)
- /*
- * If the support for a boundary area at the end of the heap
- * block allocated is turned on, then adjust the size.
- */
- if (rtems_malloc_boundary_helpers)
- size += (*rtems_malloc_boundary_helpers->overhead)();
- #endif
-
- /*
- * Perform the aligned allocation requested
- */
-
- return_this = _Protected_heap_Allocate_aligned(
- &RTEMS_Malloc_Heap,
- size,
- alignment
- );
- if ( !return_this )
- return ENOMEM;
-
- /*
- * If configured, update the more involved statistics
- */
- if ( rtems_malloc_statistics_helpers )
- (*rtems_malloc_statistics_helpers->at_malloc)(pointer);
-
- #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS)
- /*
- * If configured, set the boundary area
- */
- if (rtems_malloc_boundary_helpers)
- (*rtems_malloc_boundary_helpers->at_malloc)(return_this, size);
- #endif
-
- *pointer = return_this;
- return 0;
+ return rtems_memalign( pointer, alignment, size );
}
#endif