1 /* Encoding of types for Objective C.
2 Copyright (C) 1993-2019 Free Software Foundation, Inc.
3 Contributed by Kresten Krab Thorup
4 Bitfield support by Ovidiu Predescu
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 /* FIXME: This file has no business including tm.h. */
29 /* FIXME: This file contains functions that will abort the entire
30 program if they fail. Is that really needed ? */
33 #include "objc-private/common.h"
34 #include "objc-private/error.h"
36 #include "coretypes.h"
38 #include "objc/runtime.h"
39 #include "objc-private/module-abi-8.h" /* For struct objc_method */
42 #include <string.h> /* For memcpy. */
46 ({ typeof (X) __x = (X), __y = (Y); \
47 (__x > __y ? __x : __y); })
51 ({ typeof (X) __x = (X), __y = (Y); \
52 (__x < __y ? __x : __y); })
56 ({ typeof (V) __v = (V); typeof (A) __a = (A); \
57 __a * ((__v+__a - 1)/__a); })
60 /* Various hacks for objc_layout_record. These are used by the target
63 #define TREE_CODE(TYPE) *(TYPE)
64 #define TREE_TYPE(TREE) (TREE)
66 #define RECORD_TYPE _C_STRUCT_B
67 #define UNION_TYPE _C_UNION_B
68 #define QUAL_UNION_TYPE _C_UNION_B
69 #define ARRAY_TYPE _C_ARY_B
71 #define REAL_TYPE _C_DBL
73 #define VECTOR_TYPE _C_VECTOR
75 #define TYPE_FIELDS(TYPE) ({const char *_field = (TYPE)+1; \
76 while (*_field != _C_STRUCT_E && *_field != _C_STRUCT_B \
77 && *_field != _C_UNION_B && *_field++ != '=') \
81 #define DECL_MODE(TYPE) *(TYPE)
82 #define TYPE_MODE(TYPE) *(TYPE)
87 #define strip_array_types(TYPE) ({const char *_field = (TYPE); \
88 while (*_field == _C_ARY_B)\
90 while (isdigit ((unsigned char)*++_field))\
95 /* Some ports (eg ARM) allow the structure size boundary to be
96 selected at compile-time. We override the normal definition with
97 one that has a constant value for this compilation. */
98 #undef STRUCTURE_SIZE_BOUNDARY
99 #define STRUCTURE_SIZE_BOUNDARY (__CHAR_BIT__ * sizeof (struct{char a;}))
101 /* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently
102 target_flags. Define a dummy entry here to so we don't die.
103 We have to rename it because target_flags may already have been
105 #define target_flags not_target_flags
106 static int __attribute__ ((__unused__
)) not_target_flags
= 0;
108 /* Some ROUND_TYPE_ALIGN use ALTIVEC_VECTOR_MODE (rs6000 darwin).
109 Define a dummy ALTIVEC_VECTOR_MODE so it will not die. */
110 #undef ALTIVEC_VECTOR_MODE
111 #define ALTIVEC_VECTOR_MODE(MODE) (0)
113 /* Replace TARGET_VSX, TARGET_ALTIVEC, and TARGET_64BIT with constants based on
114 the current switches, rather than looking in the options structure. */
117 #undef TARGET_ALTIVEC
127 #define TARGET_ALTIVEC 1
129 #define TARGET_ALTIVEC 0
133 #define TARGET_64BIT 1
135 #define TARGET_64BIT 0
139 /* Furthermore, some (powerpc) targets also use TARGET_ALIGN_NATURAL
140 in their alignment macros. Currently[4.5/6], rs6000.h points this
141 to a static variable, initialized by target overrides. This is reset
142 in linux64.h but not in darwin64.h. The macro is not used by *86*. */
146 # undef TARGET_ALIGN_NATURAL
147 # define TARGET_ALIGN_NATURAL 1
150 /* On Darwin32, we need to recurse until we find the starting stuct type. */
152 _darwin_rs6000_special_round_type_align (const char *struc
, int comp
, int spec
)
154 const char *_stp
, *_fields
= TYPE_FIELDS (struc
);
156 return MAX (comp
, spec
);
157 _stp
= strip_array_types (_fields
);
158 if (TYPE_MODE(_stp
) == _C_COMPLEX
)
160 switch (TYPE_MODE(_stp
))
164 return MAX (MAX (comp
, spec
), objc_alignof_type (_stp
) * __CHAR_BIT__
);
169 return MAX (MAX (comp
, spec
), 64);
173 return MAX (comp
, spec
);
178 /* See comment below. */
179 #define darwin_rs6000_special_round_type_align(S,C,S2) \
180 (_darwin_rs6000_special_round_type_align ((char*)(S), (int)(C), (int)(S2)))
183 /* FIXME: while this file has no business including tm.h, this
184 definitely has no business defining this macro but it
185 is only way around without really rewritting this file,
186 should look after the branch of 3.4 to fix this. */
187 #define rs6000_special_round_type_align(STRUCT, COMPUTED, SPECIFIED) \
188 ({ const char *_fields = TYPE_FIELDS (STRUCT); \
190 && TYPE_MODE (strip_array_types (TREE_TYPE (_fields))) == DFmode) \
191 ? MAX (MAX (COMPUTED, SPECIFIED), 64) \
192 : MAX (COMPUTED, SPECIFIED));})
194 #define rs6000_special_adjust_field_align_p(FIELD, COMPUTED) 0
196 /* Skip a variable name, enclosed in quotes ("). */
199 objc_skip_variable_name (const char *type
)
201 /* Skip the variable name if any. */
204 /* FIXME: How do we know we won't read beyond the end of the
205 string. Here and in the rest of the file! */
208 /* Skip to the next '"'. */
219 objc_sizeof_type (const char *type
)
221 type
= objc_skip_variable_name (type
);
225 return sizeof (_Bool
);
233 return sizeof (Class
);
241 return sizeof (char);
245 return sizeof (unsigned char);
249 return sizeof (short);
253 return sizeof (unsigned short);
261 return sizeof (unsigned int);
265 return sizeof (long);
269 return sizeof (unsigned long);
273 return sizeof (long long);
277 return sizeof (unsigned long long);
281 return sizeof (float);
285 return sizeof (double);
289 return sizeof (long double);
293 return sizeof (void);
299 return sizeof (char *);
304 int len
= atoi (type
+ 1);
305 while (isdigit ((unsigned char)*++type
))
307 return len
* objc_aligned_size (type
);
318 /* The size in bytes is the following number. */
319 int size
= atoi (type
);
326 /* The GNU encoding of bitfields is: b 'position' 'type'
329 int startByte
, endByte
;
331 position
= atoi (type
+ 1);
332 while (isdigit ((unsigned char)*++type
))
334 size
= atoi (type
+ 1);
336 startByte
= position
/ __CHAR_BIT__
;
337 endByte
= (position
+ size
) / __CHAR_BIT__
;
338 return endByte
- startByte
;
344 struct objc_struct_layout layout
;
347 objc_layout_structure (type
, &layout
);
348 while (objc_layout_structure_next_member (&layout
))
350 objc_layout_finish_structure (&layout
, &size
, NULL
);
357 type
++; /* Skip after the 'j'. */
361 return sizeof (_Complex
char);
365 return sizeof (_Complex
unsigned char);
369 return sizeof (_Complex
short);
373 return sizeof (_Complex
unsigned short);
377 return sizeof (_Complex
int);
381 return sizeof (_Complex
unsigned int);
385 return sizeof (_Complex
long);
389 return sizeof (_Complex
unsigned long);
393 return sizeof (_Complex
long long);
397 return sizeof (_Complex
unsigned long long);
401 return sizeof (_Complex
float);
405 return sizeof (_Complex
double);
409 return sizeof (_Complex
long double);
414 /* FIXME: Is this so bad that we have to abort the
415 entire program ? (it applies to all the other
416 _objc_abort calls in this file).
418 _objc_abort ("unknown complex type %s\n", type
);
426 _objc_abort ("unknown type %s\n", type
);
433 objc_alignof_type (const char *type
)
435 type
= objc_skip_variable_name (type
);
439 return __alignof__ (_Bool
);
443 return __alignof__ (id
);
447 return __alignof__ (Class
);
451 return __alignof__ (SEL
);
455 return __alignof__ (char);
459 return __alignof__ (unsigned char);
463 return __alignof__ (short);
467 return __alignof__ (unsigned short);
471 return __alignof__ (int);
475 return __alignof__ (unsigned int);
479 return __alignof__ (long);
483 return __alignof__ (unsigned long);
487 return __alignof__ (long long);
491 return __alignof__ (unsigned long long);
495 return __alignof__ (float);
499 return __alignof__ (double);
503 return __alignof__ (long double);
509 return __alignof__ (char *);
513 while (isdigit ((unsigned char)*++type
))
515 return objc_alignof_type (type
);
525 while (isdigit ((unsigned char)*type
))
531 /* The alignment in bytes is the following number. */
537 struct objc_struct_layout layout
;
540 objc_layout_structure (type
, &layout
);
541 while (objc_layout_structure_next_member (&layout
))
543 objc_layout_finish_structure (&layout
, NULL
, &align
);
551 type
++; /* Skip after the 'j'. */
555 return __alignof__ (_Complex
char);
559 return __alignof__ (_Complex
unsigned char);
563 return __alignof__ (_Complex
short);
567 return __alignof__ (_Complex
unsigned short);
571 return __alignof__ (_Complex
int);
575 return __alignof__ (_Complex
unsigned int);
579 return __alignof__ (_Complex
long);
583 return __alignof__ (_Complex
unsigned long);
587 return __alignof__ (_Complex
long long);
591 return __alignof__ (_Complex
unsigned long long);
595 return __alignof__ (_Complex
float);
599 return __alignof__ (_Complex
double);
603 return __alignof__ (_Complex
long double);
608 _objc_abort ("unknown complex type %s\n", type
);
616 _objc_abort ("unknown type %s\n", type
);
623 objc_aligned_size (const char *type
)
627 type
= objc_skip_variable_name (type
);
628 size
= objc_sizeof_type (type
);
629 align
= objc_alignof_type (type
);
631 return ROUND (size
, align
);
635 objc_promoted_size (const char *type
)
639 type
= objc_skip_variable_name (type
);
640 size
= objc_sizeof_type (type
);
641 wordsize
= sizeof (void *);
643 return ROUND (size
, wordsize
);
648 objc_skip_type_qualifiers (const char *type
)
650 while (*type
== _C_CONST
654 || *type
== _C_BYCOPY
656 || *type
== _C_ONEWAY
657 || *type
== _C_GCINVISIBLE
)
666 objc_skip_typespec (const char *type
)
668 type
= objc_skip_variable_name (type
);
669 type
= objc_skip_type_qualifiers (type
);
674 /* An id may be annotated by the actual type if it is known
675 with the @"ClassName" syntax */
681 while (*++type
!= '"')
686 /* The following are one character type codes */
715 /* skip digits, typespec and closing ']' */
716 while (isdigit ((unsigned char)*++type
))
718 type
= objc_skip_typespec (type
);
719 if (*type
== _C_ARY_E
)
723 _objc_abort ("bad array type %s\n", type
);
732 /* Skip digits (size) */
733 while (isdigit ((unsigned char)*type
))
737 /* Skip digits (alignment) */
738 while (isdigit ((unsigned char)*type
))
741 type
= objc_skip_typespec (type
);
742 /* Skip closing ']'. */
743 if (*type
== _C_ARY_E
)
747 _objc_abort ("bad vector type %s\n", type
);
752 /* The GNU encoding of bitfields is: b 'position' 'type'
754 while (isdigit ((unsigned char)*++type
))
755 ; /* skip position */
756 while (isdigit ((unsigned char)*++type
))
757 ; /* skip type and size */
761 /* skip name, and elements until closing '}' */
763 while (*type
!= _C_STRUCT_E
&& *type
++ != '=')
765 while (*type
!= _C_STRUCT_E
)
767 type
= objc_skip_typespec (type
);
772 /* skip name, and elements until closing ')' */
774 while (*type
!= _C_UNION_E
&& *type
++ != '=')
776 while (*type
!= _C_UNION_E
)
778 type
= objc_skip_typespec (type
);
783 /* Just skip the following typespec */
785 return objc_skip_typespec (++type
);
789 _objc_abort ("unknown type %s\n", type
);
797 objc_skip_offset (const char *type
)
799 /* The offset is prepended by a '+' if the argument is passed in
800 registers. PS: The compiler stopped generating this '+' in
805 /* Some people claim that on some platforms, where the stack grows
806 backwards, the compiler generates negative offsets (??). Skip a
807 '-' for such a negative offset. */
811 /* Skip the digits that represent the offset. */
812 while (isdigit ((unsigned char) *type
))
819 objc_skip_argspec (const char *type
)
821 type
= objc_skip_typespec (type
);
822 type
= objc_skip_offset (type
);
827 method_copyReturnType (struct objc_method
*method
)
834 size_t returnValueSize
;
836 /* Determine returnValueSize. */
838 /* Find the end of the first argument. We want to return the
839 first argument spec, plus 1 byte for the \0 at the end. */
840 const char *type
= method
->method_types
;
843 type
= objc_skip_argspec (type
);
844 returnValueSize
= type
- method
->method_types
+ 1;
847 /* Copy the first argument into returnValue. */
848 returnValue
= malloc (sizeof (char) * returnValueSize
);
849 memcpy (returnValue
, method
->method_types
, returnValueSize
);
850 returnValue
[returnValueSize
- 1] = '\0';
857 method_copyArgumentType (struct objc_method
* method
, unsigned int argumentNumber
)
864 const char *returnValueStart
;
865 size_t returnValueSize
;
867 /* Determine returnValueStart and returnValueSize. */
869 const char *type
= method
->method_types
;
871 /* Skip the first argument (return type). */
872 type
= objc_skip_argspec (type
);
874 /* Now keep skipping arguments until we get to
876 while (argumentNumber
> 0)
878 /* We are supposed to skip an argument, but the string is
879 finished. This means we were asked for a non-existing
884 type
= objc_skip_argspec (type
);
888 /* If the argument does not exist, return NULL. */
892 returnValueStart
= type
;
893 type
= objc_skip_argspec (type
);
894 returnValueSize
= type
- returnValueStart
+ 1;
897 /* Copy the argument into returnValue. */
898 returnValue
= malloc (sizeof (char) * returnValueSize
);
899 memcpy (returnValue
, returnValueStart
, returnValueSize
);
900 returnValue
[returnValueSize
- 1] = '\0';
906 void method_getReturnType (struct objc_method
* method
, char *returnValue
,
907 size_t returnValueSize
)
909 if (returnValue
== NULL
|| returnValueSize
== 0)
912 /* Zero the string; we'll then write the argument type at the
913 beginning of it, if needed. */
914 memset (returnValue
, 0, returnValueSize
);
920 size_t argumentTypeSize
;
922 /* Determine argumentTypeSize. */
924 /* Find the end of the first argument. We want to return the
925 first argument spec. */
926 const char *type
= method
->method_types
;
929 type
= objc_skip_argspec (type
);
930 argumentTypeSize
= type
- method
->method_types
;
931 if (argumentTypeSize
> returnValueSize
)
932 argumentTypeSize
= returnValueSize
;
934 /* Copy the argument at the beginning of the string. */
935 memcpy (returnValue
, method
->method_types
, argumentTypeSize
);
939 void method_getArgumentType (struct objc_method
* method
, unsigned int argumentNumber
,
940 char *returnValue
, size_t returnValueSize
)
942 if (returnValue
== NULL
|| returnValueSize
== 0)
945 /* Zero the string; we'll then write the argument type at the
946 beginning of it, if needed. */
947 memset (returnValue
, 0, returnValueSize
);
953 const char *returnValueStart
;
954 size_t argumentTypeSize
;
956 /* Determine returnValueStart and argumentTypeSize. */
958 const char *type
= method
->method_types
;
960 /* Skip the first argument (return type). */
961 type
= objc_skip_argspec (type
);
963 /* Now keep skipping arguments until we get to
965 while (argumentNumber
> 0)
967 /* We are supposed to skip an argument, but the string is
968 finished. This means we were asked for a non-existing
973 type
= objc_skip_argspec (type
);
977 /* If the argument does not exist, it's game over. */
981 returnValueStart
= type
;
982 type
= objc_skip_argspec (type
);
983 argumentTypeSize
= type
- returnValueStart
;
984 if (argumentTypeSize
> returnValueSize
)
985 argumentTypeSize
= returnValueSize
;
987 /* Copy the argument at the beginning of the string. */
988 memcpy (returnValue
, returnValueStart
, argumentTypeSize
);
993 method_getNumberOfArguments (struct objc_method
*method
)
1000 const char *type
= method
->method_types
;
1003 type
= objc_skip_argspec (type
);
1009 /* This could only happen if method_types is invalid; in
1010 that case, return 0. */
1015 /* Remove the return type. */
1022 objc_get_type_qualifiers (const char *type
)
1030 case _C_CONST
: res
|= _F_CONST
; break;
1031 case _C_IN
: res
|= _F_IN
; break;
1032 case _C_INOUT
: res
|= _F_INOUT
; break;
1033 case _C_OUT
: res
|= _F_OUT
; break;
1034 case _C_BYCOPY
: res
|= _F_BYCOPY
; break;
1035 case _C_BYREF
: res
|= _F_BYREF
; break;
1036 case _C_ONEWAY
: res
|= _F_ONEWAY
; break;
1037 case _C_GCINVISIBLE
: res
|= _F_GCINVISIBLE
; break;
1044 /* The following three functions can be used to determine how a
1045 structure is laid out by the compiler. For example:
1047 struct objc_struct_layout layout;
1050 objc_layout_structure (type, &layout);
1051 while (objc_layout_structure_next_member (&layout))
1053 int position, align;
1056 objc_layout_structure_get_info (&layout, &position, &align, &type);
1057 printf ("element %d has offset %d, alignment %d\n",
1058 i++, position, align);
1061 These functions are used by objc_sizeof_type and objc_alignof_type
1062 functions to compute the size and alignment of structures. The
1063 previous method of computing the size and alignment of a structure
1064 was not working on some architectures, particularly on AIX, and in
1065 the presence of bitfields inside the structure. */
1067 objc_layout_structure (const char *type
,
1068 struct objc_struct_layout
*layout
)
1072 if (*type
!= _C_UNION_B
&& *type
!= _C_STRUCT_B
)
1074 _objc_abort ("record (or union) type expected in objc_layout_structure, got %s\n",
1079 layout
->original_type
= type
;
1081 /* Skip "<name>=" if any. Avoid embedded structures and unions. */
1083 while (*ntype
!= _C_STRUCT_E
&& *ntype
!= _C_STRUCT_B
&& *ntype
!= _C_UNION_B
1087 /* If there's a "<name>=", ntype - 1 points to '='; skip the the name */
1088 if (*(ntype
- 1) == '=')
1091 layout
->type
= type
;
1092 layout
->prev_type
= NULL
;
1093 layout
->record_size
= 0;
1094 layout
->record_align
= __CHAR_BIT__
;
1096 layout
->record_align
= MAX (layout
->record_align
, STRUCTURE_SIZE_BOUNDARY
);
1100 objc_layout_structure_next_member (struct objc_struct_layout
*layout
)
1102 register int desired_align
= 0;
1104 /* The following are used only if the field is a bitfield */
1105 register const char *bfld_type
= 0;
1106 register int bfld_type_align
= 0, bfld_field_size
= 0;
1108 /* The current type without the type qualifiers */
1110 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1112 /* Add the size of the previous field to the size of the record. */
1113 if (layout
->prev_type
)
1115 type
= objc_skip_type_qualifiers (layout
->prev_type
);
1117 layout
->record_size
= MAX (layout
->record_size
,
1118 objc_sizeof_type (type
) * __CHAR_BIT__
);
1120 else if (*type
!= _C_BFLD
)
1121 layout
->record_size
+= objc_sizeof_type (type
) * __CHAR_BIT__
;
1123 /* Get the bitfield's type */
1124 for (bfld_type
= type
+ 1;
1125 isdigit ((unsigned char)*bfld_type
);
1129 bfld_type_align
= objc_alignof_type (bfld_type
) * __CHAR_BIT__
;
1130 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1131 layout
->record_size
+= bfld_field_size
;
1135 if ((unionp
&& *layout
->type
== _C_UNION_E
)
1136 || (!unionp
&& *layout
->type
== _C_STRUCT_E
))
1139 /* Skip the variable name if any */
1140 layout
->type
= objc_skip_variable_name (layout
->type
);
1141 type
= objc_skip_type_qualifiers (layout
->type
);
1143 if (*type
!= _C_BFLD
)
1144 desired_align
= objc_alignof_type (type
) * __CHAR_BIT__
;
1148 /* Skip the bitfield's offset */
1149 for (bfld_type
= type
+ 1;
1150 isdigit ((unsigned char) *bfld_type
);
1154 bfld_type_align
= objc_alignof_type (bfld_type
) * __CHAR_BIT__
;
1155 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1158 /* The following won't work for vectors. */
1159 #ifdef BIGGEST_FIELD_ALIGNMENT
1160 desired_align
= MIN (desired_align
, BIGGEST_FIELD_ALIGNMENT
);
1162 #ifdef ADJUST_FIELD_ALIGN
1163 desired_align
= ADJUST_FIELD_ALIGN (type
, type
, desired_align
);
1166 /* Record must have at least as much alignment as any field.
1167 Otherwise, the alignment of the field within the record
1169 #ifndef HAVE_BITFIELD_TYPE_MATTERS
1170 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1171 #else /* PCC_BITFIELD_TYPE_MATTERS */
1172 if (*type
== _C_BFLD
)
1174 /* For these machines, a zero-length field does not
1175 affect the alignment of the structure as a whole.
1176 It does, however, affect the alignment of the next field
1177 within the structure. */
1178 if (bfld_field_size
)
1179 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1181 desired_align
= objc_alignof_type (bfld_type
) * __CHAR_BIT__
;
1183 /* A named bit field of declared type `int'
1184 forces the entire structure to have `int' alignment.
1185 Q1: How is encoded this thing and how to check for it?
1186 Q2: How to determine maximum_field_alignment at runtime? */
1188 /* if (DECL_NAME (field) != 0) */
1190 int type_align
= bfld_type_align
;
1192 if (maximum_field_alignment
!= 0)
1193 type_align
= MIN (type_align
, maximum_field_alignment
);
1194 else if (DECL_PACKED (field
))
1195 type_align
= MIN (type_align
, __CHAR_BIT__
);
1198 layout
->record_align
= MAX (layout
->record_align
, type_align
);
1202 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1203 #endif /* PCC_BITFIELD_TYPE_MATTERS */
1205 /* Does this field automatically have alignment it needs
1206 by virtue of the fields that precede it and the record's
1209 if (*type
== _C_BFLD
)
1210 layout
->record_size
= atoi (type
+ 1);
1211 else if (layout
->record_size
% desired_align
!= 0)
1213 /* No, we need to skip space before this field.
1214 Bump the cumulative size to multiple of field alignment. */
1215 layout
->record_size
= ROUND (layout
->record_size
, desired_align
);
1218 /* Jump to the next field in record. */
1220 layout
->prev_type
= layout
->type
;
1221 layout
->type
= objc_skip_typespec (layout
->type
); /* skip component */
1226 void objc_layout_finish_structure (struct objc_struct_layout
*layout
,
1228 unsigned int *align
)
1230 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1232 && ((!unionp
&& *layout
->type
== _C_STRUCT_E
)
1233 || (unionp
&& *layout
->type
== _C_UNION_E
)))
1235 /* Work out the alignment of the record as one expression and store
1236 in the record type. Round it up to a multiple of the record's
1238 #if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
1239 layout
->record_align
= ROUND_TYPE_ALIGN (layout
->original_type
-1,
1241 layout
->record_align
);
1243 layout
->record_align
= MAX (1, layout
->record_align
);
1246 /* Round the size up to be a multiple of the required alignment */
1247 layout
->record_size
= ROUND (layout
->record_size
, layout
->record_align
);
1249 layout
->type
= NULL
;
1252 *size
= layout
->record_size
/ __CHAR_BIT__
;
1254 *align
= layout
->record_align
/ __CHAR_BIT__
;
1257 void objc_layout_structure_get_info (struct objc_struct_layout
*layout
,
1258 unsigned int *offset
,
1259 unsigned int *align
,
1263 *offset
= layout
->record_size
/ __CHAR_BIT__
;
1265 *align
= layout
->record_align
/ __CHAR_BIT__
;
1267 *type
= layout
->prev_type
;