This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
objc structure size boundary problems
- To: gcc-patches at gcc dot gnu dot org
- Subject: objc structure size boundary problems
- From: Richard Earnshaw <rearnsha at buzzard dot freeserve dot co dot uk>
- Date: Wed, 10 Jan 2001 23:20:39 +0000
- cc: rearnsha at arm dot com
ARM compilers now define STRUCTURE_SIZE_BOUNDARY as a variable which can
be modified at compile time. This breaks the objc library since it
assumes that it is a simple constant. The following patch fixes the
problem on the ARM, and I think should be OK for all platforms, regardless
of how they pad structures. Does anyone have any objections to the
following:
Of course, to use it, you need to make the flag a multilib variant.
Richard Earnshaw <rearnsha@arm.com>
* encoding.c (STRUCTURE_SIZE_BOUNDARY): Redefine in a way that
determines the value dynamically.
Index: encoding.c
===================================================================
RCS file: /cvs/gcc/egcs/libobjc/encoding.c,v
retrieving revision 1.7
diff -p -p -r1.7 encoding.c
*** encoding.c 2000/09/07 01:36:11 1.7
--- encoding.c 2001/01/10 23:13:56
*************** Boston, MA 02111-1307, USA. */
*** 62,67 ****
--- 62,72 ----
#define get_inner_array_type(TYPE) ((TYPE) + 1)
+ /* Some ports (eg ARM) allow the structure size boundary to be
+ selected at compile-time. We override the normal definition with
+ one that has a constant value for this compilation. */
+ #undef STRUCTURE_SIZE_BOUNDARY
+ #define STRUCTURE_SIZE_BOUNDARY (BITS_PER_UNIT * sizeof (struct{char a;}))
static inline int
atoi (const char* str)
*************** objc_layout_structure (const char *type,
*** 724,732 ****
layout->record_size = 0;
layout->record_align = BITS_PER_UNIT;
- #ifdef STRUCTURE_SIZE_BOUNDARY
layout->record_align = MAX (layout->record_align, STRUCTURE_SIZE_BOUNDARY);
- #endif
}
--- 729,735 ----