Changeset a46da63 in mainline for libc/generic/as.c
- Timestamp:
- 2006-06-16T20:50:51Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 153a209
- Parents:
- b34fab6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/as.c
rb34fab6 ra46da63 27 27 */ 28 28 29 29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 76 76 77 77 static size_t heapsize = 0; 78 static size_t maxheapsize = (size_t) (-1);78 static size_t maxheapsize = (size_t) (-1); 79 79 80 80 static void * last_allocated = 0; … … 93 93 int rc; 94 94 void *res; 95 95 96 /* Check for invalid values */ 96 97 if (incr < 0 && -incr > heapsize) 97 98 return NULL; 99 98 100 /* Check for too large value */ 99 101 if (incr > 0 && incr+heapsize < heapsize) 100 102 return NULL; 103 101 104 /* Check for too small values */ 102 105 if (incr < 0 && incr+heapsize > heapsize) 103 106 return NULL; 107 104 108 /* Check for user limit */ 105 if ((maxheapsize!=(size_t)(-1)) && (heapsize + incr)>maxheapsize) return NULL; 106 107 rc = as_area_resize(&_heap, heapsize + incr,0); 109 if ((maxheapsize != (size_t) (-1)) && (heapsize + incr) > maxheapsize) 110 return NULL; 111 112 rc = as_area_resize(&_heap, heapsize + incr, 0); 108 113 if (rc != 0) 109 114 return NULL; 110 115 111 116 /* Compute start of new area */ 112 res = (void *) &_heap + heapsize;117 res = (void *) &_heap + heapsize; 113 118 114 119 heapsize += incr; … … 120 125 void *set_maxheapsize(size_t mhs) 121 126 { 122 maxheapsize =mhs;127 maxheapsize = mhs; 123 128 /* Return pointer to area not managed by sbrk */ 124 return ( void *)&_heap + maxheapsize;129 return ((void *) &_heap + maxheapsize); 125 130 126 131 } … … 137 142 /* Set heapsize to some meaningful value */ 138 143 if (maxheapsize == -1) 139 set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH>>1,PAGE_SIZE)); 144 set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH >> 1, PAGE_SIZE)); 145 140 146 if (!last_allocated) 141 last_allocated = ALIGN_UP((void *)&_heap + maxheapsize, PAGE_SIZE);147 last_allocated = (void *) ALIGN_UP((void *) &_heap + maxheapsize, PAGE_SIZE); 142 148 143 149 sz = ALIGN_UP(sz, PAGE_SIZE); … … 148 154 } 149 155 150 151 /** @} 156 /** @} 152 157 */ 153 154
Note:
See TracChangeset
for help on using the changeset viewer.