1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-12-26 09:26:26 +02:00

physmem.c: align memory to word and page size

- physmem.c (align_sbrk): align the end of the data segment
- physmem.c (calloc_phys_vec): align the line pointer vector to a machine
  word, just in case
- physmem.c (calloc_phys_vec): crudely align the line buffers within
  pages, to avoid page-crossing within a line (yes, this does reduce
  noise)
This commit is contained in:
Werner Almesberger 2011-04-29 13:58:02 -03:00
parent 2cee702ff4
commit debe9cc351

View File

@ -21,13 +21,25 @@
*/
static void align_brk(int alignment)
{
unsigned long addr;
addr = (unsigned long) sbrk(0);
sbrk(alignment-(addr % alignment));
}
void **calloc_phys_vec(size_t n, size_t size)
{
void **vec;
int i;
align_brk(sizeof(void *));
vec = sbrk(sizeof(void *)*n);
for (i = 0; i != n; i++) {
align_brk(512); /* crude page alignment */
vec[i] = sbrk(size);
memset(vec[i], 0, size);
}