Mercurial > ecos
comparison packages/language/c/libc/current/src/stdlib/malloc.cxx @ 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 | e97d78785e2d |
comparison
equal
deleted
inserted
replaced
| 1:72f549f0d891 | 2:443894e2e912 |
|---|---|
| 1 //======================================================================== | 1 //======================================================================== |
| 2 // | 2 // |
| 3 // malloc.cxx | 3 // malloc.cxx |
| 4 // | 4 // |
| 5 // Implementation of ANSI standard allocation routines | 5 // Implementation of ISO C memory allocation routines |
| 6 // | 6 // |
| 7 //======================================================================== | 7 //======================================================================== |
| 8 //####COPYRIGHTBEGIN#### | 8 //####COPYRIGHTBEGIN#### |
| 9 // | 9 // |
| 10 // ------------------------------------------- | 10 // ------------------------------------------- |
| 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-02-13 | 34 // Date: 1999-01-21 |
| 35 // Purpose: | 35 // Purpose: Provides ISO C calloc(), malloc(), realloc() and free() |
| 36 // Description: Implementation of ANSI standard allocation routines as per | 36 // functions |
| 37 // ANSI section 7.10.3 | 37 // Description: Implementation of ANSI standard allocation routines as per |
| 38 // ISO C section 7.10.3 | |
| 38 // Usage: | 39 // Usage: |
| 39 // | 40 // |
| 40 //####DESCRIPTIONEND#### | 41 //####DESCRIPTIONEND#### |
| 41 // | 42 // |
| 42 //======================================================================== | 43 //======================================================================== |
| 43 | 44 |
| 44 // CONFIGURATION | 45 // CONFIGURATION |
| 45 | 46 |
| 46 #include <pkgconf/libc.h> // Configuration header | 47 #include <pkgconf/libc.h> // Configuration header |
| 47 | 48 |
| 48 // Include the C library? | 49 // Do we want these functions? |
| 49 #ifdef CYGPKG_LIBC | |
| 50 | |
| 51 // And do we want these functions? | |
| 52 #ifdef CYGPKG_LIBC_MALLOC | 50 #ifdef CYGPKG_LIBC_MALLOC |
| 53 | 51 |
| 54 // INCLUDES | 52 // INCLUDES |
| 55 | 53 |
| 56 #include <cyg/infra/cyg_type.h> // Common type definitions and support | 54 #include <cyg/infra/cyg_type.h> // Common type definitions and support |
| 57 #include <cyg/infra/cyg_trac.h> // Common tracing support | 55 #include <cyg/infra/cyg_trac.h> // Common tracing support |
| 58 #include <cyg/infra/cyg_ass.h> // Common assertion support | 56 #include <cyg/infra/cyg_ass.h> // Common assertion support |
| 59 #include <string.h> // For memset() and memcpy() | 57 #include <string.h> // For memset() and memcpy() |
| 60 #include <stdlib.h> // header for this file | 58 #include <stdlib.h> // header for this file |
| 59 #include <pkgconf/kernel.h> // kernel configuration | |
| 61 #include <cyg/kernel/memvar.hxx> // Kernel variable size block allocator | 60 #include <cyg/kernel/memvar.hxx> // Kernel variable size block allocator |
| 62 | 61 |
| 63 #include "clibincl/stdlibsupp.hxx" // Additional support for stdlib stuff | 62 #include "clibincl/stdlibsupp.hxx" // Additional support for stdlib stuff |
| 64 // internal to the C library | 63 // internal to the C library |
| 65 | 64 |
| 66 // EXPORTED SYMBOLS | 65 // EXPORTED SYMBOLS |
| 67 | 66 |
| 68 externC void * | 67 externC void * |
| 69 calloc( size_t, size_t ) CYGPRI_LIBC_WEAK_ALIAS("_calloc"); | 68 calloc( size_t, size_t ) CYGBLD_ATTRIB_WEAK_ALIAS(_calloc); |
| 70 | 69 |
| 71 externC void | 70 externC void |
| 72 free( void * ) CYGPRI_LIBC_WEAK_ALIAS("_free"); | 71 free( void * ) CYGBLD_ATTRIB_WEAK_ALIAS(_free); |
| 73 | 72 |
| 74 externC void * | 73 externC void * |
| 75 malloc( size_t ) CYGPRI_LIBC_WEAK_ALIAS("_malloc"); | 74 malloc( size_t ) CYGBLD_ATTRIB_WEAK_ALIAS(_malloc); |
| 76 | 75 |
| 77 externC void * | 76 externC void * |
| 78 realloc( void *, size_t ) CYGPRI_LIBC_WEAK_ALIAS("_realloc"); | 77 realloc( void *, size_t ) CYGBLD_ATTRIB_WEAK_ALIAS(_realloc); |
| 79 | 78 |
| 80 | 79 |
| 81 // STATIC VARIABLES | 80 // STATIC VARIABLES |
| 82 | 81 |
| 83 // the data space for the memory pool | 82 // the data space for the memory pool - can be externally overriden |
| 84 static cyg_uint8 pooldata[ CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE ]; | 83 // FIXME: but should be in different file for this to work |
| 84 cyg_uint8 cyg_libc_malloc_memorypool[ CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE ] | |
| 85 CYGBLD_ATTRIB_WEAK; | |
| 85 | 86 |
| 86 // the memory pool object itself | 87 // the memory pool object itself |
| 87 static Cyg_Mempool_Variable pool CYG_INIT_PRIORITY( LIBC ) = | 88 static Cyg_Mempool_Variable pool CYG_INIT_PRIORITY( LIBC ) = |
| 88 Cyg_Mempool_Variable( pooldata, CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE ); | 89 Cyg_Mempool_Variable( cyg_libc_malloc_memorypool, |
| 90 CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE ); | |
| 89 | 91 |
| 90 | 92 |
| 91 // FUNCTIONS | 93 // FUNCTIONS |
| 92 | 94 |
| 93 void * | 95 void * |
| 216 return ret_ptr; | 218 return ret_ptr; |
| 217 } // _realloc() | 219 } // _realloc() |
| 218 | 220 |
| 219 #endif // ifdef CYGPKG_LIBC_MALLOC | 221 #endif // ifdef CYGPKG_LIBC_MALLOC |
| 220 | 222 |
| 221 #endif // ifdef CYGPKG_LIBC | |
| 222 | |
| 223 // EOF malloc.cxx | 223 // EOF malloc.cxx |
