[MLton-commit] r4685

Stephen Weeks MLton@mlton.org
Mon, 17 Jul 2006 15:05:16 -0700


Fixed a couple more "cast increases required alignment" warnings on
Sparc.  I added a union type in GC_string8 to express the fact that
the chars field was properly aligned for a pointer (I couldn't get gcc
to do this with __attribute__).  I then moved the address computation
outside of the cast, replacing

  (pointer)(&sp->chars[size])

with

  (pointer)&sp->chars + size

The only remaining warnings are in interpret.c.

----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/string.h

----------------------------------------------------------------------

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.c	2006-07-17 17:54:40 UTC (rev 4684)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/int-inf.c	2006-07-17 22:05:14 UTC (rev 4685)
@@ -346,18 +346,18 @@
   assert (base == 2 || base == 8 || base == 10 || base == 16);
   fillIntInfArg (&gcState, arg, &argmpz, argspace);
   sp = (GC_string8)gcState.frontier;
-  str = mpz_get_str(sp->chars, base, &argmpz);
-  assert (str == sp->chars);
+  str = mpz_get_str((void*)&sp->chars, base, &argmpz);
+  assert (str == &sp->chars);
   size = strlen(str);
-  if (*sp->chars == '-')
-    *sp->chars = '~';
+  if (sp->chars.c[0] == '-')
+    sp->chars.c[0] = '~';
   if (base > 0)
     for (unsigned int i = 0; i < size; i++) {
-      char c = sp->chars[i];
+      char c = sp->chars.c[i];
       if (('a' <= c) && (c <= 'z'))
-        sp->chars[i] = c + ('A' - 'a');
+        sp->chars.c[i] = c + ('A' - 'a');
     }
-  setFrontier (&gcState, (pointer)(&sp->chars[size]), bytes);
+  setFrontier (&gcState, (pointer)&sp->chars + size, bytes);
   sp->counter = 0;
   sp->length = size;
   sp->header = GC_STRING8_HEADER;

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/string.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/string.h	2006-07-17 17:54:40 UTC (rev 4684)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/string.h	2006-07-17 22:05:14 UTC (rev 4685)
@@ -15,7 +15,10 @@
   GC_arrayCounter counter;
   GC_arrayLength length;
   GC_header header;
-  char chars[1];
+  union {
+    char c[1];
+    pointerAux p;
+  } chars;
 } *GC_string8;
 
 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */