J
john
Hi,
I'm trying to put together an autoconf test that will try to detect what
allocation method is being used on the current platform by malloc()
(buddy/ fixed size pools/ etc.), and how big control blocks are etc.
The idea is that programmers might want to change allocation sizes to fit
within blocks, e.g. allocate (2^n - k) as the initial size of an array
instead of (2^n), if k is the size of the malloc control block.
So far, I've got this test program:
#include"stdio.h"
main()
{
int i;
char *p, *q, *malloc();
p = malloc(100);
q = malloc(100);
printf("difference: %d\n", (int) (q - p));
}
On gcc, this produces 112 while on tcc it's 104, so this is obviously
giving me some information about what malloc is doing in each case.
Does anyone have any suggestions for useful tests that would help
characterise the malloc() implementation? How could I distinguish buddy
from fixed pool just by looking at the outcome of a simple program
invoking malloc()?
Cheers
John
PS. I know technically some of the tests might be undefined, but
heuristics are fine for the application I have in mind.
I'm trying to put together an autoconf test that will try to detect what
allocation method is being used on the current platform by malloc()
(buddy/ fixed size pools/ etc.), and how big control blocks are etc.
The idea is that programmers might want to change allocation sizes to fit
within blocks, e.g. allocate (2^n - k) as the initial size of an array
instead of (2^n), if k is the size of the malloc control block.
So far, I've got this test program:
#include"stdio.h"
main()
{
int i;
char *p, *q, *malloc();
p = malloc(100);
q = malloc(100);
printf("difference: %d\n", (int) (q - p));
}
On gcc, this produces 112 while on tcc it's 104, so this is obviously
giving me some information about what malloc is doing in each case.
Does anyone have any suggestions for useful tests that would help
characterise the malloc() implementation? How could I distinguish buddy
from fixed pool just by looking at the outcome of a simple program
invoking malloc()?
Cheers
John
PS. I know technically some of the tests might be undefined, but
heuristics are fine for the application I have in mind.