Commit f4e12fad by Kresten Krab Thorup

(objc_sizeof_type): Assign from ROUND,

        don't increment.  Remove ; after while to fix infinite loop.
        Add float and double cases.
        (objc_alignof_type):  Add float and double cases.

From-SVN: r7929
parent 121b312b
...@@ -103,6 +103,14 @@ objc_sizeof_type(const char* type) ...@@ -103,6 +103,14 @@ objc_sizeof_type(const char* type)
return sizeof(unsigned long); return sizeof(unsigned long);
break; break;
case _C_FLT:
return sizeof(float);
break;
case _C_DBL:
return sizeof(double);
break;
case _C_PTR: case _C_PTR:
case _C_ATOM: case _C_ATOM:
case _C_CHARPTR: case _C_CHARPTR:
...@@ -122,10 +130,10 @@ objc_sizeof_type(const char* type) ...@@ -122,10 +130,10 @@ objc_sizeof_type(const char* type)
int acc_size = 0; int acc_size = 0;
int align; int align;
while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */
while (*type != _C_STRUCT_E); while (*type != _C_STRUCT_E)
{ {
align = objc_alignof_type (type); /* padd to alignment */ align = objc_alignof_type (type); /* padd to alignment */
acc_size += ROUND (acc_size, align); acc_size = ROUND (acc_size, align);
acc_size += objc_sizeof_type (type); /* add component size */ acc_size += objc_sizeof_type (type); /* add component size */
type = objc_skip_typespec (type); /* skip component */ type = objc_skip_typespec (type); /* skip component */
} }
...@@ -202,6 +210,14 @@ objc_alignof_type(const char* type) ...@@ -202,6 +210,14 @@ objc_alignof_type(const char* type)
return __alignof__(unsigned long); return __alignof__(unsigned long);
break; break;
case _C_FLT:
return __alignof__(float);
break;
case _C_DBL:
return __alignof__(double);
break;
case _C_ATOM: case _C_ATOM:
case _C_CHARPTR: case _C_CHARPTR:
return __alignof__(char*); return __alignof__(char*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment