mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fixes for structure size/alignment calculations
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22283 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
06981169ed
commit
d98714e355
2 changed files with 17 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-01-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/mframe.m:
|
||||
When calculating info about a structure, make sure its alignment is
|
||||
that of its most strictly aligned field and make sure its size is a
|
||||
multiple of its alignment.
|
||||
|
||||
2006-01-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSFileHandle.m:
|
||||
|
|
|
@ -384,7 +384,8 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
acc_align = MAX(local.align, def_align);
|
||||
}
|
||||
/*
|
||||
* Continue accumulating structure size.
|
||||
* Continue accumulating structure size
|
||||
* and adjust alignment if necessary
|
||||
*/
|
||||
while (*typePtr != _C_STRUCT_E)
|
||||
{
|
||||
|
@ -395,6 +396,14 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
}
|
||||
acc_size = ROUND(acc_size, local.align);
|
||||
acc_size += local.size;
|
||||
acc_align = MAX(local.align, acc_align);
|
||||
}
|
||||
/*
|
||||
* Size must be a multiple of alignment
|
||||
*/
|
||||
if (acc_size % acc_align != 0)
|
||||
{
|
||||
acc_size += acc_align - acc_size % acc_align;
|
||||
}
|
||||
info->size = acc_size;
|
||||
info->align = acc_align;
|
||||
|
|
Loading…
Reference in a new issue