1 /* Encoding of types for Objective C.
2 Copyright (C) 1993-2015 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)
86 #define strip_array_types(TYPE) ({const char *_field = (TYPE); \
87 while (*_field == _C_ARY_B)\
89 while (isdigit ((unsigned char)*++_field))\
94 /* Some ports (eg ARM) allow the structure size boundary to be
95 selected at compile-time. We override the normal definition with
96 one that has a constant value for this compilation. */
98 #define BITS_PER_UNIT 8
100 #undef STRUCTURE_SIZE_BOUNDARY
101 #define STRUCTURE_SIZE_BOUNDARY (BITS_PER_UNIT * sizeof (struct{char a;}))
103 /* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently
104 target_flags. Define a dummy entry here to so we don't die.
105 We have to rename it because target_flags may already have been
107 #define target_flags not_target_flags
108 static int __attribute__ ((__unused__
)) not_target_flags
= 0;
110 /* Some ROUND_TYPE_ALIGN use ALTIVEC_VECTOR_MODE (rs6000 darwin).
111 Define a dummy ALTIVEC_VECTOR_MODE so it will not die. */
112 #undef ALTIVEC_VECTOR_MODE
113 #define ALTIVEC_VECTOR_MODE(MODE) (0)
115 /* Replace TARGET_VSX, TARGET_ALTIVEC, and TARGET_64BIT with constants based on
116 the current switches, rather than looking in the options structure. */
119 #undef TARGET_ALTIVEC
129 #define TARGET_ALTIVEC 1
131 #define TARGET_ALTIVEC 0
135 #define TARGET_64BIT 1
137 #define TARGET_64BIT 0
141 /* Furthermore, some (powerpc) targets also use TARGET_ALIGN_NATURAL
142 in their alignment macros. Currently[4.5/6], rs6000.h points this
143 to a static variable, initialized by target overrides. This is reset
144 in linux64.h but not in darwin64.h. The macro is not used by *86*. */
148 # undef TARGET_ALIGN_NATURAL
149 # define TARGET_ALIGN_NATURAL 1
152 /* On Darwin32, we need to recurse until we find the starting stuct type. */
154 _darwin_rs6000_special_round_type_align (const char *struc
, int comp
, int spec
)
156 const char *_stp
, *_fields
= TYPE_FIELDS (struc
);
158 return MAX (comp
, spec
);
159 _stp
= strip_array_types (_fields
);
160 if (TYPE_MODE(_stp
) == _C_COMPLEX
)
162 switch (TYPE_MODE(_stp
))
166 return MAX (MAX (comp
, spec
), objc_alignof_type (_stp
) * BITS_PER_UNIT
);
171 return MAX (MAX (comp
, spec
), 64);
175 return MAX (comp
, spec
);
180 /* See comment below. */
181 #define darwin_rs6000_special_round_type_align(S,C,S2) \
182 (_darwin_rs6000_special_round_type_align ((char*)(S), (int)(C), (int)(S2)))
185 /* FIXME: while this file has no business including tm.h, this
186 definitely has no business defining this macro but it
187 is only way around without really rewritting this file,
188 should look after the branch of 3.4 to fix this. */
189 #define rs6000_special_round_type_align(STRUCT, COMPUTED, SPECIFIED) \
190 ({ const char *_fields = TYPE_FIELDS (STRUCT); \
192 && TYPE_MODE (strip_array_types (TREE_TYPE (_fields))) == DFmode) \
193 ? MAX (MAX (COMPUTED, SPECIFIED), 64) \
194 : MAX (COMPUTED, SPECIFIED));})
196 #define rs6000_special_adjust_field_align_p(FIELD, COMPUTED) 0
198 /* Skip a variable name, enclosed in quotes ("). */
201 objc_skip_variable_name (const char *type
)
203 /* Skip the variable name if any. */
206 /* FIXME: How do we know we won't read beyond the end of the
207 string. Here and in the rest of the file! */
210 /* Skip to the next '"'. */
221 objc_sizeof_type (const char *type
)
223 type
= objc_skip_variable_name (type
);
227 return sizeof (_Bool
);
235 return sizeof (Class
);
243 return sizeof (char);
247 return sizeof (unsigned char);
251 return sizeof (short);
255 return sizeof (unsigned short);
263 return sizeof (unsigned int);
267 return sizeof (long);
271 return sizeof (unsigned long);
275 return sizeof (long long);
279 return sizeof (unsigned long long);
283 return sizeof (float);
287 return sizeof (double);
291 return sizeof (long double);
295 return sizeof (void);
301 return sizeof (char *);
306 int len
= atoi (type
+ 1);
307 while (isdigit ((unsigned char)*++type
))
309 return len
* objc_aligned_size (type
);
320 /* The size in bytes is the following number. */
321 int size
= atoi (type
);
328 /* The GNU encoding of bitfields is: b 'position' 'type'
331 int startByte
, endByte
;
333 position
= atoi (type
+ 1);
334 while (isdigit ((unsigned char)*++type
))
336 size
= atoi (type
+ 1);
338 startByte
= position
/ BITS_PER_UNIT
;
339 endByte
= (position
+ size
) / BITS_PER_UNIT
;
340 return endByte
- startByte
;
346 struct objc_struct_layout layout
;
349 objc_layout_structure (type
, &layout
);
350 while (objc_layout_structure_next_member (&layout
))
352 objc_layout_finish_structure (&layout
, &size
, NULL
);
359 type
++; /* Skip after the 'j'. */
363 return sizeof (_Complex
char);
367 return sizeof (_Complex
unsigned char);
371 return sizeof (_Complex
short);
375 return sizeof (_Complex
unsigned short);
379 return sizeof (_Complex
int);
383 return sizeof (_Complex
unsigned int);
387 return sizeof (_Complex
long);
391 return sizeof (_Complex
unsigned long);
395 return sizeof (_Complex
long long);
399 return sizeof (_Complex
unsigned long long);
403 return sizeof (_Complex
float);
407 return sizeof (_Complex
double);
411 return sizeof (_Complex
long double);
416 /* FIXME: Is this so bad that we have to abort the
417 entire program ? (it applies to all the other
418 _objc_abort calls in this file).
420 _objc_abort ("unknown complex type %s\n", type
);
428 _objc_abort ("unknown type %s\n", type
);
435 objc_alignof_type (const char *type
)
437 type
= objc_skip_variable_name (type
);
441 return __alignof__ (_Bool
);
445 return __alignof__ (id
);
449 return __alignof__ (Class
);
453 return __alignof__ (SEL
);
457 return __alignof__ (char);
461 return __alignof__ (unsigned char);
465 return __alignof__ (short);
469 return __alignof__ (unsigned short);
473 return __alignof__ (int);
477 return __alignof__ (unsigned int);
481 return __alignof__ (long);
485 return __alignof__ (unsigned long);
489 return __alignof__ (long long);
493 return __alignof__ (unsigned long long);
497 return __alignof__ (float);
501 return __alignof__ (double);
505 return __alignof__ (long double);
511 return __alignof__ (char *);
515 while (isdigit ((unsigned char)*++type
))
517 return objc_alignof_type (type
);
527 while (isdigit ((unsigned char)*type
))
533 /* The alignment in bytes is the following number. */
539 struct objc_struct_layout layout
;
542 objc_layout_structure (type
, &layout
);
543 while (objc_layout_structure_next_member (&layout
))
545 objc_layout_finish_structure (&layout
, NULL
, &align
);
553 type
++; /* Skip after the 'j'. */
557 return __alignof__ (_Complex
char);
561 return __alignof__ (_Complex
unsigned char);
565 return __alignof__ (_Complex
short);
569 return __alignof__ (_Complex
unsigned short);
573 return __alignof__ (_Complex
int);
577 return __alignof__ (_Complex
unsigned int);
581 return __alignof__ (_Complex
long);
585 return __alignof__ (_Complex
unsigned long);
589 return __alignof__ (_Complex
long long);
593 return __alignof__ (_Complex
unsigned long long);
597 return __alignof__ (_Complex
float);
601 return __alignof__ (_Complex
double);
605 return __alignof__ (_Complex
long double);
610 _objc_abort ("unknown complex type %s\n", type
);
618 _objc_abort ("unknown type %s\n", type
);
625 objc_aligned_size (const char *type
)
629 type
= objc_skip_variable_name (type
);
630 size
= objc_sizeof_type (type
);
631 align
= objc_alignof_type (type
);
633 return ROUND (size
, align
);
637 objc_promoted_size (const char *type
)
641 type
= objc_skip_variable_name (type
);
642 size
= objc_sizeof_type (type
);
643 wordsize
= sizeof (void *);
645 return ROUND (size
, wordsize
);
650 objc_skip_type_qualifiers (const char *type
)
652 while (*type
== _C_CONST
656 || *type
== _C_BYCOPY
658 || *type
== _C_ONEWAY
659 || *type
== _C_GCINVISIBLE
)
668 objc_skip_typespec (const char *type
)
670 type
= objc_skip_variable_name (type
);
671 type
= objc_skip_type_qualifiers (type
);
676 /* An id may be annotated by the actual type if it is known
677 with the @"ClassName" syntax */
683 while (*++type
!= '"')
688 /* The following are one character type codes */
717 /* skip digits, typespec and closing ']' */
718 while (isdigit ((unsigned char)*++type
))
720 type
= objc_skip_typespec (type
);
721 if (*type
== _C_ARY_E
)
725 _objc_abort ("bad array type %s\n", type
);
734 /* Skip digits (size) */
735 while (isdigit ((unsigned char)*type
))
739 /* Skip digits (alignment) */
740 while (isdigit ((unsigned char)*type
))
743 type
= objc_skip_typespec (type
);
744 /* Skip closing ']'. */
745 if (*type
== _C_ARY_E
)
749 _objc_abort ("bad vector type %s\n", type
);
754 /* The GNU encoding of bitfields is: b 'position' 'type'
756 while (isdigit ((unsigned char)*++type
))
757 ; /* skip position */
758 while (isdigit ((unsigned char)*++type
))
759 ; /* skip type and size */
763 /* skip name, and elements until closing '}' */
765 while (*type
!= _C_STRUCT_E
&& *type
++ != '=')
767 while (*type
!= _C_STRUCT_E
)
769 type
= objc_skip_typespec (type
);
774 /* skip name, and elements until closing ')' */
776 while (*type
!= _C_UNION_E
&& *type
++ != '=')
778 while (*type
!= _C_UNION_E
)
780 type
= objc_skip_typespec (type
);
785 /* Just skip the following typespec */
787 return objc_skip_typespec (++type
);
791 _objc_abort ("unknown type %s\n", type
);
799 objc_skip_offset (const char *type
)
801 /* The offset is prepended by a '+' if the argument is passed in
802 registers. PS: The compiler stopped generating this '+' in
807 /* Some people claim that on some platforms, where the stack grows
808 backwards, the compiler generates negative offsets (??). Skip a
809 '-' for such a negative offset. */
813 /* Skip the digits that represent the offset. */
814 while (isdigit ((unsigned char) *type
))
821 objc_skip_argspec (const char *type
)
823 type
= objc_skip_typespec (type
);
824 type
= objc_skip_offset (type
);
829 method_copyReturnType (struct objc_method
*method
)
836 size_t returnValueSize
;
838 /* Determine returnValueSize. */
840 /* Find the end of the first argument. We want to return the
841 first argument spec, plus 1 byte for the \0 at the end. */
842 const char *type
= method
->method_types
;
845 type
= objc_skip_argspec (type
);
846 returnValueSize
= type
- method
->method_types
+ 1;
849 /* Copy the first argument into returnValue. */
850 returnValue
= malloc (sizeof (char) * returnValueSize
);
851 memcpy (returnValue
, method
->method_types
, returnValueSize
);
852 returnValue
[returnValueSize
- 1] = '\0';
859 method_copyArgumentType (struct objc_method
* method
, unsigned int argumentNumber
)
866 const char *returnValueStart
;
867 size_t returnValueSize
;
869 /* Determine returnValueStart and returnValueSize. */
871 const char *type
= method
->method_types
;
873 /* Skip the first argument (return type). */
874 type
= objc_skip_argspec (type
);
876 /* Now keep skipping arguments until we get to
878 while (argumentNumber
> 0)
880 /* We are supposed to skip an argument, but the string is
881 finished. This means we were asked for a non-existing
886 type
= objc_skip_argspec (type
);
890 /* If the argument does not exist, return NULL. */
894 returnValueStart
= type
;
895 type
= objc_skip_argspec (type
);
896 returnValueSize
= type
- returnValueStart
+ 1;
899 /* Copy the argument into returnValue. */
900 returnValue
= malloc (sizeof (char) * returnValueSize
);
901 memcpy (returnValue
, returnValueStart
, returnValueSize
);
902 returnValue
[returnValueSize
- 1] = '\0';
908 void method_getReturnType (struct objc_method
* method
, char *returnValue
,
909 size_t returnValueSize
)
911 if (returnValue
== NULL
|| returnValueSize
== 0)
914 /* Zero the string; we'll then write the argument type at the
915 beginning of it, if needed. */
916 memset (returnValue
, 0, returnValueSize
);
922 size_t argumentTypeSize
;
924 /* Determine argumentTypeSize. */
926 /* Find the end of the first argument. We want to return the
927 first argument spec. */
928 const char *type
= method
->method_types
;
931 type
= objc_skip_argspec (type
);
932 argumentTypeSize
= type
- method
->method_types
;
933 if (argumentTypeSize
> returnValueSize
)
934 argumentTypeSize
= returnValueSize
;
936 /* Copy the argument at the beginning of the string. */
937 memcpy (returnValue
, method
->method_types
, argumentTypeSize
);
941 void method_getArgumentType (struct objc_method
* method
, unsigned int argumentNumber
,
942 char *returnValue
, size_t returnValueSize
)
944 if (returnValue
== NULL
|| returnValueSize
== 0)
947 /* Zero the string; we'll then write the argument type at the
948 beginning of it, if needed. */
949 memset (returnValue
, 0, returnValueSize
);
955 const char *returnValueStart
;
956 size_t argumentTypeSize
;
958 /* Determine returnValueStart and argumentTypeSize. */
960 const char *type
= method
->method_types
;
962 /* Skip the first argument (return type). */
963 type
= objc_skip_argspec (type
);
965 /* Now keep skipping arguments until we get to
967 while (argumentNumber
> 0)
969 /* We are supposed to skip an argument, but the string is
970 finished. This means we were asked for a non-existing
975 type
= objc_skip_argspec (type
);
979 /* If the argument does not exist, it's game over. */
983 returnValueStart
= type
;
984 type
= objc_skip_argspec (type
);
985 argumentTypeSize
= type
- returnValueStart
;
986 if (argumentTypeSize
> returnValueSize
)
987 argumentTypeSize
= returnValueSize
;
989 /* Copy the argument at the beginning of the string. */
990 memcpy (returnValue
, returnValueStart
, argumentTypeSize
);
995 method_getNumberOfArguments (struct objc_method
*method
)
1002 const char *type
= method
->method_types
;
1005 type
= objc_skip_argspec (type
);
1011 /* This could only happen if method_types is invalid; in
1012 that case, return 0. */
1017 /* Remove the return type. */
1024 objc_get_type_qualifiers (const char *type
)
1032 case _C_CONST
: res
|= _F_CONST
; break;
1033 case _C_IN
: res
|= _F_IN
; break;
1034 case _C_INOUT
: res
|= _F_INOUT
; break;
1035 case _C_OUT
: res
|= _F_OUT
; break;
1036 case _C_BYCOPY
: res
|= _F_BYCOPY
; break;
1037 case _C_BYREF
: res
|= _F_BYREF
; break;
1038 case _C_ONEWAY
: res
|= _F_ONEWAY
; break;
1039 case _C_GCINVISIBLE
: res
|= _F_GCINVISIBLE
; break;
1046 /* The following three functions can be used to determine how a
1047 structure is laid out by the compiler. For example:
1049 struct objc_struct_layout layout;
1052 objc_layout_structure (type, &layout);
1053 while (objc_layout_structure_next_member (&layout))
1055 int position, align;
1058 objc_layout_structure_get_info (&layout, &position, &align, &type);
1059 printf ("element %d has offset %d, alignment %d\n",
1060 i++, position, align);
1063 These functions are used by objc_sizeof_type and objc_alignof_type
1064 functions to compute the size and alignment of structures. The
1065 previous method of computing the size and alignment of a structure
1066 was not working on some architectures, particularly on AIX, and in
1067 the presence of bitfields inside the structure. */
1069 objc_layout_structure (const char *type
,
1070 struct objc_struct_layout
*layout
)
1074 if (*type
!= _C_UNION_B
&& *type
!= _C_STRUCT_B
)
1076 _objc_abort ("record (or union) type expected in objc_layout_structure, got %s\n",
1081 layout
->original_type
= type
;
1083 /* Skip "<name>=" if any. Avoid embedded structures and unions. */
1085 while (*ntype
!= _C_STRUCT_E
&& *ntype
!= _C_STRUCT_B
&& *ntype
!= _C_UNION_B
1089 /* If there's a "<name>=", ntype - 1 points to '='; skip the the name */
1090 if (*(ntype
- 1) == '=')
1093 layout
->type
= type
;
1094 layout
->prev_type
= NULL
;
1095 layout
->record_size
= 0;
1096 layout
->record_align
= BITS_PER_UNIT
;
1098 layout
->record_align
= MAX (layout
->record_align
, STRUCTURE_SIZE_BOUNDARY
);
1102 objc_layout_structure_next_member (struct objc_struct_layout
*layout
)
1104 register int desired_align
= 0;
1106 /* The following are used only if the field is a bitfield */
1107 register const char *bfld_type
= 0;
1108 register int bfld_type_align
= 0, bfld_field_size
= 0;
1110 /* The current type without the type qualifiers */
1112 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1114 /* Add the size of the previous field to the size of the record. */
1115 if (layout
->prev_type
)
1117 type
= objc_skip_type_qualifiers (layout
->prev_type
);
1119 layout
->record_size
= MAX (layout
->record_size
,
1120 objc_sizeof_type (type
) * BITS_PER_UNIT
);
1122 else if (*type
!= _C_BFLD
)
1123 layout
->record_size
+= objc_sizeof_type (type
) * BITS_PER_UNIT
;
1125 /* Get the bitfield's type */
1126 for (bfld_type
= type
+ 1;
1127 isdigit ((unsigned char)*bfld_type
);
1131 bfld_type_align
= objc_alignof_type (bfld_type
) * BITS_PER_UNIT
;
1132 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1133 layout
->record_size
+= bfld_field_size
;
1137 if ((unionp
&& *layout
->type
== _C_UNION_E
)
1138 || (!unionp
&& *layout
->type
== _C_STRUCT_E
))
1141 /* Skip the variable name if any */
1142 layout
->type
= objc_skip_variable_name (layout
->type
);
1143 type
= objc_skip_type_qualifiers (layout
->type
);
1145 if (*type
!= _C_BFLD
)
1146 desired_align
= objc_alignof_type (type
) * BITS_PER_UNIT
;
1150 /* Skip the bitfield's offset */
1151 for (bfld_type
= type
+ 1;
1152 isdigit ((unsigned char) *bfld_type
);
1156 bfld_type_align
= objc_alignof_type (bfld_type
) * BITS_PER_UNIT
;
1157 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1160 /* The following won't work for vectors. */
1161 #ifdef BIGGEST_FIELD_ALIGNMENT
1162 desired_align
= MIN (desired_align
, BIGGEST_FIELD_ALIGNMENT
);
1164 #ifdef ADJUST_FIELD_ALIGN
1165 desired_align
= ADJUST_FIELD_ALIGN (type
, desired_align
);
1168 /* Record must have at least as much alignment as any field.
1169 Otherwise, the alignment of the field within the record
1171 #ifndef HAVE_BITFIELD_TYPE_MATTERS
1172 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1173 #else /* PCC_BITFIELD_TYPE_MATTERS */
1174 if (*type
== _C_BFLD
)
1176 /* For these machines, a zero-length field does not
1177 affect the alignment of the structure as a whole.
1178 It does, however, affect the alignment of the next field
1179 within the structure. */
1180 if (bfld_field_size
)
1181 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1183 desired_align
= objc_alignof_type (bfld_type
) * BITS_PER_UNIT
;
1185 /* A named bit field of declared type `int'
1186 forces the entire structure to have `int' alignment.
1187 Q1: How is encoded this thing and how to check for it?
1188 Q2: How to determine maximum_field_alignment at runtime? */
1190 /* if (DECL_NAME (field) != 0) */
1192 int type_align
= bfld_type_align
;
1194 if (maximum_field_alignment
!= 0)
1195 type_align
= MIN (type_align
, maximum_field_alignment
);
1196 else if (DECL_PACKED (field
))
1197 type_align
= MIN (type_align
, BITS_PER_UNIT
);
1200 layout
->record_align
= MAX (layout
->record_align
, type_align
);
1204 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1205 #endif /* PCC_BITFIELD_TYPE_MATTERS */
1207 /* Does this field automatically have alignment it needs
1208 by virtue of the fields that precede it and the record's
1211 if (*type
== _C_BFLD
)
1212 layout
->record_size
= atoi (type
+ 1);
1213 else if (layout
->record_size
% desired_align
!= 0)
1215 /* No, we need to skip space before this field.
1216 Bump the cumulative size to multiple of field alignment. */
1217 layout
->record_size
= ROUND (layout
->record_size
, desired_align
);
1220 /* Jump to the next field in record. */
1222 layout
->prev_type
= layout
->type
;
1223 layout
->type
= objc_skip_typespec (layout
->type
); /* skip component */
1228 void objc_layout_finish_structure (struct objc_struct_layout
*layout
,
1230 unsigned int *align
)
1232 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1234 && ((!unionp
&& *layout
->type
== _C_STRUCT_E
)
1235 || (unionp
&& *layout
->type
== _C_UNION_E
)))
1237 /* Work out the alignment of the record as one expression and store
1238 in the record type. Round it up to a multiple of the record's
1240 #if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
1241 layout
->record_align
= ROUND_TYPE_ALIGN (layout
->original_type
-1,
1243 layout
->record_align
);
1245 layout
->record_align
= MAX (1, layout
->record_align
);
1248 #ifdef ROUND_TYPE_SIZE
1249 layout
->record_size
= ROUND_TYPE_SIZE (layout
->original_type
,
1250 layout
->record_size
,
1251 layout
->record_align
);
1253 /* Round the size up to be a multiple of the required alignment */
1254 layout
->record_size
= ROUND (layout
->record_size
, layout
->record_align
);
1257 layout
->type
= NULL
;
1260 *size
= layout
->record_size
/ BITS_PER_UNIT
;
1262 *align
= layout
->record_align
/ BITS_PER_UNIT
;
1265 void objc_layout_structure_get_info (struct objc_struct_layout
*layout
,
1266 unsigned int *offset
,
1267 unsigned int *align
,
1271 *offset
= layout
->record_size
/ BITS_PER_UNIT
;
1273 *align
= layout
->record_align
/ BITS_PER_UNIT
;
1275 *type
= layout
->prev_type
;