Author: nicolas.boulenguez@free.fr
Description: big endian portability
 Migration from upstream 5.8 to 5.9 introduces a failure in build process on
 big endian architectures: powerpc, s390 and sparc, with messages like
 .
 terminal_interface-curses.ads:347:41: size for "Character_Attribute_Set" too small, minimum allowed is 32
 .
 The affected parts representation clauses are generated. The trouble is
 related to the changes of procedure gen_reps() in C source gen/gen.c.
 .
 The goal was to remove the GNAT warnings about unused bits. This patch
 directly suppresses the warnings.
 .
 On Debian, gnat >= 4.4 allows accurate warning selection like
  printf ("pragma Warnings (Off/On, \"* bits of \"\"%s\"\" unused\");", nawe);
 but upstream prefers this solution which is available on older gnat versions
  printf ("pragma Warnings (Off/On);");
Forwarded: yes

Index: b/gen/gen.c
===================================================================
--- a/gen/gen.c	2011-04-24 01:01:08.000000000 +0200
+++ b/gen/gen.c	2011-04-24 01:06:25.000000000 +0200
@@ -124,19 +124,15 @@
 	  int len,		/* size of the record in bytes          */
 	  int bias)
 {
-  const char *unused_name = "Unused";
-  int long_bits = (8 * (int)sizeof(unsigned long));
-  int len_bits = (8 * len);
-  int i, j, n, l, cnt = 0, low, high;
+  const int len_bits = (8 * len);
+  int i, l, low, high;
   int width = strlen(RES_NAME) + 3;
   unsigned long a;
-  unsigned long mask = 0;
 
   assert(nap != NULL);
 
   for (i = 0; nap[i].name != (char *)0; i++)
     {
-      cnt++;
       l = (int)strlen(nap[i].name);
       if (l > width)
 	width = l;
@@ -147,32 +143,8 @@
   printf("      record\n");
   for (i = 0; nap[i].name != (char *)0; i++)
     {
-      mask |= nap[i].attr;
       printf("         %-*s : Boolean;\n", width, nap[i].name);
     }
-
-  /*
-   * Compute a mask for the unused bits in this target.
-   */
-  mask = ~mask;
-  /*
-   * Bits in the biased area are unused by the target.
-   */
-  for (j = 0; j < bias; ++j)
-    {
-      mask &= (unsigned long)(~(1L << j));
-    }
-  /*
-   * Bits past the target's size are really unused.
-   */
-  for (j = len_bits + bias; j < long_bits; ++j)
-    {
-      mask &= (unsigned long)(~(1L << j));
-    }
-  if (mask != 0)
-    {
-      printf("         %-*s : Boolean;\n", width, unused_name);
-    }
   printf("      end record;\n");
   printf("   pragma Convention (C, %s);\n\n", name);
 
@@ -187,17 +159,10 @@
 	printf("         %-*s at 0 range %2d .. %2d;\n", width, nap[i].name,
 	       low - bias, high - bias);
     }
-  if (mask != 0)
-    {
-      l = find_pos((char *)&mask, sizeof(mask), &low, &high);
-      if (l >= 0)
-	printf("         %-*s at 0 range %2d .. %2d;\n", width, unused_name,
-	       low - bias, high - bias);
-    }
-  i = 1;
-  n = cnt;
   printf("      end record;\n");
+  printf("   pragma Warnings (Off);");
   printf("   for %s'Size use %d;\n", name, len_bits);
+  printf("   pragma Warnings (On);");
   printf("   --  Please note: this rep. clause is generated and may be\n");
   printf("   --               different on your system.");
 }
@@ -222,7 +187,7 @@
   chtype_rep("Color", A_COLOR);
   chtype_rep("Attr", (A_ATTRIBUTES & ~A_COLOR));
   printf("      end record;\n   for %s'Size use %ld;\n",
-	 name, (long)(8 * sizeof(chtype)));
+         name, (long)(8 * sizeof(chtype)));
 
   printf("      --  Please note: this rep. clause is generated and may be\n");
   printf("      --               different on your system.\n");
