[rtems commit] Use alternative API

Sebastian Huber sebh at rtems.org
Fri Feb 17 16:07:36 UTC 2012


Module:    rtems
Branch:    master
Commit:    77998753b522e28f1b6f92ebab407e1fcaef5296
Changeset: http://git.rtems.org/rtems/commit/?id=77998753b522e28f1b6f92ebab407e1fcaef5296

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Feb 17 16:54:23 2012 +0100

Use alternative API

Replaced Allocate_majority_of_workspace() with
rtems_workspace_allocate().  Replaced Allocate_majority_of_heap() with
rtems_heap_greedy_allocate().

---

 testsuites/psxtests/psxkey01/init.c       |    6 +---
 testsuites/psxtests/psxmsgq02/init.c      |    5 +---
 testsuites/psxtests/psxobj01/init.c       |    3 +-
 testsuites/sptests/spfatal22/testcase.h   |    4 +-
 testsuites/support/include/test_support.h |   18 -------------
 testsuites/support/src/test_support.c     |   39 -----------------------------
 6 files changed, 5 insertions(+), 70 deletions(-)

diff --git a/testsuites/psxtests/psxkey01/init.c b/testsuites/psxtests/psxkey01/init.c
index c7db1df..9f68442 100644
--- a/testsuites/psxtests/psxkey01/init.c
+++ b/testsuites/psxtests/psxkey01/init.c
@@ -17,10 +17,6 @@
 #include "system.h"
 #include <errno.h>
 #include "tmacros.h"
-#include <rtems/score/wkspace.h>
-#include <rtems/score/heap.h>
-
-#include "test_support.h"
 
 void Key_destructor(
    void *key_data
@@ -46,7 +42,7 @@ void *POSIX_Init(
   Init_id = pthread_self();
   printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
 
-  Allocate_majority_of_workspace(84);
+  rtems_workspace_greedy_allocate( 0 );
 
   puts("Init: pthread_key_create - ENOMEM (Workspace not available)");
   empty_line();
diff --git a/testsuites/psxtests/psxmsgq02/init.c b/testsuites/psxtests/psxmsgq02/init.c
index a9cb686..3899294 100644
--- a/testsuites/psxtests/psxmsgq02/init.c
+++ b/testsuites/psxtests/psxmsgq02/init.c
@@ -17,15 +17,12 @@
 #include "system.h"
 #include <errno.h>
 #include "tmacros.h"
-#include <rtems/score/wkspace.h>
-#include <rtems/score/heap.h>
 #include <mqueue.h>
 #include <sched.h>
 #include <fcntl.h>
 #include <time.h>
 #include <tmacros.h>
 #include <signal.h>   /* signal facilities */
-#include "test_support.h"
 
 pthread_t        Init_id;
 
@@ -48,7 +45,7 @@ void *POSIX_Init(
   Init_id = pthread_self();
   printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
 
-  Allocate_majority_of_workspace(NAME_MAX);
+  rtems_workspace_greedy_allocate( 0 );
 
   attr.mq_maxmsg  = MAXMSG;
   attr.mq_msgsize = MSGSIZE;
diff --git a/testsuites/psxtests/psxobj01/init.c b/testsuites/psxtests/psxobj01/init.c
index 8d3cdcb..070b891 100644
--- a/testsuites/psxtests/psxobj01/init.c
+++ b/testsuites/psxtests/psxobj01/init.c
@@ -16,7 +16,6 @@
 
 #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
 #include <tmacros.h>
-#include "test_support.h"
 
 rtems_task Init(
   rtems_task_argument ignored
@@ -70,7 +69,7 @@ rtems_task Init(
 
   /* out of memory error ONLY when POSIX is enabled */
   puts( "INIT - _Objects_Set_name fails - out of memory" );
-  Allocate_majority_of_workspace( 1 );
+  rtems_workspace_greedy_allocate( 0 );
 
   bc = _Objects_Set_name( &TestClass, &_Thread_Executing->Object, name );
   rtems_test_assert( bc == false );
diff --git a/testsuites/sptests/spfatal22/testcase.h b/testsuites/sptests/spfatal22/testcase.h
index d44e647..f8e0fdf 100644
--- a/testsuites/sptests/spfatal22/testcase.h
+++ b/testsuites/sptests/spfatal22/testcase.h
@@ -16,11 +16,11 @@
 #define FATAL_ERROR_EXPECTED_ERROR       RTEMS_NO_MEMORY
 
 #include <rtems/libio.h>
-#include "test_support.h"
+#include <rtems/malloc.h>
 
 void force_error()
 {
-  Allocate_majority_of_heap( 1 );
+  rtems_heap_greedy_allocate( 0 );
 
   rtems_libio_init();
 }
diff --git a/testsuites/support/include/test_support.h b/testsuites/support/include/test_support.h
index f478067..5317113 100644
--- a/testsuites/support/include/test_support.h
+++ b/testsuites/support/include/test_support.h
@@ -17,24 +17,6 @@ extern "C" {
 #endif
 
 /*
- *  Allocate a number of small blocks from the workspace
- *  until the largest free block of memory available is
- *  smaller than smallest.
- *
- *  NOTE: The memory CANNOT be freed.
- */
-void Allocate_majority_of_workspace( int smallest );
-
-/*
- *  Allocate a number of small blocks from the heap
- *  until the largest free block of memory available is
- *  smaller than smallest.
- *
- *  NOTE: The memory CANNOT be freed.
- */
-void Allocate_majority_of_heap( int smallest );
-
-/*
  *  Return a pointer to the POSIX name that is slightly
  *  beyond the legal limit.
  */
diff --git a/testsuites/support/src/test_support.c b/testsuites/support/src/test_support.c
index 757f7b3..207434b 100644
--- a/testsuites/support/src/test_support.c
+++ b/testsuites/support/src/test_support.c
@@ -40,42 +40,3 @@ const char *Get_Longest_Name(void)
   Longest_Name[i] = '\0';
   return Longest_Name;
 }
-
-void Allocate_majority_of_workspace( int smallest )
-{
-  bool                   result;
-  Heap_Information_block info;
-  void                   *temp;
-
-  puts("Allocate_majority_of_workspace: ");
-  result = rtems_workspace_get_information( &info );
-  if ( result != TRUE )
-    perror("==> Error Getting workspace information");
-
-  do {
-    result = rtems_workspace_allocate(
-      info.Free.largest - HEAP_BLOCK_HEADER_SIZE,
-      &temp
-    );
-    if ((!result) || (!temp))
-      perror("Unable to allocate from workspace");
-    result = rtems_workspace_get_information( &info );
-  } while ( info.Free.largest >= smallest );
-
-}
-
-void Allocate_majority_of_heap( int smallest )
-{
-  size_t    size;
-  void     *temp;
-
-  puts("Allocate_majority_of_heap: ");
-  size = malloc_free_space();
-  do {
-    temp = malloc( size - HEAP_BLOCK_HEADER_SIZE );
-    if (!temp)
-      perror("Unable to allocate from workspace");
-    size = malloc_free_space();
-  } while ( size >= smallest );
-
-}




More information about the vc mailing list