1 /* Encoding of types for Objective C.
2 Copyright (C) 1993-2014 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 ? */
32 #include "objc-private/common.h"
33 #include "objc-private/error.h"
35 #include "coretypes.h"
37 #include "objc/runtime.h"
38 #include "objc-private/module-abi-8.h" /* For struct objc_method */
41 #include <string.h> /* For memcpy. */
45 ({ typeof (X) __x = (X), __y = (Y); \
46 (__x > __y ? __x : __y); })
50 ({ typeof (X) __x = (X), __y = (Y); \
51 (__x < __y ? __x : __y); })
55 ({ typeof (V) __v = (V); typeof (A) __a = (A); \
56 __a * ((__v+__a - 1)/__a); })
59 /* Various hacks for objc_layout_record. These are used by the target
62 #define TREE_CODE(TYPE) *(TYPE)
63 #define TREE_TYPE(TREE) (TREE)
65 #define RECORD_TYPE _C_STRUCT_B
66 #define UNION_TYPE _C_UNION_B
67 #define QUAL_UNION_TYPE _C_UNION_B
68 #define ARRAY_TYPE _C_ARY_B
70 #define REAL_TYPE _C_DBL
72 #define VECTOR_TYPE _C_VECTOR
74 #define TYPE_FIELDS(TYPE) ({const char *_field = (TYPE)+1; \
75 while (*_field != _C_STRUCT_E && *_field != _C_STRUCT_B \
76 && *_field != _C_UNION_B && *_field++ != '=') \
80 #define DECL_MODE(TYPE) *(TYPE)
81 #define TYPE_MODE(TYPE) *(TYPE)
85 #define strip_array_types(TYPE) ({const char *_field = (TYPE); \
86 while (*_field == _C_ARY_B)\
88 while (isdigit ((unsigned char)*++_field))\
93 /* Some ports (eg ARM) allow the structure size boundary to be
94 selected at compile-time. We override the normal definition with
95 one that has a constant value for this compilation. */
97 #define BITS_PER_UNIT 8
99 #undef STRUCTURE_SIZE_BOUNDARY
100 #define STRUCTURE_SIZE_BOUNDARY (BITS_PER_UNIT * sizeof (struct{char a;}))
102 /* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently
103 target_flags. Define a dummy entry here to so we don't die.
104 We have to rename it because target_flags may already have been
106 #define target_flags not_target_flags
107 static int __attribute__ ((__unused__
)) not_target_flags
= 0;
109 /* Some ROUND_TYPE_ALIGN use ALTIVEC_VECTOR_MODE (rs6000 darwin).
110 Define a dummy ALTIVEC_VECTOR_MODE so it will not die. */
111 #undef ALTIVEC_VECTOR_MODE
112 #define ALTIVEC_VECTOR_MODE(MODE) (0)
114 /* Replace TARGET_VSX, TARGET_ALTIVEC, and TARGET_64BIT with constants based on
115 the current switches, rather than looking in the options structure. */
118 #undef TARGET_ALTIVEC
128 #define TARGET_ALTIVEC 1
130 #define TARGET_ALTIVEC 0
134 #define TARGET_64BIT 1
136 #define TARGET_64BIT 0
140 /* Furthermore, some (powerpc) targets also use TARGET_ALIGN_NATURAL
141 in their alignment macros. Currently[4.5/6], rs6000.h points this
142 to a static variable, initialized by target overrides. This is reset
143 in linux64.h but not in darwin64.h. The macro is not used by *86*. */
147 # undef TARGET_ALIGN_NATURAL
148 # define TARGET_ALIGN_NATURAL 1
151 /* On Darwin32, we need to recurse until we find the starting stuct type. */
153 _darwin_rs6000_special_round_type_align (const char *struc
, int comp
, int spec
)
155 const char *_stp
, *_fields
= TYPE_FIELDS (struc
);
157 return MAX (comp
, spec
);
158 _stp
= strip_array_types (_fields
);
159 if (TYPE_MODE(_stp
) == _C_COMPLEX
)
161 switch (TYPE_MODE(_stp
))
165 return MAX (MAX (comp
, spec
), objc_alignof_type (_stp
) * BITS_PER_UNIT
);
170 return MAX (MAX (comp
, spec
), 64);
174 return MAX (comp
, spec
);
179 /* See comment below. */
180 #define darwin_rs6000_special_round_type_align(S,C,S2) \
181 (_darwin_rs6000_special_round_type_align ((char*)(S), (int)(C), (int)(S2)))
184 /* FIXME: while this file has no business including tm.h, this
185 definitely has no business defining this macro but it
186 is only way around without really rewritting this file,
187 should look after the branch of 3.4 to fix this. */
188 #define rs6000_special_round_type_align(STRUCT, COMPUTED, SPECIFIED) \
189 ({ const char *_fields = TYPE_FIELDS (STRUCT); \
191 && TYPE_MODE (strip_array_types (TREE_TYPE (_fields))) == DFmode) \
192 ? MAX (MAX (COMPUTED, SPECIFIED), 64) \
193 : MAX (COMPUTED, SPECIFIED));})
195 #define rs6000_special_adjust_field_align_p(FIELD, COMPUTED) 0
197 /* Skip a variable name, enclosed in quotes ("). */
200 objc_skip_variable_name (const char *type
)
202 /* Skip the variable name if any. */
205 /* FIXME: How do we know we won't read beyond the end of the
206 string. Here and in the rest of the file! */
209 /* Skip to the next '"'. */
220 objc_sizeof_type (const char *type
)
222 type
= objc_skip_variable_name (type
);
226 return sizeof (_Bool
);
234 return sizeof (Class
);
242 return sizeof (char);
246 return sizeof (unsigned char);
250 return sizeof (short);
254 return sizeof (unsigned short);
262 return sizeof (unsigned int);
266 return sizeof (long);
270 return sizeof (unsigned long);
274 return sizeof (long long);
278 return sizeof (unsigned long long);
282 return sizeof (float);
286 return sizeof (double);
290 return sizeof (long double);
294 return sizeof (void);
300 return sizeof (char *);
305 int len
= atoi (type
+ 1);
306 while (isdigit ((unsigned char)*++type
))
308 return len
* objc_aligned_size (type
);
319 /* The size in bytes is the following number. */
320 int size
= atoi (type
);
327 /* The GNU encoding of bitfields is: b 'position' 'type'
330 int startByte
, endByte
;
332 position
= atoi (type
+ 1);
333 while (isdigit ((unsigned char)*++type
))
335 size
= atoi (type
+ 1);
337 startByte
= position
/ BITS_PER_UNIT
;
338 endByte
= (position
+ size
) / BITS_PER_UNIT
;
339 return endByte
- startByte
;
345 struct objc_struct_layout layout
;
348 objc_layout_structure (type
, &layout
);
349 while (objc_layout_structure_next_member (&layout
))
351 objc_layout_finish_structure (&layout
, &size
, NULL
);
358 type
++; /* Skip after the 'j'. */
362 return sizeof (_Complex
char);
366 return sizeof (_Complex
unsigned char);
370 return sizeof (_Complex
short);
374 return sizeof (_Complex
unsigned short);
378 return sizeof (_Complex
int);
382 return sizeof (_Complex
unsigned int);
386 return sizeof (_Complex
long);
390 return sizeof (_Complex
unsigned long);
394 return sizeof (_Complex
long long);
398 return sizeof (_Complex
unsigned long long);
402 return sizeof (_Complex
float);
406 return sizeof (_Complex
double);
410 return sizeof (_Complex
long double);
415 /* FIXME: Is this so bad that we have to abort the
416 entire program ? (it applies to all the other
417 _objc_abort calls in this file).
419 _objc_abort ("unknown complex type %s\n", type
);
427 _objc_abort ("unknown type %s\n", type
);
434 objc_alignof_type (const char *type
)
436 type
= objc_skip_variable_name (type
);
440 return __alignof__ (_Bool
);
444 return __alignof__ (id
);
448 return __alignof__ (Class
);
452 return __alignof__ (SEL
);
456 return __alignof__ (char);
460 return __alignof__ (unsigned char);
464 return __alignof__ (short);
468 return __alignof__ (unsigned short);
472 return __alignof__ (int);
476 return __alignof__ (unsigned int);
480 return __alignof__ (long);
484 return __alignof__ (unsigned long);
488 return __alignof__ (long long);
492 return __alignof__ (unsigned long long);
496 return __alignof__ (float);
500 return __alignof__ (double);
504 return __alignof__ (long double);
510 return __alignof__ (char *);
514 while (isdigit ((unsigned char)*++type
))
516 return objc_alignof_type (type
);
526 while (isdigit ((unsigned char)*type
))
532 /* The alignment in bytes is the following number. */
538 struct objc_struct_layout layout
;
541 objc_layout_structure (type
, &layout
);
542 while (objc_layout_structure_next_member (&layout
))
544 objc_layout_finish_structure (&layout
, NULL
, &align
);
552 type
++; /* Skip after the 'j'. */
556 return __alignof__ (_Complex
char);
560 return __alignof__ (_Complex
unsigned char);
564 return __alignof__ (_Complex
short);
568 return __alignof__ (_Complex
unsigned short);
572 return __alignof__ (_Complex
int);
576 return __alignof__ (_Complex
unsigned int);
580 return __alignof__ (_Complex
long);
584 return __alignof__ (_Complex
unsigned long);
588 return __alignof__ (_Complex
long long);
592 return __alignof__ (_Complex
unsigned long long);
596 return __alignof__ (_Complex
float);
600 return __alignof__ (_Complex
double);
604 return __alignof__ (_Complex
long double);
609 _objc_abort ("unknown complex type %s\n", type
);
617 _objc_abort ("unknown type %s\n", type
);
624 objc_aligned_size (const char *type
)
628 type
= objc_skip_variable_name (type
);
629 size
= objc_sizeof_type (type
);
630 align
= objc_alignof_type (type
);
632 return ROUND (size
, align
);
636 objc_promoted_size (const char *type
)
640 type
= objc_skip_variable_name (type
);
641 size
= objc_sizeof_type (type
);
642 wordsize
= sizeof (void *);
644 return ROUND (size
, wordsize
);
649 objc_skip_type_qualifiers (const char *type
)
651 while (*type
== _C_CONST
655 || *type
== _C_BYCOPY
657 || *type
== _C_ONEWAY
658 || *type
== _C_GCINVISIBLE
)
667 objc_skip_typespec (const char *type
)
669 type
= objc_skip_variable_name (type
);
670 type
= objc_skip_type_qualifiers (type
);
675 /* An id may be annotated by the actual type if it is known
676 with the @"ClassName" syntax */
682 while (*++type
!= '"')
687 /* The following are one character type codes */
716 /* skip digits, typespec and closing ']' */
717 while (isdigit ((unsigned char)*++type
))
719 type
= objc_skip_typespec (type
);
720 if (*type
== _C_ARY_E
)
724 _objc_abort ("bad array type %s\n", type
);
733 /* Skip digits (size) */
734 while (isdigit ((unsigned char)*type
))
738 /* Skip digits (alignment) */
739 while (isdigit ((unsigned char)*type
))
742 type
= objc_skip_typespec (type
);
743 /* Skip closing ']'. */
744 if (*type
== _C_ARY_E
)
748 _objc_abort ("bad vector type %s\n", type
);
753 /* The GNU encoding of bitfields is: b 'position' 'type'
755 while (isdigit ((unsigned char)*++type
))
756 ; /* skip position */
757 while (isdigit ((unsigned char)*++type
))
758 ; /* skip type and size */
762 /* skip name, and elements until closing '}' */
764 while (*type
!= _C_STRUCT_E
&& *type
++ != '=')
766 while (*type
!= _C_STRUCT_E
)
768 type
= objc_skip_typespec (type
);
773 /* skip name, and elements until closing ')' */
775 while (*type
!= _C_UNION_E
&& *type
++ != '=')
777 while (*type
!= _C_UNION_E
)
779 type
= objc_skip_typespec (type
);
784 /* Just skip the following typespec */
786 return objc_skip_typespec (++type
);
790 _objc_abort ("unknown type %s\n", type
);
798 objc_skip_offset (const char *type
)
800 /* The offset is prepended by a '+' if the argument is passed in
801 registers. PS: The compiler stopped generating this '+' in
806 /* Some people claim that on some platforms, where the stack grows
807 backwards, the compiler generates negative offsets (??). Skip a
808 '-' for such a negative offset. */
812 /* Skip the digits that represent the offset. */
813 while (isdigit ((unsigned char) *type
))
820 objc_skip_argspec (const char *type
)
822 type
= objc_skip_typespec (type
);
823 type
= objc_skip_offset (type
);
828 method_copyReturnType (struct objc_method
*method
)
835 size_t returnValueSize
;
837 /* Determine returnValueSize. */
839 /* Find the end of the first argument. We want to return the
840 first argument spec, plus 1 byte for the \0 at the end. */
841 const char *type
= method
->method_types
;
844 type
= objc_skip_argspec (type
);
845 returnValueSize
= type
- method
->method_types
+ 1;
848 /* Copy the first argument into returnValue. */
849 returnValue
= malloc (sizeof (char) * returnValueSize
);
850 memcpy (returnValue
, method
->method_types
, returnValueSize
);
851 returnValue
[returnValueSize
- 1] = '\0';
858 method_copyArgumentType (struct objc_method
* method
, unsigned int argumentNumber
)
865 const char *returnValueStart
;
866 size_t returnValueSize
;
868 /* Determine returnValueStart and returnValueSize. */
870 const char *type
= method
->method_types
;
872 /* Skip the first argument (return type). */
873 type
= objc_skip_argspec (type
);
875 /* Now keep skipping arguments until we get to
877 while (argumentNumber
> 0)
879 /* We are supposed to skip an argument, but the string is
880 finished. This means we were asked for a non-existing
885 type
= objc_skip_argspec (type
);
889 /* If the argument does not exist, return NULL. */
893 returnValueStart
= type
;
894 type
= objc_skip_argspec (type
);
895 returnValueSize
= type
- returnValueStart
+ 1;
898 /* Copy the argument into returnValue. */
899 returnValue
= malloc (sizeof (char) * returnValueSize
);
900 memcpy (returnValue
, returnValueStart
, returnValueSize
);
901 returnValue
[returnValueSize
- 1] = '\0';
907 void method_getReturnType (struct objc_method
* method
, char *returnValue
,
908 size_t returnValueSize
)
910 if (returnValue
== NULL
|| returnValueSize
== 0)
913 /* Zero the string; we'll then write the argument type at the
914 beginning of it, if needed. */
915 memset (returnValue
, 0, returnValueSize
);
921 size_t argumentTypeSize
;
923 /* Determine argumentTypeSize. */
925 /* Find the end of the first argument. We want to return the
926 first argument spec. */
927 const char *type
= method
->method_types
;
930 type
= objc_skip_argspec (type
);
931 argumentTypeSize
= type
- method
->method_types
;
932 if (argumentTypeSize
> returnValueSize
)
933 argumentTypeSize
= returnValueSize
;
935 /* Copy the argument at the beginning of the string. */
936 memcpy (returnValue
, method
->method_types
, argumentTypeSize
);
940 void method_getArgumentType (struct objc_method
* method
, unsigned int argumentNumber
,
941 char *returnValue
, size_t returnValueSize
)
943 if (returnValue
== NULL
|| returnValueSize
== 0)
946 /* Zero the string; we'll then write the argument type at the
947 beginning of it, if needed. */
948 memset (returnValue
, 0, returnValueSize
);
954 const char *returnValueStart
;
955 size_t argumentTypeSize
;
957 /* Determine returnValueStart and argumentTypeSize. */
959 const char *type
= method
->method_types
;
961 /* Skip the first argument (return type). */
962 type
= objc_skip_argspec (type
);
964 /* Now keep skipping arguments until we get to
966 while (argumentNumber
> 0)
968 /* We are supposed to skip an argument, but the string is
969 finished. This means we were asked for a non-existing
974 type
= objc_skip_argspec (type
);
978 /* If the argument does not exist, it's game over. */
982 returnValueStart
= type
;
983 type
= objc_skip_argspec (type
);
984 argumentTypeSize
= type
- returnValueStart
;
985 if (argumentTypeSize
> returnValueSize
)
986 argumentTypeSize
= returnValueSize
;
988 /* Copy the argument at the beginning of the string. */
989 memcpy (returnValue
, returnValueStart
, argumentTypeSize
);
994 method_getNumberOfArguments (struct objc_method
*method
)
1001 const char *type
= method
->method_types
;
1004 type
= objc_skip_argspec (type
);
1010 /* This could only happen if method_types is invalid; in
1011 that case, return 0. */
1016 /* Remove the return type. */
1023 objc_get_type_qualifiers (const char *type
)
1031 case _C_CONST
: res
|= _F_CONST
; break;
1032 case _C_IN
: res
|= _F_IN
; break;
1033 case _C_INOUT
: res
|= _F_INOUT
; break;
1034 case _C_OUT
: res
|= _F_OUT
; break;
1035 case _C_BYCOPY
: res
|= _F_BYCOPY
; break;
1036 case _C_BYREF
: res
|= _F_BYREF
; break;
1037 case _C_ONEWAY
: res
|= _F_ONEWAY
; break;
1038 case _C_GCINVISIBLE
: res
|= _F_GCINVISIBLE
; break;
1045 /* The following three functions can be used to determine how a
1046 structure is laid out by the compiler. For example:
1048 struct objc_struct_layout layout;
1051 objc_layout_structure (type, &layout);
1052 while (objc_layout_structure_next_member (&layout))
1054 int position, align;
1057 objc_layout_structure_get_info (&layout, &position, &align, &type);
1058 printf ("element %d has offset %d, alignment %d\n",
1059 i++, position, align);
1062 These functions are used by objc_sizeof_type and objc_alignof_type
1063 functions to compute the size and alignment of structures. The
1064 previous method of computing the size and alignment of a structure
1065 was not working on some architectures, particularly on AIX, and in
1066 the presence of bitfields inside the structure. */
1068 objc_layout_structure (const char *type
,
1069 struct objc_struct_layout
*layout
)
1073 if (*type
!= _C_UNION_B
&& *type
!= _C_STRUCT_B
)
1075 _objc_abort ("record (or union) type expected in objc_layout_structure, got %s\n",
1080 layout
->original_type
= type
;
1082 /* Skip "<name>=" if any. Avoid embedded structures and unions. */
1084 while (*ntype
!= _C_STRUCT_E
&& *ntype
!= _C_STRUCT_B
&& *ntype
!= _C_UNION_B
1088 /* If there's a "<name>=", ntype - 1 points to '='; skip the the name */
1089 if (*(ntype
- 1) == '=')
1092 layout
->type
= type
;
1093 layout
->prev_type
= NULL
;
1094 layout
->record_size
= 0;
1095 layout
->record_align
= BITS_PER_UNIT
;
1097 layout
->record_align
= MAX (layout
->record_align
, STRUCTURE_SIZE_BOUNDARY
);
1101 objc_layout_structure_next_member (struct objc_struct_layout
*layout
)
1103 register int desired_align
= 0;
1105 /* The following are used only if the field is a bitfield */
1106 register const char *bfld_type
= 0;
1107 register int bfld_type_align
= 0, bfld_field_size
= 0;
1109 /* The current type without the type qualifiers */
1111 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1113 /* Add the size of the previous field to the size of the record. */
1114 if (layout
->prev_type
)
1116 type
= objc_skip_type_qualifiers (layout
->prev_type
);
1118 layout
->record_size
= MAX (layout
->record_size
,
1119 objc_sizeof_type (type
) * BITS_PER_UNIT
);
1121 else if (*type
!= _C_BFLD
)
1122 layout
->record_size
+= objc_sizeof_type (type
) * BITS_PER_UNIT
;
1124 /* Get the bitfield's type */
1125 for (bfld_type
= type
+ 1;
1126 isdigit ((unsigned char)*bfld_type
);
1130 bfld_type_align
= objc_alignof_type (bfld_type
) * BITS_PER_UNIT
;
1131 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1132 layout
->record_size
+= bfld_field_size
;
1136 if ((unionp
&& *layout
->type
== _C_UNION_E
)
1137 || (!unionp
&& *layout
->type
== _C_STRUCT_E
))
1140 /* Skip the variable name if any */
1141 layout
->type
= objc_skip_variable_name (layout
->type
);
1142 type
= objc_skip_type_qualifiers (layout
->type
);
1144 if (*type
!= _C_BFLD
)
1145 desired_align
= objc_alignof_type (type
) * BITS_PER_UNIT
;
1149 /* Skip the bitfield's offset */
1150 for (bfld_type
= type
+ 1;
1151 isdigit ((unsigned char) *bfld_type
);
1155 bfld_type_align
= objc_alignof_type (bfld_type
) * BITS_PER_UNIT
;
1156 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1159 /* The following won't work for vectors. */
1160 #ifdef BIGGEST_FIELD_ALIGNMENT
1161 desired_align
= MIN (desired_align
, BIGGEST_FIELD_ALIGNMENT
);
1163 #ifdef ADJUST_FIELD_ALIGN
1164 desired_align
= ADJUST_FIELD_ALIGN (type
, desired_align
);
1167 /* Record must have at least as much alignment as any field.
1168 Otherwise, the alignment of the field within the record
1170 #ifndef PCC_BITFIELD_TYPE_MATTERS
1171 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1172 #else /* PCC_BITFIELD_TYPE_MATTERS */
1173 if (*type
== _C_BFLD
)
1175 /* For these machines, a zero-length field does not
1176 affect the alignment of the structure as a whole.
1177 It does, however, affect the alignment of the next field
1178 within the structure. */
1179 if (bfld_field_size
)
1180 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1182 desired_align
= objc_alignof_type (bfld_type
) * BITS_PER_UNIT
;
1184 /* A named bit field of declared type `int'
1185 forces the entire structure to have `int' alignment.
1186 Q1: How is encoded this thing and how to check for it?
1187 Q2: How to determine maximum_field_alignment at runtime? */
1189 /* if (DECL_NAME (field) != 0) */
1191 int type_align
= bfld_type_align
;
1193 if (maximum_field_alignment
!= 0)
1194 type_align
= MIN (type_align
, maximum_field_alignment
);
1195 else if (DECL_PACKED (field
))
1196 type_align
= MIN (type_align
, BITS_PER_UNIT
);
1199 layout
->record_align
= MAX (layout
->record_align
, type_align
);
1203 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1204 #endif /* PCC_BITFIELD_TYPE_MATTERS */
1206 /* Does this field automatically have alignment it needs
1207 by virtue of the fields that precede it and the record's
1210 if (*type
== _C_BFLD
)
1211 layout
->record_size
= atoi (type
+ 1);
1212 else if (layout
->record_size
% desired_align
!= 0)
1214 /* No, we need to skip space before this field.
1215 Bump the cumulative size to multiple of field alignment. */
1216 layout
->record_size
= ROUND (layout
->record_size
, desired_align
);
1219 /* Jump to the next field in record. */
1221 layout
->prev_type
= layout
->type
;
1222 layout
->type
= objc_skip_typespec (layout
->type
); /* skip component */
1227 void objc_layout_finish_structure (struct objc_struct_layout
*layout
,
1229 unsigned int *align
)
1231 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1233 && ((!unionp
&& *layout
->type
== _C_STRUCT_E
)
1234 || (unionp
&& *layout
->type
== _C_UNION_E
)))
1236 /* Work out the alignment of the record as one expression and store
1237 in the record type. Round it up to a multiple of the record's
1239 #if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
1240 layout
->record_align
= ROUND_TYPE_ALIGN (layout
->original_type
-1,
1242 layout
->record_align
);
1244 layout
->record_align
= MAX (1, layout
->record_align
);
1247 #ifdef ROUND_TYPE_SIZE
1248 layout
->record_size
= ROUND_TYPE_SIZE (layout
->original_type
,
1249 layout
->record_size
,
1250 layout
->record_align
);
1252 /* Round the size up to be a multiple of the required alignment */
1253 layout
->record_size
= ROUND (layout
->record_size
, layout
->record_align
);
1256 layout
->type
= NULL
;
1259 *size
= layout
->record_size
/ BITS_PER_UNIT
;
1261 *align
= layout
->record_align
/ BITS_PER_UNIT
;
1264 void objc_layout_structure_get_info (struct objc_struct_layout
*layout
,
1265 unsigned int *offset
,
1266 unsigned int *align
,
1270 *offset
= layout
->record_size
/ BITS_PER_UNIT
;
1272 *align
= layout
->record_align
/ BITS_PER_UNIT
;
1274 *type
= layout
->prev_type
;