pragma pack(<n>) fix

Jeffrey A Law law@cygnus.com
Wed Jun 30 23:15:00 GMT 1999


  In message <Pine.LNX.3.96.990611222347.28268A-101000@mercury.xraylith.wisc.ed
u>you write:
  > Fri Jun 11 22:09:13 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  > 
  > 	* c-pragma.c (push_alignment): Don't ignore alignments greater than
  > 	4 bytes.
  > 	(insert_pack_attributes): Take into account member natural 
  > 	alignment.
Thanks.  Installed.
jeff
  > Index: c-pragma.c
  > ===================================================================
  > RCS file: /homes/khan/src/CVSROOT/gcc-2.95/gcc/c-pragma.c,v
  > retrieving revision 1.1.1.1
  > diff -u -3 -p -r1.1.1.1 c-pragma.c
  > --- c-pragma.c	1999/06/10 02:09:53	1.1.1.1
  > +++ c-pragma.c	1999/06/12 01:39:19
  > @@ -141,7 +141,7 @@ pop_alignment (id)
  >      {
  >        entry = alignment_stack->prev;
  >  
  > -      if (entry == NULL || entry->alignment > 4)
  > +      if (entry == NULL)
  >  	maximum_field_alignment = 0;
  >        else
  >  	maximum_field_alignment = entry->alignment * 8;
  > @@ -163,6 +163,7 @@ insert_pack_attributes (node, attributes
  >       tree * prefix;
  >  {
  >    tree a;
  > +  int field_alignment;
  >  
  >    /* If we are not packing, then there is nothing to do.  */
  >    if (maximum_field_alignment == 0
  > @@ -173,12 +174,16 @@ insert_pack_attributes (node, attributes
  >    if (TREE_CODE_CLASS (TREE_CODE (node)) != 'd'
  >        || TREE_CODE (node) != FIELD_DECL)
  >      return;
  > +  
  > +  field_alignment = TYPE_ALIGN (TREE_TYPE (node));
  > +  if (field_alignment <= 0 || field_alignment > maximum_field_alignment)
  > +    field_alignment = maximum_field_alignment;
  >  
  >    /* Add a 'packed' attribute.  */
  >    * attributes = tree_cons (get_identifier ("packed"), NULL, * attributes)
  > ;
  >    
  >    /* If the alignment is > 8 then add an alignment attribute as well.  */
  > -  if (maximum_field_alignment > 8)
  > +  if (field_alignment > 8)
  >      {
  >        /* If the aligned attribute is already present then do not override 
  > it.  */
  >        for (a = * attributes; a; a = TREE_CHAIN (a))
  > @@ -201,7 +206,7 @@ insert_pack_attributes (node, attributes
  >  	  * attributes = tree_cons
  >  	      (get_identifier ("aligned"),
  >  	       tree_cons (NULL,
  > -			  build_int_2 (maximum_field_alignment / 8, 0),
  > +			  build_int_2 (field_alignment / 8, 0),
  >  			  NULL),
  >  	       * attributes);
  >  	}
  > 
  > Regards,
  > Mumit
  > 
  > 
  > --1753275830-1495355890-929157995=:28268
  > Content-Type: APPLICATION/x-gunzip; name="pack-tests.tar.gz"
  > Content-Transfer-Encoding: BASE64
  > Content-ID: <Pine.LNX.3.96.990611222635.28268B@mercury.xraylith.wisc.edu>
  > Content-Description: #pragma pack(n) testcases
  > 
  > H4sIAFTSYTcAA+1dbXPbNhLOV+tXYJzpjd1LHBIEX2KnvfEodq+XS5pJk365
  > 3Hgkvki0ZcpjSZP0OvnvxxdbBBZYGmRkOo6xHxKD5C4J8Vlgd4FHuhiFZ0+X
  > 8WK5ePbotoQwy3dd8ogQYrus+p9V7SuxCPF8x3Jc27ad/Kzt2P4j4t7aE3Gy
  > WixHl4Q8OpuOsqbr8suSpI8H6lcu6ve//tPeCzd6D9uyPMbQ98/yF3/1/plT
  > /m07ruM9ItZGnwKRB/7+n/04ID+St/mrJ8WrJ/Y++bCIF2REwvn5OM1Gy3Se
  > kXlCltOYjEeLNCTLPy/yC178RBbp/+L8zE40X41n8e5eYen62GJ5uQqX5Hg+
  > 3yXv4sVqtlzsF+dJgTJik/18UKjbtGjTus2KNqvbQdEOOH3vqv1sMHicZuFs
  > FcXkxWIZpfO96c/ioVk6Lo7lB5MoTsjJyS9vPgxPTgaPSd5Ms5gMf3v99td/
  > H70j278Mh9v18ZOTNFt6jMzm2aT8Z/A4ni1ileKbw/e//nGU68ZZlCb5va6u
  > eH346ujk9/fvPgzf7xQPvrv1cVB/MifFocePyx5t5Wf+2toq/iMkvy8ZHVw1
  > wmmOz7HYssUmvW5Wb4KE1+1kNh8tSXTd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9XUHePP9P3h9s8HH3
  > +ACLBXr4CLEa+Vfx/6Rg7L7tH/8e8YFWrXF8SEX1zfD/nssJphofSNUawUdD
  > 1RrHByxaa+EDlqy18AEr1lr4wLfuNOEDrSM34QOtI9+AD3Ud+av4f3Yxw+gA
  > JGgFELkgrIMQqRysBRGpGqyFEakarAUSqRqshRKpGqwHE7yuewNOkLruGih3
  > HUnfT1Hy//rN/3zu9999ZrMy/3PM97/0Iob/p4rfDP+v3gxk+H+3x/+TE517
  > xv8DSaMe/w8kjXr8P5zW1MD/w2lNKP9Pyln0+H84ramB/4fTmnD+H9wIpMf/
  > w2lNDfw/rwv/L74N/p8vE2XvGf8PrQg08P9ivCLQwP/DyRo4/68h42vg/6Fk
  > jSb+H07WQPl/DWSNJv4fStZo4v/hZI0G/h94uXr8P6brKG1KI3axXqvDahq3
  > YjWN0dJIA6spREsjDawmWITRYjXBIowWqwkWYbRYTbAIo8Vqgi6px2rCSyMo
  > q0kqwuixmsCdtFlNgdpR7gf/jxZL/jqewlp5iovXiBpcxcNrRA2+4uM1ogZn
  > kXZDanmLVPvSchep9qXlL1LtS8thpNqXlsdItS8dl5FrXzo+I9e+tJxGqn3p
  > eQ3UUrhNkf9z9Z93R4cvXx/dQo3hhvoPYe51/ce17WIvgE2pa9b/exHh94Rf
  > ZD/vVj8DHo6KHwFP5pfkc+A9/ZRmzjqZ1ZLBYA2sf+SD2R4i3M32yL/yV0HG
  > q3QWkVEWkctVtsdbiUZLxE5RuipVXv/+x5BcVr84Tj6lyylJ0s+8kbqwKZlS
  > GKlszFfLyoypMBsxYsSIESNGjBgxYsSIESNGjBgxYsSIESNGjBgxYsSIESNG
  > jBgxYsSIkW9G/g9/ooL5AMgAAA==
  > --1753275830-1495355890-929157995=:28268--
  > 




More information about the Gcc-patches mailing list