1 /* Encoding of types for Objective C.
2 Copyright (C) 1993-2022 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
149 /* On Darwin32, we need to recurse until we find the starting stuct type. */
151 _darwin_rs6000_special_round_type_align (const char *struc
, int comp
, int spec
)
153 const char *_stp
, *_fields
= TYPE_FIELDS (struc
);
155 return MAX (comp
, spec
);
156 _stp
= strip_array_types (_fields
);
157 if (TYPE_MODE(_stp
) == _C_COMPLEX
)
159 switch (TYPE_MODE(_stp
))
163 return MAX (MAX (comp
, spec
), objc_alignof_type (_stp
) * __CHAR_BIT__
);
168 return MAX (MAX (comp
, spec
), 64);
172 return MAX (comp
, spec
);
177 /* See comment below. */
178 #define darwin_rs6000_special_round_type_align(S,C,S2) \
179 (_darwin_rs6000_special_round_type_align ((char*)(S), (int)(C), (int)(S2)))
182 /* FIXME: while this file has no business including tm.h, this
183 definitely has no business defining this macro but it
184 is only way around without really rewritting this file,
185 should look after the branch of 3.4 to fix this. */
186 #define rs6000_special_round_type_align(STRUCT, COMPUTED, SPECIFIED) \
187 ({ const char *_fields = TYPE_FIELDS (STRUCT); \
189 && TYPE_MODE (strip_array_types (TREE_TYPE (_fields))) == DFmode) \
190 ? MAX (MAX (COMPUTED, SPECIFIED), 64) \
191 : MAX (COMPUTED, SPECIFIED));})
193 #define rs6000_special_adjust_field_align_p(FIELD, COMPUTED) 0
195 /* Skip a variable name, enclosed in quotes ("). */
198 objc_skip_variable_name (const char *type
)
200 /* Skip the variable name if any. */
203 /* FIXME: How do we know we won't read beyond the end of the
204 string. Here and in the rest of the file! */
207 /* Skip to the next '"'. */
218 objc_sizeof_type (const char *type
)
220 type
= objc_skip_variable_name (type
);
224 return sizeof (_Bool
);
232 return sizeof (Class
);
240 return sizeof (char);
244 return sizeof (unsigned char);
248 return sizeof (short);
252 return sizeof (unsigned short);
260 return sizeof (unsigned int);
264 return sizeof (long);
268 return sizeof (unsigned long);
272 return sizeof (long long);
276 return sizeof (unsigned long long);
280 return sizeof (float);
284 return sizeof (double);
288 return sizeof (long double);
292 return sizeof (void);
298 return sizeof (char *);
303 int len
= atoi (type
+ 1);
304 while (isdigit ((unsigned char)*++type
))
306 return len
* objc_aligned_size (type
);
317 /* The size in bytes is the following number. */
318 int size
= atoi (type
);
325 /* The GNU encoding of bitfields is: b 'position' 'type'
328 int startByte
, endByte
;
330 position
= atoi (type
+ 1);
331 while (isdigit ((unsigned char)*++type
))
333 size
= atoi (type
+ 1);
335 startByte
= position
/ __CHAR_BIT__
;
336 endByte
= (position
+ size
) / __CHAR_BIT__
;
337 return endByte
- startByte
;
343 struct objc_struct_layout layout
;
346 objc_layout_structure (type
, &layout
);
347 while (objc_layout_structure_next_member (&layout
))
349 objc_layout_finish_structure (&layout
, &size
, NULL
);
356 type
++; /* Skip after the 'j'. */
360 return sizeof (_Complex
char);
364 return sizeof (_Complex
unsigned char);
368 return sizeof (_Complex
short);
372 return sizeof (_Complex
unsigned short);
376 return sizeof (_Complex
int);
380 return sizeof (_Complex
unsigned int);
384 return sizeof (_Complex
long);
388 return sizeof (_Complex
unsigned long);
392 return sizeof (_Complex
long long);
396 return sizeof (_Complex
unsigned long long);
400 return sizeof (_Complex
float);
404 return sizeof (_Complex
double);
408 return sizeof (_Complex
long double);
413 /* FIXME: Is this so bad that we have to abort the
414 entire program ? (it applies to all the other
415 _objc_abort calls in this file).
417 _objc_abort ("unknown complex type %s\n", type
);
425 _objc_abort ("unknown type %s\n", type
);
432 objc_alignof_type (const char *type
)
434 type
= objc_skip_variable_name (type
);
438 return __alignof__ (_Bool
);
442 return __alignof__ (id
);
446 return __alignof__ (Class
);
450 return __alignof__ (SEL
);
454 return __alignof__ (char);
458 return __alignof__ (unsigned char);
462 return __alignof__ (short);
466 return __alignof__ (unsigned short);
470 return __alignof__ (int);
474 return __alignof__ (unsigned int);
478 return __alignof__ (long);
482 return __alignof__ (unsigned long);
486 return __alignof__ (long long);
490 return __alignof__ (unsigned long long);
494 return __alignof__ (float);
498 return __alignof__ (double);
502 return __alignof__ (long double);
508 return __alignof__ (char *);
512 while (isdigit ((unsigned char)*++type
))
514 return objc_alignof_type (type
);
524 while (isdigit ((unsigned char)*type
))
530 /* The alignment in bytes is the following number. */
536 struct objc_struct_layout layout
;
539 objc_layout_structure (type
, &layout
);
540 while (objc_layout_structure_next_member (&layout
))
542 objc_layout_finish_structure (&layout
, NULL
, &align
);
550 type
++; /* Skip after the 'j'. */
554 return __alignof__ (_Complex
char);
558 return __alignof__ (_Complex
unsigned char);
562 return __alignof__ (_Complex
short);
566 return __alignof__ (_Complex
unsigned short);
570 return __alignof__ (_Complex
int);
574 return __alignof__ (_Complex
unsigned int);
578 return __alignof__ (_Complex
long);
582 return __alignof__ (_Complex
unsigned long);
586 return __alignof__ (_Complex
long long);
590 return __alignof__ (_Complex
unsigned long long);
594 return __alignof__ (_Complex
float);
598 return __alignof__ (_Complex
double);
602 return __alignof__ (_Complex
long double);
607 _objc_abort ("unknown complex type %s\n", type
);
615 _objc_abort ("unknown type %s\n", type
);
622 objc_aligned_size (const char *type
)
626 type
= objc_skip_variable_name (type
);
627 size
= objc_sizeof_type (type
);
628 align
= objc_alignof_type (type
);
630 return ROUND (size
, align
);
634 objc_promoted_size (const char *type
)
638 type
= objc_skip_variable_name (type
);
639 size
= objc_sizeof_type (type
);
640 wordsize
= sizeof (void *);
642 return ROUND (size
, wordsize
);
647 objc_skip_type_qualifiers (const char *type
)
649 while (*type
== _C_CONST
653 || *type
== _C_BYCOPY
655 || *type
== _C_ONEWAY
656 || *type
== _C_GCINVISIBLE
)
665 objc_skip_typespec (const char *type
)
667 type
= objc_skip_variable_name (type
);
668 type
= objc_skip_type_qualifiers (type
);
673 /* An id may be annotated by the actual type if it is known
674 with the @"ClassName" syntax */
680 while (*++type
!= '"')
685 /* The following are one character type codes */
714 /* skip digits, typespec and closing ']' */
715 while (isdigit ((unsigned char)*++type
))
717 type
= objc_skip_typespec (type
);
718 if (*type
== _C_ARY_E
)
722 _objc_abort ("bad array type %s\n", type
);
731 /* Skip digits (size) */
732 while (isdigit ((unsigned char)*type
))
736 /* Skip digits (alignment) */
737 while (isdigit ((unsigned char)*type
))
740 type
= objc_skip_typespec (type
);
741 /* Skip closing ']'. */
742 if (*type
== _C_ARY_E
)
746 _objc_abort ("bad vector type %s\n", type
);
751 /* The GNU encoding of bitfields is: b 'position' 'type'
753 while (isdigit ((unsigned char)*++type
))
754 ; /* skip position */
755 while (isdigit ((unsigned char)*++type
))
756 ; /* skip type and size */
760 /* skip name, and elements until closing '}' */
762 while (*type
!= _C_STRUCT_E
&& *type
++ != '=')
764 while (*type
!= _C_STRUCT_E
)
766 type
= objc_skip_typespec (type
);
771 /* skip name, and elements until closing ')' */
773 while (*type
!= _C_UNION_E
&& *type
++ != '=')
775 while (*type
!= _C_UNION_E
)
777 type
= objc_skip_typespec (type
);
782 /* Just skip the following typespec */
784 return objc_skip_typespec (++type
);
788 _objc_abort ("unknown type %s\n", type
);
796 objc_skip_offset (const char *type
)
798 /* The offset is prepended by a '+' if the argument is passed in
799 registers. PS: The compiler stopped generating this '+' in
804 /* Some people claim that on some platforms, where the stack grows
805 backwards, the compiler generates negative offsets (??). Skip a
806 '-' for such a negative offset. */
810 /* Skip the digits that represent the offset. */
811 while (isdigit ((unsigned char) *type
))
818 objc_skip_argspec (const char *type
)
820 type
= objc_skip_typespec (type
);
821 type
= objc_skip_offset (type
);
826 method_copyReturnType (struct objc_method
*method
)
833 size_t returnValueSize
;
835 /* Determine returnValueSize. */
837 /* Find the end of the first argument. We want to return the
838 first argument spec, plus 1 byte for the \0 at the end. */
839 const char *type
= method
->method_types
;
842 type
= objc_skip_argspec (type
);
843 returnValueSize
= type
- method
->method_types
+ 1;
846 /* Copy the first argument into returnValue. */
847 returnValue
= malloc (sizeof (char) * returnValueSize
);
848 memcpy (returnValue
, method
->method_types
, returnValueSize
);
849 returnValue
[returnValueSize
- 1] = '\0';
856 method_copyArgumentType (struct objc_method
* method
, unsigned int argumentNumber
)
863 const char *returnValueStart
;
864 size_t returnValueSize
;
866 /* Determine returnValueStart and returnValueSize. */
868 const char *type
= method
->method_types
;
870 /* Skip the first argument (return type). */
871 type
= objc_skip_argspec (type
);
873 /* Now keep skipping arguments until we get to
875 while (argumentNumber
> 0)
877 /* We are supposed to skip an argument, but the string is
878 finished. This means we were asked for a non-existing
883 type
= objc_skip_argspec (type
);
887 /* If the argument does not exist, return NULL. */
891 returnValueStart
= type
;
892 type
= objc_skip_argspec (type
);
893 returnValueSize
= type
- returnValueStart
+ 1;
896 /* Copy the argument into returnValue. */
897 returnValue
= malloc (sizeof (char) * returnValueSize
);
898 memcpy (returnValue
, returnValueStart
, returnValueSize
);
899 returnValue
[returnValueSize
- 1] = '\0';
905 void method_getReturnType (struct objc_method
* method
, char *returnValue
,
906 size_t returnValueSize
)
908 if (returnValue
== NULL
|| returnValueSize
== 0)
911 /* Zero the string; we'll then write the argument type at the
912 beginning of it, if needed. */
913 memset (returnValue
, 0, returnValueSize
);
919 size_t argumentTypeSize
;
921 /* Determine argumentTypeSize. */
923 /* Find the end of the first argument. We want to return the
924 first argument spec. */
925 const char *type
= method
->method_types
;
928 type
= objc_skip_argspec (type
);
929 argumentTypeSize
= type
- method
->method_types
;
930 if (argumentTypeSize
> returnValueSize
)
931 argumentTypeSize
= returnValueSize
;
933 /* Copy the argument at the beginning of the string. */
934 memcpy (returnValue
, method
->method_types
, argumentTypeSize
);
938 void method_getArgumentType (struct objc_method
* method
, unsigned int argumentNumber
,
939 char *returnValue
, size_t returnValueSize
)
941 if (returnValue
== NULL
|| returnValueSize
== 0)
944 /* Zero the string; we'll then write the argument type at the
945 beginning of it, if needed. */
946 memset (returnValue
, 0, returnValueSize
);
952 const char *returnValueStart
;
953 size_t argumentTypeSize
;
955 /* Determine returnValueStart and argumentTypeSize. */
957 const char *type
= method
->method_types
;
959 /* Skip the first argument (return type). */
960 type
= objc_skip_argspec (type
);
962 /* Now keep skipping arguments until we get to
964 while (argumentNumber
> 0)
966 /* We are supposed to skip an argument, but the string is
967 finished. This means we were asked for a non-existing
972 type
= objc_skip_argspec (type
);
976 /* If the argument does not exist, it's game over. */
980 returnValueStart
= type
;
981 type
= objc_skip_argspec (type
);
982 argumentTypeSize
= type
- returnValueStart
;
983 if (argumentTypeSize
> returnValueSize
)
984 argumentTypeSize
= returnValueSize
;
986 /* Copy the argument at the beginning of the string. */
987 memcpy (returnValue
, returnValueStart
, argumentTypeSize
);
992 method_getNumberOfArguments (struct objc_method
*method
)
999 const char *type
= method
->method_types
;
1002 type
= objc_skip_argspec (type
);
1008 /* This could only happen if method_types is invalid; in
1009 that case, return 0. */
1014 /* Remove the return type. */
1021 objc_get_type_qualifiers (const char *type
)
1029 case _C_CONST
: res
|= _F_CONST
; break;
1030 case _C_IN
: res
|= _F_IN
; break;
1031 case _C_INOUT
: res
|= _F_INOUT
; break;
1032 case _C_OUT
: res
|= _F_OUT
; break;
1033 case _C_BYCOPY
: res
|= _F_BYCOPY
; break;
1034 case _C_BYREF
: res
|= _F_BYREF
; break;
1035 case _C_ONEWAY
: res
|= _F_ONEWAY
; break;
1036 case _C_GCINVISIBLE
: res
|= _F_GCINVISIBLE
; break;
1043 /* The following three functions can be used to determine how a
1044 structure is laid out by the compiler. For example:
1046 struct objc_struct_layout layout;
1049 objc_layout_structure (type, &layout);
1050 while (objc_layout_structure_next_member (&layout))
1052 int position, align;
1055 objc_layout_structure_get_info (&layout, &position, &align, &type);
1056 printf ("element %d has offset %d, alignment %d\n",
1057 i++, position, align);
1060 These functions are used by objc_sizeof_type and objc_alignof_type
1061 functions to compute the size and alignment of structures. The
1062 previous method of computing the size and alignment of a structure
1063 was not working on some architectures, particularly on AIX, and in
1064 the presence of bitfields inside the structure. */
1066 objc_layout_structure (const char *type
,
1067 struct objc_struct_layout
*layout
)
1071 if (*type
!= _C_UNION_B
&& *type
!= _C_STRUCT_B
)
1073 _objc_abort ("record (or union) type expected in objc_layout_structure, got %s\n",
1078 layout
->original_type
= type
;
1080 /* Skip "<name>=" if any. Avoid embedded structures and unions. */
1082 while (*ntype
!= _C_STRUCT_E
&& *ntype
!= _C_STRUCT_B
&& *ntype
!= _C_UNION_B
1086 /* If there's a "<name>=", ntype - 1 points to '='; skip the the name */
1087 if (*(ntype
- 1) == '=')
1090 layout
->type
= type
;
1091 layout
->prev_type
= NULL
;
1092 layout
->record_size
= 0;
1093 layout
->record_align
= __CHAR_BIT__
;
1095 layout
->record_align
= MAX (layout
->record_align
, STRUCTURE_SIZE_BOUNDARY
);
1099 objc_layout_structure_next_member (struct objc_struct_layout
*layout
)
1101 register int desired_align
= 0;
1103 /* The following are used only if the field is a bitfield */
1104 register const char *bfld_type
= 0;
1105 register int bfld_type_align
= 0, bfld_field_size
= 0;
1107 /* The current type without the type qualifiers */
1109 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1111 /* Add the size of the previous field to the size of the record. */
1112 if (layout
->prev_type
)
1114 type
= objc_skip_type_qualifiers (layout
->prev_type
);
1116 layout
->record_size
= MAX (layout
->record_size
,
1117 objc_sizeof_type (type
) * __CHAR_BIT__
);
1119 else if (*type
!= _C_BFLD
)
1120 layout
->record_size
+= objc_sizeof_type (type
) * __CHAR_BIT__
;
1122 /* Get the bitfield's type */
1123 for (bfld_type
= type
+ 1;
1124 isdigit ((unsigned char)*bfld_type
);
1128 bfld_type_align
= objc_alignof_type (bfld_type
) * __CHAR_BIT__
;
1129 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1130 layout
->record_size
+= bfld_field_size
;
1134 if ((unionp
&& *layout
->type
== _C_UNION_E
)
1135 || (!unionp
&& *layout
->type
== _C_STRUCT_E
))
1138 /* Skip the variable name if any */
1139 layout
->type
= objc_skip_variable_name (layout
->type
);
1140 type
= objc_skip_type_qualifiers (layout
->type
);
1142 if (*type
!= _C_BFLD
)
1143 desired_align
= objc_alignof_type (type
) * __CHAR_BIT__
;
1147 /* Skip the bitfield's offset */
1148 for (bfld_type
= type
+ 1;
1149 isdigit ((unsigned char) *bfld_type
);
1153 bfld_type_align
= objc_alignof_type (bfld_type
) * __CHAR_BIT__
;
1154 bfld_field_size
= atoi (objc_skip_typespec (bfld_type
));
1157 /* The following won't work for vectors. */
1158 #ifdef BIGGEST_FIELD_ALIGNMENT
1159 desired_align
= MIN (desired_align
, BIGGEST_FIELD_ALIGNMENT
);
1161 #ifdef ADJUST_FIELD_ALIGN
1162 desired_align
= ADJUST_FIELD_ALIGN (type
, type
, desired_align
);
1165 /* Record must have at least as much alignment as any field.
1166 Otherwise, the alignment of the field within the record
1168 #ifndef HAVE_BITFIELD_TYPE_MATTERS
1169 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1170 #else /* PCC_BITFIELD_TYPE_MATTERS */
1171 if (*type
== _C_BFLD
)
1173 /* For these machines, a zero-length field does not
1174 affect the alignment of the structure as a whole.
1175 It does, however, affect the alignment of the next field
1176 within the structure. */
1177 if (bfld_field_size
)
1178 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1180 desired_align
= objc_alignof_type (bfld_type
) * __CHAR_BIT__
;
1182 /* A named bit field of declared type `int'
1183 forces the entire structure to have `int' alignment.
1184 Q1: How is encoded this thing and how to check for it?
1185 Q2: How to determine maximum_field_alignment at runtime? */
1187 /* if (DECL_NAME (field) != 0) */
1189 int type_align
= bfld_type_align
;
1191 if (maximum_field_alignment
!= 0)
1192 type_align
= MIN (type_align
, maximum_field_alignment
);
1193 else if (DECL_PACKED (field
))
1194 type_align
= MIN (type_align
, __CHAR_BIT__
);
1197 layout
->record_align
= MAX (layout
->record_align
, type_align
);
1201 layout
->record_align
= MAX (layout
->record_align
, desired_align
);
1202 #endif /* PCC_BITFIELD_TYPE_MATTERS */
1204 /* Does this field automatically have alignment it needs
1205 by virtue of the fields that precede it and the record's
1208 if (*type
== _C_BFLD
)
1209 layout
->record_size
= atoi (type
+ 1);
1210 else if (layout
->record_size
% desired_align
!= 0)
1212 /* No, we need to skip space before this field.
1213 Bump the cumulative size to multiple of field alignment. */
1214 layout
->record_size
= ROUND (layout
->record_size
, desired_align
);
1217 /* Jump to the next field in record. */
1219 layout
->prev_type
= layout
->type
;
1220 layout
->type
= objc_skip_typespec (layout
->type
); /* skip component */
1225 void objc_layout_finish_structure (struct objc_struct_layout
*layout
,
1227 unsigned int *align
)
1229 BOOL unionp
= layout
->original_type
[-1] == _C_UNION_B
;
1231 && ((!unionp
&& *layout
->type
== _C_STRUCT_E
)
1232 || (unionp
&& *layout
->type
== _C_UNION_E
)))
1234 /* Work out the alignment of the record as one expression and store
1235 in the record type. Round it up to a multiple of the record's
1237 #if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
1238 layout
->record_align
= ROUND_TYPE_ALIGN (layout
->original_type
-1,
1240 layout
->record_align
);
1242 layout
->record_align
= MAX (1, layout
->record_align
);
1245 /* Round the size up to be a multiple of the required alignment */
1246 layout
->record_size
= ROUND (layout
->record_size
, layout
->record_align
);
1248 layout
->type
= NULL
;
1251 *size
= layout
->record_size
/ __CHAR_BIT__
;
1253 *align
= layout
->record_align
/ __CHAR_BIT__
;
1256 void objc_layout_structure_get_info (struct objc_struct_layout
*layout
,
1257 unsigned int *offset
,
1258 unsigned int *align
,
1262 *offset
= layout
->record_size
/ __CHAR_BIT__
;
1264 *align
= layout
->record_align
/ __CHAR_BIT__
;
1266 *type
= layout
->prev_type
;