[6cc1c29] | 1 | /* |
---|
[be8bdff] | 2 | * COPYRIGHT (c) 1989-2010. |
---|
[ccc4203] | 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
| 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
| 7 | * http://www.rtems.com/license/LICENSE. |
---|
| 8 | * |
---|
| 9 | * $Id$ |
---|
| 10 | */ |
---|
| 11 | |
---|
[b1305bb] | 12 | #ifdef HAVE_CONFIG_H |
---|
| 13 | #include "config.h" |
---|
| 14 | #endif |
---|
| 15 | |
---|
[ccc4203] | 16 | #include <fcntl.h> |
---|
| 17 | #include <tmacros.h> |
---|
| 18 | #include "test_support.h" |
---|
[be8bdff] | 19 | #include <rtems/libcsupport.h> |
---|
[ccc4203] | 20 | |
---|
| 21 | static char Too_Long_Name[PATH_MAX + 2]; |
---|
| 22 | static char Longest_Name[PATH_MAX + 1]; |
---|
| 23 | |
---|
[b1274bd9] | 24 | const char *Get_Too_Long_Name(void) |
---|
[ccc4203] | 25 | { |
---|
| 26 | int i; |
---|
| 27 | |
---|
| 28 | for ( i=0; i <= PATH_MAX; i++ ) |
---|
| 29 | Too_Long_Name[i] = 'E'; |
---|
| 30 | Too_Long_Name[i] = '\0'; |
---|
| 31 | return Too_Long_Name; |
---|
| 32 | } |
---|
| 33 | |
---|
[a00d2e5f] | 34 | const char *Get_Longest_Name(void) |
---|
[ccc4203] | 35 | { |
---|
| 36 | int i; |
---|
| 37 | |
---|
[288f8498] | 38 | for ( i=0; i < PATH_MAX-1; i++ ) |
---|
[ccc4203] | 39 | Longest_Name[i] = 'L'; |
---|
| 40 | Longest_Name[i] = '\0'; |
---|
| 41 | return Longest_Name; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | void Allocate_majority_of_workspace( int smallest ) |
---|
[b1274bd9] | 45 | { |
---|
[f0157b8] | 46 | bool result; |
---|
[ccc4203] | 47 | Heap_Information_block info; |
---|
| 48 | void *temp; |
---|
| 49 | |
---|
| 50 | puts("Allocate_majority_of_workspace: "); |
---|
| 51 | result = rtems_workspace_get_information( &info ); |
---|
| 52 | if ( result != TRUE ) |
---|
| 53 | perror("==> Error Getting workspace information"); |
---|
| 54 | |
---|
| 55 | do { |
---|
[b1274bd9] | 56 | result = rtems_workspace_allocate( |
---|
[abe5612] | 57 | info.Free.largest - HEAP_BLOCK_HEADER_SIZE, |
---|
[b1274bd9] | 58 | &temp |
---|
[ccc4203] | 59 | ); |
---|
| 60 | if ((!result) || (!temp)) |
---|
| 61 | perror("Unable to allocate from workspace"); |
---|
| 62 | result = rtems_workspace_get_information( &info ); |
---|
| 63 | } while ( info.Free.largest >= smallest ); |
---|
| 64 | |
---|
| 65 | } |
---|
[be8bdff] | 66 | |
---|
| 67 | void Allocate_majority_of_heap( int smallest ) |
---|
| 68 | { |
---|
| 69 | size_t size; |
---|
| 70 | void *temp; |
---|
| 71 | |
---|
| 72 | puts("Allocate_majority_of_heap: "); |
---|
| 73 | size = malloc_free_space(); |
---|
| 74 | do { |
---|
[abe5612] | 75 | temp = malloc( size - HEAP_BLOCK_HEADER_SIZE ); |
---|
[be8bdff] | 76 | if (!temp) |
---|
| 77 | perror("Unable to allocate from workspace"); |
---|
| 78 | size = malloc_free_space(); |
---|
| 79 | } while ( size >= smallest ); |
---|
| 80 | |
---|
| 81 | } |
---|