comparison packages/language/c/libc/current/tests/stdlib/malloc2.c @ 2:443894e2e912 ecos-v1_2_1-release

Block commit of eCos version 1.2.1
author jlarmour
date Tue, 11 May 1999 12:24:34 +0000
parents 3111d98ba7b3
children c38311975d4f
comparison
equal deleted inserted replaced
1:72f549f0d891 2:443894e2e912
20 // 20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released 21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998. 22 // September 30, 1998.
23 // 23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created 24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.
26 // ------------------------------------------- 26 // -------------------------------------------
27 // 27 //
28 //####COPYRIGHTEND#### 28 //####COPYRIGHTEND####
29 //================================================================= 29 //=================================================================
30 //#####DESCRIPTIONBEGIN#### 30 //#####DESCRIPTIONBEGIN####
31 // 31 //
32 // Author(s): jlarmour@cygnus.co.uk 32 // Author(s): jlarmour
33 // Contributors: jlarmour@cygnus.co.uk 33 // Contributors: jlarmour
34 // Date: 1998/6/3 34 // Date: 1998/6/3
35 // Description: Contains testcode to stress-test C library malloc(), 35 // Description: Contains testcode to stress-test C library malloc(),
36 // calloc() and free() functions 36 // calloc() and free() functions
37 // 37 //
38 // 38 //
43 // TESTCASE_TYPE=CYG_TEST_MODULE 43 // TESTCASE_TYPE=CYG_TEST_MODULE
44 // CYG_TEST_HEARTBEAT=120 44 // CYG_TEST_HEARTBEAT=120
45 45
46 // INCLUDES 46 // INCLUDES
47 47
48 #include <pkgconf/libc.h> // config header for C library so we can know size 48 #include <pkgconf/system.h> // Overall system configuration
49 // of malloc pool 49 #include <pkgconf/libc.h> // config header for C library so we can know
50 // size of malloc pool
50 #include <stdlib.h> 51 #include <stdlib.h>
51 #include <cyg/infra/testcase.h> 52 #include <cyg/infra/testcase.h>
52 #include <sys/cstartup.h> // C library initialisation 53 #include <sys/cstartup.h> // C library initialisation
53 54 #ifdef CYGPKG_KERNEL
55 # include <pkgconf/kernel.h> // CYGSEM_KERNEL_MEMORY_COALESCE
56 #endif
54 57
55 // CONSTANTS 58 // CONSTANTS
56 59
57 #define NUM_ITERATIONS 1000 60 #define NUM_ITERATIONS 1000
58 61
59 // GLOBALS 62 // GLOBALS
60 63
61 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) 64 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) && \
65 defined(CYGSEM_KERNEL_MEMORY_COALESCE)
62 static int problem=0; 66 static int problem=0;
63 #endif 67 #endif
64 68
65 // FUNCTIONS 69 // FUNCTIONS
66 70
74 (void)main(0, NULL); 78 (void)main(0, NULL);
75 #endif 79 #endif
76 } // cyg_package_start() 80 } // cyg_package_start()
77 81
78 82
79 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) 83 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) && \
84 defined(CYGSEM_KERNEL_MEMORY_COALESCE)
80 85
81 static void * 86 static void *
82 safe_malloc( size_t size ) 87 safe_malloc( size_t size )
83 { 88 {
84 void *ptr; 89 void *ptr;
157 return; 162 return;
158 } // if 163 } // if
159 164
160 } // fill_with_data() 165 } // fill_with_data()
161 166
162 #endif // if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) 167 #endif // if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) &&
168 // defined(CYGSEM_KERNEL_MEMORY_COALESCE)
163 169
164 int 170 int
165 main( int argc, char *argv[] ) 171 main( int argc, char *argv[] )
166 { 172 {
167 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) 173 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) && \
174 defined(CYGSEM_KERNEL_MEMORY_COALESCE)
175
168 char *str1, *str2, *str3; 176 char *str1, *str2, *str3;
169 int j; 177 int j;
170 #endif 178 #endif
171 179
172 CYG_TEST_INIT(); 180 CYG_TEST_INIT();
173 181
174 CYG_TEST_INFO("Starting stress tests from testcase " __FILE__ " for C " 182 CYG_TEST_INFO("Starting stress tests from testcase " __FILE__ " for C "
175 "library malloc(), calloc() and free() functions"); 183 "library malloc(), calloc() and free() functions");
176 184
177 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) 185 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) && \
186 defined(CYGSEM_KERNEL_MEMORY_COALESCE)
178 187
179 if ( CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE < 300 ) 188 if ( CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE < 300 )
180 { 189 {
181 CYG_TEST_FAIL_FINISH("This testcase cannot safely be used with a " 190 CYG_TEST_FAIL_FINISH("This testcase cannot safely be used with a "
182 "memory pool for malloc less than 300 bytes"); 191 "memory pool for malloc less than 300 bytes");
227 // Did it completely successfully? 236 // Did it completely successfully?
228 if (j==NUM_ITERATIONS) 237 if (j==NUM_ITERATIONS)
229 CYG_TEST_PASS("Stress test completed successfully"); 238 CYG_TEST_PASS("Stress test completed successfully");
230 239
231 #else 240 #else
232 CYG_TEST_PASS("Testing is not applicable to this configuration"); 241 CYG_TEST_NA("Testing is not applicable to this configuration");
233 #endif // if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) 242 #endif // if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_MALLOC) &&
243 // defined(CYGSEM_KERNEL_MEMORY_COALESCE)
234 244
235 245
236 CYG_TEST_FINISH("Finished stress tests from testcase " __FILE__ " for C " 246 CYG_TEST_FINISH("Finished stress tests from testcase " __FILE__ " for C "
237 "library malloc(), calloc() and free() functions"); 247 "library malloc(), calloc() and free() functions");
238 } // main() 248 } // main()