ftmemsim-valgrind/memcheck/tests/memalign_test.c
Julian Seward 37c3d2ead6 Merge (from 3_2_BRANCH) r6457/8 (Support 64k pages on ppc32/64-linux
(Jakub Jelink, Dave Nomura) )



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6459
2006-12-30 17:45:08 +00:00

28 lines
599 B
C

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
int main ( void )
{
void* a[10];
int i;
unsigned long pszB = sysconf(_SC_PAGE_SIZE);
assert(sizeof(long) == sizeof(void*));
assert(pszB == 4096 || pszB == 65536);
for (i = 0; i < 10; i++) {
a[i] = valloc(11111 * (i+1));
/* check valloc really is returning page-aligned memory */
assert( (((unsigned long)(a[i])) % pszB) == 0 );
// printf("I acquire %p\n", a[i]);
}
for (i = 0; i < 10; i++) {
// printf("I release %p\n", a[i]);
free(a[i]);
}
free(a[9]);
return 0;
}