mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[qfcc] Add failing test case for defspace_alloc_aligned_loc
qfcc is putting two temps in the same location due to defspace_alloc_aligned_loc returning the same address when there was a hole caused by an earlier aligned alloc: specifically, a size-3 hole and a size-2 allocation with alignment-2.
This commit is contained in:
parent
cdd8739577
commit
7518ba0a27
1 changed files with 34 additions and 0 deletions
|
@ -104,6 +104,39 @@ test_init (void)
|
|||
return pass;
|
||||
}
|
||||
|
||||
static int
|
||||
test_aligned_alloc (void)
|
||||
{
|
||||
defspace_t *space = defspace_new (ds_virtual);
|
||||
struct {
|
||||
int size, align;
|
||||
} allocations[6] = {
|
||||
{ 2, 2 },
|
||||
{ 2, 2 },
|
||||
{ 1, 1 },
|
||||
{ 4, 4 },
|
||||
{ 2, 2 },
|
||||
{ 2, 2 },
|
||||
};
|
||||
int offsets[6];
|
||||
for (int i = 0; i < 6; i++) {
|
||||
offsets[i] = defspace_alloc_aligned_loc (space, allocations[i].size,
|
||||
allocations[i].align);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
for (int j = i + 1; j < 6; j++) {
|
||||
if (offsets[i] == offsets[j]) {
|
||||
printf ("duplicate offset in allocations");
|
||||
printf ("%d %d %d %d %d %d\n",
|
||||
offsets[0], offsets[1], offsets[2],
|
||||
offsets[3], offsets[4], offsets[5]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, const char **argv)
|
||||
{
|
||||
|
@ -112,6 +145,7 @@ main (int argc, const char **argv)
|
|||
int pass = 1;
|
||||
|
||||
pass &= test_init ();
|
||||
pass &= test_aligned_alloc ();
|
||||
|
||||
return !pass;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue